Created
July 27, 2014 21:45
-
-
Save yorickpeterse/aa4245d577fadbfa7eb2 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
require 'httpclient' | |
require 'json' | |
repos = [] | |
days = %w{Sunday Monday Tuesday Wednesday Thursday Friday Saturday} | |
times = Hash.new do |hash, key| | |
hash[key] = Hash.new { |h, k| h[k] = 0 } | |
end | |
resp = HTTPClient.get('https://api.github.com/users/yorickpeterse/repos') | |
JSON(resp.body).each do |repo| | |
repos << repo['name'] | |
end | |
repos.each do |name| | |
resp = HTTPClient.get("https://api.github.com/repos/yorickpeterse/#{name}/stats/punch_card") | |
JSON(resp.body).each do |(day, hour, amount)| | |
times[day][hour] += amount | |
end | |
end | |
spacing = days.sort_by(&:length).last.length | |
times.each do |day_index, hours| | |
day = days[day_index] | |
hour, commits = hours.sort_by { |pair| pair[1] }.last | |
puts "#{day.ljust(spacing, ' ')} at #{hour.to_s.ljust(2, ' ')}: #{commits} commits" | |
end |
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
Sunday at 21: 54 commits | |
Monday at 22: 62 commits | |
Tuesday at 23: 65 commits | |
Wednesday at 23: 64 commits | |
Thursday at 0 : 72 commits | |
Friday at 0 : 48 commits | |
Saturday at 0 : 28 commits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment