Skip to content

Instantly share code, notes, and snippets.

@rubiety
Created August 23, 2010 01:42
Show Gist options
  • Save rubiety/544592 to your computer and use it in GitHub Desktop.
Save rubiety/544592 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
## JetBlue AYCJ Notifier
# So JetBlue doesn't want to tell us exactly when AYCJ-ers can book flights.
# This script polls my inbox for any new e-mail from JetBlue and continually
# contacts http://www.jetblue.com/aycj and sees if the "come back tomorrow" image is still there.
# If anything has changed or an error occurs, use's Mac OS "say" to dictate text and wake me up
# so I can book my damn flights. I really wonder how many people are going to stay up tonight hitting the
# refresh button every 10 seconds.
require "rubygems"
require "open-uri"
require "mime"
require "gmail"
def wake_me_up(message = "Wake up! Change to JetBlue.", repeat = 10)
puts "Saying: #{message}"
repeat.times { `say #{message}` }
end
while true do
begin
puts "[#{Time.now.to_s}] Checking AYCJ page for changes..."
wake_me_up("JetBlue page changed!") unless open("http://www.jetblue.com/aycj/").read.gsub(/<!--(.*)-->/, '') =~ /interim.png/
rescue
wake_me_up("Could not read JetBlue Page: #{$!.message}", 1)
end
begin
puts "[#{Time.now.to_s}] Checking E-mail for JetBlue Message..."
gmail = Gmail.new("[email protected]", "mypassword")
wake_me_up("New JetBlue E-mail") if gmail.in_label('JetBlue').count > 0
gmail.logout
rescue
wake_me_up("Cannot connect to Gmail: #{$!.message}")
end
sleep 120
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment