Arrow Endianness: How GNOME got sorting backwards

Conventions are important, even when it seems like it doesn’t matter one way or the other. Just look at all the people who complain about the nerve of Steve Jobs to place the close-window button on the left.

There’s no reason why the left side is better than the right side. Convention, however, says that you must choose one way and live with it, or else you’ll be forever forced to constantly convert between left-handed and right-handed traditions. Just ask anyone who’s ever had to write low-level networking code. When sending an integer, it doesn’t matter whether the big end or little end goes first, but if you don’t agree with the other party, your message will come out garbled.

So imagine my discomfort when I have to sort files in Nautilus or sort processes in System Monitor.

(more…)

Venturer HPS9308 GPS navigation system

If you ever want to modify or upgrade your Venturer HPS9308 GPS navigation system, you can easily do so by modifying or replacing the software on the SD Card. However, there are some settings that aren’t obvious and aren’t directly modifiable, so you have to follow a couple things.

It seems like the default Venturer shell, when you choose “Navigation”, looks for SDCard\MobileNavigator\MobileNavigator.exe and runs it. Thus, if you want to replace the software that gets run, you should place the executable at that path. In addition, the GPS device is on port 1 with a baud rate of 4800, at least according to a working config file I found. For reference, that was in SDCard\MobileNavigator\sys.txt with the section
[gps]
port="1"
baud="4800"

Gaming hasn’t changed

This is about an essay I wrote a couple years back about gaming, under the theme of work and play, and it’s about how video games are just a subset of gaming, and how they conceptually fit within philosophical frameworks established in the mid-20th century. Among other things, it goes into why World of Warcraft directly maps onto the four categories of games set forth by Roger Caillois in 1958: Agôn, alea, mimicry, and ilinx, which could be described as competition, chance, role-playing, and thrill.

It’s not a perfect paper and gamers might roll their eyes at reading a description of what an MMO is. There are surely some things that I would revise if I had the chance, but the version presented here is untouched from my original, save for formatting. It’s not a journal paper nor is it a book review, but I hope that some find it interesting. There is a lot that has been written on this subject, and there is much more that could be written. This is just a piece towards the theory that the core components of a fun game are readily identifiable and, with that knowledge, anybody can assemble a fun game.

Some quotes from the paper
Profit Versus Play: Business and Gaming in MMOs (application/pdf, 87 KB):

On whether MMOs qualify as games in a traditional sense:

David Golumbia, who is incidentally among such de-
tractors, could not examine this issue without first defin-
ing the French word jeu in the context of Jacques Der-
rida’s deconstruction of “play.” Fundamentally, Golumbia
establishes jeu as both “play” and “games” (and not con-
trivances like “freeplay”) and this paper will assume the
same: that “games” and “play” are merely different parts
of speech referring to the same concept without carry-
ing any intrinsic differences. And, as we’ll see, MMOs
like Ultima Online and EverQuest are certainly games in
the traditional sense as they fit like clockwork into Roger
Caillois’ categorization of games.

On the never-perfect divide between game and real:

This “contagion of reality” that plagues MMOs has
been and will continue to be money. “The minute you
hardwire constraints into a virtual world, an economy
emerges,” explained Castronova to Wired. “One-trillionth
of a second later, that economy starts interacting with
ours.”

And on harnessing Nietzschean behaviors:

It’s this type of accumulating points system that
Golumbia described as an exploitation of Machtelgust, or
the “lust for power” from Nietzsche’s writings. Golumbia
colored computer games in general as being deceptively
simplistic and degenerate. A single-player first-person
shooter (FPS) like the classic sci-fi game Half-life, while
appearing to offer freedom and a story to the player, is re-
ally a very rigid, pre-scripted experience of just shooting
anything that moves with a superficial and shallow plot
tacked on. Likewise, he wrote, MMORPGs are mostly
single-player experiences, despite the name, filled with
repetitive quests in a “surprisingly rigid, uncompromis-
ing, and even authoritarian” world.

HTML <legend> tag is broken in WebKit

All I wanted was for a legend tag to fill up its box horizontally, much like an h1 or div does by default. Apparently, legend tags are special and don’t follow the same rules as other tags in WebKit, and what I wanted to do was simply impossible. Since I wasn’t the one to choose to use the legend tag (it’s a CakePHP default), I simply replaced all instances of it with <div class="legend"> and went on with life.

Here’s an example in which the same display: block style is applied to an h3, a span, and a legend tag, each sitting in identical divs.

Gecko renders the legend tag as a block element correctly, and it fills up the div.

WebKit does something special about the width, and so it fails to fill up the div.

Given WebKit’s lineage, it’s not surprising that KHTML does even worse at the exercise.

Try it for yourself: legend width js-fiddle. Other people have had similar issues as well: StackOverflow: Cannot add margin to Legend element in Safari & Chrome.

Dial up

Parallel Map

… in JavaScript.

A number of events and coincidences have reminded me about functional programming and parallelism lately, especially an example I saw of Clojure’s pmap:

