Friday, August 07, 2009

Finally, a blog post about these out of control Town Hall meetings

Every time I see a clip of a town hall meeting descending into chaos I want to blog about it. But, over the last couple weeks as I've tried to do so, all I end up with is a half written post and a head that hurts from thinking through the problem.

I had an especially clever idea, where I was going to compare these out of control town hall meetings to the calm Gates / Crowley / Obama beer meeting. Here was an issue that has just as much potential for explosion as health care, yet got diffused in many ways by rational discussion. I was going to suggest that to counter the upcoming recess rallies, folks hold beer round tables. The idea would be to get folks you disagree with together, and actually listen to each other. Sure, at the end of the day you may have to agree to disagree on some points, but you could still learn from each other.

But, try as I may, I couldn't quite get that post written.

I think I've finally figured out why: on one level, I don't disagree with these people. If I thought for one second that the US was going to sink into communism, or that the government was going to euthanize my grandparents, you better believe I'd be screaming and yelling. The big difference between us: I don't. I think the health care bill sounds like a quite reasonable way to attack the problem of health care. Folks on the far left will be upset because it's not single payer, and folks on the far right will be upset because it does involve the government - but in general, it seems like a perfectly American way to resolve this nearly intractable problem.

But still, if I thought that America was going to go down the tubes, a little screaming and yelling may be in order. How many folks on the left, knowing what they know now about Iraq war, would have done a little more screaming and yelling back in the day?

Granted, some people at these meetings are just there to disrupt them. Heck, the Democrats could be passing a bill to outlaw the killing of kittens, and they'd be against it. However, I think there's a good chunk of people at these meetings who absolutely believe these whacky theories that are being thrown out there. They are genuinely afraid and angry.

My take away from this, then, is that anyone who wants to see this health care initiative pass should be focusing on how they can educate all these terrified constituents. I'd be taking a close look at the message and perhaps more importantly, who's delivering it. I don't know what the answer is - put the bill in comic book form, create a series of dioramas, get Larry The Cable Guy to explain it, who knows. But, I don't see how playing phone games helps. And please, dear lord, don't just ignore these demonstrations as Senator Schumer has suggested. (Ahem, may I humbly suggest creating an English Translation of the legislation.)

One final point: I think the entire Republican base owes the Dixie Chicks an apology. Don't you see, political descent and criticizing the president can be quite patriotic, No?

Thursday, August 06, 2009

Note to self - be nice to everybody

It's time for something fun and lighthearted...

David passed me this remarkable story about a homeless woman in NY who surprised the heck out of the couple that was lending her a hand. It's a good quick read, so I don't want to spoil it here.

Billy Currington has this goofy song going around that actually mirrors this story eerily well. How strange.

The moral of the story is simple: be nice to everyone, you never quite know who you're dealing with.

Business Idea: Low Cost Video Editing Service

OK, ever since my last visit to see the twins, I've had this idea kicking around in my head. The best way to get out is to yammer on about it here a bit, so please excuse me.


When I was visiting with the twins, I shot gobs and gobs of still photos but almost no video. I held off on the video for a simple reason: it was going to be a hassle to edit it down into something reasonable. I can reduce 50 photos to 5, and post them to post on the blog in just a few minutes. To look through 20 minutes of video, and try to create a half-way viewable clip, would take significantly longer.

The same scenario comes up with vacations or pretty much any one attends.

Here's my solution: why not offer a low budget video editing service for the masses. You'd drop your raw footage in the mail, or upload it to them, and for a relatively low cost you'd get two services. First, you'd get a number of short films of the best footage. Second, they would tag (think: adding keywords like: yawn, crying, smiling, .etc) and index all the footage.

The short films wouldn't be high quality movies - they'd just be whatever the editor's judgment lead them to. Throw some stock audio on top, and you're good to go. The indexing and tagging would be helpful for going back through the footage easily, to say, find all cases with Dovid in yawning or some specific case like that.

I could see the service having an elaborate website where you can browse your raw footage and view your movies. I can also see starting the service really simply, by just posting the completed work to YouTube or another video site. For the right price, I wouldn't mind doing without the extras.

The whole arrangement wouldn't be about perfection, it would be about convenience and value. I could shoot a bunch of video knowing that for a reasonable price, I could have it turned into movies suitable for family and friends.

Now, for all I know there's already a low cost service out there like this. If there is, I'd love to know their URL. If there isn't, it seems like a small business a film student could start relatively painlessly. And when you do, let me know, so I can put you to work!

My Beer Log

I've started to drink beer a little more often, but I'm a long way off from having any kind of preference. I figure my best way to form an opinion is to try it all, and see what shakes out.

So, no doubt inspired by the Wired article on tracking your life, I've started a Beer Log. Besides, I come from a family of scientists, this is just how we think.

Please add your suggestions of ones to try in the comments...

  • 8/6/20009: Avery White Rascal - I randomly tried this one tonight, and I found it quite drinkable. The waitress asked me if I could taste the hints of orange - yeah, we're not that tuned yet. Grade: A
  • 8/17/2009: Long Trail Ale & Otter Creek Copper Ale - I tried these two beers back to back, on a hot summer day when my friend got married. I found the Long Trail Ale easier to drink and tasted better, and the Otter Creek was just a bit too intense. Though, still drinkable. The heat certainly didn't hurt matters. Grade: B+, B-
  • 8/18/2009: Mother Martha’s Kolsch-style Ale - This is Rock Bottom's light beer offering. I suppose it tasted OK, though I didn't find it particularly memorable. I guess I appreciate that it was guilt (calorie wise) drinking. Grade: B.
  • 8/25/2008: El Jefe Hefeweizen - This is another Rock Bottom beer. I'm not sure how to describe this one - the first word that comes to mind is "spicy." It's one of the first times I tasted a beer and noticed something other than beer taste. I found it quite drinkable and fun to try to decode. Grade: A.
  • 9/3/2009: Coastal Flats Pale Ale - Yikes this beer was bitter. So bitter, I found I had no urge to finish the glass. I'll have to come back to it after I've gotten more beers under my belt, and see if I continue to find it as undrinkable as I did this first time. Grade: D.
  • 9/6/2009: Half Acre Over Ale - This was another bitter brew. Though, I didn't find it quite as bitter as the Coastal Flats Pale Ale, and had no problem drinking the whole bottle. It's still a taste I think I'm going to need to acquire. Grade: C
  • 9/10/2009: Corona - I finally got around to trying this standard beer. No wonder it's so popular, it drinks more like a soft-drink than a beer. While I didn't feel particularly adventurous while drinking it, it was far from disagreeable. Grade: A
  • 9/17/2009: Dogfish Head Punkin - Despite the seasonal nature of this beer, and the name, I couldn't even find a hint of Pumpkin while drinking this beer. But, I did find it flavorful enough for me to enjoy, yet not so overpowering that I'd write it off as too bitter. For my tastes, it pushed the limits of what I'll enjoy while drinking a beer - but, that's probably a good thing. Grade: A-
  • 9/20/2009: Yuengling Light Lager - This was definitely a passable beer to drink. Being a light beer, I suppose it's one I could drink with less caloric guilt. In terms of flavor, it didn't strike me as anything either amazing, or horrible. Grade: B
  • 9/27/2009: Arrogant Bastard Ale - My first thought, when tasting this beer was that there was almost something spicy about it. Though, in the end, I was having a hard time teasing out a specific flavor, other than just bitter. I'll just call it complex. Grade: B. Oh, and they have the slickest website yet.
  • 10/24/2009: Magic Hat, Odd Notion Fall 2009 - Wow, this beer had a remarkable flavor. From the website it mentions Chocolate and Clove. Alas, this flavor came across as burnt and bitter to me. It was definitely too strong for my tastes, but interesting none the less. Grade: C

Wednesday, August 05, 2009

Gotcha Of The Day: Timezone Syncing

I've spent some serious debugging time trying to figure out why a Java test works fine on one machine, but fails on another. After much investigation, I realized that the timestamps being created by Java were an hour off from those created by MySQL. Naturally, this hour was caused by a timezone issue.

What I should have done first and foremost, is confirm that times are sync for all parties involved. So here you go, some quick recipes for confirming Linux, Java and MySQL are all in sync.

Linux System Time

The following will print both local, GMT time, and your current timezone offset:

date      # Wed Aug  5 09:48:01 EDT 2009
date -u   # Wed Aug  5 13:48:21 UTC 2009
date +%z  # -0400

MySQL Time

The following query will print out the local time, GMT time and the timezone offset:

mysql> select now(), utc_timestamp(), hour(now() - utc_timestamp());
+---------------------+---------------------+-------------------------------+
| now()               | utc_timestamp()     | hour(now() - utc_timestamp()) |
+---------------------+---------------------+-------------------------------+
| 2009-08-05 09:49:34 | 2009-08-05 13:49:34 |                             4 | 
+---------------------+---------------------+-------------------------------+
1 row in set (0.00 sec)

Java Time

Grab BeanShell and run the following Linux/bsh commands:

[linux]$ java -cp  bsh-2.0b4.jar bsh.Interpreter
BeanShell 2.0b4 - by Pat Niemeyer (pat@pat.net)
bsh % print(new Date());
Wed Aug 05 08:51:41 GMT-05:00 2009

The Fix

As you can see above, Linux and MySQL are in GMT-4, which according to time.gov is correct (usually, we're in GMT-5, but with DST and all,it's -4). You can also see that Java thinks we're in GMT-05:00.

The temporary fix was to run with code with -Duser.timezone=GMT-4:00, though I believe the real fix is to run the SUN's TZupdater.

A Simple Question, A Powerful Website Feature

While I don't agree with most of the politics behind teapartypatriots.org, I do think their Patriot Feed is an inspired idea.

It's a wonderfully simple idea, they just ask the following question and post the answers on the page:

What are you doing today to preserve America's freedom?

Here's what I mean:

The question is such a smart one because the answers serve as both inspiration for the group as well as examples of concrete things readers can do.

As simple features added to a website go, it's one of the most powerful I've seen in a while.

Tuesday, August 04, 2009

Notebook and Pen Advice

My Dad passed me this helpful article on keeping an effective Lab Notebook. Being a fan of paper, I found the advice insightful.

I especially liked the analysis of the different pens and how they stand up to various punishments:

While not quite as fancy as the latest Netbooks or other electronic gadgets, there's just something remarkably powerful about the combination of notebook and pen.

Screen On The Green - A classic movie in and unlikely setting

My brother David is such a good influence. Rather than just talking about doing fun stuff around DC, he actually manages to get us to do it. Tonight's adventure: Screen on the Green. This is a fun one - you sit on the National Mall, with the Capital Building in the background, watching a classic movie. See what I mean:

As you can see above, the show opened with a classic Bugs Bunny cartoon (which was over-the-top sexist, as the witch complains how bad women drivers are) and then went onto the feature film which was On the Waterfront.

At first I found the film to be hard to follow, though, eventually, I got my head wrapped around the story. I can actually say that in the end, I liked it. I can't tell if it was hard to understand because I was missing the 1950's references/context, or if movies today are more spoon fed to you, or if I simply found some of the audio hard to understand and missed some key lines. Regardless, as classic movies go, it's one I'm glad I saw.

I can't recommend Screen on the Green highly enough. It was such a novel and fun way to take in a movie and the scenery is just perfect. If you have a chance to go, make sure you bring a blanket and some food and you'll have an excellent time.

Here are some more photos from the evening.

With David and Shira in charge, we definitely weren't late to the party. Of course, we had an excellent seat - so I can't really complain.

You see a picnic area - I see an office with the perfect view. Here I am, trying to do Just One More Thing before I call it a night.

My buddy Greg assembles his ultra-super-lightweight-sling-chair. It apparently requires a master's degree in engineering to use. And yes, he had an extra piece when he was done.

Us:

The Gang ready for the movie to start, and for me to stop snapping photos.

A long exposure shot of us watching the movie.

Sunday, August 02, 2009

The Simons Spend A Day In DC

The Men - just a bit of a resemblance among them:

Dad and Grandpa do some serious furniture shopping.

Shira and a friend's 7-month old baby - two cute ladies, no?

David tries out some time in the slammer at the National Museum of Crime and Punishment - size wise, it wasn't really that bad.

Dad takes a Harley for a spin - oh, the power of lights and sirens. Again, from the National Museum of Crime and Punishment.

Grandpa next to a mug shot of Al Capone.

How cool is it that America's Most Wanted has its studio in the basement of the crime museum, and you're welcome to invade it?

