Skip to content

Instantly share code, notes, and snippets.

View DaryMerckensGT's full-sized avatar

Dary Merckens DaryMerckensGT

View GitHub Profile
@DaryMerckensGT
DaryMerckensGT / download_picsum.rb
Created June 2, 2019 02:11
Downloading Lorem Picsum Images
JSON.parse(Net::HTTP.get_response(URI.parse("https://picsum.photos/v2/list")).body).collect{ |datum| datum["download_url"] }.map { |url| "#{url.gsub(/unsplash/, "images.unsplash")}.jpg?#{rand >= 0.5 ? "grayscale" : ""}&#{rand >= 0.5 ? "blur=#{(rand*3).ceil}" : ""}" }.each { |url| open(url) { |image| File.open(url.split("/").last.split("?").first, "wb") { |f| f.write(image.read) } } }