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.

ETags with memcached

I love ETags, but there’s something that annoys me: most implementations revolve around pulling a record out of a data store and only “rendering” the response if it hasn’t been modified. 

The problem with this approach is that request has already gone through most of your application stack–parsing params, authentication, authorization, a few database lookups–so ETags are only saving you render time and some bandwidth.

While working on a Sinatra-based JSON web service that gets very heavy traffic, I wanted to find a way to short-circuit...

Always show the page if there is an error in Cucumber

Cucumber failures can open the current page in a browser automatically, avoiding repeated "Then show me the page" reruns and speeding up debugging.

In-depth HTTP traffic analysis using tcpdump & Wireshark

From time to time we're convinced that an error must be very close to the network card, OS IP stack or compiler. In reality this is quite rare, so before continuing, triple-check that the issue is not located between chair and keyboard...

If you're still convinced that a in-depth analysis of network traffic might help you, go on:

  • Find out the IP address the client causing trouble will come from.

  • Replace 147.0.0.123 with the client address, log into your web server and run:

    `remote$ sudo tcpdump host 147.0.0.123 and port 80 -s 0 -w...

Allow a user to run a single command with root privileges

It's that simple to allow one of your Linux users to run a single command as UID 0:

  1. sudo visudo
  2. Add the line below to allow user 'deploy' to run /usr/bin/bundle with root privileges
deploy  ALL=NOPASSWD: /usr/bin/bundle

How to fix "extconf.rb:8:in `require': no such file to load -- mkmf (LoadError)"

Ruby gem installation can fail with LoadError for mkmf when Ruby header files are missing, often resolved by installing the platform’s Ruby development package.

Setting up Tomcat to use an existing OpenSSL certificate

Convert an existing OpenSSL certificate and private key into a Java keystore for Tomcat HTTPS, avoiding JSSE configuration errors and alias mismatches.

Restrict Apache access to your local computer

Apache development servers can accept connections from other machines on the network. Binding Listen to 127.0.0.1 limits access to the local computer.

Styling and scaling for mobile devices

Mobile pages need a dedicated stylesheet and viewport settings so iPhone, iPad, and Android layouts fit small screens without awkward scaling.

Shell script to clean up a project directory

Remove unused and unnecessary files from a project root with geordi clean, a cleanup command in the Geordi gem.