Skip to content

Instantly share code, notes, and snippets.

@dnase
Last active December 14, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnase/5058695 to your computer and use it in GitHub Desktop.
Save dnase/5058695 to your computer and use it in GitHub Desktop.
Superhero name generator. GPL'd or whatever. Can't be bothered to paste the license.
#define a method for each part of speech that returns a word at pseudorandom
def adjective
#we get the 0th (first) element of the array after it has been shuffled, resulting in a sort of random selector
['Incredible', 'Unstoppable', 'Unflappable', 'Amazing', 'Scrumtrilescent', 'Purple', 'Bioluminescent'].shuffle[0]
end
def pronoun
['Man', 'Woman', 'Boy', 'Girl'].shuffle[0]
end
def animal
['Bat', 'Wolf', 'Wolverine', 'Donkey', 'Spider', 'Monkey'].shuffle[0]
end
def definite_article
'The'
end
def noun
['Flash', 'Nerd', 'Tick'].shuffle[0]
end
#threads, because why not?
$threadstack = Array.new
100.times {
#create 100 threads
$threadstack.push(Thread.new {
#choose a random sentence template and output the result
puts ["#{adjective} #{pronoun}", "#{animal} #{pronoun}", "#{definite_article} #{noun}", "#{definite_article} #{adjective} #{animal}", "#{definite_article} #{adjective} #{noun}", "#{definite_article} #{adjective} #{animal} #{pronoun}"].shuffle[0]
})
}
$threadstack.each { |t|
#wait for the threads to complete
t.join
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment