Skip to content

Instantly share code, notes, and snippets.

@DaryMerckensGT
Created June 2, 2019 02:11
Show Gist options
  • Save DaryMerckensGT/ef313e031bd912da67d40d737a6bf368 to your computer and use it in GitHub Desktop.
Save DaryMerckensGT/ef313e031bd912da67d40d737a6bf368 to your computer and use it in GitHub Desktop.
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) } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment