Here’s a little trick I discovered about a year ago. The Integer#to_s method takes an argument to change the base (it defaults to base 10 of course). The highest base you can use is 36, which is [a-z0-9]. There are many names for base 36, including the proper sexatrigesimal, the common hextridecimal, and the more modern alphadecimal.

Combined with the String#hash and Time#hash methods, you can get sweet little TinyUrl style hashes.

check it:

# timestamp
>> DateTime.now.hash.abs.to_s(36)
=> "5ynfka" 

# invite code
>> "joe@momma.org".hash.to_s(36)
=> "emhs98" 

Not sure of the ultimate-in-the-entire-universe uniqueness of this type of hash, which I believe is based on some simple XORs… anyone care to comment?

actionmailer ActionView ActiveRecord activesupport agile ajax alphadecimal audio autotest BDD blocks capistrano ssh ruby console controller css dashboard widget delegate dog puppy naming name DRM email obfuscation exceptions factories factories-and-workers factory pattern filemerge find and replace finder fink fixtures fun functional testing gem gems git google maps haml hash helper helpers imagemagick install Intertrust irb javascript jquery jrails logo macro math meetup model openssl OS X patch Pioneer Electronics plugin polymorphism project management prototype.js rails rails gotcha rails,patch,validations railsconf rake rmagick RSA encryption ruby ruby on rails script scrum scrum lessons rails scrumninja shoulda subversion SyncTV TDD testing textmate tips tricks unique hashes unix shell validation view yaml zebra stripes