Skip to content

Instantly share code, notes, and snippets.

@hiepph
Last active March 6, 2020 06:45
Show Gist options
  • Save hiepph/b92a0bc86c6e229e5a1ed0a0f5daac82 to your computer and use it in GitHub Desktop.
Save hiepph/b92a0bc86c6e229e5a1ed0a0f5daac82 to your computer and use it in GitHub Desktop.
Search gists and return raw values of code
#!/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