Friday, May 29, 2009

Another List for WWDC First-Timers

Attending WWDC for the first time is sort of like getting a diagnosis from a doctor: it's a good idea to get second opinions because not everybody has the same experiences. Here's another list of suggestions for first time attendees from Mac and iPhone developer Jiva DeVoe.

Part 6

Just a quick warning. For the last several weekends, my weekend ritual has been to write an installment of the OpenGL ES From the Ground Up tutorials. The sixth installment probably won't be coming out this weekend, however.

I'm backlogged on my current writing project, plus my daughters are in four dance performances this weekend, and I have relatives coming into town. The chance that I'll be able to sneak off and geek out writing about OpenGL ES are slim to none. But never fear, more installments will be forthcoming.

Thursday, May 28, 2009

WWDC Session Data Now Available at Attendee Site

If you've got a ticket for WWDC 2009, you can now get to the "official" times and dates for the sessions, including an iCalendar you can subscribe to, by going to the WWDC 2009 Attendee Site.

Wednesday, May 27, 2009

WWDC Session Data is Gone

Well, that didn't last long. Apparently, Apple didn't want us having access to the session date, time, and room information yet. The JSON feed for the session website has been changed so the previously posted scripts no longer work.

WWDC JSON Credit

I've been remiss. I included proper credit in my tweet, but not in my blog posts. The fact that the JSON data underlying Apple's WWDC session page includes dates, times, and room information was not my discovery, it was Glenn Seueira's. Thanks Glenn, and apologies for leaving that off the earlier posts.

Another iCal Script

The Big Nerd Ranch Blog has a more elegant script for converting the WWDC session data to iCalendar format. But, though the code is more compact, they missed the time zone, which would cause a problem for me.

WWDC Session Times for iCal Import

Here's a quick-and-dirty hack of the WWDC session script to create an iCalendar file that can be imported into iCal.
Again, this is public domain, feel free to hack away and improve it.

#!/usr/bin/env ruby
#
# This program will download the latest session JSON data
# from the WWDC website and turn it into an iCal
#
# Sorry about the cheezy HTML formatting; I am not a designer.
# If you'd like to contribute a better looking design, I'll
# incorporate it.
#
# Requires one of the following two gems to be installed:
#
# gem install json
# gem install json_pure
require 'rubygems'
require 'net/http'
require 'open-uri'
require 'json'
require 'date'

output = <<OUTPUT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
OUTPUT


r = open("http://developer.apple.com/wwdc/data/sessions.json").read

parsed = JSON.parse r
data = parsed["SessionsData"]

data.each do | oneSession |

upperTime = DateTime.parse(oneSession["time"][0]["upper"])
lowerTime = DateTime.parse(oneSession["time"][0]["lower"])
output << "BEGIN:VEVENT\n"
output << lowerTime.strftime("DTSTART;TZID=US/Pacific:%Y%m%dT%H%M%S\n");
output << upperTime.strftime("DTEND;TZID=US/Pacific:%Y%m%dT%H%M%S\n");
output << "DESCRIPTION:#{oneSession["description"]}\n"
output << "LOCATION:#{oneSession["room"]}\n"
output << "SUMMARY:#{oneSession["title"]} (#{oneSession["id"].to_s})\n"

# output << "<TR>"
# output << "<TD>#{oneSession["id"]}</TD><TD>#{oneSession["title"].to_s}</TD><TD>#{oneSession["focus"].to_s}</TD><TD>#{oneSession["level"].to_s}</TD><TD>#{oneSession["type"].to_s}</TD><TD WIDTH = \"200\">Start: #{lowerTime.to_s} <BR/>End: #{upperTime.to_s}</TD><TD>#{oneSession["room"].to_s}</TD><TD>#{oneSession["description"].to_s}</TD></TR>\n"
#

output << "END:VEVENT\n"
end
output << "END:VCALENDAR"

File.open("sessions.ics", 'w') {|f| f.write(output) }

Better Session Script

Ryan McCuaig sent me a kick-ass re-write of my WWDC session script. This one outputs the information with much, much better formatting.

Here's the very fine script:

#!/usr/bin/env ruby
#
# This program will download the latest session JSON data
# from the WWDC website and will parse it into a plain
# HTML table so it can be viewed.
#
# Requires one of the following two gems to be installed:
#
# gem install json
# gem install json_pure
#
# Also requires installation of Haml/Sass:
#
# gem install haml
#
# This script was written by Ryan McCuaig, based on a script by Jeff LaMarche

require 'net/http'
require 'open-uri'
require 'rubygems'
require 'json'
require 'haml'
require 'sass'

JSON_FEED = 'http://developer.apple.com/wwdc/data/sessions.json'

class Session
attr_accessor :title,:focus,:start,:description,:type,:identifier, :room
def initialize(array)
@title = array["title"]
@focus = array["focus"]
@type = array["type"]
@start = Time.parse(array["time"][0]["lower"])
@stop = Time.parse(array["time"][0]["upper"])
@description = array["description"]
@identifier = array["id"]
@room = array["room"]
end
def when
start = @start.strftime("%l:%M %p")
stop = @stop.strftime("%l:%M %p")
[start,stop].map{|x| x.strip}.join("-")
end
end

json_data = open(JSON_FEED).read
parsed_data = JSON.parse(json_data)["SessionsData"]

sessions = []
parsed_data.each do |array|
sessions << Session.new(array)
end
sessions.sort! {|x,y| x.start <=> y.start}

class Array
# group_by doesn't exist before Ruby 1.8.7, drat
def group_by
hash = {}
each do |element|
key = yield(element)
if hash.has_key?(key)
hash[key] << element
else
hash[key] = [element]
end
end
hash
end unless [].respond_to?(:group_by)
end

sessions_grouped_by_day = sessions.group_by {|x| x.start.strftime("%A")}

html_template = <<HTML
!!!
%html
%head
%title Session Times
%style= css
%body
%div#content
- %w{Monday Tuesday Wednesday Thursday Friday}.each do |day|
%h1= day
- days[day].each do |session|
%h2
%div#when= session.when
%div
= session.title
%span.type= session.type
%span.focus= session.focus.join(", ")
%span.identifier= session.identifier
%span.room= session.room
%p= session.description
HTML


css_template = <<CSS
!indent = 150px
#content
:width 800px
:margin-left auto
:margin-right auto
h1,
h2,
p
:font-family Helvetica Neue, Helvetica
h1
:font-size 21px
h2
:font-size 16px
:margin-left 0px
div#when
:position relative
:bottom -3px
:width = !indent
:float left
:font
:weight normal
:size 13px
span
:font
:weight normal
:size 13px
:padding 0 0.5em 0 0.5em
&.type
:color red
&.focus
:color green
&.identifier
:color blue
&.room
:font
:weight bold
:size 14px
:color grey

p
:font-size 13px
:line-height 21px
:margin-left = !indent
CSS


html_engine = Haml::Engine.new(html_template)
css_engine = Sass::Engine.new(css_template)

File.open("/tmp/wwdc_sessions.html",'w') do |file|
file.write html_engine.render(Object.new,
:days=>sessions_grouped_by_day,:css=>css_engine.render)
end
`open /tmp/wwdc_sessions.html`

WWDC Session Times

Okay, the session times have not been officially released for WWDC, but the underlying data used for the sessions website contains time and room data. Of course, since this hasn't been released, it's completely unofficial and likely to change, but for those who have been asking for WWDC session times, I give you... not the session times, but a script that will fetch the latest data and format it into a HTML table for you.

It's a ruby script, so it should run on any stock OS X machine. This is public domain code, do with it what you will. If you improve it, I'd love a copy of your version.

#!/usr/bin/env ruby
#
# This program will download the latest session JSON data
# from the WWDC website and will parse it into a plain
# HTML table so it can be viewed.
#
# Sorry about the cheezy HTML formatting; I am not a designer.
# If you'd like to contribute a better looking design, I'll
# incorporate it.
#
# Requires one of the following two gems to be installed:
#
# gem install json
# gem install json_pure
require 'rubygems'
require 'net/http'
require 'open-uri'
require 'json'


output = ""
output << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n\"http://www.w3.org/TR/html4/loose.dtd\">\n<HTML><head>\n\t<title>WWDC Session Times</title>\n</HEAD><body>"
output << "<TABLE WIDTH=\"100%\" BORDER=\"1\"><TR><TH>ID</TH><TH>Title</TH><TH>Focus</TH><TH>Level</th><TH>Type</TH><TH>Time</TH><TH>Room</TH><TH>Description</TR>\n"

r = open("http://developer.apple.com/wwdc/data/sessions.json").read

parsed = JSON.parse r
data = parsed["SessionsData"]

data.each do | oneSession |


lowerTime = oneSession["time"][0]["lower"]
upperTime = oneSession["time"][0]["upper"]


output << "<TR>"
output << "<TD>#{oneSession["id"]}</TD><TD>#{oneSession["title"].to_s}</TD><TD>#{oneSession["focus"].to_s}</TD><TD>#{oneSession["level"].to_s}</TD><TD>#{oneSession["type"].to_s}</TD><TD WIDTH = \"200\">Start: #{lowerTime.to_s} <BR/>End: #{upperTime.to_s}</TD><TD>#{oneSession["room"].to_s}</TD><TD>#{oneSession["description"].to_s}</TD></TR>\n"

end

output << "</table></body>"
File.open("sessions.html", 'w') {|f| f.write(output) }
exec 'open sessions.html'

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes