« December 2007 | Main | February 2008 »

January 30, 2008

Kurosawa Primer

Of Akira Kurosawa’s works that I have watched (20 of 31 available on NetFlix by last count)—and by far overall enjoyed—a few warnings and pointers:

  • Ikiru - Slow. No folks getting chopped up, no car chases.

  • Donzoko - Like the play it is based on, characters >> plot.

  • The Bad Sleep Well - difficult to follow opening. Excellent after that, with hints of Le Comte de Monte-Cristo.

  • Dreams - selection of very artistic short stories. I liked some, but not others—perhaps dreams are too raw for direct translation to film?

January 24, 2008

Power Grabs

VP Cheney makes strong pitch for telecom immunity. Why? What have the telecoms done to deserve this immunity? What has the government done to deserve this immunity? What prevents rampant abuse of these powers? I smell rats in Washington.

Guide to Dating

Hot springs microbes hold key to dating sedimentary rocks, researchers say.

“So one of the fingerprints of calcium carbonate deposition that will tell us for sure if there were microbes present at the time it formed is the rate at which it formed,” Fouke said. “And, within the environmental and ecological context of the rock being studied, we can now use chemistry to fingerprint the precipitation rate.”

In a second paper, to appear in the Journal of Sedimentary Research, Fouke and colleagues show how the calcium carbonate record in a spring’s primary flow path can be used to reconstruct the pH, temperature and flux of ancient hot springs environments. The researchers also show how patterns in calcium carbonate crystallization can be used to differentiate signatures of life from those caused by environmental change.

Technorati Tags:

January 18, 2008

Many Small Errors

Even after being warned of the various drawbacks of glob, a #perl user decided to use a sloppy glob call to count the number of files in a directory. Example code:

#!/usr/bin/perl -wl use strict; my $count = () = glob("/the/dir/* /the/dir/.*"); # Maybe need -2 to remove the Unix standard . and .. (and # then only on Unix! How do you know that?) print $count;

The reasons we warned against this quick and dirty code include:

  • Perl glob performs lstat - even if you are only counting files, Perl is also running an lstat call against each and every file. Why even pick a solution that does this?

  • The glob may not return the correct count, should something in the file path conflict with the special rules of glob. Spaces in the directory name is one way to trigger this. There might be more. Would you code with glob if it might randomly fail, especially when a solution without the wacky edge conditions exists?

The proper solution—opendir, readdir loop, and a counter—perhaps was “too long” or “not one line”, so disfavored by the user. This is bad laziness: a count_files_in_dir subroutine can contain the actual code, and be called from elsewhere. A subroutine also allows unit tests, unlike a single random line of code mixed into a larger block. Finally, the glob solution the user picked has holes in it—“oh, they would never happen”—sure they wouldn’t. For a while, and then people forget about the limited, buggy code, copy it somewhere else, and then bam! Bug.

Many small edge conditions and inefficiencies needlessly count against performance, and worse, increase the odds that some condition will tickle a bug, possibly causing a massive outage. I’ve seen a single misplaced $ in a shell script cause a multi-million dollar outage. Granted, there were also no unit tests and other best practices, but the point remains: avoid the small errors that could blow up if a condition changes, especially when other solutions abound.

A proper solution using opendir and readdir follows.

#!/usr/bin/perl -w use strict; my $directory = shift || die "Usage: $0 directory\n"; print count_files_in_dir($directory); sub count_files_in_dir { my $directory = shift; opendir( DIR, $directory ) || die "cannot open $directory: $!\n"; my $count = 0; # grep out the . and .. files on Unix here, # if necessary $count++ while readdir(DIR); return $count; }

Technorati Tags: ,

January 10, 2008

Photogamer

January 09, 2008

amazon-util - thin wrapper around Net::Amazon

amazon-util wraps the search() method of Net::Amazon, and templates the output. This allows book searches to quickly be turned into product links:

$ amazon-util mode books power 'title: Amazon Hacks' <a href=http://www.amazon.com/o/ASIN/0596005423…

And the results quickly included in HTML, especially with the help of pbcopy(1) on Mac OS X. Example product link: Amazon Hacks.

Technorati Tags:

January 06, 2008

Vegan Corn Bread

A vegan cornbread recipe won an award (some years ago, but better late than never), so I had to try it out. The recipe is very similar to my basic cornbread recipe, though adjusts the amount of baking powder and oil used, and uses all-purpose flour. I use whole wheat flour, which makes the final product look more like a health store refugee than a traditional cornbread, but what can you do? I also substitute grade B maple syrup, though this works equally as well as brown sugar.

Round 1

Grinding flax seed then mixing it into boiling water does quickly produce a sticky, egg-white-like mass. This adhered to itself a bit too well, resulting in flax seed streaks in the batter. Also, I used a small amount of apple cider vinegar in the soy milk, which perhaps was left too long, or the batter stirred to much, as the batter ended up far too sticky.

Round 2

Better luck this time. Switched to using ¼ cup grape seed oil, 1½ cups corn meal, ½ cup whole wheat flour, and 4 teaspoons baking powder. (More like the winning recipe… shocking!) Also, spent some time stirring the ground flax seeds in water, this time not over heat. Did not leave the apple cider vinegar long in the soy milk before mixing the liquids and drys. Batter much improved: mostly runny with a few sticky spots, able to mix briefly without too much flax seed clumping. Coconut oil works well to grease the cast iron, though I have yet to try seasoning a pan with it. Increased cooking time from 20 minutes to 25 on the second batch, which turned out perfectly: a nice browned, crisp crust, and good interior. This one is a keeper.

Technorati Tags:

January 05, 2008

Somewhat Free Music

Rap is not a genre I have explored much, though THE INEVITABLE RISE AND LIBERATION OF NIGGYTARDUST! is well worth $5: I’ve paid more for less interesting CD. Trent Reznor summarizes the experiment well:

I have to assume the people knowing about this project must either be primarily Saul or NIN fans, as there was very little media coverage outside our direct influence. If that assumption is correct - that most of the people that chose to download Saul's record came from his or my own fan-base - is it good news that less than one in five feel it was worth $5? I'm not sure what I was expecting but that percentage - primarily from fans - seems disheartening.
Add to that: we spent too much (correction, I spent too much) making the record utilizing an A-list team and studio, Musicane fees, an old publishing deal, sample clearance fees, paying to give the record away (bandwidth costs), and nobody's getting rich off this project.
   — Source: nin.com

Technorati Tags:

What Rocks Know

Earthquake 'Memory' Could Spur Aftershocks. This is neat:

Much to their surprise, the earthquake machine revealed that when sound waves were applied for a short period just before the quake, they could induce smaller quakes, or, in some instances, delay the occurrence of the next major one. The sound waves seemed to affect earthquake behavior for as many as 10 earthquake events after they were applied.

More surprising still, the team found that the granular beads could store a "memory" even after the system had undergone a quake and the beads had rearranged themselves.

"The memory part is the most puzzling," Johnson said, "because during an earthquake there is so much energy being released and the event is so violent that you have to wonder, why doesn't the system reset itself?"

Technorati Tags:

January 04, 2008

Microsoft Apologists

States struggling to maintain antitrust against Microsoft. The antitrust charges miss the leading flaw of Microsoft: massive security problems from an inferior product that no consumer should rightly pay for.

Microsoft systems are the most compromised system on the Internet. Millions of hacked Microsoft systems participate in zombie networks. Anti-virus software, forever out of date against new threats, tracks many thousands of viruses and malware for Microsoft. In response to these charges, Microsoft defenders always trot out the “well, if Linux had as large a market share as Windows, then Linux would have more malware and thereby zombie networks and so forth.”

This argument is inane. Notice the quick subject change from the clear and present danger of Microsoft systems to rampant speculation. The apologist hopes the conversation will be wasted arguing about a subjective claim of vulnerability equality in totally different code bases, not the fact that Microsoft systems have been and remain deeply and widely compromised.

Defenders, if pressed, will claim “well, you need to support Microsoft systems properly”. True, because Windows is needlessly insecure, and therefore a poor choice for consumers who does not know about these hidden costs. For HIPAA, SOX, and PCI compliance, Windows systems must run anti-virus software. Linux systems can bypass this requirement by virtue of not being Windows. On Linux, the primary reason to run anti-virus software is to keep the malware as far away from the flawed Windows systems as possible. This means, unless someone can present compelling evidence to the contrary, Microsoft systems are more expensive and less secure, by virtue of requiring antivirus software.

Worse, this cost of running Microsoft is also passed on to any Unix system that must also run antivirus software to keep the big bad Internet away from Windows, firewalls that protect Windows systems, and other expenses.

Why do people support Microsoft? The software is both insecure and expensive!

Windows is also “business ugly” (my summary of the overall Windows experience), and needlessly buggy (“oh, yeah, Outlook 2007 will freeze when you do that, you should check for a new service patch”), but that’s a totally different rant.

EPA--

The EPA voted for the cars, and against humanity. For a consistent 50 state rule, the EPA rejected the higher bar requested by California against smog and toxic releases. This pollution is known to cause asthma, allergies, and blood clots that lead to heart attack and stroke. These medical issues—the costs of treatment aside—cause needless suffering for those affected by the pollution.

2008-01-04 update: a new study links increases in carbon dioxide emissions to increased mortality rates.

Again: congratulations, EPA.

January 02, 2008

Summer Rolls

first day of the year
I think longingly of the sun
on those paddy waters
   — Basho

Japan Gregorianized in 1873, meaning Basho actually wrote this poem for a different new year’s day. Calendar musings aside, the sun and paddy waters naturally recommend Summer rolls (Spring rolls without all the frying). These are tricky to make, as rice paper requires some practice to master. I did not like using noodles in a first attempt, so substituted adzuki beans. This recipe made eight far too large rolls.

  • ½ cup adzuki beans, boiled
  • 1 cup peas, steamed
  • 1 cup Hon-shimeji mushrooms, steamed
  • 1 cup shiitake mushrooms, steamed
  • ½ cup carrots, steamed
  • Shaved ginger, to taste
  • Ground black, white, and Sichuan1 peppers, to taste
  • Ground India red chili flakes, to taste
  • 1 teaspoon sesame seed oil
  • 2 teaspoons soy sauce

The above was mixed and used as filling. Good, but many improvements can be made:

  • Must cut the ingredients by half, as otherwise too much food for just me.
  • Less filling per roll: half as much or more. Pictures online show the excess wrap extends around the entire roll, not the 40% - 50% I get.
  • Lettuce would better help hold the ingredients inside, and add some crunch. Also need to reduce the amount of peas, perhaps replacing some with daikon or some other vegetable.
  • Make the dipping sauce in advance, as the Summer rolls must be consumed quickly before the wrap dries out.
  • Grill the mushrooms, or add more sauce to the filling. Maybe also blend the filling lightly, to better incorporate the flavors?

1 Warning! Excess Sichuan pepper numbs the mouth, creates an overpowering taste, and makes one drool. I only used a dusting of black and white peppers, along with a reasonable amount of Sichuan peppers here.

Technorati Tags: