Fix for “git push” timeouts on new repository

While migrating a large codebase from Subversion to Git recently I ran across the following error during the initial push from my development system to the new remote repository: Read from remote host <…>: Operation timed out error: pack-objects died of signal 13 error: failed to push some refs to ‘ssh://<…>’ Rerunning “git push” with [...]

No Comments

TextMate Pattern to Exclude Rails' vendor Directory (most of the time)

It’s useful to (a) exclude the vendor directory from normal TextMate projects, but (b) still be able to pull up the Rails source under vendor/rails from time to time. If you simply add vendor to the TextMate Folder Pattern, you’ll get (a) but not (b). To get both, add vendor$. Here are the patterns I [...]

No Comments

All Ruby Code Should Use Explicit Returns (Especially With Rails)

A lot of people who enter programming through hacking around with scripting languages rather than formal computer science educations don’t understand certain fundamentals such as the difference between functional and non-functional programming models (hint: Ruby isn’t functional). One of the Rails core team members argues that explicit return statements in Ruby code is a bad thing. [...]

No Comments

Automated Banning of Script Kiddies with fail2ban

I like to configure my webapps to automatically send me email upon any error, including 404s (file not found), since that can indicate a bad link within the app.  Unfortunately, script kiddies trying URLs like /phpMyAdmin/scripts/setup.php and hundreds of similar variants can trigger the email and flood my inbox. fail2ban to the rescue!  This wonderful tool [...]

,

8 Comments

Why I Switched From MySQL To Postgresql

I’m working on a project which has a very “wide” database schema — not many rows, but lots and lots of (text) columns.  Since I use InnoDB exclusively on MySQL (due to its lack of constraints and transactions, MyISAM is not suitable for production use), I ran into the mysterious “error 139″ when adding rows [...]

2 Comments

Ruby Class Attributes Are Not Thread Safe

Don’t use cattr_accessor, use Thread.current[].  Also note Rails bug 3457.

No Comments

How To Make $100 with MySQL REPEATABLE-READ Transactions

MySQL defaults to REPEATABLE-READ transactions.  This means that repeated SELECT statements within the same transaction return the same data (i.e., they don’t pick up interim updates made outside the transaction).  Specifically, reads take place from a snapshot of the database created for the first read in the transaction. This may lead to unexpected results when [...]

No Comments

Random Notes To Self Regarding ThinkingSphinx

You’re supposed to remember more of what you write, right? On ThinkingSphinx: Attributes are used for sorting, filtering and grouping your search results. Their values do not get paid any attention by Sphinx for search terms, though, and they’re limited to the following data types: integers, floats, datetimes (as Unix timestamps – and thus integers [...]

No Comments

FATAL bug in Capistrano 2.5.11

This change to deploy.rb in Capistrano 2.5.11 is causing the deploy:cleanup task to REMOVE THE CURRENT VERSION OF THE APP FROM THE SERVER (at least under every version of Linux I’ve tried — maybe some other OS has other semantics for “ls -xt”).  I recommend reverting to 2.5.10 until this is fixed.

1 Comment

Fix for Glassfish spontaneously exiting under Capistrano

I’m using Capistrano to deploy a Rails app running under JRuby via the Glassfish gem. For no apparent reason, the Glassfish Java process would exit immediately when started via Capistrano, but not when started via plain SSH or locally via the command line. I finally tracked this down to the following in my deploy.rb file: [...]

6 Comments