Check if object has associated attribute methodSection: Ruby on Rails
if you want to check if an object has an associated attribute method:

if a person has_one image and a gallery has_many images:

gallery.respond_to?(:images)
# => true
gallery.respond_to?(:image)
# => false
person.respond_to?(:images)
# => false
person.respond_to?(:image)
# => true
Group items without saving backreferenceSection: regex
If you want to group some items in a regular expression, but don't want to have save it for later use, put a ?: after the (

eg:
source text: test1.gif test2.png test3.jpg

To match a filename with only gif and png extensions:

/(.*?\.(?:gif|png))/ 

this wil match : test1.gif, test2.png

without the ?: this would match: test1.gif, gif, test2.png, png
Remove safari glow on input fields on focusSection: Css
*:focus { outline: 0; }
before_filter and return falseSection: Ruby on Rails
It looks like Rails 2.0 will no longer pay attention to the return value of before_filters. Currently, in our Pre-Rails 2.0 world, before_filters stop processing a request when they encounter a return value of false. You may recognize the common pattern:
  redirect_to new_session_path && return false
Rails 2.0 won't require a return value of false for a before_filter to stop the action, but will instead look to see if you called redirect_to or render. If either of these functions are called the filter chain is halted. This should clean up a lot of code and remove a lot of repetition. At the end of the day your before filters look almost the same as they always have, just drop the
&& return false
authenticate_or_request_with_http_basic and apacheSection: Ruby on Rails
If you use authenticate_or_request_with_http_basic on an apache server, sometimes the the username and password you've set seems always wrong. To fix this, put the following line in public/.htaccess:
RewriteRule ^(.*)$ dispatch.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
Sections 
- PHP (1)
- General (2)
- Ruby on Rails Snippet (3)
- Ruby on Rails (13)
- HTML (1)
- Css (1)
- regex (1)
- Photoshop (1)
- Leopard (1)
A little note to Internet Explorer users:
This site is not made for Internet Explorer. Some pages may look like shit. Yes, i could fix it for IE, but no, I'm not gonna do it. Try Opera or Firefox instead!