Shira and Grandpa - as you can see, gray is in.

The Closest I'll Ever Get To A Beatles Concert

Earlier tonight, our neighbor came by with an amazing offer - did we want to hit the Paul McCartney concert tonight, they had extra tickets? At first I was hesitant, but Shira convinced me we should go. Boy, am I glad she nudged me into it.

Turns out, McCartney played quite a bit of Beatles music which was a thrill to hear, and he found ways to reminisce without being too cheesy. Overall, he put on an awesome show and it was a thrill getting to see a living legend. It was also nice the rain held off till we made it to car for the ride home.

Photos coming soon...

Friday, July 31, 2009

Accidental Entomologist

This morning I came across this stunning beetle, which of course this photo doesn't do justice to. It must have been a couple inches in length, and was minding its own business, so I left him alone.

OK, maybe you had to be there - it was an impressive specimen.

A Hoora-ific Museum and Good Time

Apologies to all members of the Marine Corps for the cheesy title. Couldn't resist.

My parents, Grandpa, the Wife and I had a wonderful trip to the US Marine Corps Museum located in Quantico, VA. It's been on my List of DC Sites To See for a while, and when I saw it got rated as one of the top 10 things to see in Northern VA, I was sold.

The museum itself is larger and more complete than I imagined. WW II, Korea and Vietnam are all covered in depth - with plenty of hardware to be impressed with. I even found the mannequins in the dioramas to be eerily lifelike.

Even if you're not a fan of the Marines or blowing stuff up, it's still worth checking out just for the interesting historical perspective.

It's also worth noting that it's both free, and with the wheelchair they provided for grandpa, quite senior friendly.

Thursday, July 30, 2009

The Trickiest Part Of The 9th Of Av

Today is the 9th day of the Hebrew month of Av, or Tisha B'Av, the saddest day in the Jewish calendar. All sorts of horrific events have happened on this day. To mark the day, Jews observe a whole series of limitations: no eating, no drinking, no washing, no wearing of leather shoes - heck, you're supposed to avoid all levity.

You might think that for me the hardest part is going 25 hours without eating or drinking. But you'd actually be incorrect. Sure, it's no fun be hungry throughout the day, and I get cranky something fearsome, but I'll make it through.

No, the hardest restriction I have on Tisha B'Av, is that you're not supposed to greet others. Here's why, as summarized on this handy Jewish Holiday cheat-sheet:

Greeting? An odd feature of Tisha B'Av is that it's traditional not to greet people during the fast. This comes from Jewish mourning practices. When one visits a house of mourning, it's not usual to greet people either. It's OK if you slip up and say hello by accident in either case--you'd be surprised how polite people are.

It's remarkably difficult to not say hello to people who very much enjoy seeing. And how do you resist not kvetching about how hungry you are and making light of the situation? It's just not how me, or other folks in my shul, are wired.

As noted in this wonderful article, Tisha B'av is a strangely lonely holiday. Besides not greeting with people, there's no marathon communal service (for Conservative Jews, anyway) throughout the day to commiserate with others. No, it's off to work, each person taking their thoughts and fast with them.

I can't help but think there's an important and powerful lesson here. We take one day where we actively deny ourselves the benefit of coming together as a joyful community, and thereby remind ourselves what a luxury it truly is. It may not appear like something we have to work for, but it most certainly is.

For another excellent read on the topic of Tisha B'av, may I suggest this article. And if you haven't read Eicha yet, I'd suggest that too.

Gotcha Of The Day: SSL website ignoring .htaccess file

I needed to put quick Apache RewriteRule fix in place on a website, so I decided to add the rules to the .htaccess file. For the life of me, I couldn't get the rules to take effect.

After much poking around, I realized that the rules were being observed for the http version of the site, but the https version was ignoring them.

After still more digging, I could find plenty of folks talking about how to limit rules to just non-https pages, but I couldn't find anyone suggesting that SSL version of the .htaccess file would normally be ignored.

Then it hit me - the VirtualHost definition for the SSL site is a totally separate configuration than the non-SSL site. And that was the key, I had:

<VirtualHost *:80>
    ServerName something.com
    DocumentRoot /var/www/vhosts/something
    ...
    <Directory /var/www/vhosts/something>
        AllowOverride All
    </Directory>
</VirtualHost>

<VirtualHost *:443>
    ServerName something.com:443
    DocumentRoot /var/www/vhosts/something
    ...
</VirtualHost>

I had an AllowOverride clause in the non-SSL virtual host, but not in the SSL version. The result: the non-SSL version was observing the .htaccess file, the SSL version was ignoring it.

I added that clause in to the SSL version, restarted the server, and I was good to go.

Wednesday, July 29, 2009

Translation Needed - HR 3200 from Congresses to English

My friend Justin passed along an e-mail forward that's no-doubt been making the rounds. If my Goolging is correct, it was an e-mail version of this page, entitled: The HC Monstrosity-All 1,018 Pages. This blog post sets the stage with an introductory paragraph (the e-mail was missing this paragraph):

Since Congress doesn’t want to read the Health Care Bill and Obama, ACORN, Unions, Lawyers, & Special Interest Groups don’t want you to know whats in this monstrosity, I decided to do it myself. I’ve taken all my tweets on the HC bill and put them into one single place for your enjoyment. Additionally here is the link to the full bill

(ACORN? Really? Anyway, I digress)

The post, and e-mail, then go on to highlight dozens of sections of the bill, and what they mean for you as a citizen. So examples:

...
Pg 30 Sec 123 of HC bill – THERE WILL BE A GOVT COMMITTEE that decides what treatments/benes u get
...
PG 50 Section 152 in HC bill – HC will be provided 2 ALL non US citizens, illegal or otherwise ...

After reading this interpretation of the bill, how could you not be terrified of it?

One person did post a follow-up comment that attempted to refute most of the claims that were stated. For example, the above comments were addressed as:

Pg 30 Sec 123 of HC bill – THERE WILL BE A GOVT COMMITTEE that decides what treatments/benes u get

The government committee will not decide what treatment or benefits you get. The panel, which is mandated to represent both the medical field and employers, will recommend (i.e. not mandate) two things: an ”essential benefits package” (that is, minimum coverage), and cost-sharing levels for “enhanced plans and premium plans” (which would ensure a maximum individual medical expense). Not only would this committee not mandate the coverages in those plans, it would not mandate which plan is offered or which plan a person must buy. This in no way effects choice of the individual, only attempts to ensure standards under which an individual is guaranteed a certain level of care.
PG 50 Section 152 in HC bill – HC will be provided 2 ALL non US citizens, illegal or otherwise
Talk about grasping at straws. Here’s the exact verbiage of the text: “Except as otherwise explicitly permitted by this Act and by subsequent regulations consistent with this Act, all health care and related services (including insurance coverage and public health activities) covered by this Act shall be provided without regard to personal characteristics extraneous to the provision of high quality health care or related service.” Oh my God! Those evil bastards!!

Accurate or not, the issue raised by this blog post is a good one. HR 3200, heck most (all?) bills in congress are hundreds of pages of difficult to read text. It's awesome that they are available online, but the text is so hard to understand there's enormous room confusion.

When I checked out congress' version of the bill, I was impressed to find that they allowed people to comment and link to any section of it. Cool! But, the comments were surprisingly sparse and not especially helpful. Take these two comments on section 123, on the Health Benefits Advisory Committee:

So all of the members of the "Committee" are appointed by the president, since the comptroller is a position not yet filled permanently, and that position is appointed by the president.

Yes - and these few people will decide what health care coverage you will receive. Had enough Socialism yet?

Congress gets big points for offering a way to comment and permalink any section of any bill. But, they lose points for not engaging people in conversation and using their own comments to further explain what was intended.

If you ask me (and nobody does), I think a bill like HR 3200 should be accompanied by an English version. You should then be able to read a side-by-side translation. The English version should include the following:

  • A plain English description
  • What the intent of the section is
  • Where possible, a concrete example
  • Limitations on when the section applies
  • Frequently asked questions

Ideally, this translation would be "certified" by a bipartisan group of some kind.

Yes, an English translation would be a huge amount of effort to put together. But, I think everyone would benefit from it in a big way.

Tuesday, July 28, 2009

A 2 Second Google Spreadsheet Tip

Here's a quick tip that took a second to learn, and has saved me immense amount of time:

