Created
September 13, 2019 00:31
-
-
Save ulyamalikatin/c788ae4ca3bb980f614a45a8cf918fe5 to your computer and use it in GitHub Desktop.
Giat cleaner
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
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