August 2011
4 posts
8 tags
Ruby Capitalization Obeying English Title Grammar
Strings passed will be formatted to obey English title rules. "HAPPY BIRTHDAY".proper_titleize #=> Happy Birthday "OvEr THE MouNTaiN And ThrOuGH thE WooDS".proper_titleize #=> Over the Mountain and Through the Woods A link to the gist can be found below the source. class String # Converts a string into a properly capitalized English title # # @param [String] string the string to...
Aug 23rd
128 notes
8 tags
Spelling Suggestions from Google in Ruby
Google used to offer a SOAP API for spelling suggestion/correction but put it out of service in November 2010. Since then the only way I had found to reliably get Google’s recommended spelling suggestion for an incorrectly spelled phrase was through the same interface their toolbar browser extension uses to help correct spelling mistakes. My SpellCheck project is a PHP5 tool that asks Google...
Aug 9th
6 notes
5 tags
Validating YAML-style Tag Strings with Javascript
This has an admittedly very specific use-case, but recently I needed to validate strings matching the following formats: [apples, oranges] [[apples, oranges]] [apples, oranges, [peaches, grapes]] The bracket nesting is important as it will later be parsed by a YAML parser to generate nested arrays of strings [ "apples", "oranges", [ "peaches", "grapes" ] ] and then...
Aug 5th
26 notes
3 tags
MooTools focusedKeyUp Event
Recently needed to apply a keyup event to a series of textfields during MooTools domready event, but only have each field’s event execute when that field has the user’s focus. /** * Custom MooTools event, restricting firing of the keyUp event to only when the target element has focus. * * Usage: * some_element.addEvent('focusedKeyUp', function(event) { * console.debug('A...
Aug 5th
12 notes