Skip to main content

Alert WWDC 2013 announcement using Pushover and Ruby

·2 mins

Last year I used WWDCAlerts for WWDC 2012. My alert arrived two hours after the tickets were released. Luckily a friend let me know and I booked a ticket. This year I thought it be better to do it myself using Ruby and PushOver – a mobile alerting service for Android/iOS. Here’s how to setup a WWDC 2013 alert announcement using PushOver and Ruby. The idea came from this gist: https://gist.github.com/jfahrenkrug/817585

What the script does #

Search html from https://developer.apple.com/wwdc/ for the 2012 Apple WWDC graphic (‘wwdc2012-jun-11-15.jpg’). If the graphic doesn’t exist, send a PushOver alert. The assumption is the page has been updated (hopefully) to reflect the WWDC 2013 announcement.

Steps #

1. Signup for Pushover (https://pushover.net/) #

– Create an account

– Create an app – you’ll need this to send Pushover alerts

– Download the iPhone/Android app, and test you can send and receive notifications using your app. Check out the Pushover FAQ for test clients: https://pushover.net/faq

– Make a note of your user key and app key – you’ll need it for the Ruby script.

2. Create Ruby script. #

REMEMBER TO REPLACE WITH YOUR PUSHOVER APP AND USER KEYS

require 'rubygems'
require 'open-uri'
require 'net/https'

class WWDC2013
def self.announced?
begin
indicator_line = open('https://developer.apple.com/wwdc/') do |f|
# look for current 2012 image.
f.detect { |line| line =~ /wwdc2012-june-11-15.jpg/ }
end
rescue Exception => e
print "Error: #{e.message}\n"
end
indicator_line == nil
end
def self.pushOneOff
url = URI.parse("https://api.pushover.net/1/messages.json")
req = Net::HTTP::Post.new(url.path)
req.set_form_data({
:token => "REPLACE_WITH_PUSHOVER_APP_TOKEN",
:user => "REPALCE_WITH_PUSHOVER_USER_KEY",
:message => "WWDC 2013 announced!",
})
res = Net::HTTP.new(url.host, url.port)
res.use_ssl = true
res.verify_mode = OpenSSL::SSL::VERIFY_PEER
res.start {|http| http.request(req) }

end
end

# print Time.now.localtime.strftime("At %I:%M:%S%p WWDC 2013 has...")
if WWDC2013.announced?
WWDC2013.pushOneOff
else
# print "not been announced\n"
# WWDC2013.pushOneOff
end

3. TEST your Ruby script #

run it on the command line – comment in ‘WWDC2013.pushOneOff’ to force a PushOver alert. (Make sure to comment it out when you’re done testing! It should only be invoked if WWDC 2013 is announced)

4. use Cron to schedule your script to run. #

I scheduled mine to run every 12 minutes.

See you at WWDC 2013!