January 2012
1 post
3 tags
Importing large databases into Amazon RDS
I recently had to import a large database (20GB+) into Amazon RDS. I first tried using the method suggested in the RDS documentation for large databases, i.e., export the table data into CSV files then use the mysqlimport utility to import the data into the tables on your RDS instance. However, when the database tables have foreign key constraints this approach doesn’t work as you will...
December 2011
2 posts
2 tags
Undefined method `bytesize' for nil:NilClass
This error (and a related one: undefined method `unpack’ for nil) threw me for a loop today. Here’s what I was trying to do:
> s = ActionController::Base.helpers.strip_tags("foo:bar")
=> "foo:bar"
> CGI.escape(s)
NoMethodError: undefined method `bytesize' for nil:NilClass
Strange. Even less helpful was the error message that I’d get from calling the...
4 tags
How to deploy a tag to Heroku
If you are following the excellent work-flow laid out by Vincent in this post and implemented in his git extension then you will need to know how to deploy a specific tag to Heroku. The syntax for this was not obvious to me and there was little information about it on the interwebs. So, here it is (run from the master branch):
git push heroku +1.1.1^{commit}:master
What this command does is...
September 2011
3 posts
3 tags
The Save/Export for Web Color Shift
Something that I’ve always struggled with until recently is the apparent shift in color you get when you save or export (depending on the app) an image “for the web.” Recently, I learned that it has to do with the “color profile” your image editing app is using. For example, in Pixelmator, you should change to Image > Color Management > Web (sRGB) if you are...
3 tags
Running Jobs More Frequently (Than Hourly) on...
Heroku allows you to run cron jobs at most every hour. However, there are many tasks that need to be run more frequently than that. Solution? delayed_job; here’s how…
# Called by Heroku once per day (for free!)
task :cron => :environment do
# Runs this task every five minutes (24*60/5=288) using delayed_job
1.upto(288) do |run|
SomeModel.delay(:run_at => (run...
3 tags
Getting PrinceXML Working on Heroku
PrinceXML will work on Heroku; here’s how:
Download the princexml source (generic linux)
Compile princexml and include it in your repo. Use whatever your RAILS_ROOT is as the installation directory when asked; this will create two new directories: bin and lib/prince in RAILS_ROOT
Change the absolute paths in the prince schell script that prince creates in: bin/ to /app/… (this is...
August 2011
1 post
2 tags
nil is not a symbol
Thanks for that reminder, delayed_job! Almost as helpful as “Windows error 32.”
The real issue here is that the handler field in your delayed_jobs table is not large enough to hold the serialized version of your delayed method call. The “text” data type has a maximum storage capacity of 65535 bytes (in MySQL) which might be too small for some calls. For example, if...