Skip to content

Instantly share code, notes, and snippets.

@saterus
Created June 28, 2011 04:06
Show Gist options
  • Save saterus/1050467 to your computer and use it in GitHub Desktop.
Save saterus/1050467 to your computer and use it in GitHub Desktop.
Subreddit Categorization
#!/bin/env ruby
have_ap = require 'awesome_print'
if have_ap
def fancy_print(s)
ap s
end
else
def fancy_print(s)
ap s
end
end
path = ARGV.shift
lines = File.readlines(path)
lines.map(&:strip!)
categories = test = Hash.new{|h, k| h[k] = []}
lines.map do |r|
fancy_print categories
puts("#{r}: (#{categories.keys})")
i = gets
i.strip!
categories[i.intern] << r
end
fancy_print categories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment