2011-04-28

4096 bytes is more than enough for everybody

Ever try to make an AJAX call from JavaScript, only to find out that your data is truncated at around the 4k mark? If so, you must be using Firefox 3. Although there is a workaround described here, it means you have to write extra, special code to check for a custom property to really get all the data.

You can test this problem using this QuirksMode page. The page notes other limits on Opera and the Macintosh version of IE, but on the current (v11) version of Opera, I was unable to duplicate it. I also don't have a Mac, so I couldn't verify it there, either. Only Firefox fails to copy the whole text block.

Apparently, this has been fixed in Firefox 4, but that's small consolation when you're tasked with supporting what people are actually using.

2011-04-21

Let me url that for you

Today's programming annoyance is brought to you by the .Net Framework.

If you add a style to an HtmlControl in code — for example, the list-style-image to a list item element — you might use something like the following:

control.Style.Add("list-style-image","none");

You might expect that the style element would contain "list-style-image: none;".

Apparently, you'd be wrong. The tag generated looks like this:

<li style="list-style-image: url(none);">

There is a workaround, but it depends on you being able to specify all list-style properties at once. Using the shortcut, this code:

control.Style.Add("list-style","none none");

will generate the expected HTML, unmangled (and set both the list-style-type and list-style-image properties).

Having list-style-image: url(none) may not make your page look broken, but it will result in a browser request for the file "none" and result in some excessive 404 logs on your server.

If you had an actual image and set it with control.Style.Add("list-style-image","url(imageName.jpg)"); the style would not suddenly get "double-wrapped" with the url() function. By wrapping your value with url() "just in case" you forgot it, Microsoft tries to protect you from yourself, and ultimately causes more headaches by preventing you from setting the style to a perfectly valid value.

2011-04-01

Hollywood's War on Christianity Now Using Aliens

I recently saw the movie Paul. It's a comedy about two young adult male British nerds who are realizing a longtime dream of coming to America to visit Comic-Con, followed by taking a tour of famous UFO sites in the US (like Roswell and Area 51). As they're traveling, they witness a car suddenly veer off the desert highway and crash. When they stop to investigate, they meet Paul, a rather foul-mouthed alien who has escaped government capture and is trying to get home.

The movie is pretty funny, with lots of nerd references — from Star Wars (the cantina theme being played in a trucker bar, a guy shooting out his CB radio as he murmurs "Boring conversation anyway") to Close Encounters (a spaceship landing at Devil's Tower, a large firework that plays the five-note theme) and Aliens (a character quotes "Get away from her, you b---", a line spoken by Sigourney Weaver in Aliens, to Sigourney Weaver's character in Paul). It is also full of bathroom and locker room humor that's so popular with the kids these days.

The part where it starts to dig at religion comes when, soon after meeting Paul, the Brits decide to pull their RV into an RV park. They are greeted by a young blonde girl, Ruth, who comments on how she'd like to travel someday but has never gone anywhere in her life yet. The conversation is interrupted by a gruff voice calling her back to the office/house for "PRAYERS!"

The next day, Ruth visits the Brits' RV, and she starts to reveal herself as what I like to call a "Strict Creationist" — someone who believes in the literal word of the Bible, that the Earth was created 4,000 years ago in a process that spanned six days, and that there is no possible way there could be "alien life" elsewhere, as we were all created in God's image. Paul, somewhat put out by this, emerges from his hiding place in the bathroom. After fainting (something of a running gag in the film), she awakens and tries to convince herself it was her imagination, until she sees Paul again. She then goes into a fit of hysterics.

Up to this point, it's not so bad. Hollywood loves its stereotypes, especially taken to extremes. An openly gay character will be extremely flamboyant; a character born in the Lone Star State will almost invariably be wearing a cowboy hat and calling every female "Darlin'". It's almost a foregone conclusion that an openly Christian character will end up being extreme fundamentalist.

To stop her fit and from denying his very existence, Paul does this "alien thing" where he gives Ruth all of his knowledge and experience, including memories of his galactic travels.

Here's where it starts to turn south.

Filled with this knowledge, Ruth decides that all of what she believed is wrong, decides there is no God, and she is free to swear and fornicate. She then spends the rest of the movie trying to swear (in a manner not completely unlike Captain Kirk trying to "fit in" to contemporary Earth in Star Trek IV). Paul does make a token effort at trying to settle her down and say his experience doesn't necessarily preclude the existence of God, but his comment is ignored.

Going from one extreme to another isn't completely out of place in a low-brow Hollywood comedy. But the telling scene comes at the end, when, in a very sober moment, Paul says he's sorry for destroying Ruth's faith. Her reply? "You didn't destroy me; you freed me."

That actually made me a little angry. This was not a comedic scene; it was said with all seriousness, like it was one of the morals of the story. Faith is confining, and a foul mouth and spread legs is freedom. The disdain for religion is reinforced when Ruth's father wishes him well by saying "God be with you", and Paul scoffs, "Yeah, whatever."

I know it's just a story, and I should really just relax. And, when it comes down to it, I do see fundamentalism to be rather confining. I believe God has created this whole universe and there are many wonders and possibilities we have yet to even discover; and refusing to acknowledge wonders God has created because you cling to your narrow interpretation of what you know of Him today is akin to wearing blinders. I just object to this assertion that immorality and atheism is automatically superior to religion. These things are never "free", whether you believe in God or not — not believing does not release you from the consequences. And I'm not just talking about "fire and damnation". Promiscuity can lead to unwanted pregnancies, diseases, lack of trust in relationships; foul language can lead to loss of respect.

But, I guess, if you really believe your existence is over and done in 80 years, even these "little" consequences don't mean much, either.…