Retrieve the total number of records when paginating with will_paginate
will_paginate pagination can hide the full result size; total_entries returns the pre-pagination record count, but may require a slow second query.
Keep Pidgin up to date
If your pidgin IM fails to connect to ICQ, you may need to update it. The ubuntu default sources are usually outdated.
Just follow the instructions 1-4 and 1-3 on the page linked below.
Making SSL connection work
If you can not connect using SSL, open up the account settings and enable "clientLogin". Also, your Server should be set to slogin.icq.com.
Making AJAX Applications Crawlable
This document describes an agreement between web servers and search engine crawlers that allows for dynamically created content to be visible to crawlers. Google currently supports this agreement. The hope is that other search engines will also adopt this proposal.
Problems with Rails 3 Remote Links and Forms Using jQuery .live() in IE
There is a problem with AJAX response handling for Rails 3 remote links and forms in Internet Explorer. This problem affects applications still using jQuery 1.4.2.
Git: Stash unstaged changes
Stash only unstaged changes in Git with git stash -k; use -u to include new files, and keep the working tree clean before git stash pop.
Bookmarklet to generate a commit message with Pivotal Tracker story ID and title
Generate commit messages from selected Pivotal Tracker stories with ID and title for traceable git history.
scribd's flash_heed at master - GitHub
Fixes all Flash elements on a page so that they heed DOM stacking order
Change the id of an ActiveRecord record
Changing an ActiveRecord record’s primary key is usually unsafe, but a direct update_all can replace one id with another when it is unavoidable.
Migrate or revert only some migrations
Selective Rails migrations can be moved up, down, redone, or targeted by version instead of processing the full sequence.
Aliases for routes
The following initializer provides an :alias => "my_route_name" option to restful routes in your route.rb. This simply makes the same route also available under a different ..._path / ..._url helpers.
For example,
map.resources :notes, :alias => :snippets
Gives you
notes_path, notes_url, new_note_path... #as always
snippets_path, snippets_url, new_snippet_path... #from the alias
Put this into an initializer:
Git: "Interactive reverts"
Reverting only selected changes from one or more commits can be done interactively by staging parts of the diff and discarding the rest.
Git diff a file with another revision (or branch)
Compare one file against another commit or branch to inspect changes without reviewing the entire repository.
Install a specific version of a gem
Pinning a gem version avoids accidental upgrades and keeps installs reproducible. gem install supports exact version selection with --version or -v.
Prevent Bundler from downloading the internet
As a user of Bundler you have spent significant time looking at this message:
Fetching source index for http://rubygems.org/
To make Bundler skip this index update and only use installed gems, you can use the --local option:
bundle install --local
Unfortunately this does not work with bundle update.
It is said that Bundler 1.1 will use a feature of Rubygems.org that allows partial index updates. Hopefully the wh...
Generate a Unicode nonbreaking space in Ruby
Regular spaces and non-breaking spaces look alike; a small Ruby helper can return the Unicode nonbreaking space instead of using HTML entities or raw character codes.
Defining and using sub-classes with modularity
Nested classes in modular traits can lose their original namespace, breaking references from class methods and other code. Using class self::Bar preserves the enclosing class name.
Install gems for all bundled projects
Batch-installs Ruby gems for every project in a directory, speeding up setup on a new system; native extensions still fail without required system dependencies.
Select a random table row with ActiveRecord
Randomly selecting a database row with ActiveRecord is possible, but ORDER BY RAND() scales poorly and can overload large tables.
Test that a CSS selector is present with Cucumber
Cucumber step for checking whether a CSS selector is present or absent on a page with Capybara or Webrat.
Bash Cheat Sheet (standard Emacs mode)
Handy Bash key bindings and history shortcuts reduce typing and speed up command-line editing, repetition, and reuse of previous arguments.
Rails 3 Remote Links and Forms: A Definitive Guide
Thanks to habits engrained by Rails 2’s link_to_remote and remote_form_for, we expect that Rails 3 would also handle the AJAX response for our remote links and forms. But it doesn’t; it leaves that for you.
Share your Internet connection under Ubuntu
Turn an Ubuntu PC into a simple internet gateway for another computer using a second network interface and connection sharing.
Terminus: a client-side Capybara driver
Terminus is a Capybara driver where most of the driver functions are implemented in client-side JavaScript. It lets you script any browser on any machine using the Capybara API, without any browser plugins or extensions.