By Matt Butcher
November 2009
Dave Hall: Review of "Drupal 6, JavaScript, and jQuery"
Submitted by matt on Mon, 2009-11-30 09:10Dave Hall recently reviewed my Drupal 6, JavaScript, and jQuery book.
I found this observation particularly apt:
This book is definitely not for the copy and paste coder, nor the developer who just wants ready made solutions they can quickly hack into an existing project. Some may disagree, but I think this is a real positive of this book. Matt uses the examples to illustrate certain concepts or features which he wants the reader to understand. I found the examples got me thinking about what I wanted to use JS and jQuery for in my Drupal sites.
This is what I want to accomplish in the book. My goal is to get coders thinking about what they can do (and how they can do it) rather than simply re-using code. I'm so glad that Dave noticed this and brought it into focus. If you are interested in taking a peek at the book, you can download one of the chapters.
Iteration Techniques and Performance in QueryPath
Submitted by matt on Thu, 2009-11-26 11:41QueryPath provides multiple methods of iterating. This article demonstrates the performance impact of various looping types. In this article, we are going to look at four different ways of iterating through the items wrapped by a QueryPath object:
- Using QueryPath's iterator
- Looping through
DOMNodeobjects - Using
each()and a callback - Using
each()and an anonymous function
This last item is specific to PHP 5.3 and later, and offers intriguing possibilities when paired with closures.
Finally, at the end of the article, I will show some representative performance numbers.
Installing XDebug 2 on Mac OS 10.6 Snow Leopard (with PHP 5.3)
Submitted by matt on Sun, 2009-11-22 16:16A while back, I wrote an extensive article on installing XDebug on OS X with MAMP. Now that I have Snow Leopard, I am making a new attempt at working with XDebug on OS X. This article discusses working with XDebug 2.0 or greater on Mac OS 10.6 with PHP 5.3, as packaged with OS X. Continue on for step-by-step instructions. (For more notes on upgrading a PHP dev environment for Snow Leopard, read this article.)
PHP Developer's Snow Leopard Upgrade Notes
Submitted by matt on Sat, 2009-11-21 19:20I'm upgrading to Snow Leopard, and I intend to switch from MAMP to the built-in PHP/Apache 2 configuration. As a PHP developer, there are several notable things that I wanted to track as I performed my upgrades. This article tracks those changes
PHP 5.3
My current OS 10.5 toolchain for PHP was this:
- PHP 5.2.6 (MAMP)
- Apache 2 (MAMP)
- MySQL 5 (MAMP)
- TextMate
- Git
- XDebug
- Several PEAR packages installed into MAMP's PHP 5, including PHPUnit, PhpDocumentor, Phing, and XDebug
One of the desired outcomes was to switch to the OS X version of PHP and Apache, which is tenable now that PHP is more robust (and now that I know how to use PEAR with the OS X version). It's also desirable because Snow Leopard is now running PHP 5.3. Here are my notes on the upgrade.
Update: Problems with PHPUnit and Phing.
QueryPath Performance Optimizations on Reduncery
Submitted by matt on Fri, 2009-11-20 09:40
Continuing a trend on the non-evilness of optimization, this article discusses some methods of improving performance in QueryPath.
Early this week, a Twitter analysis tool called Reduncery was launched by a friend of mine. Reduncery calculates how much of a "redunce" a particular user is -- that is, what percentage of a user's tweets are retweets (RT). It can also calculate how ineffective it is for one person to retweet another. In this case, it calculates the overlap in the followers of the original tweeter with the followers of the retweeter. In what follows, we will look at the ways Reduncery optimizes QueryPath to keep page load times down.
"The Fallacy of Premature Optimization": A must-read
Submitted by matt on Thu, 2009-11-19 20:59Sir Tony Hoare historically remarked that, "premature optimization is the root of all evil." Have we let this view (or a mis-application or misinterpretation of it) dictate too much of our programming methodology? In his article The Fallacy of Premature Optimization, Randall Hyde argues that we have indeed.
I feel it my philosophic duty to point out that there is in fact no fallacy in the statement. But I think that Hyde makes a very good argument, terminological shortcomings aside aside. Of particular interest are his nine observations in the middle.
Reduncery: Calculating retweet idiocy
Submitted by matt on Wed, 2009-11-18 09:54Ever get irritated by reading the same tweet multiple times, retweeted by the same old people? Ever wondered how effective re-tweeting is? Are new people really reading the tweet, or are the same people just being notified multiple times? You can now find out for sure with Reduncery.
Reduncery
Reduncery was built on QueryPath and Drupal. In a future blog, I'll tell you about some of the the performance optimizations Reduncery uses to speed up searches of 200k+ users.
Creating a Custom Phing Task
Submitted by matt on Tue, 2009-11-17 23:45Out of the box, Phing provides numerous features for creating high-powered source code management scripts. In an earlier post, I talked about metaprogramming in Phing, merely scratching the surface of what Phing can do. In this article, I want to illustrate how easy it is to extend Phing.
Phing can move, copy, package, unpackage, modify, touch, and delete files. But one thing it can't do out of the box is download files. In this short article, I will illustrate how easy it is to build a new Phing task to download a file from an arbitrary URL.
The desired goal it to make it possible to write a phing task that looks like this (in the build.xml):
<download url="http://example.com/mypackage.tgz" tofile="SomeFile.tgz"/>
This task, when executed, should download the package from the target url and, if tofile is set, store the file with the name given there.
Doing this is going to involve two parts:
- Writing the task in PHP.
- Telling Phing, in the build.xml, where the new task is.
The first part is the harder of the two... it'll take a couple dozen lines of very basic code.
Five Ways to Metaprogram PHP with Phing
Submitted by matt on Tue, 2009-11-10 20:12There are a handful of PHP development tools that I find myself using project after project. One of them is Phing, a PHP-centered build tool similar to Ant, rake, or GNU Make.
The primary purpose of Phing is to make it easy for PHP developers to write build scripts for our applications. If you are familiar with Ruby on Rails, you might compare this to rake's usage. rake makes it easy to manage your Rails application. You can rebuild the database, start and stop the webserver, and so on from within rake.
Phing uses a declarative XML language to create targets (commands you can run) that are composed of tasks (individual steps for each command). Phing is built entirely in PHP, and is easily extended. Even without writing a line of PHP, you can squeeze a seemingly endless number of tasks out of a Phing script.
Here are some common tasks I use Phing for in my PHP projects. The first four meet some common needs. The last one is by far the coolest, though.
- Let Phing catch your typos.
- Automate Your Automated Testing.
- Let Phing Write Your Documentation
- Package Your Applications
- Build Your Own Toolchain
Using Flashy to Play Video inside Lightbox2
Submitted by matt on Fri, 2009-11-06 16:17By default, the Drupal Lightbox2 module supports the flvPlayer flash movie player, which is not Open Source. However, Drupal has a 100% Open Source video player called Flashy. Here's a quick method of overriding Lightbox's setup to use Flashy instead of flvPlayer. Update: Fixed for Internet Explorer.
OS X Security Warning on Email Attachments: Getting rid of them
Submitted by matt on Mon, 2009-11-02 17:10A colleague of mine recently pointed out that when you unzip an archive of scripts received as an email attachment, every time you open a file, you get a warning like this:
“csvimport.inc.php” is a script application which was attached to a mail message. Are you sure you want to open it?
When you have dozens of scripts to look at, clicking through this warning each time is irritating, to say the least. A little examination of the xattr flags on these files, though, revealed the problem:
$ python Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import xattr >>> xattr.listxattr('config.inc.php') (u'com.apple.quarantine',) >>>
There is a flag on such files called 'com.apple.quarantine'. This flag needs to be cleared.
Originally, I was going to write a script to do this, but a quick google obviated that need. Mark Liyanage has done this already. He shows two different ways to clear the flag.









Recent comments
1 day 19 hours ago
2 days 19 hours ago
3 days 5 hours ago
3 days 5 hours ago
4 days 12 hours ago
5 days 7 hours ago
6 days 8 hours ago
1 week 5 hours ago
1 week 2 days ago
2 weeks 1 day ago