Skip to content

Instantly share code, notes, and snippets.

@will3216
Created October 23, 2015 01:20
Show Gist options
  • Save will3216/fabecc1cf828c73ffa1a to your computer and use it in GitHub Desktop.
Save will3216/fabecc1cf828c73ffa1a to your computer and use it in GitHub Desktop.
Some random console commands for use in rails
# Generate random text via an online API: Useful for generating fake data
# For more options see: https://baconipsum.com/json-api/
#Generate random sentence
require 'open-uri'
def random_sentence(count=1); open("https://baconipsum.com/api/?type=meat-and-filler&sentences=#{count}&format=text&start-with-lorem=0").read; end
# < random_sentence
# => "Bacon ipsum dolor amet aute brisket cupidatat ribeye, ball tip consequat shoulder pig chuck adipisicing shankle."
# Random paragraph
def random_paragraph(count=1); open('https://baconipsum.com/api/?type=meat-and-filler&paras=#{count}&format=text&start-with-lorem=0').read; end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment