Right thinking on Healthcare

I see this as the bravest statement made in the 2nd Obama-McCain debate:

I think [healthcare] should be a right for every American. In a country as wealthy as ours, for us to have people who are going bankrupt because they can’t pay their medical bills—for my mother to die of cancer at the age of 53 and have to spend the last months of her life in the hospital room arguing with insurance companies because they’re saying that this may be a pre-existing condition and they don’t have to pay her treatment, there’s something fundamentally wrong about that.

Healthcare is something that no one truly wants any person to be without, but few politicians have the guts to declare it a right because of the fears surrounding the notion of “national healthcare” and the slippery slope towards socialism.

Continue reading  

Getting phpQuery running under XAMPP for Windows

While trying to run the initial test scripts included with phpQuery 0.9.4 RC1, I got the following warning:

Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in C:\xampp\htdocs\phpQuery-0.9.4-rc1\phpQuery\phpQuery.php on line 280

This is strange because DOMDocument’s constructor has only optional arguments.

As it turns out, XAMPP for Windows ships PHP with the old PHP4 “domxml” extension enabled by default (appears as extension=php_domxml.dll in \xampp\apache\bin\php.ini). This deprecated extension has a somewhat less-documented OO API, with domxml_open_mem() being accessible via new DOMDocument(). I.e. domxml hijacks PHP5’s DOMDocument constructor.

Comment extension=php_domxml.dll out with a semicolon, restart Apache and phpQuery seems to work as designed.

Joining in on the commentary

I think we’re very lucky that both presidential candidates have the potential to bring more intelligence to the position, and that the excitement seems to be getting more of us paying attention to what our elected officials are doing for (and against) us. I’ve certainly never been more interested in a presidential race, and access to information about candidates and issues seems better than ever.

That said, both campaigns and supporting organizations have ensured this will be another dirty race to the White House. Continue reading  

flock() blocking reads

(Sigh.) After applying recent upgrades to our Red Hat 5 server at work, suddenly PHP file locking blocks the script execution for exactly 30 seconds! Both a shared reading lock (LOCK_SH) and exclusive writing lock (LOCK_EX) do this. This was, shall we say, unpleasant to diagnose. Since we use Cache_Lite (which locks by default) to cache lots of stuff and sometimes in multiple layers, most of our pages suddenly took 30, 60, etc. seconds to load! Here were duration times from a test script:

  'write' => '0.00257301',
  'read' => '0.00039792',
  'write w/ exclusive lock' => '30.00274611', (file_put_contents w/ LOCK_EX)
  'fopen' => '0.00080800',
  'get shared lock' => '29.99504590', (flock w/ LOCK_SH)
  'read file' => '0.00034904',
  'close file' => '0.00005412',

Awesome. Now it is documented that flock() “will not work on NFS” (which we are on), but this has worked fine for over a year and continues to work on our unpatched server. The versions of Apache and PHP did not seem to change. Here’s how Red Hat listed them:

old: httpd-2.2.3-6.el5 new: httpd-2.2.3-11.el5_1.3
old: php-5.1.6-12.el5 new: php-5.1.6-20.el5_2.1

So… any ideas? I’ll have to turn off fileLocking in Cache_Lite to move forward, but I’d love to know what’s up. This especially troubles me because I recently added default cache locking to Minify. Locking is also the default in Zend_Cache_Backend_File, so it seems like the right thing to do.

Javascript humor

hasthelargehadroncolliderdestroyedtheworldyet.com has a news feed. It also has this in the source:

if (!(typeof worldHasEnded == "undefined")) {
document.write("YUP.");
} else {
document.write("NOPE.");
}

Folks without Javascript get a more definite answer:

<noscript>NOPE.</noscript>

Also appreciated:

<!-- if the lhc actually destroys the earth & this page isn't
yet updated please email mike@frantic.org to receive a full
refund -->

uTag: like snurl, but crappy!

A SitePoint blogger recently wrote about uTag. Like my favorite, snurl, it’s one of many make-a-shorter-link URL redirect services, but with a 90’s twist! When you click on these, instead of getting a page, you get a frameset with ads on top, broken addressbar usability, and, if you know how uTag works, the warm fuzzies that the jerk who put you through this annoyance got ad revenue while the site they deemed worth linking to doesn’t even get PageRank credit for the inbound link. The best part is that uTag encourages site owners to replace all their links with crappy uTag links, so when uTag folds your site can add to the collective link rot. Also, if more site owners do this, browsing their sites starts to look like this:

Surfing a wonderful web of uTag links

Tip: Unless you’re as established as about.com (hated for this practice), you probably can’t get away with annoying users this thoroughly.

Site owners, it may be time to dust off this snippet:

if (top !== self) top.location.replace(document.location.href);

Case of the NS_ERROR_DOM_SECURITY_ERR

Working on a bookmarklet, I ran across “security errors” in Firefox and Opera (may happen in others, I didn’t check). In Firefox the code threw “Security error (NS_ERROR_DOM_SECURITY_ERR)” and in Opera it was something similarly vague.

The culprit code was trying to access the cssRules property of a style sheet from a different domain (my CSS is on a subdomain). It appears browsers apply the same origin policy to the DOM CSSStyleSheet interface. Effectively, you can access the href property of a different domain styleSheet object, but not its cssRules. In Firebug, the cssRules property will be null, but attempting to even read it in user script causes the exception.

If your script is throwing NS_ERROR_DOM_SECURITY_ERR, check for code trying to access objects on a different domain.

Thanks, Recuva

Recuva is a drop-dead simple Windows file recovery program [aside 1] that just saved me two hours of work. I was trying to reorganize some directories and ended up deleting two freshly written PHP files [2]. I’ve used about a half-dozen file recovery apps over the years due to my affliction [3], but Recuva was the most intuitive by far. Within 30 seconds I opened the program for the first time and closed it with my recovered files saved.

I tried to write a little review on download.com, but their Javascript was too broken for Opera.

[1] DOS’s “undelete.exe“, as crummy as it was, was the only reason ever to miss Win9x.

[2] Subversion lesson: Don’t commit directory renames/moves at the same time as modifications to descendant files/folders. Commit the rename, breathe, commit the rest.

[3] The shortcut geek in me developed the terrible habit of using [secret key]+[Delete] to delete a file, bypassing the Recycle Bin (if you don’t already know this key combination, don’t look it up; forget it existed; I wish I could).

9/6 update: Recuva just recovered 62G of Kathleen’s stuff from a failing external drive. OSX couldn’t mount it and a supposedly more heavy-duty Windows recovery app I tried couldn’t open the drive either.