Skip to content

Instantly share code, notes, and snippets.

@mikker
Created October 16, 2012 15:37
Show Gist options
  • Select an option

  • Save mikker/3900029 to your computer and use it in GitHub Desktop.

Select an option

Save mikker/3900029 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Generates a random, 16 char password and adds it to the clipboard
# Requires ruby >= 1.9
chars = ((0..9).to_a + ('a'..'z').to_a + ('A'..'Z').to_a).join
password = Array.new(16).inject([]) do |password, i|
password << chars[rand(chars.length-1)]
end.join
%x{printf "#{password}" | pbcopy}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment