Skip to content

Instantly share code, notes, and snippets.

@alvin2ye
Created August 10, 2009 02:48
Show Gist options
  • Save alvin2ye/164989 to your computer and use it in GitHub Desktop.
Save alvin2ye/164989 to your computer and use it in GitHub Desktop.
# String random
class String
def self.random(length=10)
chars = ('a'..'z').to_a + ('A'..'Z').to_a + ("0".."9").to_a + ['_']
hash = ""; length.times { hash << chars[rand(chars.size)] }; hash
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment