Friday, August 29, 2008

Sharp's dirty advertisement

Well, as far as I know, Sharp currently only sells LCD TV, though I admit that their LCD screens are one of the best if not the best.

But look at this ad.



Such a lowly and misleading ad. It brings you to this page full of LCD TVs. Do they need to do that?

Friday, August 8, 2008

Ruby return & ensure gotcha

If you have return and ensure in your method, be very very careful. What happens is when you call return, the method will not return immediately, but it will execute the ensure block.

This can become a problem on Rails and I guess most of other things.


def some_action
return render :action => 'something' if some_condition
# do other things
rescue Exception => ex
# handle exception
ensure
if other_condition
render :action => 'other_thing'
else
render :action => 'default'
end
end


Let's say some_condition is true, you'll end up with the render inside ensure block and things will get double rendering fun.