Skip to content

Instantly share code, notes, and snippets.

Created November 25, 2014 00:46
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 anonymous/958efc7552df8e250afa to your computer and use it in GitHub Desktop.
Save anonymous/958efc7552df8e250afa to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'json'
thread = "http://www.reddit.com/r/millionairemakers/comments/2na6tu/reddit_lets_make_a_millionaire.json"
def get_authors(thread)
json_content = JSON.parse(open(thread).read)
json_content[1]["data"]["children"].inject([]) do |arr, p|
arr << p["data"]["author"]
arr
end
end
authors = get_authors(thread)
puts "Number of total posters:\t #{authors.size}"
puts "Number of unique posters:\t #{ authors.uniq.size }"
unless authors.size == authors.uniq.size
perps = authors.group_by { |e| e }.select { |k, v| v.size > 1 }.map(&:first)
puts "\n--- USERS BREAKING THE RULES ---\n"
puts
perps.each do |u|
puts u
end
puts "\n\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment