Last active
March 6, 2020 06:45
-
-
Save hiepph/b92a0bc86c6e229e5a1ed0a0f5daac82 to your computer and use it in GitHub Desktop.
Search gists and return raw values of code
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'json' | |
q = ARGV[0] | |
def get (url) | |
uri = URI(url) | |
return Net::HTTP.get(uri) | |
end | |
gists = JSON.parse(get('https://api.github.com/users/hiepph/gists')) | |
gists.filter { |g| g['description'].downcase.include? q }.each do |item| | |
# puts "\"#{item['description']}\" #{item['git_pull_url']}" | |
puts item['description'] | |
item['files'].each do |f, v| | |
puts f | |
puts get(v['raw_url']) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment