Where'd my job go?

The company I work for just went into ‘hibernation mode’, so we’re all out of work, at least temporarily, maybe permanently.

I’ve updated my entry on WorkingWithRails.com to show my new-found availability, and am waiting for the offers to come flying in!

tom@craz8.com will get you in touch with me, if you need a Rails programmer to do work on short notice.

Posted by Tom Thu, 01 Feb 2007 00:04:18 GMT


Why is my code in a loop?

Today, I wrote some code that looked a little bit like this:

class Model < ActiveRecord::Base

  ...

  def update
    RAILS_DEFAULT_LOGGER.info "Update Called"
    # Read some data from wherever
    # Set some properties on my object
    save!
  end
end

Imagine my surprise when my log output was a long stream of Update Called lines.

What happened here is that save is implemented as a call to update when the object already exists.

Inadvertently picking a method name that is the same as an important Rails method can be hard to track down. I already had my logging in there, so I wasn’t left wondering why the call never completed.

Posted by Tom Thu, 25 Jan 2007 04:09:42 GMT


Start the weekend with a boat rescue!

Lisa and I just had a ‘Joe and Petunia’ moment.

I noticed a small boat in trouble just off shore from the Kirkland marina today. The boat just stopped and they started waving an orange flag – they also started bailing. Lisa called 911.

Before the rescue boat arrived, the boat in trouble drifted into the docks at the North end of Marina Park and the two gentlemen rescued themselves.

Living on the lake provides so much entertainment.

Posted by Tom Sat, 20 Jan 2007 21:29:47 GMT


View your Divx videos on your Xbox 360

I just installed TVersity to do on the fly transcoding of Divx videos for my XBox 360. The key is to have the correct versions of all the other software. Here is a post about how to do this

This is way easier to setup than the Media Connect software that Microsoft ships.

My server is a dual core 2.8 GHz monster machine (from 18 months ago!). TVersity uses 100% of both cores to transcode my videos.

The videos I’ve watched so far actually look really good – not Hi Def, but pretty good. Certainly not good enough to be confused with HD

Posted by Tom Fri, 19 Jan 2007 04:11:10 GMT


Low memory spam reduction using Greylisting

In my search for reducing memory usage on my OpenVZ VPS, I took a look at my email server configuration. I originally used the configuration instructions from Howto Forge to setup my server. Even with adjusting the configuration, the memory used by all the mail components, especially the protection system – Spamassassin, ClamAV and the pieces necessary to run them – was over 100MB.

However, if I remove this protection, bad stuff will get through!

What about greylisting, I thought.

In summary, a server that performs greylisting denies the first incoming mail request. Any regular SMTP server will retry the request later, and this request will be allowed through. Spammers use custom software that usually doesn’t retry, they just move on to the next email in their list. Regular mail gets through with a delay the first time and spam is effectively blocked.

I uninstalled all the postfix add-ons I’d added-on, and used apt-get install postgrey to add greylisting to Postfix on my server.

Some spam still gets through, but 90% is gone. I use Thunderbird to access my email account here, and this detects the junk mail very well (actually better than my install of Spamassassin did).

Greylisting works better than I thought it would, and the best part is that the server uses less than 12MB of my precious OpenVZ memory allocation

Posted by Tom Wed, 17 Jan 2007 06:15:33 GMT


acts_as_taggable is dead, long live has_many_polymorphs

Evan Weaver has just posted about how to replace all the different acts_as_taggable implementations with his has_many_polymorphs plugin.

Since the current owners of the acts_as_taggable gem seem to have abandoned it, and DHH’s identically named acts_as_taggable plugin also seems dead, this is probably the best way forward if your writing new code or planning changes to old code in the near future.

I haven’t checked this out yet, but my tag cloud code should be able to work with has_many_polymorphs with little to no modification.

Posted by Tom Sun, 14 Jan 2007 06:12:49 GMT


Karma sucks when you lose your hard disk!

I’ve been giving Ben grief most of the week because his Mac laptop was in the shop (and is now on its 3rd motherboard).

2pm Friday, my laptop hard disk just stops working! Not readable in any way.

Karma!

Some things lost, but the main hassle is installing everything from scratch.

Posted by Tom Sat, 13 Jan 2007 03:53:04 GMT


Migrate your Typo blog to Wordpress

There are some scripts available, but I never found a step-by-step set of instructions for how to migrate my Typo 4.0 blog to Wordpress 2.0. This post documents what I did to transfer my blog from one platform to the other.

Install Wordpress

I am now running my Wordpress blog on Dreamhost. I used my own instructions on how to set this up with Capistrano

I took this opportunity to switch themes too!

Add the Ultimate Tag Warrior plugin

To get tag functionality in Wordpress, I added the Ultimate Tag Warrior plugin I still need to add code to show the tags in posts, but the underlying data is there.

Save the Typo database

On my Typo server dumped the MySQL database using mysqldump.

Import the Typo database into Wordpress database

On my Dreamhost account, this is as simple as running mysql -u [user] -p < typo-dump-file

Run the migration script

Stuart Johnson has a Typo to Wordpress migration script that almost worked for me. I had a problem with the post content not showing up. I simplified the SQL for this step, as I didn’t have the pre-generated HTML or the extended pieces. I just copied the existing content field directly over to Wordpress.

This script sets up the permalinks for the posts in the database.

In Admin, save the permalink configuration

To activate the permalink structure, you need to go to the Wordpress options > permalinks and just click Save. This updates the .htaccess file with the redirects.

Approve all the comments

All the comments seem to come into Wordpress needing moderation. In lieu of changing the migration script, I just approved them all and dealt with an email for each going to my mailbox!

Note: It looks like the Typo 2.6 comment text isn’t being imported correctly.

Install Textile wrapper plugin

I use Textile for my Typo posts, so I needed this Wordpress plugin

Install GeSHi wrapper plugin

From the same place as the textile plugin, I installed the GeSHi wrapper to do my code tags. Note that, as of this writing, I still need to go through the DB and change my typo:code tags to the appropriate code tag.

Add the /articles/tags/foo rewrite to .htaccess

I’m trying to setup the rewrite rules to allow the /articles/tags/foo urls to work, but this has been problematic so far!

Update DNS or switch out the directories

Since I switched servers, I updated my DNS to point at the new location and waited until my site was switched.

Update Feedburner

I use Steve Smith’s Feedburner plugin. Feedburner will fail to change its configuration if the new url doesn’t exist, so you have to wait for the DNS changes to propogate before you can update your Feedburner configuration.

Cleanup the database

The Wordpress database is left with a bunch of unused Typo tables that need to be deleted. Dreamhost has phpMyAdmin that helps with this. Anything without a wp_ prefix should be removable.

Update!

Forgot to mention this, but I changed the upload directory for Wordpress from wp-content/uploads to files to match Typo and moved the files over from the Typo server.

Posted by Tom Fri, 12 Jan 2007 04:41:29 GMT


Blog moved again!

Following up on my post about memory usage with OpenVZ, I’ve moved my blog from Typo to Wordpress. This saves me about 150MB of memory on my VPS host, which translates directly to $10/month.

With the low level of traffic I receive, 150MB is a little overkill. Rails isn’t the best framework for very low traffic sites.

Posted by Tom Wed, 10 Jan 2007 05:18:32 GMT


Resize is in the wild

I just received an email from Fabio Trezzi that he has used my resize code in a site he’s just released.

Go check out http://www.stickyshare.com

Posted by Tom Wed, 03 Jan 2007 05:05:07 GMT