Created
June 4, 2013 23:34
-
-
Save larzconwell/5710523 to your computer and use it in GitHub Desktop.
Correlation between people who use tabs vs spaces and people use double vs single spacing after sentence (WIP)
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
var request = require('request'), | |
async = require('async'); | |
// Gets the first >=1000 unique(not forked) repos from Github | |
function getRepos (callback) { | |
var repos = [], | |
lastId = 0, | |
reqOpts = { | |
uri: 'https://api.github.com/repositories', | |
qs: {since: 0}, | |
headers: {'User-Agent': 'something that makes no sense'}, | |
json: true | |
}; | |
if (process.env.SECRET) { | |
reqOpts.headers["Authorization"] = "token " + process.env.SECRET; | |
} | |
async.until(function () {return repos.length >= 1000;}, function (done) { | |
reqOpts.qs.since = lastId; | |
request(reqOpts, function (err, res, body) { | |
if (err || res.statusCode !== 200) { | |
done(err || body.message); | |
return; | |
} | |
var repo, i; | |
lastId = body[body.length - 1].id + 1; | |
for (i in body) { | |
repo = body[i]; | |
if (repo.fork) { | |
continue; | |
} | |
repos.push('git@github.com:'+repo.full_name+'.git'); | |
} | |
done(); | |
}); | |
}, function (err) { | |
callback(err, repos); | |
}); | |
} | |
getRepos(function (err, repos) { | |
if (err) { | |
throw err; | |
} | |
console.log(repos.length); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment