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 | |
# Find common Twitter friends | |
# Usage: ./twat.rb user1 user2 ... | |
lists = ARGV.inject({}) do |hash, username| | |
page = 0 | |
while !(output = `curl -s http://twitter.com/statuses/friends/#{username}.xml?page=#{page += 1} | grep "<screen_name>"`.gsub(%r{</?screen_name>}, '').split).empty? | |
hash[username] = ((hash[username] || []) + output).sort | |
end | |
hash | |
end.values.inject { |a, b| a & b }.each { |user| puts user } | |
# Gems are nice too |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment