Skip to content

Instantly share code, notes, and snippets.

@gdiggs
Created March 7, 2014 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdiggs/9419545 to your computer and use it in GitHub Desktop.
Save gdiggs/9419545 to your computer and use it in GitHub Desktop.
require 'typhoeus'
class Array; def in_groups(num_groups)
return [] if num_groups == 0
slice_size = (self.size/Float(num_groups)).ceil
self.each_slice(slice_size).to_a
end; end
gifs = []
threads = []
gifs += File.open('gifs.txt').read.each_line.to_a
gifs.in_groups(16).each do |group|
threads << Thread.new do
group.each do |url|
request = Typhoeus.get url
puts url if request.code == 200
end
end
end
threads.each { |thr| thr.join }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment