Archive for August, 2007

I’ve Moved!

Tuesday, August 7th, 2007

Virtually, that is. And thanks to some URL rewrite magic, you hopefully didn’t notice a thing. As I mentioned in New Web Hosting, the new server is a bit snappier with PHP applications like WordPress, which powers this blog, and Gallery2, which hosts my new photo gallery. The latter was the impetus for moving, and I do have to say that it looks pretty good loaded up with photos.

Overall, the move wasn’t too bad given everything involved: new host, setting up secure shell & FTP, moving two databases, two PHP applications, static content, and loading the gallery with a custom script. The latter was by far the most complicated, and I ultimately settled for a 90% solution. The curve to make it 100% was quickly becoming exponential :) Given it’s incompleteness and the small niche of people moving from album.pl to Gallery2, I’m rethinking the additional effort of releasing it to the world.

I didn’t track my hours for this project, which were surely obscene, but one number I did grab was 8.5 hours - the time it took to upload all my full-size photos at 84 k/s on my “high speed DSL”. That’s the last of the technical minutae for now - back to real content and taking more photos, which also have their own feed now.

On Location

Monday, August 6th, 2007

I saw Shooter over the weekend, and one of the things that made it enjoyable was how much of it was shot on location. Part of the story takes place in Philadelphia, where I can appreciate that they did more that just get a few wide aerial shots before returning to LA. It definitely adds to the dramatic tension when you can really sense the reality of a scene, be it in the city or on top of a glacier.

Also, for those who like their “mild drug references” slightly aged, the lead character stocks up on whippets for some homebrew bullet removal surgery.

Log4php Example

Saturday, August 4th, 2007

As an engineer turned software developer, I’m slowly moving from the world of printf debugging to proper logging. We use log4net at work, and having harnessed a bit of its power, log4php seemed like a natural fit for some debug logging in my migration script. Unfortunately, their configuration format is different and not nearly as well documented.

After much hunting, I finally spent $5 on a single PDF edition of some Canadian PHP magazine that had an article on log4php. Those examples didn’t quite do what I originally wanted, but got me on another path to success. Here’s my configuration:

log4php.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<log4php:configuration
  xmlns:log4php="http://www.vxr.it/log4php/"
  threshold="all" debug="true">
 <appender name="default" class="LoggerAppenderEcho">
  <layout class="LoggerLayoutHtml" />
 </appender>
 <root>
  <level value="DEBUG" />
  <appender_ref ref="default" />
 </root>
</log4php:configuration>

bootstrap.inc (or some other high-level include file):

define("LOG4PHP_CONFIGURATION",
 "/full/path/log4php.xml");
define('LOG4PHP_CONFIGURATOR_CLASS',
 '/full/path/log4php/xml/LoggerDOMConfigurator');

And finally, in the actual code class:

require_once('/full/path/log4php/LoggerManager.php');

class ItemAddFromServer extends ItemAddPlugin {

 var $log;

 function ItemAddFromServer() {
   $this->log =& LoggerManager::getLogger('ItemAddFromServer');
 }

 function DoSomething() {
   $this->log->debug('DoSomething');
 }

}

That gives you an HTML table display of your log, which interrupts the flow of your application, but gives you a convenient way to immediately view the results.

SSH Keys and LFTP

Saturday, August 4th, 2007

Having SSH and SFTP with my New Web Hosting meant a little more configuration to be able to login without a password prompt every time. A2 had a good writeup on creating SSH keys - just be sure to put the public one on the server.

Where I got mired was using the keys on the command line, which wasn’t always well documented. Here’s SSH:

ssh -pport user@hostname.com'

And LFTP:

lftp -p port -u user,placeholder sftp://hostname.com

Both assume you put your SSH keys in the default ~/.ssh directory and that your host uses a non-standard SSH port. The placeholder for LFTP is just that - some text is needed after the comma to stop it from prompting for a password.

New Web Hosting

Saturday, August 4th, 2007

After years of struggling with various web hosting limitations, I finally shelled out for an upgrade, and registered matthewbotos.com before the food terror guy Matthew Botos got it. (R/C helicopter Matt Botos already has mattbotos.com). I’ve dealt with the limitations for a long time because it was free, courtesy of my dad’s “family plan”.

I was primarily looking for someone with better PHP performance, having seen how slow both WordPress and Gallery became even with built-in caching. (Purehost declined to install the recommended PHP accelerator, which would’ve reduced their load as well.) As long as I was shopping, I also wanted to add a few other features: PHP optimization (of course), SSH, SFTP, unlimited email quotas, and one-click installs of popular packages. A2 Hosting, who has good street cred from hosting 43folders, offered all that for a reasonable price, plus Subversion, Python, and Ruby (so I can finally see what makes people so fanatical about it).

Activation was incredibly fast; my account was created and domain live in seven minutes, on a Saturday afternoon. These guys are obviously on the ball enough to have the whole thing automated, which really makes you disdain anyone still charging “setup fees”. I paid none, even though I only bought a month as a trial.

I think I’ll be keeping it, though; it’s noticeably faster. Their support was also pretty good; I got an actual engineer on their chat to help me out with setting up my ssh keys, so that I can automate my FTP mirroring and logins. Having a proper shell is awesome; especially for things that shouldn’t be served publicly like raw photo data and backups. Even the error logging is a step up - they actually have them timestamped!

For the moment, I only moved my Gallery beta to the new host. The old one is still here, though in a funky move state, along with WordPress. Once everything is ready to go at the new place, I’ll announce a hopefully seamless transition.

What a Pain!

Friday, August 3rd, 2007

After setting up and theming Gallery2, my next step was to import all my old photos. This is over 2000 photos in dozens of albums, so I figured it was worth my while to write a migration script. (This is as big a job as many things I’ve done at work, so I figure I get to use “enterprise” software terms.) I also foolishly figured this would be fairly straightforward given I was working with a mature, open source product instead of my own homebrew hacks.

In reality, the 20/80 rule quickly took effect: the last 20% took 80% of the effort. I was able to modify the import script fairly logically to use photo captions and album descriptions from my previous  system. The devil proved to be timestamping the albums. Their API provided a function to reset it after getting a lock on the album, but it didn’t actually work, and my post to their development forum went unanswered. So I set about doing it the hard way, which was, well, hard. (I had to dig much deeper intro the onion that is the Gallery2 code and ultimately modify some of the base classes to set the timestamp at creation.)

It was a frustrating enough experience to make me wonder why I even bother, particularly when I’m likely the only one to care about the level of detail in everything having the proper date. Though I suppose that’s one of the advantages in being your own customer: no one will criticize you for running over schedule or failing to deliver enough “return on investment” or “earned value”. I also did learn a good bit of PHP in the process, making this a worthwhile investment since I’m sure to continue hacking PHP systems like Gallery2 and WordPress.

Top Google Queries

Wednesday, August 1st, 2007

Here are some of the top queries people have been clicking in Google to get here:

  1. kabobs on the grill
  2. sonicare battery replacement
  3. slow striptease
  4. macbook unboxing

How to Sell Software

Wednesday, August 1st, 2007

I just bought CrossOver Mac from Codeweavers to run Picasa on Mac, and these guys know how to sell software:

  1. 30-day trail of the full version to kick the tires
  2. Click the link from the trail to purchase
  3. Enter your email and password from the website in the software and it upgrades the license

I’m so conditioned to awkward licensing models, I was actually hunting around for some goofy string I would have to cut and paste into some obscure dialog in the tool - this was way better!