Skip to content

Instantly share code, notes, and snippets.

@alloy-d
Last active November 1, 2015 21:03
Show Gist options
  • Save alloy-d/09d66a8bd4a1c739258d to your computer and use it in GitHub Desktop.
Save alloy-d/09d66a8bd4a1c739258d to your computer and use it in GitHub Desktop.
A handy utility for opening a bunch of files one at a time, in random order. Made as a studying helper utility.
require 'json'
require 'pathname'
dir = ENV["DIR"] || "Midterm"
images = Pathname.new(dir).children.select do |f|
f.basename.to_s.match(/\A\d+\.(jpg|png)\z/)
end.shuffle
while !images.empty?
one = images.shift
STDERR.puts(JSON.dump({showing: one, remaining: images}))
`open -W #{one}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment