Created
January 24, 2015 23:10
-
-
Save neonmate/98b716b0b90a30ee3625 to your computer and use it in GitHub Desktop.
Avatar Random Seed Data
This file contains hidden or 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
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