Fix for “git push” timeouts on new repository
Posted by tjones@barbarycodes.com in Uncategorized on January 16, 2011
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 [...]
TextMate Pattern to Exclude Rails' vendor Directory (most of the time)
Posted by tjones@barbarycodes.com in rails, tools on January 1, 2011
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 [...]
All Ruby Code Should Use Explicit Returns (Especially With Rails)
Posted by tjones@barbarycodes.com in rails, ruby on October 7, 2010
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. [...]
Automated Banning of Script Kiddies with fail2ban
Posted by tjones@barbarycodes.com in Uncategorized on October 6, 2010
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 [...]
Why I Switched From MySQL To Postgresql
Posted by tjones@barbarycodes.com in mysql, postgresql on March 18, 2010
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 [...]
Ruby Class Attributes Are Not Thread Safe
Posted by tjones@barbarycodes.com in rails on March 2, 2010
Don’t use cattr_accessor, use Thread.current[]. Also note Rails bug 3457.
How To Make $100 with MySQL REPEATABLE-READ Transactions
Posted by tjones@barbarycodes.com in Uncategorized on February 18, 2010
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 [...]
Random Notes To Self Regarding ThinkingSphinx
Posted by tjones@barbarycodes.com in rails on February 3, 2010
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 [...]
FATAL bug in Capistrano 2.5.11
Posted by tjones@barbarycodes.com in ruby on January 4, 2010
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.
Fix for Glassfish spontaneously exiting under Capistrano
Posted by tjones@barbarycodes.com in rails on December 16, 2009
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: [...]
