Skip to content

Instantly share code, notes, and snippets.

@markglenfletcher
Created September 4, 2014 20:51
Show Gist options
  • Save markglenfletcher/c45782029a45cd425423 to your computer and use it in GitHub Desktop.
Save markglenfletcher/c45782029a45cd425423 to your computer and use it in GitHub Desktop.
class String
class << self
def random_string
chars = [*('A'..'Z'),*('a'..'z'),*(0..9)]
chars.map { |c| [0,1].sample == 0 ? nil : c }.compact.shuffle.join
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment