Tag Archives: coding

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 correctly claim that “Your URL is http://kai.mactane.org” — even [...]

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 nice [...]

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 I [...]

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 that [...]

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 spots [...]

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 [...]

Grousing About PHP’s Limitations

Drat. I would like to chase back up the class hierarchy of a bunch objects, and then do something based on the second-from-the-top of that chain. (For example, when the chain goes Word > Noun > Animal > Mammal > Human, and I’ve instantiated a Human, I’d like that object to be able to tell that it’s a Noun.)
Unfortunately, I’m [...]