Created
December 31, 2015 10:05
-
-
Save ahmadawais/858f982639d9a537b56a to your computer and use it in GitHub Desktop.
Perl: Git: GitHub Public Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Finds GitHub public events for your profile | |
# and lists the names of repositories | |
# | |
# Accounts for: | |
# - Pull Requests | |
# - Issues | |
# - Comments and similar events | |
# | |
# Usage: | |
# 1- Download the script | |
# 2- Through terminal excute it with `perl my_github_events.pl` | |
# | |
# Pre-requisite: | |
# 1- Perl must be installed, you can check that within terminal by typing `perl -v` | |
# 2- Change the username at line #19 | |
use v5.12; | |
use warnings; | |
use utf8; | |
my $uname = 'YourGitHubUsername'; | |
my ($curr_month, $curr_year) = (gmtime)[4,5]; | |
$curr_year += 1900; | |
$curr_month += 1; | |
my %projects; | |
for my $year (2012..$curr_year) { | |
for my $month (1..12) { | |
last if $year == $curr_year && $month > $curr_month; | |
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="([^"?]+)/g) { | |
my (undef, $user, $repo) = split m{/} => $1; | |
$projects{"$user/$repo"}++; | |
} | |
} | |
} | |
say "$projects{$_}: $_" for sort keys %projects; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment