Skip to content

Instantly share code, notes, and snippets.

@kimhunter
Created April 22, 2013 21:27
Show Gist options
  • Save kimhunter/5438701 to your computer and use it in GitHub Desktop.
Save kimhunter/5438701 to your computer and use it in GitHub Desktop.
wwdc 2012 cron check
#!/usr/bin/env ruby
require 'open-uri'
require 'date'
require 'nokogiri'
URL = "https://developer.apple.com/wwdc/"
MP3 = "~/Projects/wwdc-check/giants.mp3"
found = false
def wwdc_is_here
`open -a VLC #{MP3}`
`osascript -e 'set volume 7'`
`open -a Safari #{URL}`
`/usr/bin/osascript "~/Projects/wwdc-check/callMe.applescript"`
end
def try_macrumours_too
mrxml = Nokogiri::XML(open('http://www.macrumors.com/'))
h2_with_wwdc = mrxml.xpath('//h2').map {|e| e.text }.select {|title| title =~ /wwdc/i }
is_on_macroumors = h2_with_wwdc.size > 0
wwdc_is_here if is_on_macroumors
is_on_macroumors
end
open(URL).each do |line|
if line =~ /2012/ && !(line =~ /copyright/i)
found = true
wwdc_is_here
break
end
end
try_macrumours_too unless found
`echo "Successfully run on $(date)" >> ~/Desktop/wwdc_check.log`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment