Sunday, February 13, 2011, talking bacon toothpaste, Die Hard 5, and reelizer.com
Sunday, February 13, 2011, talking bacon toothpaste, Die Hard 5, and reelizer.com
Working on a Magento 1.4.2 CE instance today, the client said they had set up polls earlier this week, but now they disappeared from the sidebar. Trying to replicate it, I noticed that there is a “Disallow Voting in a Poll Multiple Times from Same IP-address” under System->Web->Polls. I assumed if you set that to No, the polls would stay in the sidebar, showing the results even if a visitor voted.
Testing it out myself, thats clearly not how it works.
Digging around in the code, in the Mage_Poll_Block_ActivePoll constructor
So, to figure out which polls to display, Magento figures out which polls the user voted in already, and ignores them. If there is only one poll, and the user voted, they won’t see any polls.
There are a couple of options here. Either set $votedIds to an empty array or comment out most of getVotedPollsIds. getVotedPollsIds doesn’t seem to be used anywhere else, so I decided to comment it out by first copying app/code/core/Mage/Poll/Model/Poll.php to app/code/local/Mage/Poll/Model/Poll.php, and making sure getVotedPollsIds returns an empty array.
This is what happens when you don’t pay attention. I was working on a project that started out when Magento 1.4.1.1 was the latest stable version. There is a bit of development left, but I decided to upgrade the install to 1.4.2 via subversion. I go get some coffee, come back, and assume the upgrade is done.
Then I try to load the homepage, and I get a blank screen. Eh, ok. Time to display errors by commenting the following line in index.php.
Lets see what the logs say:
Well, what exactly is the code throwing this error? In Abstract.php:
How can Varien_Db_Select::TYPE_CONDITION not exist? I looked at my Varien/DB/Select.php and there was no TYPE_CONDITION. Then I looked at Varien_Db_Select in the Magento docs, and it was there. Weird.
Then I looked back at the terminal which was doing Subversion update, and noticed that there was an error. Apparently my Internet connection had died and the update didn’t complete. Ugh.
After restarting the Subversion update, I look at Varien_Db_Select:
There it is.
Moral of the story. Make sure your updates actually complete before making such an assumption.

Wanting to learn more about node.js, I grabbed the latest stable branch of the source code and tried to install it on my Ubuntu 10.04 dev box. Simply doing a ./configure returned the following:
Oh oops, no compiler has been installed. There are a couple different ways to proceed: (1) either install only the packages needed, or (2) wuss out and install build-essentials which will load all the necessary packages and some extra ones for general development. I prefer to wuss out, so I do:
After all that installs, I try ./configure again, only to get:
Bah, the SSL packages haven’t been installed yet. Do a:
And then you can do a ‘make; sudo make install; make test’ to get it all running.
There are many better ways to do this, but here is one method if you need to do a quick and dirty jobs of cropping and renaming a bunch of files in a batch with ImageMagick.
Quick little background. Even though I’ve got a Macbook, if I have to look at code, I’m usually on a desktop thats running Ubuntu 10.04. We host client sites on servers running Ubuntu 10.04, so its best to write code in that environment. So today, after finishing up code for a Magento site, I needed to upload a set of fabric swatches that would be used with configurable products. The client provided images for the fabric swatches, but they were all different sizes. All I needed was a 60x60px selection of each image and the filenames to be something descriptive with the image size.
Of course, this can be done pretty easily in Photoshop. I’m sure there is some plugin for it, but you can record an action, and run it against a batch of files. The problem was that I didn’t want to hop on my Macbook just to crop and rename files.
Since I was on an Ubuntu machine, my first gut reaction was to fire up Gimp and see if I could do it. Turns out there is a plugin called David’s Batch Processor that pretty much does that. Ubuntu has the plugin in the repository, just search for ‘gimp-plugin-registry’ in Synaptic. Gimp also supports scripting, but the scripting language is Scheme-like, and I didn’t want to recall knowledge from freshman year in college to do this.
Then I remembered ImageMagick. While ImageMagick has a GUI for image manipulation, its got a powerful CLI that lets you do pretty much anything you want to do. So no need to open up a big honkin’ application just to do some basic cropping and renaming.
So save the following code in the directory of the files you want cropped and renamed and run it:
Most of this should be pretty self-explanatory. Up top we define what sizes we want the images to be cropped to and from where in the image we want to crop. Then we grab a list of all the files we want to crop, and grab the filename before the extension (to be used for saving the new files). The convert command is what actually does the cropping and saving the files with the new names, in this case, something like oldgold_60x60.jpg.
The script is most definitely not robust, but hopefully it will be a good starting off point for some.
Isn’t it fun hunting down bugs? Today, I noticed a community Magento extension that I was trying out would only partly output what it was supposed to. Digging into the Apache error logs, I see this:
The problem code was
Doesn’t look problematic…unless you are running PHP 5.3. In PHP 5.3, namespace is a reserved keyword. Oops.
Renaming NAMESPACE to anything will work in this instance:
Tada!
I have no way of actually describing this ride. Its basically a ride through a tunnel to cross the Hangpu River in Shanghai. Its all…umm… psychedelic.
The wife and I spent a few days in China, visiting Shangai, Xi’an, and Beijing. This is the first in a few video clips from the trip.
When leaving Shanghai, we hopped on the maglev train to go to Pudong Airport. It took around 8 minutes to go 18 miles. Not too shabby.
You get to see the different bits and pieces of China as you ride the maglev train:
Grabbing some dinner with Josh Chase at a snazzy Taco Bell, talking about dieting and how hot dogs are made.