Created
March 7, 2014 20:37
-
-
Save gdiggs/9419545 to your computer and use it in GitHub Desktop.
This file contains 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 '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