-
-
Save earlonrails/3fb7b86712f0b9ba2b86 to your computer and use it in GitHub Desktop.
Revisions
-
earlonrails renamed this gist
Mar 4, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
earlonrails revised this gist
Mar 4, 2015 . 1 changed file with 0 additions and 70 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,28 +1,7 @@ #!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'rubygems' class ObjectStash def self.store obj, file_name marshal_dump = Marshal.dump(obj) @@ -42,52 +21,3 @@ def self.load file_name end end end -
siong1987 renamed this gist
Aug 16, 2009 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
siong1987 revised this gist
Aug 16, 2009 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -91,5 +91,3 @@ rescue Exception => e end ObjectStash.store $last_seen_id, "#{ENV['HOME']}/growl.stash" -
siong1987 created this gist
Aug 16, 2009 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,95 @@ #!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'rubygems' require 'rufus/verbs' # gem rufus-verbs require 'json' # gem json or json_pure require 'growl' # gem growlnotifier (and rubycocoa) def get_password key result = `/usr/bin/security 2>&1 >/dev/null find-internet-password -gs #{key}` if result =~ /password: "(.*)"/ $1 else raise "Unknown password" end end # get password from keychain USER = 'user_name' PASS = get_password 'twitter.com' GROWL = Growl::Notifier.sharedInstance GROWL.register('twatch', ['twitter_update', 'issue']) class ObjectStash def self.store obj, file_name marshal_dump = Marshal.dump(obj) file = File.new(file_name,'w') file.write marshal_dump file.close return obj end def self.load file_name begin file = File.open(file_name, 'r') ensure obj = Marshal.load file.read file.close return obj end end end begin $last_seen_id = ObjectStash.load "#{ENV['HOME']}/growl.stash" rescue $last_seen_id = '' end def fetch_tweets if $last_seen_id == '' res = Rufus::Verbs.get( "https://twitter.com/statuses/friends_timeline.json", :hba => [ USER, PASS ] ) else res = Rufus::Verbs.get( "https://twitter.com/statuses/friends_timeline.json?since_id=#{$last_seen_id}", :hba => [ USER, PASS ] ) end raise "#{res.code} != 200" if res.code.to_i != 200 json = JSON.parse(res.body) json.each_with_index do |message, i| # store the last id $last_seen_id = message['id'] if i == 0 user = message['user'] u = user['profile_image_url'] u = OSX::NSURL.alloc.initWithString(u) i = OSX::NSImage.alloc.initWithContentsOfURL(u) GROWL.notify( 'twitter_update', "#{user['name']} (#{user['screen_name']})", message['text'], :icon => i ) end end begin fetch_tweets rescue Exception => e GROWL.notify('issue', 'twatch issue', e.to_s) end ObjectStash.store $last_seen_id, "#{ENV['HOME']}/growl.stash"