Answering How Many with Software

How many? is a typical question that comes up when programming. I use a variety of software for projects and there are subtly different ways to answer that question depending on the context.

Here is an alphabetical list of ways I’ve recently answered that question. A more detailed comparison of programming languages can be found on Wikipedia.

Command Line

# How many rows are in this file?
wc -l < file


// How many elements are in this array?


// How many elements are in this array?

// How many elements in this array are greater than 5?
d3.count(array, (d) => d > 5)

// How many rows are in this Apache Arrow table?

Liquid Tags in Jekyll

<!-- How many elements are in this array? -->
array | size


# How many elements are in this list?

# How many elements are in this pandas dataframe?
df.size # including missing values
df.count() # excluding missing values

# How many elements are in this numpy array?


# How many elements are in this array?

# How many rows are in this Active Record table?


-- How many elements are in this PostgreSQL array?
array_length(array, 1)

-- How many elements are in this DuckDB list?

-- How many rows are in this table?
select count(*) from table


# How many elements are in this list?

Random Hacks of Kindness Milwaukee

A friend invited me to Random Hacks of Kindness in Milwaukee. I haven't been to Milwaukee or a hackathon in sometime, so I was excited to visit the city and meet other developers.

I met my friend downtown at 6:30am, but since I was so preoccupied the night before with submitting my Apps for Metro Chicago, IL entry before the midnight deadline, I overlooked the fact that I had to buy a travel ticket in advance. I managed to get a ticket at the last-minute and was on my way with about 5 hours of sleep under my belt. Half way through the trip my friend asked me if I brought my ticket to the event. I didn't even register! I was clearly flying by the seat of my pants on this one. At least I had my trusty T61 laptop.

read more »

Make Flickr shapes JSON parsable

Update: Flickr has released version 2.0.1 so this is no longer necessary. Thanks Flickr :D

read more »

Internal Type Juggling in PHP 5.2 vs PHP 5.3

There is an undocumented case where the output of an internal function is different in PHP 5.2 vs PHP 5.3 when you pass it an invalid argument.

read more »

Don't Use maxlength on Password Inputs

On the HTML input form element, you must define a type and may define a maxlength attribute. This is in regards to the password type and the relation it has to the maxlength attribute. If the maxlength on a password input is wider than the width of the input, there is no way to tell if what you are typing (or pasting) is actually going into the field.

Below are two test forms that will illustrate my point. Each form looks identical, but have much larger implications in practice. Test the following KeePass generated password in the following forms:


What you have just experienced is a problem that exists on many website's user registration. If this were a real user registration, the password you entered will not completely save and you will be locked out when attempting to log in. This happens when sites validate the length of the password by specifying a maxlength as opposed to correctly checking its length during the form processing. Overall, using client side markup to validate form values is precarious. Therefore, maxlength should be limited to text input types, if it is backed up by server side validation.

P.S. Stop putting maximum length requirements on passwords, period. Just hash the password and store that. And no, password retrieval is not an excuse; have the user reset their password instead.

Load-bearing Code

The term 'load-bearing code' can be used to refer to software that exhibits the following attributes.

Jerry, these are load-bearing walls, they're not gonna come down!

Cosmo Kramer in the Seinfeld episode "The Chicken Roaster"

I have encountered load-bearing code in legacy open source applications, inherited projects, or debugging production software.

Calculating Different Mii Combinations

On November 19th 2006, I set out with a friend to buy a Wii on launch day. After futilely showing up at about five stores, we took a chance at this small electronic boutique with ten people waiting outside. After getting into line at eleventh place, I was hearing murmurs of this place only having ten Wiis. We decided to wait the hour and a half and hope for an extra Wii. Five minutes to 11:00 am, this girl that was second in line with her boyfriend decided she was hungry and went to get a bite. Much to my surprise, when the guy came out of the store to tag who would get a Wii, she wasn't there and I got the tenth and last Wii they had.

read more »

Click here to go to a web page about the overuse of 'click here'

As with many early internet paradigms 'click here' has become the equivalent of the verbal overuse of 'like': an unnecessary filler before getting to the real point.

Admitting You Have a Problem

It is worth realizing that yours is not the first web site your user has seen (unless you are the operator of acoolwebsite.com). For the rest of us, telling a user what to do with a hyperlink is on par with having instructions on how to scroll and see the rest of a web page. Is it underlined? Does it react when I hover over it? Does it stand out from the rest of the text? If so, I know it's a link and I have a pretty good clue what is going to happen if I click it. The text of a link should answer a user's questions. "Where do I go to read more of this article" should translate to a 'Read more' link. "How do I get to the next page" gives us a 'Next page' link. "What is this web site's privacy policy" can turn into 'Privacy'.

Wait, What?

Obviously We Have a Problem

Search TermResults from Google
"click here"1,620,000,000
"click here to"831,000,000
"click here to go"16,800,000
"click here to go to"7,730,000
"click here to go to a web page about the overuse of 'click here'"1 unique


The overuse of 'click here' In conclusion, I believe using a 'click here' qualifier to help the user actually makes it more confusing considering how inconsistent the 'Click here' linking can be. Any argument for keeping it I would have to rebut with the actualization that you would have to put 'click here' in front of every link. Imagining a menu navigation with that much filler should clarify my point.

How to Prevent Your Debit Card Signature from Smearing

I have recently changed financial institutions. I received my new debit card the other day which reminded me of a strategy of mine.

I carry my debit card in my pocket and, in past iterations, my signature line would smear off causing problems at the checkout.

Now, when I get a new debit card, I make sure to take a strip of scotch tape and cover over the signed signature area on the back of the card.

Once the tape is in place, it is trimmed to size. My previous debit card’s signature line is still in as good of shape as it was when I attached it two years ago.

Previously I attempted to tape over more areas to preserve the number shine and the magnetic stripe, but those proved to cause errors in scan reads or elicit peculiar looks at the checkout.