Mr Speaker

Category: Dictaphone

The proverbial “proverbial notes to self”

One-line array wrap

I like this lil’ one-liner for wrapping around an array forward, or backwards. Given an array, with a current index, you want to move either to the next item, or the previous one. Here’s the setup: var a = [“alice”, “bob”, “charlie”], current = 0; // start with “alice”, direction = Math.random() < 0.5 ? […]

AI Class Playlists

Lil’ reference for anyone doing the Stanford AI class… It’s a collection of playlists for each unit, so you can grab them with something like youtube-dl (I use the command youtube-dl -w -t -f 18 http://playlisturl. I didn’t check what those flags do, but it says “wtf”, and that’s all that matters).

Anonymous functions for inline event handlers

Inline event handlers… remember them?! Yes, they’ve gone the way of the blink tag and Adobe Flash, but recently I used one while debugging and realised: “Hey! I have no idea how to get the event object in an inline even handler!” and, shortly after “In fact, no idea how to write an anonymous function […]

Nifty jQuery trick: setting attributes

I’ve been knee deep in the jQuery source code recently. It’s all gooey, but you do get to see some snazzy things. Today’s nifty jQuery trick is about programmatically setting attribute values via a function. To follow along at home you’ll need some scissors, a length of string, and some double sided tape…

Closures with self-invoking functions

Just a quick note-to-self… I’m a big fan of using self-invoking anonymous functions to keep stuff out of the global namespace, but I forgot that they are also nifty for keeping variables in scope via closures. Here’s the problem… Let’s say with have an array that we’d like to populate with functions. The functions simply […]

Convert WordPress fetch_rss to fetch_feed

I realised that I wasn’t properly handling the return value on a feed I was grabbing to display the “Spiffy things from the Internet” section of the blog. I went to WordPress to look up the fetch_rss API details, only to find that it had been deprecated in WordPress 2.8.something. Being the ever-vigilant beacon of […]

Faking email delivery in .NET

Well here’s a tip that would have prevented me from barraging the owners of test.com and asdf.com with mountains of garbage test emails, had I discovered it many years ago (sorry about that, guys!). In .NET you can easily specify a location to dump emails ready to be picked up by the SMTP server. If […]

Revisions in WordPress 2.7

Quick note for those running WordPress 2.7, and are starting to freak out about the 500 gazillion revision rows that are now getting inserted into your database… There are a few ways to cull them – such as deleting all posts with type “revision”, but that’s pretty annoying. Thankfully, the WordPress docs now have a […]

Wolfram Alpha and jQuery Easing

Wolfram Alpha is out and about, and promising to link all information in the world together in a way that will render further human thought obsolete. Most people who know that thinking is boring, and want to learn important things about b-grade celebrities, quickly realised this weird search engine wasn’t going to tell them anything […]