Archives for the ‘Programming’ Category

PHP’s wonderful pseudo-functions

There is a pseudo-function in PHP called empty, that tells you whether a variable is “empty” for someone’s definition of empty. The empty string, zero, null, and undefined variables are all considered to be empty. [php] <?php $x = null; echo empty($x); // prints "1" echo empty($nothere); // prints "1" [/php] Well, how did they […]

Getting the Sparkfun EL Escudo to work

I’m really disappointed in Sparkfun. I recently purchased the EL Escudo shield for driving EL wire with a microcontroller, and woe be upon anybody who doesn’t do hours and hours of Internet research before plugging the thing in. There were 3 years of questions from poor customers with only a few answers, and the few […]

Ubuntu works great with the MSP430 Launchpad

I got my MSP430 TI Launchpad more than a year ago simply because of the price. It was (and still is) $4.30 (with free shipping!) for a development board, two MSP430 microcontrollers, external crystal, and USB cable. Unfortunately, Windows was the only supported OS at launch time with a couple proprietary bundled IDEs. It still […]

Using the Chez Scheme debugger

Achtung! Chez Scheme and Petite Chez Scheme do not give the same debugging information. Petite Chez Scheme is often much less helpful than Chez Scheme, and is probably half the reason why nobody actually tries debugging programs in Chez Scheme. Here’s a sample, buggy program: [scheme](define myreverse (lambda (ls) (if (null? ls) ‘() (append (myreverse […]

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 […]

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 […]

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 […]

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 […]

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 […]

iOS keycodes in Javascript

Here are the iOS keycodes for the keyDown and keyPress events in JavaScript as generated by an iPad running iOS 4.3.3: