Teach me py.test (Haecksen miniconf, Tuesday)

I didn’t manage to go speaking-free for LCA2013 after all, because I have volunteered to help out my roommate Brianna Laugher with the py.test presentation in the Haecksen miniconf.

The plan is that we will do “Teach me py.test” along the lines of Steve Holden’s “Teach Me Twisted” session at PyCon 2008 (see Catherine Devlin’s report). The idea of the session is that I (genuinely new to py.test, although not to either Python or to unit testing in general) will hook my laptop up to a projector and learn how to write tests in py.test, with Brianna teaching me.

We have pulled some of the business logic out of Zookeepr into this git repository in preparation for the talk at 16:05 in MCC6. I am not sure how much we will cover in 25 minutes, presumably not a lot, but it should be an interesting experiment in presentation style.

Gain world-wide fame and adoration*

WordPress has an annoying feature of its spam handling, namely that it shows you the entire spam content in the spam comment interface (where one must venture in order to rescue legitimate comments). This is how it works:

  1. look at first line of spam, agree that it is for sure spam
  2. scroll down
  3. scroll down
  4. … scroll down
  5. oh good, here’s definitely-spam message #2
  6. scroll down…

Two things that would help:

  1. a WordPress plugin that reduced spam to short expandable excerpts
  2. an update to the Akismet Auntie Spam Greasemonkey script to make it work with current versions of WordPress

Consider your path to world-wide fame and adoration laid out before you. (I am technically capable of doing both those options, but I don’t have time for a new path to glory right now.)

* Offer may not be valid to residents of South Australia.

A petty rant

See the title? Consider yourself warned.

OK, geek culture. I am ambivalent with claiming particular things as being geeky or not in the first place, because half the time I fall outside it. (I’m not a night person, I don’t especially identify with or even like cats, to give some trivial examples.) And if it excludes me, it must be wrong. Duh.

But perhaps we should claim being petty and pedantic. Here’s my line in the sand: you do not count discrete things starting at a zeroth thing. Well, if you do, I say it’s not geeky.

There’s a sort of a general understanding that “geeks count from zero”. Here’s where it comes from: in many programming languages, arrays begin at zero, so array[0] retrieves the first item in the array and array[1] the second and so on. This is actually somewhat confusing, and results in plenty of off-by-one errors (for example, if an array has length l, then one is tempted to ask for the last item as array[l] when it’s actually array[l-1], and forgetting that is not at all uncommon).

It has meaning: it’s fairly obvious why this is done in C, it’s because elements in a C array are stored in contiguous memory and the name “array” is already a pointer to the first memory address. Say the array starts at memory address 7, then to access the items of the array you would do:

  • array[0], which is an alias for *(array + 0) or *array, ie, find out what is at memory address 7 (the dereference operator * means “look up what is at this memory address”)
  • array[1] or *(array + 1), ie, find out what is at memory address 7 + 1 = 8
  • array[2] or *(array + 2), ie find out what is at memory address 7 + 2 = 9

And so on.

Dennis Ritchie’s The Development of the C Language shows that this notation is inherited from C’s precursor B.

And it’s not a silly way to count some things. It’s the same way we count age in the Western world: at the beginning of your first year, you are age 0 and at the beginning of your second year, age 1, and so on. The first year of someone’s life begins at birth[0] as it were.

But it’s a silly way to count objects. It is not more geeky to count, say, two apples as a zero/zeroth apple and a first apple. You could perhaps refer to the zeroth apple offset, ie, the point just before the beginning of the first apple, if you had reason to refer to that point (I never have).

Try as I might, this has always bugged me about the history of linux.conf.au: CALU was not the “zeroth because it’s geeky!” linux.conf.au. It’s like someone made that up specifically to annoy me personally. I will find you, whoever you are, and I will take your zeroth apple away from you and unlike you, I will have my first apple. And I will enjoy it.