Skip to content

Instantly share code, notes, and snippets.

Created April 21, 2012 04:58
Show Gist options
  • Save jimryan/2434114 to your computer and use it in GitHub Desktop.
Save jimryan/2434114 to your computer and use it in GitHub Desktop.
RailsConf 2012 ical generator
source ""
gem 'json'
gem 'ri_cal'
gem 'tzinfo'
require 'net/http'
json_cal = JSON.parse(Net::HTTP.get_response(URI.parse('')).body)
cal = RiCal.Calendar do |cal|
json_cal['activities'].each do |activity|
cal.event do |event|
time_slot = json_cal['time_slots'].select{ |k, v| k['_id'] == activity['time_slot_id'] }.first
description = ''
description << activity['description'] if activity['description']
if activity['speakers'].any?
description << "\n\nSpeakers:"
activity['speakers'].each do |speaker|
description << "\n#{speaker['name']}"
description << " (@#{speaker['twitter_username']})" if speaker['twitter_username']
description << "\n\t{speaker['github_username']}" if speaker['github_username']
description << "\n\t#{speaker['job_title']}" if speaker['job_title']
description << "\n\t#{speaker['company']}" if speaker['company']
description << "\n\t#{speaker['url']}" if speaker['url']
description << "\n\tBio: #{speaker['bio']}" if speaker['bio']
event.dtstart = DateTime.parse(time_slot['starts_at']).with_floating_timezone
event.dtend = DateTime.parse(time_slot['stops_at']).with_floating_timezone
event.summary = activity['title']
event.description = description
if activity['location_override']
event.location = activity['location_override']
track = json_cal['tracks'].select{ |k,v| k['_id'] == time_slot['track_id'] }.first
event.location = track['title'] if track
end'railsconf.ics', 'w') { |f| f.write(cal) }
Copy link

jimryan commented Apr 21, 2012

I have another gist going with the ics, you can use this to add it to iCal or other calendars (except Google, because it'll complain about GitHub's robots.txt):

If you'd like to add it on Google, I'm hosting it here:

I'll try to keep them updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment