Skip to content

Instantly share code, notes, and snippets.

@latentflip
Forked from remy/weekend-commits.js
Last active December 11, 2015 20:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save latentflip/4654470 to your computer and use it in GitHub Desktop.
Save latentflip/4654470 to your computer and use it in GitHub Desktop.
$.getJSON('https://github.com/users/'+document.location.href.split('/')[3]+'/contributions_calendar_data', weekendWork);
function weekendWork(contribs) {
var inwe = false, streak = 0, highest = 0, total = 0, possible = 0;
contribs.forEach(function (c) {
var d = new Date(c[0]).getDay();
if (d === 6) {
inwe = true;
} else if (d === 0 && inwe) {
possible++;
if (c[1] !== 0) {
total++;
streak++;
if (streak > highest) highest = streak;
} else {
streak = 0;
}
} else {
inwe = false;
}
});
console.log('Potential weekends relaxing: ' + possible + ', total weekends working: ' + total + ', number of weekends IN A ROW working: ' + highest);
if (highest > 0) console.log('Take a break. Take a kitkat');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment