Skip to content

Instantly share code, notes, and snippets.

@lei-clearsky
Created September 26, 2013 14:31
Show Gist options
  • Select an option

  • Save lei-clearsky/6715041 to your computer and use it in GitHub Desktop.

Select an option

Save lei-clearsky/6715041 to your computer and use it in GitHub Desktop.
def get_from_digg
res = JSON.load(RestClient.get('http://digg.com/api/news/popular.json'))
res["data"]["feed"].map do |story|
s = {}
tags = []
s[:title] = story["content"]["title"]
story["content"]["tags"].map do |tag|
tags << tag["display"]
end
s[:category] = tags.join(", ")
calculate_upvotes s
puts show_new_story(s)
end
end
@bswinnerton
Copy link
Copy Markdown

Just a quick tip, if you save the file as gistfile1.rb instead of gistfile.txt, you'll get syntax highlighting : )

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