Skip to content

Instantly share code, notes, and snippets.

@tachyons
Last active November 8, 2015 20:07
Show Gist options
  • Save tachyons/48a3655845b1a988aa91 to your computer and use it in GitHub Desktop.
Save tachyons/48a3655845b1a988aa91 to your computer and use it in GitHub Desktop.
cricinfo status in your desktop
#!/usr/bin/env ruby
require 'date'
require 'rubygems'
require 'libnotify'
require 'net/http'
require 'rexml/document'
require 'xmlsimple'
def every( time )
Thread.new {
loop do
sleep(time)
yield
end
}
end
class Numeric
def seconds
self
end
def minutes
self * 60
end
def hours
self * 60 * 60
end
end
last_details=""
every( 30.seconds ) {
# fetch score
url = 'http://static.cricinfo.com/rss/livescores.xml'
# get the XML data as a string
xml_data = Net::HTTP.get_response(URI.parse(url)).body
data = XmlSimple.xml_in(xml_data)
details=data["channel"][0]["item"][0]["description"][0]
if details != last_details
Libnotify.show :summary => "Score", :body => details
end
last_details=details
}
# Do some other processing so it stays alive
sleep(10000)
@tachyons
Copy link
Author

install dependencies
Ruby 1.8.7
gem install xml-simple
gem install libnotify

@RohitR
Copy link

RohitR commented Mar 26, 2015

simple and cool.. !tHuMbS uP!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment