Skip to content

Instantly share code, notes, and snippets.

@jimryan
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 "http://rubygems.org"
gem 'json'
gem 'ri_cal'
gem 'tzinfo'
require 'net/http'
Bundler.require(:default)
json_cal = JSON.parse(Net::HTTP.get_response(URI.parse('http://railsconf2012.busyconf.com/event.json')).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:"
end
activity['speakers'].each do |speaker|
description << "\n#{speaker['name']}"
description << " (@#{speaker['twitter_username']})" if speaker['twitter_username']
description << "\n\thttp://github.com/#{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']
end
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']
else
track = json_cal['tracks'].select{ |k,v| k['_id'] == time_slot['track_id'] }.first
event.location = track['title'] if track
end
end
end
end
File.open('railsconf.ics', 'w') { |f| f.write(cal) }
@jimryan
Copy link
Author

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): https://raw.github.com/gist/2434125/af4f20c3f377b019f909a0395770a3df936a7fe1/railsconf2012.ics

If you'd like to add it on Google, I'm hosting it here: http://room118solutions.com/wp-content/uploads/2012/04/railsconf-2012.ics

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