Come to the 2010 CMS Expo

July 2009

My Review of "Decoding Liberation"

My review of the fantastic book Decoding Liberation has been published in the American Philosophical Association's newsletter on Computers and Philosophy. I highly recommend the book. (Shameless self-promotion: My perspective on the Freedom Zero problem is discussed in the second chapter.)

Decoding Liberation: The Promise of Free and Open Source Software
Samir Chopra and Scott Dexter (Routledge, 2007) 232 pages. ISBN: 978-0-415-97893-4.
Reviewed by Matt Butcher
Loyola University Chicago
http://www.apaonline.org/publications/newsletters/v08n2_Computers_18.aspx

QueryPath: "What's with the 
 at the end of every line?"

Old problems never die, it seems. A few people have mentioned an interesting QueryPath problem they have experienced. Roughly summarized, the question is "What's with the &#13 at the end of every line?"

note: The trailing ; of the entity name has been removed to avoid stripping by an overzealous content filter.

I hadn't experienced this problem for myself until recently, as I worked on an importer that was parsing thousands of ancient HTML files. These files came from all over the place, and dozens of them had the XML entity &#13 appended to the end of every line. While this may look odd at first glance, a second glance reveals that this is a problem we've likely all seen in the past.

What is &#13?

One of the things QueryPath does automatically (unless you tell it not to) is re-code entities. This is important for XML, since it does not (out of the box) support the array of named entities that are part of HTML. Instead of using named entities like  , XML uses numeric representations of the character.

What is &#13? It is the decimal notation for Carriage Return (often encoded as \r). Yup, the old CR-LF problem rears its head again. When a document with Windows CR-LFs is serialized by QueryPath (which, in turn, just uses the PHP DOM library), any CRs are converted to entities.

How do we solve the problem?

As far as I can tell, this behavior accords with the XML standard. For that reason, I'm not inclined to change it.

However, you can avoid the problem altogether by removing CR characters from a document. This is as easy as doing something like this:

<?php
$doc = str_replace(chr(13), '', file_get_contents($file));
qp($doc);
?>

The above will remove all of the carriage returns using str_replace<code>, and then pass the file contents on to QueryPath.

Favorite Three iPhone Apps

When it comes to iPhone apps, I am a minimalist: Fewer is better. Other than the preinstalled apps, I have only four applications installed:

  1. Mobile Fotos: Basically a robust Flickr client with lots of features. I like being able to upload photos as I take them. I also like checking out what the Pandas are up to.
  2. iTwitter: For a long time I held off grabbing a Twitter client for the iPhone. Mainly, the ones I saw didn't provide the features I wanted. iTwitter, on the other hand, is quite nice. Multiple accounts, photo support, website support, and saved searches... just what I need to productively waste more time.
  3. Facebook: I hate the FaceBook website. The iPhone app is much more usable. I haven't visited Facebook.com since I downloaded this app.
  4. iRemote: Keynot is pretty. And being able to walk through my slideshow while walking around a room is great. I've used this several times to give large presentations, and it works very well.

Vim Colorschemes

Here's a small tip for burgeoning Vim (VI Improved) users. Vim supports various colorschemes in its colorized editing mode. If you don't like the default syntax highlighting colorscheme that Vim uses, you can change it easily by running a command like this (within Vim):

:colorscheme koehler

The :colorscheme command takes one argument: the name of the colorscheme. Above, I am setting the syntax highlighting colorscheme to the koehler scheme. At any point, I can change it back to the default by running:

:colorscheme default

Using Phing from TextMate to run PHPUnit tests

I have recently converted some of my PHP projects over to use the awesome Phing build tool. Phing is similar to Apache Ant, a tool I am familiar with from my Java development days. I have crafted Phing's build.xml for QueryPath to handle building packages, generating API docs, running coverage analyses, linting, and (of course) running QueryPath's ~250 tests.

Having left IDEs behind for the time being, I have been working hard to build an personalized toolchain for PHP development. I've settled on TextMate as my editor (though I still use vim quite often). One thing I wanted to be able to do is run unit tests from within TextMate.

Initially I built a shell script to run the unit tests. But after moving to Phing, it seemed like it should be possible to take advantage of Phing's unit test running abilities (and lovely HTML output) from within TextMate. Working this out took two major stages:

  1. Writing a custom target in Phing's build.xml
  2. Creating a simple TextMate bundle for running Phing tasks

This article shows how to accomplish each of these steps.

Review of "Drupal 6 JavaScript and jQuery"

Kat Bailey posted a very kind review of my Drupal 6 JavaScript and jQuery book.

From the review:

The book aims to get people with little to no knowledge of Drupal or JavaScript up to speed with creating really awesome functionality, really fast. In fact, its title almost belies the breadth of its scope: although the use of jQuery in Drupal 6 is the one topic that it covers exhaustively, it doesn't skip over any of the basic tools or concepts required to get going with Drupal, and so it would work pretty well as a first Drupal book for any aspiring front-end Drupaler. It covers everything from the ultra-utra-basic ("what is CSS?", "what is a Drupal block?") to Drupal JavaScript Behaviors (and everything else in drupal.js), to JavaScript Theming, to AJAX, to building modules with AJAX functionality, to jQuery syntax, effects, and even writing jQuery plugins!

I've spent the last week or so doing nothing but writing Drupal-centered JavaScript. Every time I reflect back on what JavaScript coding used to be like, I can't help but appreciate the hard work of the jQuery and Drupal JavaScript teams.

Recent comments