Skip to content

Instantly share code, notes, and snippets.

@QuinnStephens
Last active August 29, 2015 14:27
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 QuinnStephens/e0d1486c1ba43532c233 to your computer and use it in GitHub Desktop.
Save QuinnStephens/e0d1486c1ba43532c233 to your computer and use it in GitHub Desktop.
Grabs random paragraphs from Edward Butler-Lytton's 1830 novel PAUL CLIFFORD, source of the famous "It was a dark and stormy night." Use it if you're bored of lorem ipsum.
require 'nokogiri'
require 'open-uri'
require 'clipboard'
page = Nokogiri::HTML(open('https://www.gutenberg.org/files/7735/7735-h/7735-h.htm'))
count = ARGV[0] ? ARGV[0].to_i : 1
output = ''
count.times do |i|
output << page.css('p').to_a.sample.text.strip.split.join(' ') << (i < count - 1 ? "\n\n" : "\n")
end
Clipboard.copy(output)
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment