Last night I put the finishing touches on a new Magento-driven e-commerce project, SpiritStripes.com, and wanted to tie Google Analytics into the site. After quite a bit of digging I finally found the solution, and it’s built right into Magento. Login to the admin console and navigate to System -> Configuration. Click the Google API link located under the Sales section, and open the Google Analytics tab. Enable it, and paste your Analytics ID into the Account Number text field.
Stringing together WHERE clauses with Zend_DB_Table
The Zend_DB_Table component provides an easy interface for interacting with your database tables. I’m particular fond of the sane way it offers to string together various query clauses, particularly as the query complexity grows. I thought I’d post a quick example for those just getting started with the component:
$table = new Entries();
$select = $table->select();
$select->from($table, array('MAX(id) AS id'))
->where('user_id = ?', $user_id)
->where('dayofweek(entry_date) = ?', $meeting_day)
->order('id DESC')
->limit(1);
$row = $table->fetchRow($select);
PDT - Disabling Code Folding
Over the years I’ve tried every IDE under the sun, and have yet to find one better than PDT. It’s fast, has every feature I reasonably need, and relatively bug free. However, the code folding feature is wildly annoying, although the validity of such a statement is probably more a matter of preference than fact. Anyway, you can disable code folding by navigating to Window -> Preferences -> Editor -> Code Folding, and then disabling “Enable folding”.
Venkat Subramanian Keynoting at CodeMash 2009
I’m excited to announce Dr. Venkat Subramaniam’s gracious acceptance of our
invitation to speak at the 2009 event.
Dr. Venkat Subramaniam, founder of Agile Developer, Inc. has trained and
mentored thousands of software developers in US, Canada, Europe, and Asia.
He helps his clients succeed with Agile Development and various software
technologies. Venkat is a frequently invited speaker at various
international software conferences. He authored “.NET Gotchas” (O’Reilly),
and co-authored the 2007 Jolt Productivity Award winning book “Practices of
an Agile Developer” (Pragmatic Bookshelf). His most recent book is
“Programming Groovy” (Pragmatic Bookshelf).
Venkat is the first of three keynote speakers we’ll be announcing in the
coming weeks!
Date-based MySQL Queries
An application I’m currently working on requires a variety of date-based calculations to be performed based on timestamped data residing in a MySQL database. MySQL supports powerful date manipulation and selection capabilities, but the SQL can often be a bear to recall, so I thought I’d post a few useful queries here for the benefit of others trying to sort out the syntax:
Select all rows inserted within the last 24 hours:
mysql>SELECT * FROM entries WHERE entry_date > UNIX_TIMESTAMP(NOW()) - 86400;
Select all rows inserted before 12:00am of the current day:
mysql>SELECT * FROM entries WHERE date(entry_date) = date(NOW());
Determine the weekday of the most recent entry for a specific user:
mysql>SELECT DAYNAME(MAX(entry_date)) AS day FROM entries WHERE user_id = 22;
Counting Selected Rows with the Zend Framework
I’ve been contracted to build a rather large Web application, and given the organization’s pre-existing investment in PHP am using the Zend Framework to build the application. I’ve been a fan of the ZFW since its inception, but am occasionally at a loss as to why some clearly useful features are missing (perhaps instead of whining I should take some time to submit a patch). For instance, there’s apparently no straightforward facility for counting the number of selected rows from a returned Zend_DB result set. The only apparent way to do so is to use PHP’s count() function, which is kind of ugly given the surrounding code is all OOP. Nonetheless I’d imagine others are scratching their heads over the very same matter and so thought I’d mention it here. For instance, this is how you’d determine whether a particular email address already exists in a table:
$query = $db->select();
$query->from('users', array("email"));
$query->where("email = ?", $email);
$result = $db->fetchAll($query);
if (count($result) == 0)
// Email doesn't exist
else
// Email does exist
The Business is Growing
In the months following my departure from Apress, some of you know I’ve been steadily growing a consulting and development business. Despite all of the claims of pending economic collapse, contract opportunities have been streaming in, insomuch that I’ve made the move to an actual office, complete with a coffee machine and a water fountain down the hall. For those of you familiar with Columbus, it’s in Grandview above Figlio, one of the area’s better pizzerias.

After working for the better part of eight years out of a home office, the move has admittedly been a pretty exciting adventure, and only three days into it I’m already wishing I did it years ago.
Other than the simple reason of deciding to join “the real world” during its workday, I was looking for larger, more accessible digs as I’m looking to collaborate with an area web designer on a 1099-basis. If you fit the bill, and want to work on some killer projects, shoot me an e-mail at jason(insert AT sign here)wjgilmore.com.
Geocoding with the Rails GeoKit Plugin
In the second installment of my new Rails/Google Maps API series for Developer.com, you’ll learn how to retrieve coordinates using GeoKit, but also to take advantage of several other fascinating GeoKit features to perform tasks such as calculating the distance between two points, finding all points within a specified radius, and identifying user locations simply by ascertaining their IP address.
Adding Google Maps to Your Rails Applications
Been way too busy to post to this blog, but I have managed to bang out an article for my new Developer.com series covering Rails and the Google Maps API. You can read the first installment here.
CodeMash’s Growing Influence
Microsoft Developer Evangelist Chris Koenig recently blogged about the success of Dallas Techfest, an event which came about in part as a result of the noise generated by CodeMash. It’s really great to see these sort of events popping up across the nation!

