Created
February 14, 2013 18:48
-
-
Save trevorturk/4955199 to your computer and use it in GitHub Desktop.
Delete all private gists
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
# 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
See also https://github.com/lateplate/gist-cleaner