Thursday, September 2, 2010

Enjoy the Silence. Because I'm a Creep.

Following up on the abrupt non-sequitur that derailed my almost-triumphant return to the blogosphere...

A few months ago, my wife asked me if I liked choral music (which would have been an odd question if her sister weren't a member of the 18th Street Singers in Washington, DC). I gave some characteristically cryptic answer along the lines of "Eh, only if it's nifty," upon which I was asked to elaborate. Stumbling and stammering for specific examples (as usual), I tried to explain that, while old-school church hymns, regurgitated Baroque compositions, and so forth were not at all interesting to me, I am a fan of (a) the sparse, creative, and/or unexpected use of a choral ensemble, and (b) choral arrangements of music that you wouldn't ever expect to be sung by a choir. (Glee almost qualifies as the latter, but it's technically a capella.)

"Oh sure?" said the wife, who then waved a magic wand and a bunch of assorted baked goods spontaneously materialize. I had failed to explain myself.

Well, as of a few days ago, a seismic example of case (b) smacked me in the face when I saw the trailer for The Social Network that I mentioned a couple of posts ago, which is set to a choral arrangement of Radiohead's "Creep" performed by the Scala & Kolacny Brothers choir. Although "Creep" has never really been my favorite Radiohead song, the arrangement completely floored me, and I stayed awake for another two or three hours listening to this all-female Belgian group. It turns out that they have several arrangements of 80s/90s/00s pop, some of which are complete earworms, and others of which are just kinda bleh. You can find many of their album recordings and performances on Youtube. (And oh yes, you can buy their stuff on iTunes.)

These five in particular I can't get out of my head:
Less catchy, but interesting in unexpected ways:
Anyway, this is why I haven't downloaded the latest Arcade Fire album yet... although I have to say, their interactive music video is an mesmerizing experience if you're rocking an HTML5-compatible browser (e.g. Chrome).

Footnote: For those of you who are curious, a prime example of case (a) occurred way back in 1997 with Final Fantasy VII. Imagine: there you are, sitting in front of your TV with your brand-new Sony PlayStation (the original) -- having slogged through 40-50 hours of one of the most convoluted and ambiguous video game plots of all time (think Lost), you have reached the final battle against a villain who's planning to crash a meteor into the planet so that he can become a god. (See previous comments regarding plot.) Just when you think you've defeated him, you suddenly find yourself in the middle of a ring of swirling clouds, and your nemesis descends from above in the form of an angel with a single bat-wing in place of his right hand, glaring at you and ready to fight some more. A new battle song starts playing, and after about a minute, as you're hacking and slashing and struggling to stay alive, you start to hear an ominous, disembodied choir chanting something in Latin -- holy shit, WTF is that?!

You have to understand: in 1997, video games didn't talk, not to mention sing, or sing in Latin. Pulling off a stunt like this, at the moment of highest tension, was a game-changer, for both the player and the industry. It also made the bad guy's mega-attack that destroys the entire solar system -- a two-minute animated sequence that is easily the most ridiculous move in all of video game history -- seem frivolous by comparison.

(Random-coincidence trivia: the name of this battle song, "One-Winged Angel," is also the name of a Scala & Kolacny album.)

Anyway, that's an example. And it appears that I have once again derailed myself.

Monday, August 30, 2010

Educated-but-uninformed Letters to Congress, Part I

I don't follow politics as closely as I used to, and there's a reason for it -- it's excruciatingly exhausting and endlessly frustrating. Thanks to the 24-second news cycle, an explosion of cable news channels that don't actually report news (and CNN's decision to follow suit), the rise of social media that no one quite knows how to utilize, and so on, and so forth, our legislative process has essentially degenerated into a schoolyard game of tag-dodgeball-foursquare, in which there are no one-handers, gobstoppers or fishies, and tagbacks are only allowed on Thursdays unless the ball hits you in the face while chewing on Red Hots, in which case you can give cooties to up to five members of the opposing team. (Yes, Teacher is present to preserve the general integrity of the underlying system, but inasmuch as s/he doesn't understand the rules, she is unable to police the game as it unfolds.)

As an adult who has reached the Age of No Credibility within the past year, it is no longer an effective use of my time to track every drop of sulfur that spews forth from the bottomless fountain of vagaries, platitudes, scandals, and hypocrisies that fill the 3000-bazillahertz of "news" spectrum everyday. Rather, I just try to stay informed on the issues that are going to matter in the long-run -- e.g. energy policy, caring for the environment, fixing Social Security/Medicare, unemployment/job growth (and yes, foreign policy, but it often makes my head hurt if it doesn't put me to sleep) -- and periodically check in on the status of how these issues are being addressed. Or not, as the case has increasingly -- maddeningly -- tended to be of late.

Do I know what it's like to actually work in Washington? Do I know what kind of micro-scale wheeling and dealing, arm-twisting, and general slithering actually needs to happen in order to pass legislation? Do I have any understanding of congressional hierarchy and the arcane procedural rules that govern both bodies? Absolutely not. But I'd like to think that I'm a fairly well-educated, intelligent person, who, not knowing any better about the nuts and bolts of what goes on inside the beltway, could make some helpful suggestions. (I realize that Obama probably felt the same way before we elected him to be eternally suffocated by pollsters and political consultants.)

And so, without further ado, here is the first installment.

Dear Members of Congress:

Please stop screwing around with Roger Clemens. Most baseball fans have long presumed his guilt with regard to the use of performance-enhancing drugs, and could care less whether his self-delusional lies constituted a felony deserving of 18 months imprisonment and a fine that amounts to 0.000011% of our nation's GDP. There are more pressing issues for you to address. Speaking of which (and of our GDP):

It's the economy, stupid.

People are not fundamentally unhappy because we're becoming a socialist state, or paying historically-low taxes, or continuing to take a self-contradictory attitude toward immigrants, or adding marginal amounts to record paper-money deficits that have been with us since the the early aughts. They're unhappy because they don't have a job, because their 401(k)'s (if they were lucky enough to have one) have been cut in half, and because it seems like everyone else is getting bailed out while they're being told to be frugal. Ask yourself: how many people in Middle America do you think would rather block the construction of a mosque at Ground Zero (conveniently disregarding the fact that there are already two within four blocks) than feel secure about their employment situation and financial well-being?

To Republicans, in particular: stop fillibustering everything. Not only is this a ludicrous waste of your own time, but wasn't it you guys who kept clamoring for a simple up-or-down vote on the Bush tax cuts (which, by the way, added $1 trillion to our national debt) and hinted at the "nuclear option" of eliminating the fillibuster itself? Look, it's pretty simple: if you were against the fillibuster then, certainly you must still be against it now (because you established in 2004 that changing your mind on an issue is unacceptable), so naturally you're voting for cloture 100% of the time, right? More generally, if you're so concerned with how egregiously damaging the Democrats' propositions will be to our nation's future, surely you have an intellectually-honest counter-proposal for each measure that you block for our collective safety?

To Democrats, in particular: if you're the party of change, let's see it. Since you've had control of the White House and both houses of Congress, you've:

  • Spent several months passing a healthcare-reform bill (which, by the way, was probably priority #4 on many of your constituents' lists) that, in your efforts to compromise with an uncompromising opposition and to ensure that the flow of re-election campaign dollars remained intact, became so watered down that it essentially became a government-mandated handout to the insurance industry (but hey, at least it doesn't kick in until 2014).
  • Passed a similarly diluted financial "reform" bill, in which many of the regulations that were repealed during the anything-goes 1980s and 90s remain repealed, and under which financial institutions are still free to become too big to fail (and to be bailed out at taxpayer expense), and for-profit stock exchanges and high-frequency trading systems can team up to knock 1,000 points off the Dow in five minutes. Meanwhile, banks are continuing to borrow money from the Fed at near 0% while not loaning it out to consumers and small businesses (which, you know, might, I dunno, stimulate the economy and create jobs?) because it's more profitable for them to invest those funds in treasuries and/or route them to their proprietary trading desks. How was none of this addressed?
  • Displayed a remarkable tendency to cower in the face of misinformation. If you have a good idea that you truly believe in, you should defend it. If someone puts out a press release saying that bill that cuts taxes for the middle class will raise taxes on 99% of Americans, you should put out a press release correcting that misinformation and calling out / into question its sources and motives. Just because someone is proclaiming the earth is flat louder than you are proclaiming it is round doesn't mean you should back down.

To everyone: You're adults. You're public servants. You're our representatives on the world stage. Act like it.

Sincerely,
The Captain


(Fair readers, please accept my apologies for running out of steam... I had like maybe five or six more points of discussion on my mind, but I'd actually like to have a life this evening.)

Thursday, August 26, 2010

I Do Not Need to Explain My Absence

Many events have transpired on or near the surface of the earth since I lasted posted. Most oddly, I've received 38+ comments (apparently authored by an army of Chinese webbots) on my previous post, for reasons I can barely fathom, even with a #2 pencil lodged in my skull. But, prehaps most significantly, I've become a homeowner. This quintessential part of The American Dream, which is not very easily realized (if at all) here in the Great Concrete Desert of the Northeastern United States, also happens to be a lot of work. Things break and need to be fixed. Other things need to be blown up and rebuilt, because they weren't the way you wanted them. And, of course, everyone wants a rocket-house.

"O Lord, bless this rocket-house and all who may dwell within the rocket-house." -- Homer Simpson

However ruinous the trials of homeownership (not to mention the mortgage-brokering and refinancing process, especially when people who never passed Remedial Counting are involved) may or may have not been thus far, they are not the reason why I have been absent for something like a year. Indeed, as Occham's Razor (the only Unified Theory of Everything you need) would have it, the reason is far simpler: I'm lazy. And highly prone to distraction, aimless ambling, and the drunken-man's tendency to inevitably fall into vat of carbolic acid.

OMG. I just saw a trailer for The Social Network, which should be all counts be a hilariously god-awful movie (a la Tokyo Drift), but this particular trailer is actually very well-done, strangely moving, and unexpectedly (unintentionally?) meaningful.

http://www.sonypictures.com/previews/movies/thesocialnetwork/clips/2300/

Set against a haunting, choral rendition of Radiohead's "Creep," what you see for the first minute doesn't resemble a movie trailer at all, but rather a series of all-too-familiar images, phrases, and clicks... And by the end of this minute, as the trailer loses its disguise, you start to wonder, within the contemplative, introspective realm that the song lyrics conjure up: "Has this been my life for the last six years? Has this been all of our lives for the last six years? What motives drive us to spend so much time doing this?" (Alas, I doubt that these are the questions about which this flick concerns itself.)

Anyway, I'm back. For now, at least. More to come. Theoretically.

Wednesday, August 25, 2010

Saturday, August 15, 2009

The Assumption of the Average

Every so often, it occurs to me that I've duped myself in the qualitative evaluation of something.

Today, in pursuit of simple and arbitrary pleasures, I decided to stroll over to the local Panera to grab a late lunch and some free Wi-Fi action on their open-air patio. (Yes, these are the things in life that make me happy.) I consider myself to be fairly well-versed in Panera's offerings, as my co-worker and I usually patronize the one on Route 9 in Natick every Monday. I don't really need to look at the menu (except to determine whether a favorite seasonal offering has returned), I just usually blurt out one of three or four of their sandwiches that I like and get it with a bag of chips and a salad (occasionally tacking on a smoothie or an iced chai latte). The cashier hands me a pager, and five minutes later, I've got my food.

Unfortunately, that's not exactly an accurate description of the Panera experience that I had today. After ordering my food (turkey sandwich, chips, salad, and an iced chai latte) and receiving my pager, I sat down at a table and waited for the pager to buzz. After five minutes, I wandered over to the specialty drink counter (no latte yet), and then continued over to the food prep area to monitor the progress of my order.

This is where things started to get strange. There were two people (likely college or high school kids on hiatus) assigned to sandwich- and salad-making duty, but what they were actually doing was far less clear. (From what I could tell, it involved slowly walking in circles while occasionally commenting about someone named Roy.) Five other people (including an extremely pregnant woman, who I'll call Claire due to her striking resemblance to Emilie de Ravin) who had ordered before me were also standing and waiting, their faces awash with a mix of concern and irritation. At some point, one of them looked over and noticed everyone waiting, and doing his best to conceal an expression that can only be described as the Universal "Oh Shit" Face (which I hereby trademark, along with the acronym UOSF) and tore off a chain of three or four order tickets from a printer device.

Clearly, I wasn't getting my sandwich anytime soon, so I wandered back to the beverage counter. Still no iced chai lattes in sight, and a thorough scientific analysis of the situation led me to hypothesize that this was because no one was working at the station. Claire wandered over at some point, looking physically distressed, and perhaps this triggered someone to actually pay attention, because it wasn't ten seconds later that the young lad who'd taken my order -- visibly sporting a UOSF -- was asking us whether we were waiting for anything. Claire, who looked like she was in immense physical pain and holding back tears (I didn't know whether it was my place to ask her if she was okay, but I nearly did) indicated that she was waiting for a frozen lemonade, and I reminded him of my iced chai latte. The young man nodded, murmured some excuse about thinking that "someone else already helped you guys," and got to work.

Meanwhile, back at the food prep counter, there were several plates assembled with various sandwiches and salads, but since none of them looked like my order (at least not within a 95% confidence interval), and since my pager hadn't yet buzzed, I figured that none of them were mine. However, seeing as how the sandwich-makers had returned to their walking-in-circles-while-discussing-Roy routine, I stepped up to take a closer look. Sure enough, one of the order tickets matched mine, even though there was a baguette instead of chips, and even though they'd never rung my pager. After badgering one of the so-called employees to exchange the baguette for chips, I returned to the beverage counter.

"Here you go, buddy," said the drink-maker. It was a strawberry smoothie. "Sorry I forgot about your smoothie."

At this point, correcting him -- again -- seemed to be the ultimate exercise in futility, so I took the damn smoothie and left to eat.

As I ate, the simple thought Wow, this Panera sucks crossed my mind, as I'm sure happens to many of us at the conclusion of a similar experience. But then it occurred to me to ask: was that necessarily true? Is it really this particular Panera that sucks, or do all Paneras generally suck except for the one that I happen to patronize on a weekly basis? What if the abysmal customer-service experience that I had just been through was, in fact, closer to the norm than it was an exception to the rule?

When we evaluate an instance of a particular object or experience for the first time (whether it be dining at a Panera restaurant, playing whiffleball, or riding in a hot air balloon), I think we have a tendency to presume that the instance we're evaluating is perfectly average and falls in the middle of the bell curve of all possible instances of the same object/experience. From a statistical perspective, this seems like a reasonable presumption: 68% of your impressions will be of an "average" instance, and 95% of the time you'll be evaluating a "roughly average" instance. It also makes sense from the standpoint of natural selection: if, the first time your little brother Grrglmmick tried to jump onto a sleeping T-Rex he got eaten, it's reasonable to assume (for the purposes of preserving your gene pool) that Grrglmmick's experience is what "usually" happens when you try to jump onto a sleeping T-Rex.

And yet, thanks to the beauty of statistics, there will still be many cases in your life where your initial impression of something is actually one of those outliers that resides within 2.5% of either end of the bell-curve. (Recall the saga of Red Sox pitcher Clay Buchholz who, in his second major-league start, threw a no-hitter, and then proceeded to be one of the worst pitchers in all of baseball for the next half-year until he was sent back to the minors.) It is cases such as these that cause you to recognize and question your natural inclination to give greater weight to your initial impressions of something, and doing this can feel a little unsettling, perhaps even humbling, as though you're realizing that you've pulled off a doozy of a con-job on yourself.

But if you ask me, it's an acceptable consequence of living in a universe that, in spite of being doomed to an eventual heat-death at the hands of entropic degradation, takes a thankfully (and thanklessly) unpredictable path toward its final destination.

Sunday, March 1, 2009

The Vampire Blood in My Wine Glass Speaks!

"There are too many bears that have fallen into bottomless pits with trapezoidal openings."

"The wheel upon which are all spinning -- it measures 392.7 meters across, even though Napolean's scientists incorrectly defined the meter as being 1/10,000,000th of the distance between the north pole and the equator, whereas nowadays it is simply defined as the length of the path travelled by light in vacuum during a time interval of 1/299,792,458 of a second. Morons."

"I was at peace with my current position in the space-time continuum, but then Locke let Ben move the island and now we're all randomly warping back and forth through time, occasionally suffering from a fatal nosebleed. Ah crap."

"When a child hunts for easter eggs, he or she does not expect the act of finding one to cause his or her basket to explode. Yet this happens all the time. Why?"

"1, 1, 2, 3, 5... Eureka! Awk! Pah-cuck!" (all birds speak chicken)

"You should get contacts because you can't see anything. I recommend a +1.25 for your right eye, and a link of hot italian sausage for your stomach."

"If cows could fly around and devour Billy Corgan, the world would become devoid of music that no one has listened to in over a decade."

"Sports teams playing each other is funny when the combination of the names of the participating teams and the result implies a balance of power that makes no sense in the natural world. For example: Eagles 27, Bears 3. In real life, it would be: Bears 4,398,186, Eagles 4."

"I am the Man in the Iron Mask, and I can shoot fireballs."

Wednesday, February 11, 2009

Internet Explorer Mobile and File Upload: Utterly Flimsy

Okay, a brief respite from the usual random babbling. This post has a mission. And if you're not a web developer, your eyes are about to glaze over.

Ready?

So, I just spent the entirety of my day yesterday trying to get one conceptually-simple thing to work. As part of an ongoing mobile web application development project, all I needed to do was to enable a smartphone or PDA user to upload a file from their device to a server. In today's alleged "Web 2.0" word, this type of file-upload capability is virtually ubiquitous across most interactive and community-based websites.

To enable file-upload in a standard desktop browser, all a web developer has to do is include something like the following code within a web form:

<form action="Upload.aspx" method="post" enctype="multipart/form-data">
   <input type="file" name="MyFile">
   <input type="submit" value="Upload!">
</form>

Additionally, if you're using ASP.NET as your development platform (as I am), you can just use this little snippet:

<asp:FileUpload runat="server" ID="MyFile">
<asp:Button runat="server" ID="btnUpload" OnClick="btnUpload_Click">

Continuing with the ASP.NET example for a moment, to actually process the upload, you write a handler for the btnUpload button's Click event, like so:

protected void btnUpload_Click(object sender, EventArgs e)
{
   if (MyFile.HasFile)
   {
       // Do something with the file here, such as:
      MyFile.SaveAs(Path.Combine(@"C:\Uploads", MyFile.FileName);
   }
}

Simple, no? (I bet even some of you non-coders were able to follow along...)

Indeed, in most cases, it really is that simple. For just about any modern web browser, whether it's Internet Explorer, FireFox, Chrome, or Opera, and whether it's running on your PC, PDA, or smartphone, this example will work without any hassle. Of course, having read the title of this post, you know that there's one browser that's a glaring exception to this rule, and that's Internet Explorer Mobile. (Strangely enough, another one is the version of Safari that runs on the iPhone.)

"Now, what just a minute!" you might say. "Mobile browsers are still fairly primitive creatures, and only recently have a scant handful started to support file upload. I mean, yes, if I were in charge of a team that was building a mobile browser, I'd make file upload a high-priority task, since of course most mobile application developers are going to want to be able to take advantage of their users' rapidly advancing photo and video-capturing capabilities..."

Well, yes, this is technically true. Many mobile web browsers are just achieving a basic level of usability, and there are many mobile browser vendors who openly state that their products do not yet support file upload. Microsoft, for its part, has stated that Internet Explorer Mobile running on Windows Mobile 6 Professional Edition (but not Classic) does support file upload. And while that is also technically accurate, their implementation of this feature is so utterly broken (and in such an asinine way) that you'd be hard-pressed to convince yourself that they're telling anything resembling the truth.

So, what's wrong with file upload in IE Mobile? To the casual debugger stepping through the ASP.NET code such as the earlier example, you may (or may not) notice one or more of the following symptoms:

  • The Click event of the Upload button never fires.

  • The Request.Files collection is empty.

  • The HasFile property of the FileUpload control is false.

  • In spite of the above, the Request.ContentLength property is larger than the size of the uploaded file.

  • The contents of Request.InputStream include the uploaded file's data, along with some (but not all) of the ASP.NET form values.

  • All ViewState information on the page is lost. (This seems to happen with any ASP.NET multipart/form-data postback, in my experience, regardless of browser.)

  • Many (but not all) members of the Request.Params collection are missing.


After spending many hours capturing, studying, and stepping through the raw HTTP requests and responses of a simple file-upload web application and a variety of desktop and mobile web browsers, I discovered that the following conditions will cause IE Mobile's multipart HTTP request to become corrupted:

  • The user uploads a file whose name exceeds 15 characters in length. (This length includes the file's ".ext" extension, but does not include any directory path that the user supplies.) For example, if the user attempts to upload a file called File1234.doc (12 characters), the upload request will succeed, but if the user tries to upload a file called File12345678.doc (16 characters), the upload request will become corrupted.

  • The <input type="file"> or asp:FileUpload tag appears on an ASP.NET page that uses a Master Page. This one baffles me. I can't even begin to think of why using an ASP.NET Master page would cause IE Mobile to corrupt the upload request. Does it have to do with the way ASP.NET names and renders a container's child controls with all of those funky dollar signs and such? I've read that it's because the Master Page form's enctype doesn't get set to multipart/form-data, but in my testing I did not find that to be true. At any rate, if anyone who knows the answer to this little puzzle, please provide your explanation in a comment to this post, and you'll rewarded with a gold star (possibly one gleaned from a Google Images search).


Of these two bugs, it's the first one that really gets me. 15 characters?! What is this, 1988 and MS-DOS 4.01?! My guess is that this is some kind of non-terminated string oversight, most likely because some nitwit declared and allocated a char* buffer that was 16 bytes long, but then forgot to check the size of the actual string he wanted to load into that buffer, causing some kind of memory corruption that cascades into the text of the HTTP request.

Given these obstacles, what's a mobile web developer to do to get around them? Well, keep in mind that Opera Mobile -- which is now the default browser on the Windows Mobile 6.1 phones that Verizon, Sprint and AT&T are offering -- handles file upload requests flawlessly. (In fact, when I compared the multipart HTTP requests of Opera Mobile and the desktop version of Internet Explorer side-by-side, I noticed virtually no difference.) So, really, all you have to worry about is dealing with IE Mobile.

Thankfully, IE Mobile has pretty good JavaScript support, and you can use this to your advantage when you design your file upload web form. One possibility is to have your web page inject a special JavaScript validation function if it detects that the browser is IE Mobile, and wire your Upload button to run this script when clicked. All the script has to do is check the length of the file upload control's text (making sure to strip the path from the filename), and if it exceeds 15 characters, warn the user about IE Mobile's limitation and prevent the form's submission.

Here's an example:

ASP.NET Web Form:

<script type="text/javascript">
function ValidateFile(ctlidFileUpload) {
   var fileUpload = document.getElementById(ctlidFileUpload);
   if (fileUpload) {
      var sFilename = fileUpload.value;
      var nLastSlash = sFilename.lastIndexOf('\\');
      if (nLastSlash >= 0) {
         sFilename = sFilename.substring(nLastSlash + 1, sFilename.length);
         if (sFilename.length > 15) {
            alert("Internet Explorer Mobile requires that the document's filename (including extension) be 15 characters or less. Please rename this file and try again.");
            return false;
         }
      }
   }
   return true;
}
</script>


Code-behind:

protected void Page_Load(object sender, EventArgs e)
{
   // Inject validation script if necessary
   if (Request.Browser.IsBrowser("IEMobile"))
   {
      btnUpload.OnClientClick = "return ValidateFile('" + fileUpload.ClientID + "')";
   }
}

As for the issues with Master Pages, well, think of your file-upload page as having the same role and function as an "Open File" dialog box would in a desktop application. Essentially, you're just prompting the user to select a file for some greater, more interesting purpose. Does the dialog box need to have the same look-and-feel as the overall application? Not really, and if you think about it, neither does your file-upload page. You can maintain a relatively smooth, continuous user experience by just including a few visual cues (colors, logos, etc.) from your Master Page on your file-upload page. Give it a try and walk through the application flow -- you'll be surprised.