pmap
function
Usage: (pmap f coll)
       (pmap f coll & colls)

Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the consumption, but doesn’t realize the entire result unless required. Only useful for computationally intensive functions where the time of f dominates the coordination overhead.

I’ve heard, for a long time, the argument that functional programming offers a programming style better suited for parallelism. After all, MapReduce is perhaps the ultimate form of famous-brand massive parallelization. In a typical map operation, you don’t have to worry so much about all the nasty little parallelism problems since your code, by convention, is side-effect free.

parallelmap

So, as my contribution to the world of JavaScript hackery, here’s parallel map in JavaScript:

parallelmap(proc, tasks, callback)

where proc is a function that takes one argument, tasks is an array of things, and callback is a function that will be called with the results when processing has completed. The computation will occur in parallel and show dramatic speedups on processing-intensive tasks.

(more…)

Ants on the brain

Google AI Challenge—Week 2:

I think my ants are losing faith in me, as I haven’t uploaded a new version of my AI to the official server for a couple days now. New things are still in the pipeline, but I’ve lost my last 3 matches (though my opponents were ranked higher than me and probably deserve it too).

IU now has more than 5 people with active submissions, but the upcoming CS Club Hackathon will change that! I’m excited to co-organize the hackathon, which will consist of an all-day coding party dedicated to writing an ants AI. Dustin and I, as organizers, will be running matches and generally running things, and since we already have entries in the competition, we’ll be helping other aspiring antlords to get their own AI up and running.

Thanks to the school, we should have a competition server up and running soon, as opposed to running an unofficial TCP server. Prizes will also be offered to our hackathon winners, so I hope to see some creative strategies. I expect that there will be somebody wanting to use Haskell or JavaScript, but we’ll see how far they get.

Of course, I’ve been thinking about people’s choices of languages in the competition. The top-ranking bots are mostly “industry” languages like C++, Java, and Python, but there are a couple bots written in Go, OCaml, and Pascal up there. There’s definitely a trade-off between compiled languages like C and C++ and higher-level languages like Java and Python. In this competition, time is becoming a sticking point on many bots—you simply can’t run A* on as many ants in Java as you can in C. On the other hand, the time I’ve spent debugging memory errors could have probably been spent on improving my AI strategies.

Language designers are working to pull together this gap between productivity and speed: Google’s Go combines garbage collection and better concurrency models with the spirit of C, and Rust is another interesting but young language out of Mozilla. In the meantime, Java bot writers in the competition are just making do with timers to keep track of when to stop their calculations.

Some interesting sorting algorithms

Walking back from Falafels today with CS majors, we somehow began discussing strange sorting algorithms.

A good sort to know (not really) is bead sort. Imagine you have a bunch of beads on rods, like an abacus, and cross-wise they represent numbers. If you simply tilt the whole thing over, then gravity will let them all fall and they’ll sort themselves. For example, we have the numbers 3, 2, 4, and 2 read horizontally. When they fall, we get 2, 2, 3, 4. Easy!

Another sort, “random sort,” “shuffle sort,” or the more common name “bogosort” was suggested as a good example of an O(∞) algorithm. But, as people have pointed out, if the quantum many-worlds theory holds, then you could sort in O(n) time: Use true quantum randomness to randomize the list and if the list is not sorted, then destroy the universe. The only universe that remains will have a sorted list.

Finally, Graham showed me the wonders of sleep sort. I’ll just leave the bash source code here:

seq="1 9 2 3 5 6 4 7"
for i in $seq; do
    (sleep $i;echo $i)&false;
done

git-dude, meet hg-dude

Git-dude is a cool little thing. Given a directory of git repos, it continually fetches updates and displays a popup if you get any new commits. When I first saw it on Google Plus, somebody inexplicably commented, “This is a neat thing and I dont [sic] think there is a mercurial equivalent.”

Given that Git and Mercurial are isometric for most intents and purposes, this baffled me. Clearly, this could not be some special Git-exclusive functionality. I dug into the git-dude source code and found out it was little more than a single bash script that pipes some git commands through sed and awk.

A few minutes later, I made hg-dude, which offers similar functionality for Mercurial. There’s a couple things that aren’t supported. Git-dude offered special notifications for tags and branches, and I didn’t translate them to Mercurial because the concepts, even though they have similar names, don’t quite match up. Regardless, it is still as useful as git-dude for commit notifications, which I expect is the primary usage.

Some may notice the irony of hosting a Mercurial tool on Github, but that was the easiest way to preserve its history from its git-dude days. Bitbucket fans can check out hg-dude’s Bitbucket repo.

Get hg-dude at Github or Bitbucket.

Why deterministic encryption algorithms do not satisfy multiple-message

Let’s say you have some private-key (symmetric-key) encryption scheme. It takes a key and a message, and outputs a ciphertext. Nobody without the key can decrypt the message using the decrypter. Is that secure? Not if it’s deterministic.

(more…)