Skip to content

Instantly share code, notes, and snippets.

@bollu
Forked from trevorturk/gists.rb
Created March 13, 2014 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bollu/9529494 to your computer and use it in GitHub Desktop.
Save bollu/9529494 to your computer and use it in GitHub Desktop.
# gem install httparty
# ruby gists.rb
require 'httparty'
class Gists
include HTTParty
@username = 'x'
@password = 'x'
base_uri 'https://api.github.com'
basic_auth @username, @password
def self.delete_private_gists
gists = get("/users/#{@username}/gists")
# gists = get("/users/#{@username}/gists?page=2") # ETOOLAZYFORPAGINATION
gists = gists.select { |g| g["public"] == false }
if gists.empty?
false
else
gists.each do |gist|
id = gist["id"]
puts "deleting #{id}"
delete "/gists/#{id}"
end
end
end
end
loop do
break if Gists.delete_private_gists == false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment