Created
April 1, 2012 21:43
-
-
Save harmesy/55ecd17e554d0818bd47 to your computer and use it in GitHub Desktop.
Grab a random word. For when you're too lazy to be creative.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
word_list = [] | |
generate_word = true | |
File.open("/usr/share/dict/words") do |words| | |
words.each { |word| word_list << word.strip } | |
end | |
puts "Grabbing a random word:" | |
while generate_word | |
word = word_list[rand(word_list.length)] | |
puts word | |
print 'Hit "y" if you want this one. Hit "n" to generate a new word: ' | |
while true | |
response = gets | |
case response.strip | |
when "y" | |
IO.popen('pbcopy', 'w').print word | |
generate_word = false | |
break | |
when "n" | |
break | |
else | |
print "Sorry, didn't understand that one. Try again: " | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment