How do I get a list of all the GitHub projects I’ve contributed to in the last year? [duplicate]

Thanks to a tweet from @caged, I wrote this Perl script to iterate over months in my contributions:

use v5.12;
use warnings;
use utf8;
my $uname="theory";

my %projects;
for my $year (2012..2014) {
    for my $month (1..12) {
        last if $year == 2014 && $month > 1;
        my $from = sprintf '%4d-%02d-01', $year, $month;
        my $to   = sprintf '%4d-%02d-01', $month == 12 ? ($year + 1, 1) : ($year, $month + 1);
        my $res = `curl 'https://github.com/$uname?tab=contributions&from=$from&to=$to' | grep 'class="title"'`;
        while ($res =~ /href="https://stackoverflow.com/questions/21322778/([^"?]+)/g) {
            my (undef, $user, $repo) = split m{/} => $1;
            $projects{"$user/$repo"}++;
        }
    }
}

say "$projects{$_}: $_" for sort keys %projects;

Yeah, HTML scraping is kind of ugly, but did the trick for my needs.

Leave a Comment