Wednesday, October 27, 2010

The I Can't Take It Anymore Diet

Several years ago I was diagnosed with severe sleep apnea with a minimum blood oxygen saturation of around 70% which is to say, "you're dying because your brain is starving." I was placed on a CPAP machine and was immediately relieved of almost all symptoms. Problem solved, right? Well, no.

Life on a CPAP machine isn't fun. You have a bulky thing that you have to carry around anywhere you intend to sleep and anyone who intends to sleep with you has to deal with your having medical equipment strapped to your face and making airflow noises all night long. Mind you, it's much quieter than most apnea sufferers themselves, and far less distressing to hear than a pause in breathing followed by a loud snoring, choking intake of breath, but it's not exactly sexy.

Those were just cosmetic/lifestyle issues though, and I could have lived with that. The real problem was that I found the thing painful to wear and while it gave me a better night's sleep, it also caused me to get less of it, due to the difficulty of falling asleep and plenty of events where I would wake up with it pulled partially off.

So, I decided to give it up. That's not a small decision. I essentially decided to risk injury to my brain and/or death, so I needed a plan. Most apnea sufferers, myself included, have their breathing problems as a result of their weight. Over a certain, individual-specific weight threshold, your airway just doesn't work the way it was designed to. In my case, I was 265 lbs. and the threshold was about 230 lbs.

This made a diet a fairly obvious solution. (click the title for the rest of the story)

Wednesday, October 13, 2010

Something new every day: Bourne Shell variables

I've worked with the Unix Operating System and its variants since the late 1980s. I've worked with the Bourne Again Shell (bash) since the early 1990s. And yet today I learned something new about variable expansion. In the startup scripts for a source code indexing system called OpenGrok, I found this gem:
somecommand ${PROG:+-c} ${PROG}
Now, I know that ${FOO-bar} will be replaced with the value of $FOO if it is currently set or "bar" if it's not. That much I learned many years ago, but this usage of "+" was new to me. After some testing, I found that "+" substitutes the following text if and only if the variable is set, otherwise it substitutes nothing. Thus if $PROG were set to "foo", the above text would execute:
somecommand -c foo
But if $PROG were not set, then somecommand would be run with no arguments at all. Very slick!

How I managed to go over 20 years without learning that, I'm unsure (then again, perhaps I've learned and forgotten it...)

Tuesday, October 12, 2010

A Google App Engine failure

Long ago, I wrote a Perl script that generates random names for my roleplaying games. It's a simple thing, but it can take input lists from any language and spit out similar-sounding made-up names. It's a powerful, but simple tool, and it seemed a natural fit for my first exploration of Google App Engine. Sadly, it didn't work out that way, and I thought it might serve as a useful caution to others who might plan the same sort of work.

The fundamental problem is that my app is IO-hungry. It reads in the entire source list every time someone asks for a made-up word, crunches it down into first-parts, mid-parts and end-parts (2-3 letter segments which are rooted at the beginning or end of the word or neither). We then sort the lists of parts according to frequency of occurrence and perform a weighted, random pick of a first part, then each subsequent part is chosen in the same way, but from a subset of all of the parts, which overlaps the previous segment. The combination of weighted choice and overlapping leads to words which tend to be pronounceable in the source language of the input list.

This process of reading and processing all of the words every time wasn't something I was going to be able to do in Google App Engine, however, since costs are associated with resources consumption. So, I set out to store the pre-digested versions of the input lists as sorted word-segments in the Google App Engine datastore. This is where my problems began. While it's entirely possible to store the data this way, what I found was that my need to access so many records from the database as I performed my random walk down the lists of word-parts left GAA gasping for breath. In practical terms, I'd created the world's slowest tool for producing babble. Of this, I'm sure my mother feels proud.

Frankly, I'm not sure what I can do about this. GAA just doesn't seem to have been designed for this sort of thing. A shame, really. Of course, I could pre-compute a queue of results for each source namelist and keep re-populating them with a periodic job, but that really seems like a cheesy way to solve a problem that takes a few seconds for my original Perl script.

How not to open source a roleplaying game

After the phenomenal success of open source software development in the 1990s, someone at Wizards of the Coast decided to try to follow this model for their roleplaying game, Dungeons & Dragons, purchased in 1997 when they acquired TSR. Specifically, they decided to publish a cut-down set of rules called the SRD, which represented the core of what it takes to publish a Dungeons & Dragons-compatible game. The idea at the time, which worked well, was to encourage what marketing people call an "ecosystem" of publishers who made everything from full roleplaying game systems to source books for D&D.

All of this made sense, but Wizards had opened the genie's bottle, and there was no putting it back. As long as they continued to encourage their new ecosystem, they were assured of their place as king of the mountain. However, in 2008, they announced that they would end support for D&D version 3.5 and begin publishing version 4.0. This new version would not be available to third party publishers for creating their own games, at least not at first (they have since published a new, more restrictive set of rules called the GSL).

At the same time, a small publisher named Paizo had been licensed the rights to publish Dragon and Dungeon magazines. These two magazines were in decline at the time, but Paizo manged gain the enthusiasm of the roleplaying community by dipping into the well of nostalgia that many players had for the game. The printed updates to classic adventures in Dungeon and breathed new life into old stapes of Dragon such as the "Ecology of the..." series. They also fanned the flame of the original Dungeons & Dragons setting: Greyhawk. Their most impressive accomplishment was the enthusiasm generated by their "Adventure Paths." These 12-issue serial adventures were published in Dungeon magazine and the first was then collected as a hardcover book. Overall Paizo did quite a bit of cheerleading for Wizards and in 2007 they received their reward: notice that their licenses to all Dungeons & Dragons products were being revoked so that Wizards could develop a stand-alone Web site to replace the print magazines in coordination with the launch of the 4.0 edition.

Of course, the consensus at the time was that Paizo was doomed, but Wizards' Open Gaming License for the 3.5 edition was their way out. They immediately converted all existing Dungeon and Dragon subscribers over to new products based on the Open Gaming License. In less time than most publishers take to decide to take on a project, Paizo had their own campaign setting for D&D 3.5, published under the OGL along with a new adventure path, Rise of the Runelords. However, the OGL also allowed for full 3.5-compatible systems, and that was Paizo's next step. Over the course of the next two adventure paths that they published, Paizo continued to work on their variant system: the Pathfinder RPG.

Today, with several adventure paths published under their new system and a constant stream of supplement books published for their world of Golarion, one has to wonder if Wizards of the Coast is feeling burned. The popularity of the Pathfinder RPG hasn't reached the level of D&D, but it continues to build a dedicated base of adherents and is frequently referred to as "D&D 3.75."

So should Wizards not have created their "ecosystem?" Of course they should, it was a shot in the arm to what many declared a dead product. What they should not have done is assume that because they wanted to move on with a new edition that the industry would either follow or contentedly watch their businesses crumble. Wizards should have built support for 4.0 among their publishers and then eased into it without yanking the rug out from under Paizo. This would have resulted, at the very least, in reducing the number of long-term players that walked away from their version of the game.

Friday, October 8, 2010

Google's WEBP image format and World of Warcraft

I got my hands on Google's new image file format today and started testing it on some images I had lying around. I specifically wanted to see how it did with bad JPEGs of rendered sceenes. Hard edges and re-processed artifacts are something that JPEG traditionally handles very poorly, so there's some real, practical benefit to having a new format that can do these things well.

I took 9.5MB of input screenshots from my library and got 3.9MB of images out at 75% quality. Now, 75% in JPEG is pretty poor, but these don't look all that bad at all. At least not worse overall than the input (WoW compresses its screenshots pretty heavily).

More interestingly, however, here are some visual comparisons. All of these images are PNG format, converted either from the original JPEG input or from the converted WEBP at the given resolution.

Original screenshot (cropped region saved as PNG from original JPEG). Full file size: 541KB.
This is the 75% quality version of the same image as WEBP. Full file size: 257KB.
And this is the same WEBP conversion again, this time at 85%. Full file size: 347KB.
A second original image, again cropped and saved as PNG from a JPEG original screenshot. Full file size: 189KB. (re-compressed at 75% quality as JPEG, it was 132KB).
A 75% quality WEBP conversion. Full file size: 72KB.
An 85% quality WEBP conversion. Full file size: 109KB.

The lessons I learned from this are:
  • WEBP does have some visual loss, even at 85% when it comes to highly saturated color, especially red.
  • The file size drop is quite dramatic, even over a re-compressed JPEG at a lower quality.
  • Overall, the look of the WEBP files is impressively smooth.
  • I noticed (not in the samples, above) that splotchy regions of similar color, but varying value were sometimes flattened to the point that information was clearly being thrown away. At 75% quality this was a substantial change, but at 85% quality, it was hardly noticeable.
I really look forward to this format being available in the majority of browsers, so I can safely start using it!

Wednesday, October 6, 2010

Quatermass poster

While I was sick, recently, I found myself watching the 1979 British TV series, "Quatermass," which is a 4-episode mini-series that follows the exploits of an old 1950s and 1960s character that was a sort of prototype for Doctor Who. This series follows him through a new adventure where young people are either becoming ultra-violent (resulting in a breakdown of the inner-cities all over the world) or they're leaving the cities to wander under the name, "Planet People." These Planet People are basically hippies who are convinced that they'll be taken up to another, unspoiled planet by benevolent aliens. That's the ground-work that the first two episodes lay out. Oddly, I loved the story, but hated the series. I found it slow and exceedingly dated. The cold war tension is a bit overwrought (but then in 1979 that wasn't surprising) and the females in the show all have one of two reactions to the hippies: they fall in line, often without on-screen comment, or they go into hysterics. There's only one female character who responds sanely the the events and even she is clearly not very stable. Sad, really.

The most damning point, though, is that the narrative never really takes over. We're never quite sure why the Americans are deferring to our hero, nor why he's the only one who can think of the ultimate solution, which isn't, in fact, very clever. It's not clear why the hippies scare people so badly, nor why it takes quite so long to come to some of the conclusions that people reach. In effect, the series is a long string of events, some of which are painfully boring, and many of which do not appear to affect the overall plot (especially when so many characters that are established with painful deliberation are killed off-screen).

Anyway, as a 2-hour movie, I think I'd enjoy a modern re-make. As 4, hour-long episodes, it was torturous. But the easily recognized professor and the oft-repeated tag-line of the hippies, "soon," gave me the idea for the poster below (click the title to go on if you're seeing this on the front-page), which I'm threatening to turn into a button and wear to conventions. Enjoy!

Friday, October 1, 2010

The Great Humor Friendly Spam Is Translate!

I'm having far too much fun reading my spam box via Google Translate. If you haven't tried this game (which I'm called "The Great Humor Friendly Spam Is Translate!"), then you really need to give it a shot. In Gmail, click on your spam folder and then click on any message whose subject is in another language. At the top of the message, you should see a "Translate" link above the body. Click the translate link and read until you stop being able to breathe.

For example, here are some gems from my inbox:

From the Chinese:
why sales staff who are always working attitude, do not want more input?
From a Russian message describing the generic plot of all disaster movies:
It all begins with small problems, then all these problems
noticeable on the Congress is going to scientists and government
and concludes that the planet Earth (town, country, continent)
remain there for long, and starts fighting with the elements
successful or not.
From a Japanese site that appears to be offering dating and/or romantic advice:
I send this email to members of the audience to applicants capped.
Cross your fingers unsubscribe, thank you from the URL at the end
A Spanish ad for spam-based marketing suggests this nugget of wisdom:
GHOSTS ARE NOT ALWAYS GIVE YOU SUPPORT
This came as a shock to me, but I'm slowly coming to terms with the idea that I need to approach the living for my tech support needs.