PHP Namespaces with Autoloader Example

It took a while to wrap my mind around PHP namespaces - despite the fact I've needed them for years. It's just one of those features that seems weirder in PHP than in other systems. But that's normal for PHP - quirky. Unfortunately, it's not quirky like Perl, where the quirk eventually makes you feel good. With PHP you just feel kind of odd, maybe a little inferior... like your language is slipping toward becoming the Visual Basic of the web.


Recipe 1

Recipe 2

Umeboshi is a pickeld apricot that's popular in Japan and increasingly in America. Most people have seen a tiny red thing in their bento-box that's extremely salty. That's umeboshi. However, the kind you make for yourself is different. For one, there's no red food coloring, and it's larger and more fleshy and gooey.

Type and Social Context (Eric Gill's "Gill Sans")

I just read a long ass post about why graphic artists shouldn't stretch type or slant a face. "no duh" as we used to say in school.

MS Access to KML Data Dump

Here's a script that helps to export KML files for Google Earth from Access tables. The idea is that you create a query with columns named "Latitude" and "Longitude" and any other columns you need. Open that query, and pass the recordset to this dumper. You also specify a file name, and a list of columns to use for the name and definition fields.

How to Register Trademarks, Cheap

I've only done this once, but, it was easier than expected. You don't need to pay a service hundreds of dollars to do this.

It costs $325 for the one trademark, but the costs can rise if your mark is used in different contexts. If you use the online forms and are well-prepared, you can save some money and get it done for $275.

This article is intended for ultra-small-time operators and microbusinesses that have more ideas than money, experience, or connections (or attorneys).

Craigslist Independent Contractor Jobs and Employee Status

Recently, I saw an ad on Craigslist that described a job, and stated that they would not accept telecommuters, all work was on-site, and "independent contractor." This ad might have been illegal, because there are laws about what defines an independent contractor and what defines an employee. Small businesses that misclassify workers can get an unfriendly visit from the tax man.

Fixing Phone Numbers so they Fit a Common Format

It's common to get a list of names and phone numbers in a spreadsheet or from the web, and the formatting varies. In the US, people don't use a standard formatting consistently. Lately, they have taken to making phone numbers look like domain names or ip addresses, example: 415.555.1212. This function normalizes phone numbers to look like this: 213-555-1212 x1234. The code's structured so multiple regexes are used to perform the matching, allowing for easier modification of the code. (This code was written in Excel, but should work in any VBA application.)

PHP Runs an Old Version of PCRE Causing Problems with Drupal and MediaWiki

This seems to happen a lot - and it took several searches and many pages of reading to find the solution. This page will try to even the odds a little more.

The solution was found here: PCRE Problem Appearing in PHP Related to Apache Webserver

After building a new Apache, then a new PHP, and configuring both, Drupal started throwing error messages "Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support".

Checklist of things to do Before Purchasing a SSL Certificate

A short list of things to make purchasing an SSL cert easier.

1. Check your domain registration and make sure the Registrant and Administrative Contact will match the party that will purchase the SSL cert. Just to be safe, make sure the address matches the billing address of the credit card you will use. Changes may take a while, and may require email verification.

2. Decide on which domain name you want to associate with the cert.

3. In the DNS, make sure the IP address of the server matches the domain. Changes may take a day to propagage.

Automatically Restart Apache when it Freezes

This is a rough watchdog script to restart apache on the local machine when the website gets slow. If a GET to the url fails, or takes longer than 60 seconds, the local web server is restarted.

I started to use this after installing a new version of Apache. The system hadn't been properly tuned, and the side effect was that Apache would be nearly wedged, but the rest of the system was merely slow. This happens when Apache or MySQL are getting wedged, but it's not due to the system overloading with too much traffic. Why does it happen?


Soapmaking's been popular with the gourmet soap folks, but I was totally unaware. I learned about soapmaking from a Red Devil lye bottle back in the 80s, and always wanted to do it, but never did.

Today, Red Devil no longer makes pure lye, but the brand "Rooto" does. I got mine from Vermont Outlet, a True Value franchise. It was about $5 for a pound.

The soap recipes on the web used a lot of fat for 16 oz of lye, so I decided to use only half the jar - 8 oz - and scale recipes to fit. I figured I'd have the required fat for that.

Jennifer Lynn Aaker on Social Media (good talk)

This is a good 10 minute presentation about how to use social media. I got it from a podcast I listen to.


Takeaway points:

Magic Folder to Convert DOC and OpenOffice to PDF

Most of the information in this post is derived from It's posted as a service, because the code there needs some editing.

Also, a useful thread about executing OOo macros is at

Here's the code to automate the opening and saving of a file as PDF, using Open Office. Paste this into your standard macros.

Generate a Page of Random Passwords with Javascript

The attached HTML page is a password generator that creates a page of random 10-character passwords. It helps you manage one password per website, so a password leaked for one site doesn't get used on other sites. To use it, click and view the file.

Hacker Scripts Decoded: eval gzunzip base64_encode str_rot13

I got hacked (more than once) and they installed a backdoor php shell. It sucked (and I must suck for allowing it to happen... but anyway) and here's a snippet of code that you can use to decrypt these nasties. To use it, paste the function definition for "dc" below into the hack script. Then replace that first instance of "eval" with "dc", which calls this function. Then run the script. The output will be the source of the script. View source to read it formatted correctly - and use Save As... to save it. You may need to edit the output to get it working.

function dc($s) {
Syndicate content