In a Google Spreadsheet, type Control+<Arrow Key> to quickly jump to the end of the row or column. Try it, it makes getting around an online spreadsheet a breeze.

I use Google Spreadsheets to track everything from incoming business leads to my running progress, and scrolling around a 400+ row spreadsheet can be a pain. That's why this one key combination is such a hit.

Here are even more handy key shortcuts.

Bonus Tip: If you create a bookmark on your browser toolbar to the URL http://spreadsheets.google.com/ccc?new, you can visit to create a new spreadsheet with just a single click.

As usual, Jon Stewart says it best

This is exactly what I was talking about when I wrote this yesterday. Oh Jon, where would I be without your clever editing team.

The Daily Show With Jon StewartMon - Thurs 11p / 10c
Moment of Zen - Sarah Palin Warns of Government Largesse
www.thedailyshow.com
Daily Show
Full Episodes
Political HumorJoke of the Day

Monday, July 27, 2009

Sarah, Promise me this isn't goodbye

Check out Sarah Palin's exit speech from office:

While not quite as winding as her resignation speech , and lacking the cool wardrobe selection of her media interviews, she still managed to not disappoint me. In a single speech, she:

  • Explain what a fantastic job she did as governor and all the wonderful things she accomplished
  • Explain that government is the problem and not the solution
  • Reiterate that it's obvious why she's stepping down: a lame duck Governor is powerless
  • She's going to fight harder than ever for Alaska

The contradictions between these statements seems so obvious to me, that when I try to write them out, my head actually begins to hurt. I just can't reconcile them. If you want to fight for Alaska, what better job than Governor? Aren't you only a lame duck Governor because you decided you wanted to be one? If you did such wonderful things as Governor isn't that proof that government can do good things?

The logical part of me thinks that John Feehery is right, it's time for us to move on past Sarah. But oh, the guilty pleasure I'd miss by not keeping up with her. I can only hope she keeps tweet'ing away!

Ball Game Vegetarian Options

Shira and I have really been enjoying our trips to the ballgame. And the fact that they have Kosher food options is huge. But, I had no idea they also had some many vegetarian options - as this Washington Post Article explains.

There's veggie burritos, tacos and chili. Heck, you can even get a veggie hot dog (got to say, I've never been a fan of these).

Unfortunately, while the food options are there, the article doesn't always rank them very high. We actually tried one of Noah's pretzels yesterday, and were surprised that it wasn't as tasty as a typical Auntie Ann's pretzel was. Of course, once I learned the back story behind Noah's Pretzels, I could give them a break on the taste and will continue to buy them.

Ballpark food is is meant for the masses, so I give the vendors at the Nats stadium credit for at least offering interesting options. And besides, there's always beer.

Sunday, July 26, 2009

The Nats and The Boys, An Excellent Combination

We had an excellent time going to yet another Nats game today, this time The Boys (well, most of the boys - Spencer, we missed you!). While the game was pretty well matched, we did manage to pull out a win in the 10th inning. Even the weather was in our favor, and we were spared the predicted thunderstorms.
Some photos from our fun day below.
Just about the whole gang;
The boys and the bobble head George:
Ben takes his Rock Band signing up a notch by performing for those unlucky enough to be in the gaming pavilion. Sorry all.
Forrest scores an autograph:
The boys pose for one more photo - they are such a patient bunch when I have my camera!
Us!

Friday, July 24, 2009

Some Design Inspiration

Looking for some design inspiration? Check out these 50 blog designs. Wow.



Thanks to @SeanMalarkey for the tweet that included the URL.

Dev Site Of The Day: php-date.com

Need to know how to format an HTTP header date in PHP? How about for an RSS date field? php-date.com has you covered. Besides date formats, it gives hints on parsing dates and doing date math.

It's part reference material, part cheat sheet and all goodness.

If you PHP and don't happen to have photographic memory for the various specs out there - you'll want to keep this site handy.

Thursday, July 23, 2009

Another Gotcha Of The Day: empty Zip file generated by PHP

I wanted to use the Zip library offered by PHP to generate a .zip file. The API is nice and simple, you just do something like:

$zip = new ZipArchive();
$filename = "test.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
    user_error("cannot open <$filename>\n");
}
$zip->addFile("/usr/local/foo.gif","/foo.gif");
$zip->addFile("/usr/local/baz.gif","/bar.gif");
$zip->close();

For the life of me, though, I couldn't figure out why my code was generating an empty (0 byte) zip file. I could see the temporary files I was added to the zip file were on disk, but for some reason they wouldn't end up in my Zip archive.

To add insult to injury, the methods on the ZipArchive object just return back true or false, and don't say why they failed.

Eventually I narrowed down my woes to $zip->close() failing. But why? It would not say.

Finally, I put even more checks in place and realized that of the 20 files or so I was adding to the ZipArchive, one of them did not exist. The call to addFile() worked fine, but apparently later on when I called close() the archive was corrupted.

To avoid this type of issue in the future, I wrote a quick wrapper class around ZipArchive. Calling addFile on a non-existent or non-readable file will immediately raise an error. Here it is - enjoy!

<?php
/*
 * An extension to ZipArchive that's more verbose about 
 * issues that may cause things to break
 */

class SafeZipArchive extends ZipArchive {

  function open($file, $mode) {
    $result = parent::open($file, $mode);
    if($result !== true) {
      user_error("Failed to open the zip file $file ($mode)");
    }
    return true;
  }

  function addFile($path, $local) {
    if(!file_exists($path)) {
      user_error("Can't add |$path| to zip file, the path does not exist");
    }
    if(!is_readable($path)) {
      user_error("Can't add |$path| to zip file, the file is not readable");
    }

    $result = parent::addFile($path, $local);
    if($result !== true) {
      user_error("Unexpected error while adding the file |$path| as |$local|");
    }
    return $result;
  }

  function close() {
    $result = parent::close();
    if($result !== true) {
      user_error("Failed to close (and build) the zip archive");
    }
    return $result;
  }
}
?>

Gotcha Of The Day: fopen(...) failed to open stream: Success

I'm updating a PHP app to generate a bunch of temporary files on the fly and ran into the oddest of error messages. I was basically saying:

  $stuff_name = tempnam("/tmp", "stuff-");
  $stuff_handle = fopen($stuff_name, "+w");

And was getting the error message:

Error Message: fopen(/tmp/stuff-K6Y5qv) [function.fopen]: failed to open stream: Success

Let me get this straight, there's an error, and yet the detail is Success. Huh?

Googling didn't help. So I went back and trip checked my work. And of course, there was an error. I said +w when I meant to say w+. D'oh! This code works:

  $stuff_name = tempnam("/tmp", "stuff-");
  $stuff_handle = fopen($stuff_name, "w+");

Wednesday, July 22, 2009

The Anatomy of A Blogger Gadget

Blogger gives you the ability to add gadgets to your blog to extend its functionality. While there are hundreds many (what the heck - the big list of gadgets seems to be gone?!) available, earlier today I had an idea for gadget that I couldn't find implemented. No problem, I thought I'd whip up my own. I clicked on the Add your own link and...

...got totally stumped. In all my poking around the Blogger help site, I couldn't find any documentation as to how you actually code the gadget. I found this promising article - but it just explains how you can put code on your website that allows people to add specific content with a single click. While useful, it's not what a gadget is.

Finally I found this announcement which solved the mystery: to create your own Gadget, use the Google Gadget API. Well, duh.

Also in my search, I found these real life examples which are especially helpful.

I'm quite impressed with the API, it seems really complete.

Next up - finding time to actually write the gadget. But, now that I know the API they use, that should be infinitely easier to do.

HTTP Caching Headers Explained

I always get confused about which HTTP caching header does what, and what the expected effect of each one is. So, I'm glad I found this caching tutorial which it explains it all remarkably clearly. If you're looking for a way to speed up your site, HTTP caching is big win - so check out the above tutorial.

I also found these articles valuable:

The last article is especially handy because it suggests changes that you can make in a .htaccess file, which is available to you even if you can't change the Apache global configuration.

Tuesday, July 21, 2009

Some Coding History

Google mentioned today that the source code for the Command Module and Lunar Module have been made available in digital form. You can actually read the source code that landed a man on the moon.

Wow, now that's some impressive programming. Not only were the computers incredibly limited, the programming bare bones, and science/art of developing software in its infancy - but one misplaced keystroke could easily cost people their lives. No 5 year beta testing period for this code. It had to absolutely work every time.

I'm humbled.

I wonder if the source code will be worked into the whole we-never-landed-on-the-moon conspiracy - as either proof against or for.

NSA for Kids - Huh?

I have to admit, I was quite surprised when I learned that the NSA - the organization that has a reputation for listening in on us - had a kid oriented site.

And the thing is, it's well done. If you want to teach your kid about ciphers and codes - this seems like a fun way to do it.

Look at that, who knew a government agency that at one point was denied to even exist, could be so warm and fuzzy?

McCain sinks to a new level

This just fires me up. I can't believe McCain has gone the route he has with this health care survey he's running. The e-mail I just got on the topic starts off innocuous enough:

Last week, I sent you an email asking for your voice on healthcare through Country First's Future of America's Healthcare Survey. I'm happy to tell you that over 30,000 people have filled out the survey online in less than a week. I'd like to share some of the early results:

You want to do the whole grassroots thing, excellent. More power to you.

The results are a bit troubling. Like:

90% of survey respondents believe America's healthcare system is the finest in the world, but still needs some reform.

Uh, who the heck cares what the perception of the Unite State's health care system is? In a case like this, the Senator should be looking at actual data, not what people think they think.

And then there's this whacky one:

80% of survey respondents believe the Federal Government should have no role at all in deciding an individual's healthcare.

I'm actually amazed it's only 80% and not 100%. Who, I'd like to know, is arguing for the federal government to make health care decisions for individuals? That's certainly not Obama's plan or anyone else's that I've heard of.

And then there's the survey itself. Calling it a survey is being generous - it's more like a fire-folks-up-so-I-can-get-the-data-I-want form.

And finally there's this gem:

As you know, right now, President Obama, Democrats in Congress, powerful special interests and influential lobbyists are hard at work in Washington, D.C. trying to drastically change our current health care system. They seek to replace it with a nationalized system where the politicians and government officials will dictate the kind of medical services you and your family receive and the rules under which you access care and coverage.

I don't know of a pretty way of saying this - this paragraph is a lie. If you want know what Obama's plan is for health care, then just watch one of the endless speeches he's given on the topic.

Two things tick me off about this e-mail: First, it's not helping us to have a constructive debate. Rather than talking about matters of substance, like how we can ensure the public plan and private plans have a level playing field, we're stuck debating imaginary ghosts.

Second, both Obama and Republicans appear to want the same thing: an incremental change to health care, not a massive overhaul; more choice for folks; and a financially responsible solution. Why do we have to behave as though we are on opposite sides of the spectrum, when we're really working off the same playbook.

I'll include my usual disclaimer here - I'm not picking on McCain or the Republicans. I'm just seeing devise chaff that's getting in the way of an important decision we are making as a country, and it ticks me off. If Obama pulled these same kind of shenanigans (and perhaps he is?) I'd be just as critical.

Can't we try acting like adults here?

Monday, July 20, 2009

The Uniform Project: 1 outfit, 365 days

Fashion has to be one of those topics that I know nearly nothing about - but even I can appreciate the challenge and creativity behind TheUniformProject.com. Here's how it works:

Starting May 2009, I have pledged to wear one dress for one year as an exercise in sustainable fashion. Here’s how it works: There are 7 identical dresses, one for each day of the week. Every day I will reinvent the dress with layers, accessories and all kinds of accouterments, the majority of which will be vintage, hand-made, or hand-me-down goodies. Think of it as wearing a daily uniform with enough creative license to make it look like I just crawled out of the Marquis de Sade's boudoir1.

And she's pulling it off:

What a fun example of how you can take your cause global with just a good idea and the web.

1Marquis de what? - ah hell, what do I know.

Sunday, July 19, 2009

Parting Shots

A few parting shots, as we had to say good bye to the twins this morning and head back home. We had a great time with them and their parents. We hope they all had fun, too!

I am really going to miss my work partner. Productivity may increase, but it won't be nearly as much fun. In this shot, I'm explaining to Chana the main key combinations she'll need when she's using Emacs. Helmy, as you can see, I start recruiting them young.

So, there's no blood relation, but tell me there isn't a resemblance!

Is that Shira with the twins again? It's amazing we didn't miss our flight home!