Continously run command under bash
Sometimes you want to run a command forever, e.g. to compile a haml to html file on the console. Use this:
$ while(true) do haml index.haml index.html; sleep 1.5; done
Cucumber fails without giving error message
Cucumber can fail with little or no visible error output; a backtrace, verbose formatter, or debug mode can expose the underlying cause.
Linux: rename or change extension of multiple files
Bulk file renaming on Linux is error-prone with shell wildcards; Perl rename can change extensions or strip filename prefixes in one command.
Deploy and migrate with a single Capistrano command
Run database migrations during deployment with cap deploy:migrations to restart an application after schema changes, but task hooks can make the sequence unsafe.
Show the description of a Capistrano task
In order to bring up a textual description of a Capistrano task you can say
cap -e taskname
... where taskname is the name of the task you're not sure about.
Auto-hide player controls in the default Flash video player component
Hiding the default Flash video player's controls keeps the skin from staying visible during playback. Set skinAutoHide to true in the component inspector.
Test that a select field contains an option with Cucumber
Cucumber steps can verify that a form select contains or excludes a specific option, without checking the currently selected value.
Fix errors when rendering PDF output
If you run specs or your application and get an error like:
ActionController::MissingFile in 'ProductsController#show, should render PDF'
Cannot read file /some/file.pdf
You may be missing the HTMLDOC binary on your system. Install it like this on Debian/Ubuntu:
sudo apt-get install htmldoc
Show the name and version of your Linux distribution
Get the Linux distribution name and version from release files with a single command.
hyphenator
Javascript that implements client-side hyphenation of HTML-Documents.
remove_index fails silently for non-existing indexes in Rails 2 migrations
When you try to remove a non-existing index using remove_index, the migration will incorrectly pass without an error. The schema will not be changed, but the migration will be considered migrated.
Since this might be fixed in the future, you cannot mend your database by adding another migration on top of the faulty one. You should manually alter the database schema to the previous migration on all machines that migrated the faulty migration (inform your fellow developers), then delete the faulty migration from the repository.
The Case Against Queues
Networked message queues often encourage overengineered systems and operational headaches, adding latency, hidden complexity, and 4AM incidents instead of solving communication problems.
Using Firebug Lite to inspect HTML in Internet Explorer and other browsers
Firebug Lite brings Firebug-style DOM inspection to Internet Explorer and other browsers, including older IE versions, using a JavaScript bookmarklet.
babushka: test-driven sysadmin
The idea is this: you take a job that you'd rather not do manually, and describe it to babushka using its DSL. The way it works, babushka not only knows how to accomplish each part of the job, it also knows how to check if each part is already done. You're teaching babushka to achieve an end goal with whatever runtime conditions you throw at it, not just to perform the task that would get you there from the very start.
OscarGodson/jKey - GitHub
jQuery plugin to register callback functions to keyboard shortkuts. Keyboard events in vanilla Javascripts are super-painful to work with, so hopefully this library can help.
The Difference Between jQuery’s .bind(), .live(), and .delegate()
The difference between .bind(), .live(), and .delegate() is not always apparent. Having a clear understanding of all the differences, though, will help us write more concise code and prevent bugs from popping up in our interactive applications.
Calling selected methods of a module from another module
Need access to only a few methods from another module without exposing them all; module_function makes selected methods callable externally while keeping the rest private.
Split an array into groups
Ruby arrays can be split into fixed-size groups or a chosen number of groups with ActiveSupport, padding or omitting leftovers as needed.
Freeze (vendor, unpack) a single Ruby gem with and without Bundler
Vendoring a patched Ruby gem in Rails can fail without gem metadata, especially with Bundler. A proper .specification file and :path setup make the local copy usable.
MySQL: "LOAD DATA INFILE" says "file not found"
This might be due to AppArmor denying the MySQL server access to most of the filesystem. You can instead use
LOAD DATA LOCAL INFILE ...
to pipe data through the MySQL client, which can read everything the executing user can.
Properly sanitizing column names for MySQL
Backtick quoting alone does not prevent MySQL column-name injection when SQL fragments are built from user input. Removing backticks before quoting makes malformed identifiers fail safely.
Test the status code of a response in Cucumber
Checking response status in Cucumber can verify error handling and redirects during acceptance tests. Webrat and Capybara expose status information for custom step definitions.
Perform HTTP basic authentication in Cucumber (with or without Selenium)
Cucumber step for HTTP basic auth in Capybara, Rack::Test, or Selenium when visiting protected admin pages via path_to.
Access the documentation of all locally installed gems
Offline RubyGem documentation becomes available when rubydoc.info is unavailable or slow. gem server provides a local browser for installed gems and generated docs.