Skip to content

Instantly share code, notes, and snippets.

@remy
Last active January 14, 2020 08:09
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save remy/4654404 to your computer and use it in GitHub Desktop.
Run this in the console of your github.com/<user> page (i.e. http://github.com/remy) and see how many weekends you were in front of a computer and committing code instead of taking a break.
$.getJSON('https://github.com/users/' + location.pathname.replace(/\//g, '') + '/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. Have a kitkat');
}
@remy
Copy link
Author

remy commented Jan 28, 2013

Me:

Potential weekends relaxing: 53, total weekends working: 26, number of weekends IN A ROW working: 6
Take a break. Take a kitkat

6!! :(

@gr2m
Copy link

gr2m commented Jan 28, 2013

Potential weekends relaxing: 53, total weekends working: 22, number of weekends IN A ROW working: 6
Take a break. Take a kitkat

@aitor
Copy link

aitor commented Jan 28, 2013

I forgot to change the json URL. Real stats are even worse:

“Potential weekends relaxing: 53, total weekends working: 46, number of weekends IN A ROW working: 14”

@SteveEdson
Copy link

Think I lose here...

Potential weekends relaxing: 53, total weekends working: 44, number of weekends IN A ROW working: 23

@raul
Copy link

raul commented Jan 28, 2013

Potential weekends relaxing: 53, total weekends working: 42, number of weekends IN A ROW working: 12

@latentflip
Copy link

This fork just workstm: https://gist.github.com/4654470

@matijs
Copy link

matijs commented Jan 28, 2013

I think I just like what I do…

Potential weekends relaxing: 53, total weekends working: 50, number of weekends IN A ROW working: 41
Take a break. Take a kitkat

@miguelff
Copy link

This is for sure wrong: Potential weekends relaxing: 53, total weekends working: 51, number of weekends IN A ROW working: 24. Take a break. Take a kitkat

I hardly ever work on weekends

@raul
Copy link

raul commented Jan 28, 2013

I think @miguelff is right, there may be a bug in either the script, the data or the graph. The script says I worked 42 weekends but my graph doesn't look that bad: my graph

@passcod
Copy link

passcod commented Jan 28, 2013

I believe the inner if is inverted, line 10 should read if (c[1] !== 0) { instead. It does brings @remy's streak up by one :) Here're mine:

(orig) Potential weekends relaxing: 53, total weekends working: 14, number of weekends IN A ROW working: 10

(fixed) Potential weekends relaxing: 53, total weekends working: 14, number of weekends IN A ROW working: 3

@Ferdev
Copy link

Ferdev commented Jan 28, 2013

Potential weekends relaxing: 53, total weekends working: 51, number of weekends IN A ROW working: 43
Take a break. Take a kitkat O_O

@zigotica
Copy link

I'm sure there IS something wrong with the results, my graph is obviously much more scattered than this message:
Potential weekends relaxing: 53, total weekends working: 53, number of weekends IN A ROW working: 53
Take a break. Take a kitkat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment