RailsConf 2009 Notes

Tuesday 05/12/2009  –  Category: Uncategorized  –  1 Comment

Can someone smell stale blog?  It's been busy on this side and I haven't had any blogworthy material for awhile...until now.

I had the opportunity to go to RailsConf last week in Las Vegas.   A lot of smart people, an overwhelming array of Apple products and geeky shirts, and tons of nerdy sessions.

Here are some brief notes from the conference:

jQuery on Rails

  • good review of basic jquery selectors and more advanced DOM selectors like siblings(), nextall(), find(), filter()
  • .live() can bind events after elements are added (new with jQuery 1.3)
  • http://plugins.jquery.com/project/metadata/
  • <div data="{some: 'data'}">
  • $("div").metadata().some // returns 'data'
  • Rails 3 will implement unobtrusive js


  • Rack is a generic interface for Ruby and Ruby frameworks
  • provides a standard interface for creating middleware that gets run going down the stack
  • sample basic Rack: http://gist.github.com/110847
  • use case: progressive caching - middleware that holds a session and allows cached page to dynamically load personalized content
  • use case: Twitter "embiggener" - a middleware that Twitter could use to replace all tinyurls with full urls
  • http://assets.en.oreilly.com/1/event/24/And the Greatest of These Is ___ Rack Support Presentation.pdf


Rails 3 - some new features

  • XSS protection: auto-escaped by default
  • use <%=raw %> to force raw
  • UJS finally!
  • html5 style data-foo attributes so will validate but can also be accessed by any JS library
  • cleaner router

UI fundamentals for programmers

  • terseness is not a value for ui design.  need explanation!
  • "from the customer's point of view, the UI is the entire application"
  • separate screens into REST-named conventions (new/index/show/edit)
  • focus on the inside-out, content that matters first!
  • "we should really have a weak tag" when applying least effective difference principle
  • don't be clever by extracting html into helpers--things can change and need flexibility
  • separate CSS and JS for separate actions

JS testing

Chris Wanstrath (github) keynote

Twitter on Rails

JRuby on Google App Engine

  • it's possible! takes quite a bit of footwork to set up though.
  • limitations: no sockets, writing to filesystem, must use Google's DB system
  • worth keeping an eye on in the future as a deployment option

Mountable apps in Rails 3

  • will enable multiple apps that can share functionality
  • a more versatile pluggable architecture (think Drupal/Wordpress-like plugins)
  • example: an auth component that can be used as a SSO gatekeeper across different components (blog, admin section, etc)


  • a CSS meta-framework that uses haml and sass
  • can integrate popular frameworks like 960, YUI, Blueprint
  • can create reusable mixins, constants
  • export as expanded, compact, or compressed
  • http://wiki.github.com/chriseppstein/compass


  • a version of Ruby 1.9 that runs on top of Mac OS core frameworks
  • Ruby types are ported to their Cocoa equivalent: string = NSString, array = NSArray, etc...
  • so you can use Cocoa methods in addition to Ruby methods
  • you can use Interface Builder like normal and use Ruby classes to power the interface

php usort

Tuesday 02/10/2009  –  Category: Uncategorized  –  2 Comments

I learned about a nifty PHP function that allows you to sort an array with a user-defined comparison function. This is useful if you have an array of database results and need to sort by one element in the result array (normally it would be better to sort with the SQL query but I had a mixed dataset to sort).

This is a bit similar to ranges in Ruby where the objects you're comparing have to be comparable with the <=> operator.

Sample usort with custom function:

function cmp($a, $b) {
	if($a["view_order"] == $b["view_order"]) return 0;
	else if($a["view_order"] > $b["view_order"]) return 1;
	else if($a["view_order"] < $b["view_order"]) return -1;
usort($tab_items, "cmp");

Google Latitude

Monday 02/9/2009  –  Category: Uncategorized  –  No Comments

I've been wondering when Google was going to jump on the location-based service bandwagon after seeing apps like Brightkite and Loopt started getting popular when the iPhone came out.

As of now, the following devices are supported:
- Android-powered devices with Maps v3.0 and above. G1 users in the US will be receiving Maps v3.0 in a system update soon.
- Most color BlackBerry devices
- Most Windows Mobile 5.0 and above devices. Note: Some Windows Mobile devices don't support cell-ID location detection.
- Most Symbian S60 devices

No iPhone yet?? I guess I'll have to stay with the web interface (which is a bit clunky within the iGoogle framework IMO). At the very least I'd expect some automatic location detection via IP geocoding...

IE – Expected identifier, string or number

Monday 02/9/2009  –  Category: Uncategorized  –  1 Comment

If you're getting this error, chances are you have an extra comma after a curly brace:

a = {
   b: function() { },
   c: function() { },

Get rid of the trailing comma and your JS error woes will disappear!

Safari doesn’t read inline css

Monday 02/9/2009  –  Category: Uncategorized  –  No Comments

I'm not sure why I haven't come across this until this past week, but I found out that Safari doesn't render css within style tags outside the head tags.

The workaround is to inject the style into the head with javascript--similar to what Rails' content_for does:

var cssDefinitions = '..my style chunk goes here';
var style = document.createElement('style');'

(jquery code from stackoverflow)

After this things were looking dandy in Safari but now IE was giving a weird "unexpected call to method or property access" error. It turns out that IE doesn't let you add style elements like this. The workaround for IE looks like this:

var styleElement = document.createElement("style");
styleElement.type = “text/css”;
if (styleElement.styleSheet) {
  styleElement.styleSheet.cssText = “a { color: red }”;
} else {
  styleElement.appendChild(document.createTextNode(”a { color: red; }));

source: YUI blog

 Page 7 of 15  « First  ... « 5  6  7  8  9 » ...  Last »