Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created June 13, 2009 13:11
Show Gist options
  • Select an option

  • Save ucnv/129237 to your computer and use it in GitHub Desktop.

Select an option

Save ucnv/129237 to your computer and use it in GitHub Desktop.
require 'net/http'
$KCODE = 'u'
unless ARGV.size == 2 then
puts 'Usage: ruby spritzer.rb USERNAME PASSWORD'; exit
end
username, password = ARGV
http = Net::HTTP.new 'stream.twitter.com'
req = Net::HTTP::Get.new '/spritzer.xml'
req.basic_auth username, password
Signal.trap(:INT) { throw :sigint }
catch(:sigint) do
http.request(req) do |res|
res.read_body do |b|
if b.match(/<text>([^<]*)[\s\S]*<screen_name>([^<]*)/) then
print "\033[0;36m[#{$2}]\033[0m "
puts $1.gsub(/&#(\d*);/) { [$1.to_i].pack('U') }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment