Created
April 22, 2013 21:27
-
-
Save kimhunter/5438701 to your computer and use it in GitHub Desktop.
wwdc 2012 cron check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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