Posts tagged: TIPS

Tim Bray: "No New XML Languages"

I avoid XML as much as possible, but once in a while I’ve had a project where I thought about making an ad-hoc XML dialect. I’m going to file away Tim Bray’s recent blog posting to keep me out of trouble during those moments of temptation. His advice boils down to this: If you are tempted to make a new XML dialect, instead try fitting it into one of what he calls the the “big five”:

How to use vim, really

I’m an Emacs man myself. I’ve never really used vim at all, and I use vi only for crontabs and commit messages. I’ve always grasped in the abstract the potential advantages of its modal editing, but that’s as far as it ever went.

Jonathan McPherson’s site has a great introduction to using vim that opened my eyes. His explanations of vim’s features offer just the right amount of detail. Most importantly he explains why particular commands are a good idea. Not explaining that is one of the classic failings of manpages – and I suspect that the vi manpage is the beginning and end of many users’ attempts to learn it. They learn about insert mode, command mode, loading and saving files, and that’s about it. Luckily, those just happen to be the prerequisites for McPherson’s tutorial. Clever fellow.

You really should learn regular expressions

Here’s another advice post. Luckily, many of you can test out of it, like a college Gen Ed requirement. Here’s the test:

  1. What does the following regular expression do? ^http[s]?://([a-z]+\.)?example\.com/$ (Answer below.)

The target audience for this post is people who have heard of regular expressions, but don’t use them. Or who have used them a little, but have the feeling they really should know them better.

You’re right. You should.

Quick, but not dirty, PHP

Though I’m doing more and more work in Python, I still write a lot of PHP code, especially for quick one-off web automation tasks.

There is plenty of activity on the other end of the scale in the PHP world now: frameworks like Cake, WASP, Solar, TaniPHP, the forthcoming Zend Framework. All this action is very cool, but doesn’t address the one-page script – and the one-page script is still worth doing right.

Many people come into PHP helter-skelter, not realizing that “Wow, it works!” is not the highest level of achievement possible. I don’t offer myself as a PHP guru, but below are some of the conventions (I dare not call them “patterns”) I use that I think are worth passing along.

Beware of the "just"

This post on the 37signals blog validates something I have been saying for years, and have recently been telling my students to watch out for: client requests that hinge on the word “just.”

As in: “Can you just make this webcam grab into a 16x20 print?” Or, “Can you just make our shopping cart work like Amazon.com?”

“Just” means, “I have no idea how this is actually going to be accomplished, but I would like it to be instantaneous.”