Created
October 10, 2013 05:49
-
-
Save archydragon/6913639 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.010; | |
use JSON qw( decode_json ); | |
use LWP::Simple; | |
my $user = $ARGV[0]; | |
my $url_repos = "https://api.github.com/users/$user/repos"; | |
my $repos = decode_json(get $url_repos); | |
my $bytes = {}; | |
my $count = {}; | |
for my $item (@{$repos}) { | |
if (!$item->{'fork'}) { | |
my $repo = $item->{'name'}; | |
my $url_langs = "https://api.github.com/repos/$user/$repo/languages"; | |
my $langs = decode_json(get $url_langs); | |
for my $l (keys %{$langs}) { | |
$count->{$l} += 1; | |
$bytes->{$l} += $langs->{$l}; | |
} | |
} | |
} | |
for my $k (keys %{$bytes}) { | |
say sprintf("%s: %d bytes (%d times)", $k, $bytes->{$k}, $count->{$k}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment