Skip to content

Instantly share code, notes, and snippets.

@chrisberkhout
Created May 14, 2011 05:26
Show Gist options
  • Save chrisberkhout/971942 to your computer and use it in GitHub Desktop.
Save chrisberkhout/971942 to your computer and use it in GitHub Desktop.
Github's code for generating participation graphs
ParticipationGraph.prototype = {
readData: function () {
var a = this.data.split("\n");
this.allCommits = a[0] ? this.base64BytesToIntArray(a[0]) : "";
this.ownerCommits = a[1] ? this.base64BytesToIntArray(a[1]) : ""
},
// ...
base64ByteToInt: function (a) {
// This is known as modified Base64 for regexps: http://en.wikipedia.org/wiki/Base64#Regular_expressions
var d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!-";
return d.indexOf(a)
},
base64BytesToIntArray: function (a) {
for (var d = [], c, b = 0; b < a.length; b++) if (b % 2 == 0) c = 64 * this.base64ByteToInt(a.charAt(b));
else {
c += this.base64ByteToInt(a.charAt(b));
d.push(c)
}
return d
}
// ...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment