Skip to content

Instantly share code, notes, and snippets.

@pope
Created August 22, 2008 02:05
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 pope/6717 to your computer and use it in GitHub Desktop.
Save pope/6717 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'twitter'
require 'ruby-growl'
require 'simple-daemon'
require 'tempfile'
require 'net/http'
class Growitter < SimpleDaemon::Base
SimpleDaemon::WORKING_DIRECTORY = "/Users/dir/Desktop"
@@twit = Twitter::Base.new('username', 'password')
@@options = {}
@@profile_image_cache = {}
def self.start
puts "Starting growitter"
loop do
timeline = @@twit.timeline(:friends, @@options)
if timeline
timeline.reverse.each do |s|
unless @@profile_image_cache.has_key?(s.user.profile_image_url)
f = Tempfile.new("growitter")
f << Net::HTTP.get(URI.parse(s.user.profile_image_url))
f.close
@@profile_image_cache[s.user.profile_image_url] = f.path
end
system "growlnotify -n growitter --image #{@@profile_image_cache[s.user.profile_image_url]} -t #{s.user.name.inspect} -m #{s.text.inspect}"
@@options[:since_id] = s.id
end
end
sleep 60
end
end
def self.stop
puts "Stopping growitter"
end
end
Growitter.daemonize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment