Thursday, May 29, 2008

Disable rails session for robot (search engine crawler)

class ApplicationController < ActionController::Base
session :off, :if => lambda {|req| req.user_agent = ~/(Google|Slurp)/i}
# Google for Google and Slurp for Yahoo!.
# Explore your log for more robots

* Cited from The Rails Way

Rails RJS examples and official doc

With rjs, you can call the ajax helper without specifying the html elements. Moreover, you can do whatever you want after the action(update several divs, etc.).

render :update do |page|
page.replace_html 'div1', "HAHA"
page.replace_html 'div2', :partial => 'person', :object => @person

OR, you can create a rjs template:show.js.rjs, and put the rjs code there.

In the controller, you'll then have:
def show
...
#no render at all
end

Rails will pick the right template automatically.

Official rjs docs

Handy behavior driven Rails Ajax helpers

Periodically_call_remote:

periodically_call_remote(:url => 'update', :frequency => '20', :update => 'news_block')

observe_field:
<%= observe_field :suggest, :url => { :action => :find_suggestion },
:frequency => 0.25,
:update => :suggest,
:with => 'q'
%>

Rails named route

map.purchase 'products/:id/purchase', controller => 'catalog'

can be invoked with purchase_url(:id => 1)

Rails 2.0 Root Route

The proper way of setting root route in Rails 2.0

map.root : controller => "homepage"

Friday, April 25, 2008

Two very good interview guides

I find these two posts extremely helpful.

The Guerrilla Guide to Interviewing (version 3.0)

Take-home message: Smart and get things done.

Get that job at google

Take-home message: Get prepared, both mentally and technically.

Thursday, April 24, 2008

First shot

It has been a while since I opened this blog. My intention was to record whatever tech tips I got from the daily work for my own reference and hopefully for others who need it. And, it's also a good way for me to practice my English writing(yea...), since I'm not a native eng speaker.

It is until I started to read Steve Yegge's blog that I realized how big you could be from writing blog. Plus you can make money out of it. (Adsense, snaptalent, yahoo, etc.) So, I'm here.

Stevey's Blog Rants
Very very very good blog!
Hey, I'm actually adding his page rank...

I do have a lot of things that I want to write here, both from my previous Rails experience and my current job which is from a famous search engine company that everyone loves. The info from them is sort of sensitive though, so I'll think twice(or even more) before I post them.

That's it. I'll start to work on my Adsense account.