Thursday, May 22, 2008

My New Time Clock




require "rubygems"
require "rbosa"
require 'ruby-growl'

def make_it_rain
itunes = OSA.app('iTunes')
itunes.back_track
track = itunes.current_playlist.search("Let It Rain")[0]
track.start = 15
track.finish = 42
track.play(:once => true)

g = Growl.new "localhost", "ruby-growl",
["ruby-growl Notification"]
g.notify "ruby-growl Notification", "Make It Rain!",
"$$$$$$$$$$ "* Integer(@money / 100)
end

print "Hourly Rainfall? "
rate = Float(gets)

time = 0
next_hundred = 1

start_time = Time.now

trap("INT") do
puts "\nYou worked for " +
"#{'%0.2f' % ((Time.now - start_time) / 60) } minutes"
exit
end

loop do
sleep 5
time += 5
puts "$ #{'%0.2f' % @money = (time / 60.0 / 60.0) * rate}"
if @money.to_f / 100 >= next_hundred
next_hundred += 1
make_it_rain
end
end
Because everyone wants a small celebration complete with hip-hop and dollar signs filling the screen every 100 dollars they make!

1 comment:

Anonymous said...

You, sir, are my hero!
- Allen