The Most Important Epiphany I’ve Ever Had

If there’s one experience I would wish on everyone above all others, it’s the chance to feel your conscious desires become so at odds with your instincts that, in one brief moment, it snaps into clarity that, whether or not you feel that your rational mind is “you”, you are not your emotions either.

For me, this happened while I was taking a course on the programming language, Prolog (a language very different from the half-dozen or so I already had experience with). I was working away at the assigned exercises and frustration was building as I tried to figure out how to reconcile what my program was doing with what I thought it was supposed to be doing.

I started to lose motivation and to feel that the endeavour was “stupid” because “I already know several perfectly good and very versatile programming languages, such as Python”. I struggled to continue on despite this and, in a flash of insight, I realized that I was simultaneously holding two conflicting viewpoints: On a purely conscious level, I was still fascinated and my desire to expand my mind by internalizing the mindset embodied in the language had not waned but, on an emotional level, I considered it a waste of time.

With that revelation in mind, I found a renewed sense of motivation and was able to more effectively dismiss the emotional desire as simply a product of an instinctively lazy neurobiology trying to save precious calories, much like the desire to give up when you’re engaging in physical exercise.

I still do backslide from time to time, which is unsurprising given that the conscious mind evolved merely as a pathfinding program subordinate to the goals set by our instinctive desires, but, whenever I do manage to recall this revelation and the mindstate which accompanied it, it never fails to bolster my resolve.

Posted in Web Wandering & Opinion | Leave a comment

My Little Pony Fics and Songs For Non-Bronies

Since my last mention of the subject, I’ve grown somewhat attached to the fanfiction and songs coming out of the My Little Pony fandom. I still wouldn’t say I’m into it enough to be a brony but I appreciate good content. (After all, not everyone who watched Star Trek on TV was automatically a trekkie)

As such, I thought I’d offer some links for fics and songs that, by their quality and their focus, are most likely to be enjoyed by people who may only know the MLP characters from their Wikia pages. If you’re willing to give good characterization and good humour a try, regardless of its source, give them a look.

The Fics

The Wizard and the Lonely Princess by Harry Leferts (Also on
More a Harry Potter fic than a My Little Pony fic, this explores what might happen if a Freaky Friday wish for a friend lead young Harry Potter to meet Princess Luna during her thousand-year exile on the moon.
This fic makes an excellent entry point to the fandom because, in addition to being familiar territory in a less controversial fandom, it puts a lot of work into fleshing out and exploring Nightmare Moon as her own interesting character (Showing that a villain is a person with believable motivations tends to make for a good story in general) and the interactions between her and Princess Luna.
Also, who can resist the image of Hermione Granger debating whether H.P. Lovecraft is a good author with a possessed plush doll?
Shinji’s Nightmare by Harry Leferts (Also on
While absorbed into Unit 01, Shinji Ikari comes to the attention of the banished spirit of Nightmare Moon. What results is a rather unique character-centric fic where Shinji loses his humanity, but gains so much more and Nightmare Moon mellows out a bit as she realizes that she’s gained the one thing Celestia and Luna can never have… a son truly her own.
Arrow 18 Mission Logs: Lone Ranger by AdmiralTigerclaw
It’s the future and scientists on Earth realize that, rather than orbiting a black hole as previously thought, one of the stars they’ve been observing is actually orbiting what appears to be an Earth-like planet. Unfortunately, politics end up whittling the crew of the resulting mission down to just one guy.
What makes this fic so special is that, rather than just being an ordinary “Human in Equestria” fic, the writing style and tone of the story make it feel more like someone took a sci-fi story and wrote a crossover. It follows the perspective of a main character who does not have a Universal Translator and casts the artistic differences between realistic depictions of horses and the cartoon’s art style as actual, in-setting differences. The end result of all this is a very satisfying “apolitical first contact” story.
…and so on
Since I had to register an account on to receive e-mail updates for new chapters, I’ve decided to maintain a curated list of good stories on my user profile page. If you like what I linked above and want more, that’s where I’d suggest looking next.
The three thumbnail boxes list the top 5 fics in each category while the “Runners-up” box contains anything else that I’d rate highly.
My one warning is to avoid the site’s dedicated “Favourites” tab on my profile. It’s rather useless because the site forces you to “favourite” something in order to watch it for updates. (But gives you the option of skipping the e-mails on something you’ve starred in case you want to favourite something but opt out of e-mails.)

The Songs

In addition to the songs I already mentioned in Trifles Make Perfection, there are a few others I’d suggest…

Winter Wrap-Up and This Day Aria
Both of these songs from the show itself are ridiculously catchy and have a surprising amount of work put into them.
For example, in Winter Wrap-Up, listen to the chorus. There’s clapping in the background from the beginning, but it gets louder each time and you only really notice it the third time the chorus plays… to excellent effect.  Also, I really like the counterpoint between Applejack’s voice alone (1:57) and the backup chorus at the end of her verse (2:12). Finally, it’s not every day you see a song in a children’s show which has enough poetic awareness to use a grammatical construct like “tough task ahead I face” to maintain its rhyming structure. (2:29)
The cover by ponyphonic is also very nice.
As for This Day Aria, the main detail I really appreciate is how well the singer managed to put two distinct characterizations into the same voice. (Especially given how Queen Chrysalis’s use of Cadance’s voice brings to mind some self-absorbed “queen of the high school”)
Nightmare Night by WoodenToaster and Mic The Microphone
Focused around the episode in which Princess Luna drops in on their Nightmare Night celebrations (the in-setting equivalent to Halloween), this song is technically rap, but with much more work than usual put into the non-lyrical elements.
I found it extremely catchy and, if you feel you like the instrumentals more than the voice, the YouTube video’s description contains download links not just for the song itself, but also for an instrumental-only version, a MIDI file, and sheet music for the piano intro. There’s also an orchestral-styled cover by StormWolf.
Discord (EuroChaos Mix) by Eurobeat Brony
A catchy, upbeat song focused on the original defeat of Discord, a Sealed Evil in a Can villain who once ruled over Equestria and, when he escapes again, proves that it is very appropriate that he happens to be voiced by John de Lancie).
Luna (DREAM MODE) by Eurobeat Brony
This was actually the first MLP song I ever discovered in the form of this crazy-mode StepMania playthrough of the dubstep remix.
Rainbow Factory by WoodenToaster
A catchy, dark techno song which paints a darker picture of Cloudsdale. It has spawned a fanfic, but I haven’t read it.
etc. etc. etc.
As with the fics, I maintain a list of favourite music on my FIMFiction profile if you want more. (Plus a list of favourite fan art.)
Posted in Otaku Stuff | Leave a comment

The Infectious Foolishness of GNOME’s Save Iconography

Over the last few years, I’ve noticed an increasing trend for Linux icon themes to follow the lead set by the Tango and GNOME icon themes in using a naked internal hard drive with a downward-pointing green arrow to indicate “Save” rather than a diskette. The problem is that doing so does not provide any benefits and actually makes things worse.

Let’s start by exploring what criteria are actually used to evaluate the appropriateness of an icon. I’ve identified three:

  1. Visual Consistency (Does it fit in with the rest of the theme?)
  2. Learnability (How long does it take for the user to memorize the icon’s meaning?)
  3. Visual Distinctiveness/Acquisition (How long does it take an experienced user to pick the icon out from a field of other bits and bobs?)

Visual consistency within the theme isn’t relevant to this argument, since we can safely assume that any popular Linux icon theme will have it. However, the “arrow to a drive” icon loses to the diskette on both of the other points:


If you don’t give it much thought, it seems to make perfect sense that, now that we don’t use diskettes anymore, we shouldn’t use them in our iconography. However, over 95% of users have never seen a naked hard drive, so that component of the new look is, on the face of it, equally disadvantaged.

I’m assuming that GNOME is following Apple’s lead here, since MacOS X also uses naked hard drive iconography, but there’s a significant difference: On a Macintosh, users are trained by experience that their files live inside the naked hard drive icons on their desktop, whether or not they understand the nature of what they are looking at. Most Linux desktop environments don’t offer this convention for accessing partitions and, even on those which do, it’s an optional feature. As a result, a critical link in the learning process is absent.

Also, nobody learns in a vacuum. For decades, we’ve built up the diskette, not just as a storage medium, but as something that can be used as an abstract glyph for “Save” and, in older websites (where the two functions are often equivalent), for “Download”. (This is probably a large part of why the original concept () for the language icon failed. It looks like a pictographic representation of a diskette.)

Because of this effect, a generation has grown up recognizing diskettes as “Save”, regardless of whether they’re old enough to have used them. This effect is bolstered by the tendency of Windows and KDE icons to still use them as such.

Finally, while I wasn’t able to identify the exact page, I distinctly remember one of my old textbooks1 saying that, once a user has learned an icon, their performance is unaffected by the affordance of having the icon resemble something familiar.

Visual Acquisition

Once you’ve grown used to an icon, the most relevant question is “How quickly can I find this when I want to click on it?” This is where GNOME’s choice fails multiple tests (some of which Apple’s implementation also falls short on).

First, it has poor visual contrast. Gray and green are very common colours to be used in popular icon themes, so it is difficult for the eye to quickly distinguish a save icon from other gray/green icons on a background that is often also gray. (Remember, even if light-on-dark is a common choice for GNOME-based desktops, these icon themes are also used in other desktops which have chosen to remain with the traditional dark-on-light for a default color scheme.)

By contrast, very few icons use the combination of red and blue traditionally used for diskette icons. This helps to compensate for how the ability to perceive variations in color and shape decreases as you move away from the center of our field of vision. (I have to stop and search for a drive icon if I haven’t become habituated to its position in the window. The diskette leaps out at me with no trouble whatsoever.)

Second, it is very common for green downward-pointing arrows to indicate “download” and “next page”. These two uses aren’t usually a problem, since these two uses rarely occur together in the same program and the meaning of “down as next” is disambiguated by the color of the nearby upward-pointing arrow.

However, having download and save in the same program doesn’t benefit from those same advantages. This forces the user to dedicate more of their attention to determining the meaning of the icon, slowing them down.

Finally, the icon is visually ambiguous in less-than-ideal circumstances. At small sizes such as 16×16 and 22×22, which are commonly used in toolbars, when the user is tired, has poor vision, or isn’t looking directly at the icon, it can be confused with either the Download icon or the Print icon (something I’ve encountered among less tech-savvy family members).


While I have said consistency within a theme is not relevant, consistency between themes is an issue since, even now in 2013, not all applications properly use the system icon theme.

Old applications, some 3rd-party applications, and KDE applications which need to provide icons outside the standard set still sometimes produce diskette-based icons which are not (or, in some cases, cannot be) replaced by the user’s chosen icon theme.


I am honestly curious what motivated the GNOME and Tango developers to choose drive-based iconography, given that the only advantage it seems to grant is consistency with Apple’s proprietary operating system and the single-platform applications within.

Not only does it highlight theming inconsistencies to users who might otherwise not have noticed, it throws out years of real-world experience in developing related metaphors.

For example, one derived icon which is often necessary is “Save All” or “Save Project”. With a diskette-based icon theme, this can be represented intuitively and at very small sizes as a cascade of diskettes. I have yet to see a viable metaphor for this operation when using disk-based icons. Most icon themes I’ve examined don’t even include such an icon.

As a result, this often results in toolbars for IDEs and other such programs presenting a cascade of diskettes to the right of the “hard drive with an arrow” save icon, harming the user’s ability to identify consistent metaphors.

In summary, I get the impression that the individuals involved in designing this iconography have little professional training in user interaction design and simply copied certain surface elements of MacOS X in hopes that some of Apple’s good juju would rub off on them.

1. Human-Computer Interaction, Third Edition by Alan Dix, Janet Finlay, Gregory D. Abowd, and Russell Beale

Posted in Web Wandering & Opinion | Leave a comment

Functional Programming Concepts for the Lay Programmer – Part 3

I really need to stop saying when the next one of these is likely to be out. In Part 2, I say that I hope it doesn’t take me a year and a half to write it and how long has it been? Almost two years.

Anyway, on to business.

map() and reduce()

The key to understanding the significance of these functions lies in two things:

First, when you have a list and you want to process it item-by-item, what do you do? You probably write a loop… but that’s boilerplate and some languages don’t have loops. Anyway, the computer should know what a loop looks like. All you want is to tell it to perform some task on each item in the list. That’s their original purpose… as a clean way to say “use this function on that list to transform/aggregate the data within”.

Second, whether you’re running it on your little home PC or Google’s massive server cluster, the loop you wrote will do the same thing… use one processor to do exactly what you told it to. If you want to scale up, you need to either write or find some code to spread your task out across multiple processors.

That’s what Google needed to do too… and they realized that map() and reduce() were a very clean way to talk to such a library. In languages like Python, these functions may be little more than syntactic sugar around a loop, but scalable MapReduce libraries like Google’s can use the exact same “apply this function to each item in that list” interface to farm your operation out over what may be thousands of processors just as easily as with one.

As for why there’s two of them? map() takes a list and returns a new list of the same length. reduce() takes a list and uses your function to merge each item into some running aggregate. You’d probably use a parallel map() to do multi-core thumbnailing; Google uses it to toss your search out to several dozen servers in their cluster. I don’t have a handy reduce() example for home use, but Google uses it to merge the results from map() into one unified list. (The Wikipedia page gives a few more examples.)

Functional languages also tend to have filter(), which takes a list of things and only keeps the ones where your function returns True. In Python, rather than using the built-in map() or filter() you’re advised to use List Comprehensions since they’re cleaner and more concise.


Closures or, more specifically, lexical closures, rely on the way lexical scoping and anonymous functions work in many modern languages (eg. JavaScript, Python, PHP 5.3+, etc.). This is easiest to explain with an example, so I’ll give one:

def makeAnnotateFunction(prefix):
    def do(text):
        return str(prefix) + str(text)

    return do

error = makeAnnotateFunction('ERROR: ')
warning = makeAnnotateFunction('WARNING: ')

Because do() has access to the environment it was created in, even after makeAnnotateFunction() exits, this works as you’d expect it to. The example is slightly contrived , but it’s in the same vein as some of the tricks I’ve used it for in test suites and logging systems. do() acts as a template for a bunch of similar functions I need.

Another common use for closures is in asynchronous programming situations like JavaScript. For this one, I can give a more concrete example using jQuery:

 var foo = function(selector) {
    var node = jQuery(selector);

    jQuery.get('', function(data, i, j) {

If you’re not familiar with JavaScript and jQuery, here’s what’s going on:

  1. We define a function named foo which takes a CSS selector.
  2. When called, the function uses jQuery to find matching elements on the current page.
  3. It then performs an HTTP GET request for and, when that returns, inserts the data it got into the selected elements.

The key is understanding that jQuery.get() is asynchronous. It returns immediately, rather than freezing up the page while waiting for the HTTP request to complete. If you want to do something with the result of the request, you have to provide a callback… but how do you make sure that the callback can see node so it can call node.html()?

That’s what closures do. The callback definition is executed within the parent function, so it keeps a reference to the parent function’s local scope, no matter what part of the browser may end up calling it later on.


Let’s think about our metaphors for object-oriented programming. A class is a blueprint for building objects. So… what if you need to specify a blueprint for building classes? Hence, the metaclass.

That level of abstraction can be difficult to explain (I’m not even sure I fully understand it) but their most visible use in practice is redefining the behaviour of class definition to implement a domain-specific language such as Django ORM’s model definitions. They give the ORM a very clean way to let you write a class for each table in your database without also requiring you to manually hook up the “magic” that does the translation.

…or, if you’re familiar with function and class decorators, think “like those, but you can have inheritance”.

There’s an in-depth Python explanation on StackOverflow.

Bonus Features

Matrix Transposition

Matrix transpose is an operation that can be explained in two ways:

  1. Given a grid of data stored as list of rows, restructure it to be stored as a list of columns (or vice-versa. same thing.)
  2. Imagine you have a grid of numbers printed on something rigid and clear like a piece of plexiglass. Using one hand, pick it up by pinching the top-left and bottom-right corners. Now, with your other hand, spin it 180 degrees so it’s facing away from you. (Ignore that the individual numbers within the grid are now mirrored and rotated 90 degrees.)

When you’re doing it with a grid stored as a list of lists, Python and Ruby call it zip() and it has a lot of uses.

For example, suppose you’re storing scores in a game and each player gets their own list.

>>> scores = [
...    [8.7, 5.8, 9.4, 7.4, 6.5, 6.5, 8.8, 8.9, 5.8, 8.9], # Dave
...    [6.8, 9.9, 7.2, 5.4, 7.9, 6.7, 9.7, 9.3, 8.5, 9.5], # Anne
...    [7.7, 6.6, 8.7, 6.4, 9.7, 5.9, 9.3, 7.0, 7.1, 9.6], # Ellen
...    [7.2, 8.9, 6.8, 7.8, 6.0, 5.4, 7.7, 6.1, 5.3, 5.2], # Mike

…and now you want them round-by-round. Do you loop through them manually? Nope. Just transpose.

>>> scores_by_round = zip(*scores)

>>> from pprint import pprint
>>> pprint(scores_by_round)
[(8.7, 6.8, 7.7, 7.2),
 (5.8, 9.9, 6.6, 8.9),
 (9.4, 7.2, 8.7, 6.8),
 (7.4, 5.4, 6.4, 7.8),
 (6.5, 7.9, 9.7, 6.0),
 (6.5, 6.7, 5.9, 5.4),
 (8.8, 9.7, 9.3, 7.7),
 (8.9, 9.3, 7.0, 6.1),
 (5.8, 8.5, 7.1, 5.3),
 (8.9, 9.5, 9.6, 5.2)]

Now Dave is column 1 and you can access the scores for round 1 as the first row. (Just keep in mind that it will truncate all of the sub-lists to the length of the shortest one unless you pad them out.)

This is also very useful for tabular display of numbers at the command-line. Just generate each column as a list and zip() them together before you print row-by-row.

Why Programmers Should Study Computer Science

When it all comes down to it, if you can Google for everything you need, why would you want to study Computer Science… especially if you want to write programs to solve real-world problems?

That’s what I used to think. The thing I didn’t realize was that, no matter how good you are, you can’t Google for things you never even imagined could exist. That’s what an education in computer science brings to a programmer. It expands your horizons and gives you new ways to look at what you already know.

(And, honestly, I think it may even be better to learn by doing first, so you can better understand the relevance and significance of what you’re learning when you go to school.)

Posted in Geek Stuff | 1 Comment

A Disingenuous Mistake in Dan Ariely’s Talk About Dishonesty

I ran across this post draft while clearing out old notes and, since I don’t think I’ve ever blogged about the instinctual underpinnings of “piracy” before, here you go…

A few days ago, I saw RSA Animate’s video for The (Honest) Truth About Dishonesty  by Dan Ariely. On the whole, it’s an interesting talk, as pretty much anything chosen for RSA Animate is… but there was one problem which I found myself dwelling on.

While Dan Ariely makes an excellent point about the importance of incorporating forgiveness into society to improve social behaviour, his argument is greatly crippled because one of his examples elicits dismissive behaviour far in excess of any benefit he may gain from using it. Specifically, his example of illegal music downloading as extreme rationalization.

Why does this cause his credibility to take such a hit among certain viewers? Because he gives no indication that he understands the deep psychological underpinnings of the distinction between eating and running and downloading a file.

For the vast majority of human existence, music was free. It was a flowing, living cultural artifact similar to gossip or telling jokes. Then, we gained the ability to record it and each of those wax cylinders or plastic discs took effort to make, so we charged for them… but going back to the other model was inevitable.

As soon as computers made it possible for us to copy files en masse at vanishingly small costs, a different set of instincts took over. Files are like jokes and recipes, not balls and ice-cream cones. People need to be taught to share a scarce item like a ball, but they laugh at you and then become outraged when they realize you’re serious if you tell them they can’t re-tell a joke without paying.

As human beings, we are terrible at fighting our own instincts. That’s why so many of us have trouble saving money or stopping eating or getting up the confidence to talk to a stranger we’ll probably never meet again. We’re still wired as tribal apes and we’re terrible at fighting those very same instincts that tell us to share culture like mad. (Speaking of which, borrow Mean Genes by Terry Burnham and Jay Phelan next time you stop by your local library.)

By dismissing this distinction, Mr. Ariely comes across as ignorant, which calls his position as an authority on other psychology-related matters into question… matters on which his argument depends.

Posted in Web Wandering & Opinion | Leave a comment

Emptying “Deleted” Files

A few days ago, I woke to find my home partition 100% full and programs erroring out because of it.

“No problem,” I thought and fired up ncdu Install via APT to figure out what had eaten up the 12GiB I’d had free the night before. (Nothing beats ncdu for efficient workflow though FileLight Install via APT is a good alternative if you’re willing to trade keyboard shortcuts for a GUI)

Nothing showed up so, on a hunch, I tried using lsof Install via APT to see if it was a deleted file being held in existence by an open file handle. Bingo!

…it was the ~/.xsession-errors that I’d deleted weeks ago, it was being held open by half the apps on my desktop (including my session manager), and I had in-progress tasks that I couldn’t interrupt to restart my session. Here’s where it got tricky. I had to somehow get rid of a file that was already “deleted” when I no longer had a name to reference it by.

Thankfully, after a fair bit of searching, I found a solution. The key lies in how, on Linux, you can access all open files via /proc if you know the process’s PID, even if they’ve been deleted. (It’s the second column in the lsof output. You’ll also need the file descriptor number, but you can trial-and-error that using something like less)

Once you’ve got that, you can use a root shell to truncate the file to a length of zero.

you@host:~# > /proc/<PID>/fd/<FD>

(Yes, that’s using a non-appending redirect without providing a command to redirect output from)

I hope this helps if you ever find yourself in a similar situation.

Posted in Geek Stuff | Leave a comment

A little tool for command-line playlist building

For the last few years, I’ve been amassing a collection of little scripts I use every day to build playlists, both for Audacious and for MPlayer.

About a week ago, I realized that they’d started to duplicate each others’ functionality and refactored them into a single script which has different default behaviours depending on what it’s called as (but you can also use command-line flags).

So far, here are the behaviours it implements based on what you call it as (either via MPRIS [1] [2] or using a command provided via --exec such as mplayer):

Add the given paths to the playlist.
Like aq but start the first one playing too.
Like aq but use locate -i to search for the first argument, filter for known media types and filter for the following arguments, then display a chooser.
Like laq but start the first one playing too.
Randomly select -n NUM songs (default: 10) from the paths provided (default: XDG_MUSIC_DIR) and add them to the playlist.
Like rap but start the first one playing too.

…and all of these are just aliases to options listed in --help.

Until two days ago, the chooser was a simple little thing where you were given a numbered list of filenames and you typed in a sequence of numbers, optionally including Python-style start:stop slice syntax.

Now, if you’ve got urwid installed, you get a nice ncurses-style pseudo-GUI, complete with mouse interaction… though the scroll wheel support is preliminary and I’m still trying to figure out how to set up Tab-based focus switching.

Here’s a screenshot:

I haven’t had time to fully bring the codebase up to spec, write the last few new features, and write a test suite for it, but it’s good enough for my day-to-day use so, if you want to give it a try, it’s on GitHub in ssokolow/profile as home/bin/lap. (It has its own GitHub repo now.)

The queue option in the chooser can be toggled via the Q key or Meta+Q and, once you’ve selected all the tracks you want using Spacebar or the mouse, press Enter to commit.

In case I ever move it to its own repo and forget to update the link, you can also grab the revision at the time of this posting.

Posted in Geek Stuff | 6 Comments