Use Shoulda's validate_uniqueness_of matcher correctly

validate_uniqueness_of in Shoulda needs an existing record; without it, RSpec can raise “Could not find first Keyword” during uniqueness checks.

Automatically run bundle exec if required

There will probably be better solutions as we become more experienced with using Bundler, and more command line tools become Bundler-aware.

b will use bundle exec if there is a Gemfile in the working directory, and run the call without Bundler otherwise.

b spec spec

This script is part of our geordi gem on github.

jQuery Countdown

A jQuery plugin that sets a div or span to show a countdown to a given time

Automatic Flushing: The Rails 3.1 Plan « Katz Got Your Tongue?

This post explains, in some detail, how we will implement a nice performance boost for Rails developers. Understanding the details might help gain the full benefits of the optimization, but you will gain some benefits even if you have no idea how it works.

jQuery Captify (v1.1.3) / Simple Animated Image Captions

jQuery plugin for attractive image rollover captions on hover, adding simple animated text overlays to images.

rhulse's rails-css-views at master - GitHub

This gem is designed to provide CSS views to Rails, and a process to concatenate and minify these files to one file for production.

Unstage an added file in Git

Remove a mistakenly added file from the staging area while keeping local changes; git reset HEAD path/to/file also works for conflicted files.

Retrieve exchange rates

The ECB has an XML feed with EURO exchange rates to other currencies. It is updated daily.

Airbrake notification in Rake tasks

Rake tasks can report exceptions to Airbrake without notifying in development or test environments, using the usual notification rules for tasks that depend on :environment.

The dangers of url_for in Rails applications

In a great post about named routes in Rails, path vs. url, Viget Labs ponders which variant is best used.<br />
<br />
Most often we use foo_path, which when used in Rails URL helpers will generate a relative path, where foo_url generates a full URL. In most cases the path makes most sense, but not always.

Make box shadows look the same in IE and other browsers

The box shadows created rendered in IE by CSS3PIE look darker and are blurred differently than in browsers that render box-shadow natively.

If possible, try to be OK with this. If not, make an IE-only stylesheet that uses a different color and blur radius:

// Real browsers:
+box_shadow("0 4px 10px #bbb")

// IE with PIE:
+box_shadow("0 5px 15px #888")

We should try to package this solution in a neat way so we don't need different stylesheets.

See also this [cross-browser box-shadow comparison]...

Scope to records with a given state in state_machine

with_state from state_machine can break in complex scope chains; a custom having_state scope keeps record filtering reliable.

Fighting the @font-face FOUT « Paul Irish

Cached web fonts can still cause a flash of unstyled text during loading.

Bundler for Rails 2.3.x

Bundler support for Rails 2.3.x requires updated RubyGems and Passenger, a bundled Gemfile workflow, and bundle exec for tests and deployment.

Disable Rails XSS protection in ActionMailer views

Rails XSS protection can escape ActionMailer email bodies unexpectedly. A configuration initializer prevents rails_xss from escaping mail content.

Use the same template for multiple ActionMailer actions

One option is to use partials. Or you can set the @template field to the name of another action:

class Mailer < ActionMailer::Base
  def foo
    subject "Hello World"
  end
  
  def bar
    subject "Hello Universe"
    @template = 'foo'
  end
end

Recursively remove unnecessary executable-flags

Unexpected executable bits can appear on normal project files after copying from Windows or a Samba share. geordi remove-executable-flags clears them recursively with chmod -x.

Hide the last bottom margin in a container

Child elements’ bottom margins can create unwanted inner spacing in boxes like sidebars. A Sass mixin removes the last child’s bottom margin; older IE needs a class fallback.

Linux: create a symbolic link

You may omit the /path/to/link_name to have a link with the same filename appear in the current directory

ln -s /path/to/file /path/to/link_name

unlink link_name       // to remove the link and not where it is pointing at

Vadikom » Poshy Tip - jQuery Plugin for Stylish Tooltips

With this plugin, you can create a scalable tooltip by just using a single background image for the tooltip body.

Prototip 2 - Create beautiful tooltips with ease

Prototip allows you to easily create both simple and complex tooltips using the Prototype javascript framework.

Please note: "Permission to use Prototip on your domain is required and can be obtained by paying a small fee."

Programming Things I Wish I Knew Earlier

The point is, evented I/O is not magic scalability pixie dust, and like anything, there is a tradeoff.