Skip to content

Instantly share code, notes, and snippets.

@oinak
Created October 5, 2017 09:57
Show Gist options
  • Select an option

  • Save oinak/d5662e6d82b8a86604a371cdd2dfde07 to your computer and use it in GitHub Desktop.

Select an option

Save oinak/d5662e6d82b8a86604a371cdd2dfde07 to your computer and use it in GitHub Desktop.
XKCD approved password generator (https://www.xkcd.com/936/)
# https://www.xkcd.com/936/
module Clave
extend self
def run
puts((1..4).map { safe_words.sample }.join(" "))
end
private
SAFE_SET = /\A[A-Za-z]+\Z/.freeze
def safe_words
@safe ||= words.select{ |w| SAFE_SET.match(w) }
end
def words
@words ||= File.read("/usr/share/dict/spanish").split("\n")
end
end
Clave.run if __FILE__ == $PROGRAM_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment