Skip to content

Instantly share code, notes, and snippets.

@trevorturk
Created February 14, 2013 18:48
Show Gist options
  • Save trevorturk/4955199 to your computer and use it in GitHub Desktop.
Save trevorturk/4955199 to your computer and use it in GitHub Desktop.
Delete all private gists
# 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
@trevorturk
Copy link
Author

@gabmontes
Copy link

For those who may like it in plain old JS: https://gist.github.com/gabmontes/b14a33fdd7081939b932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment