Skip to content

Instantly share code, notes, and snippets.

View DrkSephy's full-sized avatar
🕶️

David Leonard DrkSephy

🕶️
View GitHub Profile
router.get('/issues_closed', function(req, res) {
request({
url: 'https://api.github.com/repos/' + req.query.owner + '/' + req.query.repo + '/contributors' + '?' + 'client_id=' + CLIENT_ID + '&' + 'client_secret=' + CLIENT_SECRET,
headers: { 'user-agent': 'git-technetium' },
json: true
}, function(error, response, body) {
if(!error && response.statusCode === 200) {
var contributors = [];
for(var contributorIndex = 0; contributorIndex < body.length; contributorIndex++){
contributors.push(body[contributorIndex].login);
@DrkSephy
DrkSephy / Report Display
Created August 16, 2014 03:59
Better github report display
'use strict';
gitApp.controller('reportController', function($scope, commitsFactory, locFactory, commitCommentsFactory,
issuesAssignedFactory, issuesClosedFactory, issuesOpenedFactory, issuesCommentsFactory,
pullsFactory, pullRequestCommentsFactory){
$scope.commitData = [];
$scope.locData = [];
$scope.commitCommentsData = [];
$scope.issuesAssignedData = [];
@DrkSephy
DrkSephy / Github Pagination Algorithm (Completed)
Created August 14, 2014 19:20
Completed pagination algorithm for Github API
/**
* Precondition:
* ownerName (string): The owner username of the target repository
* repoName (string): The target repository name
* Postcondition:
* An array of objects, where each object contains the following properties:
* name (string): The contributor username
* issues_opened (string): The number of issues closed by the respective contributor
**/
router.get('/issues_closed', function(req, res) {
@DrkSephy
DrkSephy / Pseudo-pagination algorithm
Created August 13, 2014 02:43
Github API Pagination Algorithm for Node
/*
PROBLEM: We do not know how many iterations we'll need to perform to access all of the data.
We want an algorithm to iterate over a page of data, and under some conditions
continue to run the requests function repeatedly until we reach a break condition.
Essentially, the runtime of the loop is dynamically changing and we need a way to
handle an indeterminate number of requests.
*/
// Starting page counter
@DrkSephy
DrkSephy / gist:801a44e3af4a70098119
Created August 12, 2014 01:54
async.each example
async.each(urls, function(url, callback){
console.log("Grabbing Dataset from " + url);
makeRequest(url, function(){
callback();
});
}, function(err){
console.log("Hello");
if(err){
console.log("Error grabbing data");
} else {