Tag Archives: coding

On jQuery’s .data() Call Syntax

I recently had a developer on my team who had some trouble with jQuery’s $(…).data() syntax. In case anyone else has trouble, maybe I can clarify things a bit. I’m anonymizing all the code involved, of course. We wanted to make certain items have certain behaviors under certain circumstances. And so we set up a “whatToDo” […]

Why Did My Layout Just Go All Wonky?

If you add Boostrap’s CSS to a layout that’s already working just fine, you may find that things shift in strange, subtle ways. And even not-so-subtle ones, like basically your entire layout breaking. Generally, this seems to manifest as block-level elements becoming too small, and clipping out content inside their bounding boxes. A div that used […]

Skipping Regexes in ES6 is Nothing Compared to Skipping Boolean-Comparison Warts

Yesterday, Wes Bos tweeted about ES6’s startsWith(), endsWith(), and includes() methods. He said it was “[t]hree less JavaScript Regexes you’ll have to write”. Which is true, but I feel it misses the point. I mean, the regexes for initial match and final match are really not that hard, and the regex for plain inclusion is, well, […]

Smart Apostrophes: They’re a Problem (in URLs)

Recently, The American Prospect published an article excoriating the “men’s rights” movement. It was a pretty good article, and well-received. Lots of people tweeted links to it… or, they tried to. Curiously, those tweets all broke in the exact same way, pointing at a truncated version of the correct URL. That’s because the next character after […]

Good Things About FizzBuzz

Over a year ago, I mentioned FizzBuzz as a basic competence screen during interviews. At the time, I said: “My only real quarrel with FizzBuzz is that, at this point, any developer worth their salt is familiar with it.” I seem to have been wrong, becuase I keep running into coders who definitely are competent, […]

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