Skip to content

Instantly share code, notes, and snippets.

@c650
Created November 7, 2016 23:39
Show Gist options
  • Save c650/145fc2610cfd3f5fc2e80270c2da9a92 to your computer and use it in GitHub Desktop.
Save c650/145fc2610cfd3f5fc2e80270c2da9a92 to your computer and use it in GitHub Desktop.
=begin
count-all-code.rb
@author Charles Bailey
@version 1.0.0 11/7/16
Ever wanted to know how much code you've written?
This nifty little script will download ALL of your
public repositories so you can find out!
=end
require 'httparty'
unless ARGV.length >= 1
puts "[!] Usage: ruby count-all-code.rb <user>"
exit
end
USER = ARGV[0]
resp = HTTParty.get(URI.parse("https://api.github.com/users/#{USER}/repos"))
Dir.mkdir("/tmp/allcode") unless Dir.exists?("/tmp/allcode")
Dir.chdir("/tmp/allcode")
i = 0
resp.each do |repo|
next if repo["private"] || repo["owner"]["login"] != USER
i += 1
puts "#{i}: #{repo["name"]}"
puts "\t#{repo["git_url"]}"
`git clone #{repo["git_url"]}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment