Archive for December, 2012
Here is a… composition of some sort… that I made from gavel sounds and a few other clips from the Judge John Hodgman podcast. I don’t know much about making music, but I’ve got GarageBand, and I’m allowed to abuse it occasionally. I’m not sure if I’m allowed to abuse Judge John Hodgman’s content in this way though. I’d usually get permission or only use Creative-Commons-licensed stuff, but I guess I’m living dangerously. I probably shouldn’t try to anger a fake judge.
I’ve wanted to do this for ages, and was waiting for the right card to come up. But although I’ve had all week off work, I didn’t notice this card until Friday, so it was the usual weekend rush. It came out pretty much as I’d imagined it though — something like Bonzo Dog Doo-Dah Band’s ‘The Intro And The Outro‘. I’d worried I wouldn’t be able to combine anything in a logical way and fit everything into a short enough track. When I first came up with the idea. I deliberately looked through both of my Manneken Pis decks for some kind of judge so I could decide on when to do it, but I must have thought this was from a royal court rather than a law court.
I used almost every episode up to episode 90, excluding a few that used the same gavel sound, a few I can’t find on my hard drives and had trouble downloading, and the bonus podcasts for donors. Every gavel sound and its ‘this is the sound of a gavel’ introduction is used unaltered the first time, then sometimes reused later without the introduction. I didn’t try to adjust the volume of the various clips, since within GarageBand you can only adjust the volume of entire tracks, and if I had a separate track for each clip GarageBand wouldn’t be able to play it in real-time.
I only noticed afterwards that the word ‘pie’ is said at 3:14.
To be sung to the tune of My Favourite Things from The Sound of Music (though like in my other My Favourite Things parody, the structure is modeled more on various other parodies of that song.) Feel free to record yourself singing it so I don’t have to:
Catch all exceptions; what are they the heck for?
Just return nulls that the callers won’t check for,
or show an error box, if they insist,
brought back by loops every time it’s dismissed.
Checks and injection and joins are just theories;
just add more levels of nested subqueries,
lace all your filters with unescaped strings,
fetch from a multi-use table called THINGS.
Love the warning
all your huge source files;
they’re all just suggestions, there’s no need to test
as long as it all compiles.
Code reuse means not one code block is wasted —
ev’ry last one has been copied and pasted.
Make up for duplicates no more the same:
reclaim some space with a one-letter name.
I’ve used these same antipatterns since FORTRAN;
why should I listen to hacks I’m paid more than?
Even my students are older than you;
how dare you tell me I need code review?
Slam resource leaks
till you’re hoarse, geeks!
Rail against that kludge.
There’s no way to beat them; you’ll have to submit
to The Daily What The Fudge.
First, check out Vi Hart‘s video about the Thanksgiving turduckenen-duckenen:
Okay, there are monkeys instead of turkeys, and the mathematics isn’t quite as explicit, but it’s pretty similar, don’t you think? Now, let’s imagine that Mike Phirman is actually singing the recipe for a fractal turducken, or rather, monducken. You can imagine all the monkeys are turkeys if you’d rather eat the result than present it to some pretty thing to please them. (Note: Please do not kill any actual monkeys.) Monkeys, like birds, belong in trees, so I wrote an AppleScript to draw binary trees in OmniGraffle based on the text of the song. You can try it for yourself if you like; all you need is a Mac, OmniGraffle, and a text file containing some words. See the bottom of this post for links and instructions.
If Mike’s reading the binary tree recipe layer by layer, like the first example in Vi’s video, one possible tree for the first stanza of Chicken Monkey Duck looks like this, where the orange ovals are monkeys, blue hexagons are chickens and green clouds are ducks. You can click it (or any other diagram in this post) for a scalable pdf version where you can read the words:
I added numbers so you can easily tell the chickens, monkeys and ducks apart and see which way to read the tree. It’s simple enough now, but the numbers will be useful for reading later trees which are not in such a natural reading order. This is called a breadth-first traversal of the tree, in case you’re interested. Now, what do birds and monkeys do in trees? They nest! So I wrote another script that will take any tree-like diagram in OmniGraffle and draw what it would look like if the birds, monkeys, or whatever objects they happen to be (the drawing is pretty abstract) were nested inside each other, just like the quails inside the chickens inside the ducks inside the turkey. This is what the monducken described by the first stanza of Chicken Monkey Duck, in the tree structure shown above, would look like:
The Monducken script allows using a different shape for each animal as redundant coding for colourblind people, even though it already chooses colours which most colourblind people should be able to distinguish. But that makes the nested version look a little messy, so here’s the above diagram using only ovals:
If you named this particular recipe in the other way, going down the left side of the tree and then reading each branch in turn in what is known as a pre-order traversal, it would be called a Monenmonenduckduckmon-monmonducken-enenmonduckmon-enmonduck-enduckmonducken-enmonen-duckenenmon-monenmon. It doesn’t sound nearly as nice as Turduckenailailenailail-duckenailailenailail because Mike Phirman didn’t take care to always put smaller animals inside large ones. I’m not holding that against him, because he didn’t realise he was writing a recipe, and besides, it’s his birthday. For reasons I’m not sure I can adequately explain, it’s always his birthday.
But what if I completely misunderstood the song, and his recipe is already describing the fractal monducken as a pre-order traversal, always singing a bird or monkey immediately before the birds and monkeys inside it? Well, don’t worry, I added a ‘pre-order’ option to the script, so you can see what that would look like. Here’s the tree:
and here’s how the actual birds/monkeys would look if you cut them in some way that showed all the animals, dyed them the correct colours, and looked through something blurry (here’s the version with different shapes):
Okay, but that’s only the first stanza. What if we use the whole song? If we pretend the recipe is breadth-first, this just means all the extra monkeys and birds will be at the bottom levels of the tree, so the outer few layers of our monducken will be the same, but they’ll have a whole lot of other things inside them:
Here’s a close-up. Isn’t it beautiful?
If the entire song were treated as a pre-order monducken recipe, we’d still have the same monkey on the outside, but the rest would be quite different:
We could also read the birds and monkeys from left to right, as Vi did in her video. That’s what’s called an in-order tree traversal. But as delicious as they are mathematically, none of these orderings make much sense from a culinary perspective. Even if the monkeys were turkeys, it’s obvious that a nice big goose should be the outer bird. Vi suggested that herself. Of course, we could put the goose on the outside simply by reversing the song so it started with goose. But it would be much more fun and practical to pretend that Mike is naming the two inner birds before the one that contains them. This is called a post-order traversal, because you name the containing bird after the two birds or monkeys it will contain. It makes sense for a recipe. First you prepare a monkey (or turkey) and a chicken, then you immediately prepare a chicken and put them into it. You don’t have your workspace taken up with a whole lot of deboned birds you’re not ready to put anything into yet. Here’s one way the recipe could be done:
Note that no matter what kind of traversal we use, there are actually several ways the recipe could be interpreted. If Mike says ‘monkey chicken chicken’ you know you should take a monkey and a chicken and put them in a chicken. But if the next words are ‘monkey chicken’, do you take that stuffed chicken and a monkey and put them inside a chicken? Do you debone the monkey and the chicken and wait for the next bird to find out what to put them into? What if there’s no next bird? What if there’s only one more bird (let’s say a duck) and you end up with a stuffed chicken, a stuffed duck, and nothing to stuff them into? You’d have to throw one of them out, because obviously your oven only has room for one monducken. Assuming you want two things in each thing, and you don’t know how long the song’s going to be, the best way to minimise this kind of problem is to always take your latest stuffed thing and the next, unstuffed thing, and put them inside the thing after that. The worst that’ll happen is you’ll have to throw out one unstuffed bird or monkey. But then you end up with a really unbalanced monducken, with a whole lot of layers in one part and lonely debonely birdies floating around in the rest.
It helps to have a robot chef on hand to figure out how many full layers of monducken you can make without it being too asymmetric. Mine makes the trees completely balanced as deeply as possible, and then does whatever was easiest to program with the remaining birds and monkeys. In this case it was easiest for my program to stuff a whole lot of extra animals into that one monkey on the left. This is what it looks like, with the varied shapes this time. Luckily, geese are rectangular, so they fill your oven quite efficiently:
I like how you can see the explosion of duck radiating out from the inner left, engulfing all the other birds and monkeys before itself being swallowed by a goose. Such is life.
If you would like to make diagrams like this yourself, there are two AppleScripts you can use. Both of them require OmniGraffle 5 for Mac, and if you want to make trees with more than 20 nodes you’ll probably need to register OmniGraffle.
The first is Monducken diagrammer, which you can download either as a standalone application (best if you don’t know what AppleScript is) or source code (if you want to tweak and critique my algorithms, or change it to use OmniGraffle Professional 5 instead of OmniGraffle 5.) Because it’s AppleScript, it works by telling other applications what to do, rather than doing things itself. So when you run it, TextEdit will ask you to open the text file you want to turn into a tree. Once you’ve opened one, OmniGraffle will start up (you may need to create a new document if it’s just started up) and ask you two things. First it will ask what kind of tree traversal the text file represents. Then it will ask you what kinds of shapes you want to use in your tree. You can select several shapes using the shift and command keys, just as you would for selecting multiple of just about anything on your Mac. Then you can sit back and watch as it creates some shapes and turns them into a tree.
The other one is Tree nester (standalone application/source code) You should have an OmniGraffle document open with a tree-like diagram in it (I suggest a tree generated using Monducken diagrammer; it has not been tested on anything else, and will probably just duplicate most of the shapes that aren’t trees or end up in an infinite loop if there’s a loopy tree) before you run this. It won’t ask any questions; it’ll just create a new layer in the front OmniGraffle document and draw nested versions of any trees into that layer.
If you’re looking at the source code, please bear in mind that I wrote most of this while on a train to Cologne last weekend, based on some code I wrote a while ago to draw other silly diagrams, and I really only dabble in AppleScript, and I forgot about the ‘outgoing lines’ and ‘incoming lines’ properties until I’d almost finished, so it probably isn’t the best quality AppleScript code. Not the worst either though. I welcome any tips.
This weekend Geneva celebrates the Fête de l’Escalade, so I made a video of the piece I wrote about various things called marmites, their nutritional value, use in soup cooking, and effectiveness against invading Savoyards. It’s been adapted slightly to work on video, and includes some destruction, a dangerous stunt, and a slight tilt I didn’t have time to correct.
I read this at the Geneva Writers’ Group on Saturday, using all the same props, and the Marmite was smashed in a way probably closer to the tradition than all the other Marmite-smashings I’ve induced. It’s the last one in the video. I am not sure how many people tried the various yeast spreads, but several told me of their preexisting preferences.
I felt like reading this one aloud. In retrospect, I should have taken the trouble to memorise it and set up a proper camera rather than recording it with a webcam while reading it from a screen. The story I refer to, which I did not actually reread before writing this, is after the break.
When I was a teenager I wrote a story about my experience staying in Starship Children’s hospital for a while, and presented it to a writing class. I mentioned that I was somewhat glad, after several weeks there, to get back to the real world.
“But surely you can’t get much more real than a hospital,” a middle-aged woman in the class responded.
This puzzled me at the time, but I think I understand now. Reality is pain, and sickness, and IV drips, and wheelchairs, and bed pans, and rarely going outside, and machines that beep all night, and parades of doctors taking turns prodding and asking if it hurts, and teenagers who know they will not live to adulthood, and healing, and nurses at your beck and call, and surprisingly good food delivered to you in bed, and visitors that bring better food to overcompensate, and a play specialist who comes by regularly to play with you, and a games cart that comes by less often with new games, and glass lifts facing the atrium that have a view of the playground and all seven different-coloured storeys, and an in-house movie channel that shows mostly The Lion King, by request, and an in-house radio station that plays mostly Mysterious Girl and Wonderwall, also by request.
Anything else you think you experience is merely the product of your deranged imagination.
This is a collaboration by many fans on Jonathan Coulton’s forums to celebrate Jonathan’s birthday, and it would have been nothing but an idea without everyone else, but I think I put enough effort into it (lyrics based on Pizza Day, video editing, and even singing) to count it as a card towards this Writing Cards project. It happens to feature the Jack of Spades, but I’ve already done two of those, so how about calling it a grand unification of JoCo fans. It’s the continuation of a tradition that started in 2009; I recommend watching the previous videos if you like this one. He seemed to like it.
This afternoon I might already record a video of what will probably be the four of clubs, a very short piece I wrote in the middle of the night which I feel like reading aloud. Then I’ll have brought my average back up toward one a week.