We were playing with some ideas over at PostRank and realized we needed a way to give out some unique codes. We didn’t want some random string of letters and numbers as that isn’t very memorable. We wanted real words. We wanted something entertaining.
I spent a bit of time looking around. The closest thing I found to what we wanted was Webster. While Webster would work, I wasn’t a big fan of the words we were getting out of the system in some quick tests. After some more fruitless searching, in a fit of not invented here syndrome, I created my own.
Enter, Moniker. Moniker will take a list of descriptive words and a set of animals and give you a string. There are, currently, just over 42 thousand combinations. Enough for what we needed. The system is pretty simplistic and it’s up to you to make sure you aren’t getting duplicates.
>> require ‘rubygems’
>> require ‘moniker’
=> true
>> Moniker.name
=> "octagon-zebra"
>> Moniker.name
=> "shallow-lion"
>> Moniker.name
=> "concave-parrot"
The code is all up on GitHub so take a look and feel free to play. Let me know if you’ve got any ideas for improvements
You could try rufus-memo
http://github.com/jmettraux/rufus-mnemo/blob/master/lib/rufus/mnemo.rb
Maybe you could even add it to Moniker as a post/prefix to get something like
“#{ Rufus::Mnemo::from_integer(user.id) }-#{ Moniker.name }” -> “karasu-octagon-zebra”
That would give you virtually infinite monikers