Skip to content

Instantly share code, notes, and snippets.

@gdiggs gdiggs/gifs.rb
Created Mar 7, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.