Skip to content

Instantly share code, notes, and snippets.

@neonmate
Created January 24, 2015 23:10
Show Gist options
  • Save neonmate/98b716b0b90a30ee3625 to your computer and use it in GitHub Desktop.
Save neonmate/98b716b0b90a30ee3625 to your computer and use it in GitHub Desktop.
Avatar Random Seed Data
require 'open-uri'
require 'json'
# fetching random faces from twitter
url = 'http://uifaces.com/api/v1/random'
size = 'normal' # epic, bigger, normal or mini
count = 10
count.times do |i|
open("image_#{i}.jpg", 'wb') do |file|
STDOUT.write "\rProgress: #{(i.to_f / count) * 100} %"
data = JSON.parse(open('http://uifaces.com/api/v1/random').read)
file << open(data['image_urls'][size]).read
end
end
STDOUT.write "\r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment