Skip to content

Instantly share code, notes, and snippets.

@thesowah
Created June 23, 2014 01:44
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 thesowah/ee9999e789fbb86403f4 to your computer and use it in GitHub Desktop.
Save thesowah/ee9999e789fbb86403f4 to your computer and use it in GitHub Desktop.
Utility script for Afridevcmty
# This utility class is help gather data while avoiding
# Github's seach restriction of 1,000 results
# and traverse through the results using Link headers
# FYI: Our results is about 2700
require 'rest_client'
require 'json'
class Utility
@url = "https://api.github.com/search/users"
@dates = ["<=2012-01-01", "2012-01-01..2012-12-31", "2013-01-01..2013-12-31", ">=2014-01-01"]
def self.get_all
data = []
@dates.each do |date|
begin
1.upto(Float::INFINITY) do |i|
params = {:params => {:q => "location:africa created:#{date}", :per_page => '100', :page => "#{i}"}}
response = RestClient.get @url, params
response = JSON.parse(response, :symbolize_names => true)
data.concat(response[:items])
sleep 5
end
rescue Exception => err
next
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment