Skip to content

Instantly share code, notes, and snippets.

@haileys
Created December 27, 2013 14:06
Show Gist options
  • Save haileys/8147308 to your computer and use it in GitHub Desktop.
Save haileys/8147308 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
gem "twitter", "~> 5.3.0"
require "twitter"
def usage
abort "Usage: twitter-intersect (<username>.following|<username>.followers)..."
end
usage if ARGV.empty?
$client = Twitter::REST::Client.new do |config|
config.consumer_key = "nope"
config.consumer_secret = "nope"
config.access_token = "nope"
config.access_token_secret = "nope"
end
ids = []
ARGV.map { |arg| arg.split(".") }.each do |handle, command|
case command
when "following"
ids << $client.friend_ids(handle, count: 5000).attrs[:ids]
when "followers"
ids << $client.follower_ids(handle, count: 5000).attrs[:ids]
else
puts "Unknown command: #{command}"
puts
usage
end
end
puts $client.users(ids.reduce(:&)).map(&:screen_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment