Skip to content

Instantly share code, notes, and snippets.

@archydragon
Created October 10, 2013 05:49
Show Gist options
  • Save archydragon/6913639 to your computer and use it in GitHub Desktop.
Save archydragon/6913639 to your computer and use it in GitHub Desktop.
#!/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