Category Archives: Uncategorized


I’ve finished porting a substantial chunk of (now completely) my friend Mars Saxman‘s Starfish—a C program for generating seamlessly tiled procedurally-generated wallpapers—into HTML5/JavaScript. You can try it out here, or there are some samples of some of the wallpaper tiles it has generated:

turvey-green-cream-dunes fuscia-avocado-storm regal-age blue-glisten

The original program has five different image-generating algorithms, that are chosen at random, coloried and layered one upon another; my current JavaScript port has only three of the original algorithms (one of them modified), but I’m already so pleased with the results I decided to post the program as it currently stands. I’ll probably get the remaining two image generators ported in the next week (Starfish’s C code is surprisingly easy to adapt into JavaScript). (StarfishJS now has all the layer-generators of the original. Some of them have been modified to my taste.)

If you want a little peak under the hood, you can see the individual image-generating algorithms at play: the three generators currently available are Coswave, Spinflake, Rangefrac, Flatwave, and Bubble.

The image generators all operate in monochrome values, and translated into color later. Some of the generated images aren’t displayed directly, but instead are used to hide/reveal pixels of other layers.

A units-of-measure implementation in JavaScript

I made something kinda interesting this week in JavaScript. It probably qualifies as “over-engineering”, but it was for my use, to meet my needs, and I had making it, and I’m having fun using it (so there! :-p).

It’s an implementation of measurable units of various types that I tend to use in my recent JavaScript-games-making excursions: such as seconds, milliseconds, pixels, radians, and frames. It lets you express that quantities are in rad/s, f/s, px/s^2 (for acceleration values), etc, and convert between them via multiplication and division (px/s divided by a time value results in px/s^2 (pixels-per-second-per-second), or if multiplied produces a value in number-of-pixels). It throws an error if you mix up which units you meant to use, which helps enforce the sanity of the arithmetic you’re performing.

Usage looks something like this:

The reason for this little library is that I’ve frequently run into problems thinking in the wrong units in my games. One variable might hold a length of time in seconds, another in milliseconds (from new Date()), and I’ll try to use them together, forgetting to convert between them. In MajicUnits, they’re all represented in seconds under the hood, and I can specify what unit I want when pulling them back out.

Or I often forget to scale a velocity or acceleration by the inter-frame time before adding to current state, resulting in a full second’s acceleration taking place in a single frame. Using MajicUnits, I’ll see an exception thrown if I forget to multiply by the frame delta.

It’s the sort of stupid error that led to NASA losing its $125 mil Mars orbiter because one group coded for metric units while another used imperial. If you have a language to express (and enforce!) unit types being used, you’ll catch the problem. Better, of course, if you can do it at compile-time, without requiring the offending code to run before you can catch it, but this is JavaScript, and writing my own to-JavaScript compiler that adds units of measure as strictly-enforced types at the language level would be really drastically over-engineering. :)

The library’s pretty crude at the moment: I’ve coded exactly as much as I need for the moment. There are places you could feed it bad input and break its assumptions. It automatically creates plural versions of your added units, adding ‘es’ if it ends in ‘s’, otherwise adding ‘s’. That obviously wouldn’t work with ‘activity’ (-> ‘activitys’), and can’t handle exceptions like ‘forum’ -> ‘fora’ or something. Rather than have an automatic pluralizer, I should be having the user explicitly specify when they register the unit… (All of the above is no longer accurate.)

A bigger problem is that when an exception is thrown I can’t currently just find what line of code went wrong. I throw an Error object (which includes file and line number info), but it points at the place inside the library that threw the exception, rather than at the failing invocation that caused the exception. Most implementations of Error provide some sort of stacktrace, so perhaps I can generate one and then turn it into a string that includes that stacktrace info… because when it comes out on my Firefox console I don’t get the stacktrace currently. Anyway.

You can see the current implementation (as of this writing) here (UPDATED), if you’re curious and/or masochistic (it does some magic with JS prototypes to do its job, and lacks any useful documentation/comments, though I plan to add some).

It’s written as one part of this game Gate Arena that I’ve been working on lately, but am rewriting to emphasize a more declarative style of expressing objects and logic and their relationships, to increase code reuse and the ease of adding new enemy types, etc. I plan to reuse the resulting engine for further games, increasing my flexibility for participation in game jams and whatnot.

Is the World Getting Better, or Worse?

A FaceBook friend posed this question. It was a good opportunity to give a reasonable summary of my current thoughts on the world, so I’m also placing my answer here. (Revised 23 January 2014)

Better. But I have to keep reminding myself that.

Everything looks pretty horrible at the moment, but I think it’s largely because, having made such great strides over the last few centuries, and even the last few decades, some of us are more keenly aware of how very far we have yet to go, than anyone was before. Continue reading

Quotes from Wise Man’s Fear

Patrick Rothfuss, author of The Name of the Wind, and its recently-released sequel, The Wise Man’s Fear, recently solicited people on his blog for their favorite quotes from The Wise Man’s Fear. I read it on my Kindle, and highlighted most of my favorite passages, so it wasn’t much work for me to come up with a list, which I posted there. Figured I might as well put it up here on my blog, too, while I’m at it.

As a pianist, I can empathize with, “This is why there are so few musicians. A lot of folks can sing or saw out a tune on a fiddle. A music box can play a song flawlessly, again and again. But knowing the notes isn’t enough. You have to know how to play them.”

Though I love to play, I rarely listen to live or recorded piano performances, because too many people are focused on being technically accurate rather than being emotive. One counter-example would be Rachmaninoff, but of course his recordings are old and low-quality. You can still hear the difference loud and clear, though.

“My rooms were so pleasant it took me almost a full day to realize how much I hated them.”

“I idly wondered how exactly one was supposed to lounge. I couldn’t remember ever doing it myself. After a moment’s consideration, I decided lounging was probably similar to relaxing, but with more money in your pocket.”

“[T]he only act of creation I accomplished was to magically transform nearly a gallon of coffee into marvelous, aromatic piss.”

“I briefly entertained the notion that I was insane and didn’t know it. Then I considered the possibility that I had always been insane, acknowledged it as more likely than the former, then pushed both thoughts from my mind.”

“Only a fool worries over what he can’t control.” (Like the musician quote, this one resonates closely with something I frequently think about.)

And, finally,

“‘But no. I won’t lock you up. You haven’t done anything less than proper.’
  “‘I broke that boy’s arm,’ I said.
  “‘Hmm,’ he rumbled darkly. ‘Forgot about that. He reached into his pocket and brought out ha’penny. He handed it to me. ‘Much obliged.’”

Final Fantasy 7 versus 8

Recently on Facebook, I mentioned downloading the Japanese version of Final Fantasy VIII, and a college friend of mine on Facebook retorted with a “too bad FF8 sucked” comment. Here was my reply, which I think pretty much sums of the core ideas of VII and VIII fairly well. Please note: I absolutely adore Final Fantasies VII, VIII and X. VII and VIII are tied in terms of my affection for them, though given the descriptions below, from a purely story-focused viewpoint, VIII wins hands down. I think I’d love VI, too, if I could ever play it all the way through. IX and XIII are good too, but not in the same league as the others.

Spoilers ahead. Duh. Continue reading

37th in Health Performance? has an article on how we get the fairly misleading number “37th in Health Performance” worldwide. A revealing point is that we’re actually ranked 15th overall, before per capita expense is taken into consideration (a problem current proposals seem unlikely to resolve).

This doesn’t mean there aren’t severe problems with the current healthcare system, though: the 2008 WHO report points out “persistent under-performance of the United States health sector across domains of health outcomes, quality, access, efficiency and equity”, citing
U.S. Health System Performance: A National Scorecard
, which notes that US placed 15th in fatalities that were “potentially preventable with timely, effective care”, and scored the nation 66/100. Ouch!


So, I’ve recently been toying with the idea of getting a smartphone. The iPhone had been looking good to me for a while, and especially the 3gs, but then I hadn’t been looking much at what else is out there.

Looking at the iPhone, it’s probably one of the most fluid and natural devices from a user-interface perspective, and especially as an MP3 player compared to other MP3 players (besides, of course, the iPod Touch, which is just an iPhone without the phone). Targeted apps for Facebook, WordPress, Amazon, Pandora? Love it! Best of all, I qualify for an upgrade to the 3g for $50 if I renew my contract for two years.

And then the 3gs with its better performance, video capabilities, and a camera with a tap-to-focus feature! And, yeah, the compass and voice-activation features, but I’m not nearly so interested in those. That being the case, the fact that it’ll cost me $150 more to upgrade put it just out of my consideration. Even if it plays Katamari Damacy (I’m told it’s not worth trying on the 3g).

But then, I’m not jazzed that I’d have to use iTunes whenever I wanted to interface it with my computer. I don’t have a Mac, and I don’t enjoy using Windows. All my MP3s are on my Ubuntu disk, and so I’d have to transfer them all to a FAT32 disk and use that as my main base of MP3-playing operations. And either boot into Windows or fire up a larger-than-I’d-like Windows VM just to talk to the iPhone. Not cool.

And, of course, not having a Mac means I can’t write software for it, but have to make do with rigging up a website (and hoping I’ve got connectivity) to add customization to the thing. And I can’t even easily load it up with PDFs or offline-stored web content or what have you.

But of course, all third party apps these days will have an iPhone version, and that’s support I can rely on (until my version of iPhone becomes too obsolete, anyway).

So I looked at some alternatives: Google Android-based phones. The great thing about these is they have many, if not all, of the apps I really care about. Obviously all the Google-related ones, a web browser, GMail, Google Maps; and also at least Facebook and Pandora. And the best part is, it’s emminently hackable. I can access it like a hard drive, and load whatever software I want—which I can write in Java on my Ubuntu laptop, and test in their Java-based Android emulator.

The problem with these phones, though, is that the only Android-based phones currently available don’t work with AT&T (and by “work”, I of course mean that they can use AT&T’s 3g network, and not just the standard cell data service). It’s expensive to switch, and on top of that the phones themselves are more expensive, even with the contract.

A coworker pointed out the new, Linux-and-Gnome-based Maemo OS, which is the sexiest “mobile computing” OS I’ve ever seen. And the Nokia N900, which is apparently releasing next month, is the most powerful smartphone/mobile computer I’ve seen yet; and of course, it’s also
completely hackable.

However, the price tag is steep. $800 for a phone, when my laptop (with which I’m perfectly pleased) cost me $350 new (yes, I’m cheap, but my needs are low), is… well, it’s a lot.

And, too, while I’m at work all day, I have a wifi connection, and my laptop. When I’m home, which is the vast majority of the rest of the time, I have a wifi connection, and my laptop. The idea of getting a smartphone would be to cover the other, what, one or two percent of my time when I’m not near wifi. To cover me when I’m on the train to work, or in the waiting room. Given that I pay close to $30 a month for my connection at home, paying an additional $30 a month to cover the gaps just feels wrong, if I can avoid it.

Anyway, during all this, I’d also been eyeing Amazon’s 2nd-generation Kindle e-book reading device. It’s not a smartphone, obviously, or any kind of phone, and while it does boast internet connectivity, it’s not a “mobile computer” by any stretch of the imagination, and my interest in it had been in its excellent display, and of course its usefulness in consolidating my library of books-to-read in one, very small, very slim, very readable device.

I do a lot of reading, and I typically buy several books on Amazon every month. I got to check out a friend’s Kindle 2, and was amazed at how close it was to reading off a piece of paper. The resolution, combined with the set of grays available, is good enough that you don’t see the pixels; it looks like printed words. It’s “e-Ink”, not LCD, and it looks terrific even when you’re reading in direct, bright sunlight. And it’s tied directly via free wireless network to Amazon, which is the store I’m familiar with and use for most of my non-book purchases as well. After seeing it live, and knowing the price had dropped into the ballpark of “reasonable”, at $260, I was having a hard time convincing myself I didn’t absolutely need one.

But here’s the thing. As I said, the Kindle is connected to a free wireless network; in fact, it uses Sprint’s 3g network. But it’s not just usable for getting to Amazon’s Kindle store: the Kindle 2 includes a web browser, too! It’s not much of a web browser, to be sure: it’s roughly as powerful as the text-based, built-in browsers for non-smartphones like my Motorola RAZR. But it can handle JavaScript (once you enable it), and… it’s free. Free Internet access. My phone might have almost as good a browser, but without a data plan I have to pay a buck to download 100k of data, and an unlimited plan costs (as I said) around $30, which is a major reason why I don’t use that to cover my “one percent” time. Plus, my cell phone doesn’t do 3g, either.

But, with Kindle’s browser, I’ll be able to see Facebook updates (and write my own), manage my Netflix account, read blogs (it’s especially good for that task), and read WikiPedia (Kindle has direct integration for searching WikiPedia quickly, without having to first open up the browser first). Apparently people can even get their GMail on.

So why get a smartphone? My Kindle’s on its way now! :)

The only thing that I really dislike about the Kindle, is its lack of native PDF support. You can have PDF files converted to a format that Kindle can use, but it’s pretty much just the text; it won’t keep the fonts and layout, and may not keep all the images. There are techniques to get around that—such as converting the PDF to a series of image files, and then sending that to be converted to Kindle format—but of course such tricks have definite shortcomings. The larger, more expensive Kindle DX—which has a page-sized view, and so is better suited to viewing the PDFs anyway—has native PDF support, but it’s too bulky to be practical for my needs, and too expensive ($500). Sony’s e-book devices have native PDF support; but in other ways they don’t hold up quite so well to the Kindle; for me, at least. Their devices are very similar to Amazon’s, but they are (at this moment) more expensive, and lack the internet access that makes the Kindle so attractive. In fact, in the currently available models (a new one will be remedying this shortly), you can’t even access their store using the device; you have to download it to your computer first, and then transfer—and several reviews I’ve read complain about serious quality issues in the desktop software. Upon finishing the first book in a new series, it will be very convenient to be able to immediately just start reading the second, without even having to wait for it to ship (or wait until I get home to my desktop to purchase it).

13-Year-Old Girl Strip-Searched on Suspicion of Possessing Prescription-Strength Ibuprofen

Here it is. Found via Slashdot. I’m simply dumbstruck.

13 years old. Strip-searched. Ibu-friggin’-profen.

I don’t care that they have a zero-tolerance drug policy at the school, if all you suspect (incorrectly, as it turned out…) is ibuprofen, how is a strip-search, by any conceivable stretch of the imagination, warranted?

(The story itself is not new; the actual news is that it will be heard by the Supreme Court. The incident itself took place 6 years ago, and the girl in question is now 19. But hell, it’s the first I’d heard of it…)