Last active
October 13, 2015 01:18
-
-
Save nickserv/4116668 to your computer and use it in GitHub Desktop.
Quotes Script
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 | |
# quotes.rb | |
# Picks a random quote from quotes.txt and prints it to stdout. | |
# Quotes should be separated by double newlines (single empty lines) in the file. | |
# We need to define Array#sample if this version of Ruby is really old. | |
unless Array.respond_to? 'sample' | |
class Array | |
def sample | |
self[rand(length)] | |
end | |
end | |
end | |
# Here we go! | |
puts File.open("#{File.dirname __FILE__}/quotes.txt").read.split(/\n\n/).sample |
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
"Many people ask what are Beatles? Why Beatles? Ugh, Beatles, how did the name arrive? So we will tell you. It came in a vision--a man appeared in a flaming pie and said unto them 'From this day on you are Beatles with an A.' 'Thank you, Mister Man,' they said, thanking him." - John Lennon | |
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein | |
"I reject your reality and substitute my own!" - Adam Savage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment