Last active
May 1, 2016 00:30
-
-
Save stefansundin/fcef4e824f7747d07d1453ef2011afea to your computer and use it in GitHub Desktop.
Plot GitHub API rate limit usage with gnuplot.
This file contains hidden or 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 ruby | |
# gem install httparty | |
require "httparty" | |
trap "SIGINT" do | |
STDERR.write "\nBye!" | |
exit 1 | |
end | |
while true | |
begin | |
r = HTTParty.get("https://gh-rss.herokuapp.com/ratelimit", format: :json) | |
if r.success? | |
data = r.parsed_response | |
remaining = data["remaining"] || "5000" | |
puts "#{Time.now.to_i} #{remaining}" | |
STDOUT.flush | |
end | |
sleep 10 | |
rescue => e | |
STDERR.puts "Error: #{e}." | |
sleep 10 | |
end | |
end |
This file contains hidden or 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
#!/bin/bash | |
# empty line to indicate a break in the data | |
echo "" >> github.dat | |
./github.rb >> github.dat |
This file contains hidden or 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 gnuplot | |
set terminal png size 900, 300 | |
set output "github.png" | |
set xdata time | |
set timefmt "%s" | |
set grid | |
set xtics 3600 | |
plot [:][:] "github.dat" using 1:2 title "GitHub API Limit" with lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment