Tag Archives: coding

Beware of Optional Curly Braces — They Will Bite You

I was looking through some PHP code from a third-party vendor recently, and saw something that made my jaw drop. It’s pretty innocent-looking, at first. Here’s a somewhat anonymized and genericized version of the code, but the thing that bothered me is still intact. It’s not really a bug, per se; the code will function as [...]

The Problem With Jamie Zawinski and Regular Expressions

Jamie Zawinski, also known simply as jwz, is famous for his quote: “Some people, when confronted with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems.” It’s a very amusing line, and I can totally see why people all over the world are using it in their .sig files: It [...]

Developers Are Not QA Testers

When a company says “we can’t afford a QA department”, what they’re really saying is, “we accept that our software will be infested with bugs, and quality is not important to us.” When they compound this basic error by saying, “the developers will just have to do their own QA”, they prove that they have [...]

Silly Coding Tricks: “Inverted” String Match

First things first: Never actually do this. This is just a fun curiosity, for amusement value only. Because of the way JavaScript’s search() method works, you can do: var my_url = 'http://kai.mactane.org'; if (! my_url.search(/http:\/\/kai.mactane.org/)) {     alert("Your URL is http://kai.mactane.org"); } else {     alert("Nope, your URL isn't http://kai.mactane.org"); } Try running this, and it will [...]

Testing Backward-Incompatible Changes

Let’s say one day you decide to add a feature to your software or service. For example, you need a new flag on user accounts, so that different types of users get different features. (These don’t even have to be tiered account levels; maybe accounts of type “music lover” get a widget in the sidebar [...]

What Characters Are Allowed in Twitter Usernames

A while back, when I was writing Hummingbird, I needed to look for Twitter usernames in various strings. More recently, I’m doing some work that involves Twitter at my new job. Once again, I need to find and match on Twitter usernames. Luckily, this time, Twitter seems to have updated its signup page with some [...]

Hummingbird Updated to Version 0.60

I’ve always questioned the wisdom of building a startup company based around someone else’s platform, like Facebook games or Gmail inbox add-ons. You’re totally at the mercy of the other company. (Many people have found out how silly it was to go up against Microsoft or Apple in just the same way.) And yet, here [...]

Notes on LJ Content Sieve

My latest project is something I call “LJ Content Sieve”: a Greasemonkey script to filter out content on one’s Livejournal views based on nearly any attribute of a post or comment. However, Livejournal is very customizable. It has 31 different “layouts”, each of which can then be further “themed” by application of CSS. This means [...]

Would Shlemiel the Painter Optimize Prematurely?

I don’t want to optimize this code prematurely. And “while you’re still writing it” is probably premature. On the other hand, totally ignoring algorithmic complexity is a sure route to a Shlemiel the Painter’s algorithm. Do I really want to just write the whole thing, and then start profiling it to see where the hot [...]

TDD and Peace of Mind

Let’s face it, we’re not perfect. As much as I might realize that automated testing is a good practice, it still feels like a chore sometimes. In my latest round of personal-project development, just setting up a decent set of test fixtures and a working test framework turned into something of a hassle, as it’s [...]