Please visit the new location of this blog:
RailsConf 2011 Best of Sessions
Below I put together my personal list of best RailsConf 2011 presentations that have online slides or PDFs. I put my comments next to each. Click on the link, then click on the “slideshow” or “PDF” links for each talk. And if you are feeling sentimental, and added bonus:
mms-mime: MM7/MMS MIME parsing gem
https://github.com/kigster/mms-mime
This gem was written with a simple aim to parse MM7 wrapped binary and base64 encoded MMS messages received via MM7/XML HTTP post from an MM7 compatible gateway connection (such as OpenWave, OpenMarket, etc).
The gem provides a simple way to parse and access MMS message contents, such as from, to, subject and content parts (including image and text parts).
>Amazing Map of World of Warcraft World Routes and Travel Paths post Cataclysm
>If you are playing Cataclysm, you may be baffled by the new travelling routes between continents. Well, baffle no more! My amazing artistic wifey had created this fantastic map of routes, so you can figure out how to get from anywhere to everywhere without a handy mage
>GoGaRuCo 2010 – San Francisco Ruby Conference
>Had an awesome time here for two days, listening to talks, hacking on some code, learning, networking, even managed to sign up for the UCSF gym and to take a swim.
Very nice organization, excellent venue, and fantastic talks. Definitely coming back next year. For the price it’s well worth it.
Here are some highlights:
- Super useful resource for lookup up shell commands: http://shellhaters.heroku.com/posix
- Terminator plugin: start your dev environment as you like it. Gem install terminator
- http://github.com/rdy/fixture_builder Factory to Fixtures converter to speed up your tests.
- pprof profile Ruby interpreter. Rack-Profiler project, great profiling tool.
- Coffee Script – wrapper (ruby-esque) for javascript; rails 3.1 supports coffee script templates
- Machine Learning – great talk, and O’Reiley book, http://twitter.com/igrigorik
- minitest fastest testing framework, many mentions, very fast, supports RSpec and Test::Unit syntax
- Caching: using fresh_when(:last_modified => …) to enable proper HTTP caching in Rails 3.1
- Arel: enables fragment caching that does not run SQL if the fragment is cached
- ruby 1.9: require ‘objspace’ allows inspection of object counts and memory usage in VM
>Twitter is the slowest social network, Facebook the fastest
>
Interesting statistics just came out on AlertSite blog post about performance and response time of various highly trafficked social networks.

Unsurprisingly, Facebook is the fastest, and Twitter is the slowest. Facebook has so much more data to deal with, so much media, and so many more users, that it really is a shame for Twitter with it’s 140 character data set to be in this unglorious last place.
After continuous reports about migrating to Cassandra, Twitter still serves their tweets out of MemCaches that sit in front of MySQL. When those caches die, it takes a long time to refill them and the site yet again drops the very familiar Fail Whale.
Perhaps Twitter’s infrastructure group could use some new blood to work on scaling and up-time. I am guessing that adding experienced people who scaled Facebook, or other high traffic sites could really help in the long run. The problem is that hiring experienced contributors to work on this pain point may feel threatening to the existing crew who continually tried and ultimately failed to fix Twitter’s performance problems. Don’t fall into this trap Twitter: people who are having hard time re-engineering current architecture will continue to have a hard time without an influx of fresh energy and new ideas. Consider making the necessary changes, and then perhaps you could pull out of that miserly last place.
>Rails3, Rack and "Where did my Metal go?"
>
Our Rails3 (beta4) application had one route mapped in config/routes to a Sinatra app, by means of the following route:
match '/foo', :to => EndPointApp, :as => :endpoint
The route was being defined to run as a Sinatra Application
require 'sinatra'
class EndPointApp < Sinatra::Application
post '/foo' do
...
end
end
This was working mostly fine, but it was returning Set-Cookie header with the standard Rails sessions cookie, which in this case was preventing the client of this endpoint from successfully interpreting the result. As I could do nothing about the client side, I had to remove Set-Cookie from the headers, but only for this end-point and obviously not from the entire app. This proved to be somewhat more complicated than I had hoped, so let me share the solution here in hopes it might save someone else an hour or two.
First, I ran “rake middleware” and observed the following Rack stack:
use ActionDispatch::Static use Rack::Lock use ActiveSupport::Cache::Strategy::LocalCache use Rack::Runtime use Rails::Rack::Logger use ActionDispatch::ShowExceptions use ActionDispatch::RemoteIp use Rack::Sendfile use ActionDispatch::Callbacks use ActiveRecord::ConnectionAdapters::ConnectionManagement use ActiveRecord::QueryCache use ActionDispatch::Cookies use ActionDispatch::Session::CookieStore use ActionDispatch::Flash use ActionDispatch::ParamsParser use Rack::MethodOverride use ActionDispatch::Head run Kigster::Application.routes
As can be immediately seen from here, the routes execute very last after Session::CookieStore already wrapped the request. OK, so looks like I need to bypass the routes somehow, and so I started to look at Rails::Metal, which is supposed to run before all other processing.
Once I started to look for Rails::Metal, I realized pretty quickly that I am missing metal generator:
> rails g metal Could not find generator metal.
After a few more rounds of digging around, it turns out that in Rails3 Beta4 Rails::Metal has been completely removed, because it is no longer needed in a Rack environment.
So I had convert my Sinatra module to a Rack module, and insert it into the Rack middleware stack before the Cookie/Sessions:
require File.expand_path('../../../config/environment', __FILE__) unless defined?(Rails)
module Kigster
class EndPoint
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ /^foo/
process_request(env)
else
@app.call(env)
end
end
private
def process_request(env)
req = Rack::Request.new(env)
params = req.params
# do stuff
[ 200,
{ "Content-Type" => "text/html",
"Content-Length" => "0" },
[""]
]
end
end
end
I had add the following to my config/application.rb to enable this Rack module, and have it run before the ActionDispatch::Session::CookieStore:
# config/application.rb
# require the file directly
require File.join(File.dirname(__FILE__), '../app/metal/kigster_endpoint')
....
module Kigster
class Application < Rails::Application
config.middleware.insert_after Rails::Rack::Logger,
Kigster::EndPoint
end
end
Now my handler executes before the session, and the result does not include Set-Cookie header.
Any other suggestions on how to make this any simpler, or more correct are as always welcome!
