Sometimes you have to work with HTML which is not structured in semantically meaningful ways. Here's a quick code snippet for finding the HTML between two DIVs using PHP's DOMDocument and DOMXPath. More »

Drupal installation profiles are usually just starting points for a new site, but sometimes you want to leave an installation profile untouched, adding your own additions in a separate space and leaving a "clean" upgrade path for future versions of the profile. Here's a handy script I use for such situations. More »

I often use the excellent Migrate suite of modules to import data into Drupal. It's great for getting any type of content into a Drupal node, file, taxonomy term, user, and more. My latest task: importing content from raw HTML into a Drupal node. Not finding any pre-built classes in Migrate to handle this, I built a few simple classes myself. More »

Today I launched a new service called (taking advantage of the new .pw domains). It's a random password generator, with lots of customization options to help you find a memorable but secure password, and it even has a password strength checker. More »

In PHP 5.3, anonymous functions (or "closures") were introduced. To those who know Javascript well, these will be familiar. They allow you to create a sort of one-off function, and they're all sorts of useful. More »

There are tons of code snippets out there to convert a CSV file to an associative array, where the first line contains the column headings for the rest of the file. Most of them were really long, but I came up with what I think is the shortest way to accomplish this in PHP. More »

I encountered a situation today where I needed to format a date which was far into the future (Anno Domini 2199). However, my standard approach of converting the string into a timestamp via strtotime and then formatting it with date produced weird results. In situations like this, it's best to create a date object. More »