Here’s Contrigraph, a “data visualisation” (?) created by generating commits to match the Contribution Graph Shirt from GitHub.
It was pretty much a hack; first, I read the colours straight off the shirt, producing a big block of data like
0002342
2223322
2323241
2224333
3322122
2242231
...
Then we read that in one digit at a time, work out what day to start on so everything aligns correctly, and how many commits on a given day produce each gradient of colour. The result isn’t pretty:
start = Time.new 2012, 4, 23, 12, 0, 0, 0
tbl = {"0" => 0, "1" => 0, "2" => 1, "3" => 9, "4" => 14, "5" => 23}
3.times do
dbd.each do |n|
tbl[n].times do
`echo 1 >> graafik`
`git commit -a -m 'contrigraph' --date='#{start.to_s[0..9]}T12:00:00'`
end
start += 86400
end
end
Three times so this thing will scroll on for the next few years. Other values
for tbl
would work too; I just didn’t bother to do anything better. I’ve
written clearer code, but that wasn’t really the point either.
I actually screwed this up twice: first I didn’t remember to treat the 0
entries correctly (i.e. I should have skipped those days, whereas I ignored
them entirely); second, it seemed like I was getting hit by timezone issues
where everything was shifted up a block.
In retrospect, I should have first produced a mini-contributions graph generator (i.e. one that takes a Git repository and produces what GitHub would do), validate that against an existing user/repo, then use that to ensure it’d work the first time. I did a similar thing to ensure I had the data correct, by producing a graph directly from the data: