Skip to content

Instantly share code, notes, and snippets.

@ulyamalikatin
Created September 13, 2019 00:31
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 ulyamalikatin/c788ae4ca3bb980f614a45a8cf918fe5 to your computer and use it in GitHub Desktop.
Save ulyamalikatin/c788ae4ca3bb980f614a45a8cf918fe5 to your computer and use it in GitHub Desktop.
Giat cleaner
require 'httparty'
class GistCleaner
include HTTParty
@username = 'your_username'
@password = 'your_password'
base_uri 'https://api.github.com'
basic_auth @username, @password
def self.delete_private_gists
gists = get("/users/#{@username}/gists", headers: {"User-Agent" => @username})
gists = gists.select { |g| g["public"] == false }
if gists.empty?
false
else
gists.each_with_index do |gist, i|
id = gist["id"]
puts "#{i+1}. DELETING: http://gist.github.com/#{@username}/#{id}"
delete("/gists/#{id}", headers: {"User-Agent" => @username})
end
end
end
end
loop do
break if GistCleaner.delete_private_gists == false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment