Skip to content

Instantly share code, notes, and snippets.

@larzconwell
Created June 4, 2013 23:34
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 larzconwell/5710523 to your computer and use it in GitHub Desktop.
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)
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