Skip to content

Instantly share code, notes, and snippets.

@miketierney
Created April 14, 2009 23:33
Show Gist options
  • Save miketierney/95493 to your computer and use it in GitHub Desktop.
Save miketierney/95493 to your computer and use it in GitHub Desktop.
# Generates a random string, defaults to 30 characters in length.
def String.random_alphanumeric(size=30)
(1..size).collect { (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61))).chr }.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment