Movie: “Lust, Caution”

Yesterday, I took a day off and went to see this new Ang Lee’s new movie “Lust, Caution” with my wife. There were only two movie theaters in the entire Silicon Valley showing this movie – probably due to the NC-17 rating and the fact that the almost the entire movie are spoken in Chinese Mandarin – some parts were in local dialects of Shanghai and Cantonese. We went to see it at the Prune Yard in Campbell. (It’s been a long time (> 2~3 years) since I visited Prune Yard. Lots of the new shops were opened – very nice.)

I don’t think there are many movies that make you think and wonder about what you would have done in their shoes after seeing the movie. The movie was derived from a short story (28-page, 14 pages from my printer) by Chang, Ai-ling, a famous Chinese writer famous for her “strange” writing – my wife and I were not fond of her fictional stories. The story took place in Shanghai, 1942 during the Japan’s occupation, about a young, naive young college drama student who embarked on an attempt to assassinate at Mr. Yee, the evil traitor of the Chinese people but she ended up falling in love with him …

I had the benefit of seeing the interview of Ang Lee and Tang Wei (the leading actress) the night before on the Chinese TV channel. Ang Lee talked about how he first read the novel and put it aside for several years due to its short length but the story kept a deep impression on him. The story plot was simple and yet deep enough to make him wanted to do something about it. He had to add a few more plots and revised the order slightly to make the story more coherent. He hoped and believe that he had achieve the desire outcome of the the original author. He also wanted to use the movie to remind the current generation that part of Chinese history that has started to fade in people’s memory. It’s not something an American can readily appreciate, as mentioned to Ang Lee by an Indian interviewer a day earlier because America was never occupied by another foreign entity. Tong Wei, who portrays the Mak Tai Tai, is a new rising star and clearly carries the movie, along with Tony Liang. The main female character, as insinuated by Tong Wei, represents heart and soul of the author (Chang Ai-Ling), who did not have her parents while growing up and craved for the love and affection. The author was torn between the rational (cautionary) part of her to rid the country of this traitor and the lustful/passionate side of her who craved for the love and affection from this person, who truly fell in love with her. At the end it was the passionate part that won her over and she lost her life for it.

There were a few (~5) “bed” scenes in the movies. As defended by Ang Lee, there were three development stages of relationship between the evil man and his assassin. The sex scenes were artfully and sensually done and are probably needed to show the “lustful” side of main characters and the sacrifice and the internal struggle of the woman assassin. Would the movie miss any of the sex scenes, probably so. But, I don’t think the movie would have been rated NC-17 in a more liberal countries like those in Europe.

Overall, I love the move. Ang Lee really made a faithful attempt at bringing back the era – the people, the place, the conflicts, and mostly the hearts of the souls of these people living in that era. I think this is the best of Ang Lee. “Crouching Tiger” and “Brokeback Mountain” are for Americans. This one is for the Chinese people. Bravo! Bravo!

lust-caution.jpg

Keeping Things Simple is Complicated and Takes Hard Work

I notice that my desks at work and at home get messy once every one or two months or so. Then I would force myself to clean it up, which takes a lot of work to sort things out and throw out or file them away. The same thing happens to my email inbox. I would have the emails accumulated to many thousands and then slowly work them down to a few thousands. I kept asking myself, why can’t I just keep things simple so I don’t have to accumulate things that need to be sorted out or “managed” later. Based on my observation of my own behavior, the basic answers to that question are twofolds:

1. Self-induced: Life is too boring to be kept simple. There are always exciting books to read (I borrowed lots of books from library on a regular basis as you can tell from my book review blogs). And there is a always a tendency to put off doing the boring stuff of reading, sorting and filing. The common excuse I have is that the things may come in handy later or I’ll get to it soon enough. Sometimes, I would initiate a new project/experiment just for the fun of it. Meanwhile, stuff piles on the tables.

2. Externally-induced: Life is full of “shocks” and interruptions. At work, there are crises to fight, new initiatives/fire drills to lead and complete from the management, customers, and colleagues. Every time a new crisis happened, the emails get queued up in order to maintain the historical perspectives or the regular work queued up in the inbox.

Physics’ entropy theory holds up well here. Entropy tends to go up or things tend to go chaotic naturally. To reduce entropy, it takes energy and work.

So here are the solutions I propose:

1. Bound the self-indulgence. I’d like to set a limit on how far I drift away from my simple life. For example, set a time limit on how long a pet project (e.g. composting, books to read) should last. I also set a limit on how long I should spend reading a book. (By the way, the library sets a limit on how long I can borrow the book so I’m set there). I also clean up my desk every two weeks or so to avoid our housekeeper from going through the desk during my absence.

2. Be conscious of the mounting complexity by benchmarking the email inbox: I found that my work is tied very closely to the email inbox. The more I allow the emails to queued up, the more work I queued up for myself. So the best way is to manage the inbox pro-actively. Using the new email statistic software I came up with, I’m now benchmarking against the goal of keeping the emails in the inbox for 60 days or less and continually reducing my inbox email count.

3. More delegations and automate the mundane work: Delegating the work to more competent people may help if managed properly. The key word is “manage properly.” Delegating to the wrong person or not managing properly may lead to more work later. Automating the bill pay process, taking a chapter from the “Automatic Millonaire,” helps to reduce life complexity and keep me from paying late fee.

4. Be prepared/preventive for crisis/external shocks: Keeping an eye out for upcoming crisis can help simplify life a bit. I use emails to do this. I tend to over-subscribe to certain alias so I can watch out for upcoming crisis. Of course, this works against keeping things simple but preventing a crisis from occurring is more valuable to me. There needs to a good balance.

5. Reduce commitments
: The best way to lead a simple life is not to have too many commitments/responsibilities. At some point, if you feel you cannot stay above the water, you should reduce the water level (work load). The majority of the extra workload that complicates things is the quantity of them. You’re bound to drop a few balls if you juggle too many balls. Delegate them (#3) or just don’t commit to them.

In summary, streamlining work is a lot of hard work but allowing it to get too complicated may take even more work later on. An ounce of prevention goes a long way.

I came across the Simplicity Pattern video on Youtube. It’s very funny.

Imap Email Statistics with PHP

Below is a PHP script that I run daily (via a cron job) to check my imap email statistics. It generates a report like below. I use this statistic report to tell me how behind I am on my emails. It also reports a distribution of the emails for the last few weeks. You can run it on the web browser or run it on php command line (command: “php imap.php”)

Derek's INBOX Statistics:
Total number of mails = 2842
Month 2007-08 has an email count of       528   ( 15.9 MB)
Month 2007-09 has an email count of      1210   ( 76.7 MB)
Month 2007-10 has an email count of      1104   ( 79.7 MB)
Week[-8] has an email count of     81   (  3.1 MB)
Week[-7] has an email count of    186   (  5.8 MB)
Week[-6] has an email count of    200   (  5.6 MB)
Week[-5] has an email count of    198   (  6.8 MB)
Week[-4] has an email count of    298   ( 19.5 MB)
Week[-3] has an email count of    336   ( 21.4 MB)
Week[-2] has an email count of    339   ( 26.8 MB)
Week[-1] has an email count of    530   ( 33.6 MB)
Week[-0] has an email count of    674   ( 49.7 MB)
Total mail box size = 172.3 MB
Maximum email size  =   2.9 MB
Earliest email date = 08/14/2007 (58 days ago)
Elapsed time = 2 seconds

================ imap.php ========================================
<?php
global $tdate, $today;
$tdate = getdate();
$today = $tdate[0];
$php_out = 0; /* =1 if html format is desired. =0 for std text output */
$max_msg_size = -10.0;
$earliest_date = $tdate[0];

$start_time = time(); /* capture the start time for elapsed time calculation */
if ($php_out) {
   print "\n";
   print "<h1>Derek's INBOX Statistics:</h1>\n";
}
print "Derek's INBOX Statistics:\n";
$total_size = 0.0;
/* Replace the following line for your application */
$mbox = imap_open("{yourhost.com:993/imap/ssl/novalidate-cert}INBOX", "username", "your_password");
$n_msg = imap_num_msg($mbox);
if ($php_out)
   echo "<h2>Total number of mails = ".$n_msg."</h2>\n";
else
   echo "Total number of mails = ".$n_msg."\n";

for ($i=1; $i<=$n_msg; $i++) {
  $header = imap_headerinfo($mbox,$i);
  if ($header == false) {
     echo "Call failed
\n"; break; } else { $size = (float) $header->Size; if ($size > $max_msg_size) $max_msg_size = $size ; $msg_date=strtotime($header->Date); if ($msg_date < $earliest_date) $earliest_date = $msg_date; $month_key = date('Y-m',$msg_date); if ( is_null($msg_month[$month_key])) { $msg_month[$month_key] = 0; /* $msg_size[$month_key] = 0.0; */ } $msg_month[$month_key] += 1; $msg_week[getweektodate($msg_date)] += 1; $msg_week_size[getweektodate($msg_date)] += $size; $msg_size[$month_key] += $size; } } foreach ($msg_month as $key => $mon ){ $size = $msg_size[$key]/1e6; $total_size += $size; printf ("Month %s has an email count of %5d (%5.1f MB)\n",$key, $mon, $size); } foreach ( $msg_week as $key => $num ) { printf ( "Week[-%d] has an email count of %5d (%5.1f MB)\n",$key,$num,$msg_week_size[$key]/1e6); } printf ("Total mail box size = %5.1f MB\n",$total_size); unset ($key,$mon); $time_elapsed = time() - $start_time; printf("Maximum email size = %5.1f MB\n",$max_msg_size/1e6); printf("Earliest email date = %s (%d days ago)\n",date('m/d/Y', $earliest_date),($tdate[0]-$earliest_date)/60/60/24) ; print ("Elapsed time = $time_elapsed seconds\n"); imap_close($mbox); if ($php_out) print ""; function getdaystodate($indate) { return ($tdate[0]-$indate)/60/60/24; } function getweektodate($indate) { global $today; /* echo "Indate= $indate, today = $today\n"; */ return ((int) ($today-$indate)/60/60/24/7); } ?>

Book Review: “Confession of an Economic Hit Man” by John Perkins

This book is a tell-all book about an economist, John Perkins, who used his profession to cook up the growth projection on engineering projects so US engineering firm, like Maine, can put the 3rd-world country in deep debt (loaned by IMF) to US that they would need to give concession to US demands. According to the author, this was the early stage of how US extends its global empire. Later, there were oil-rich countries like Saudi Arabia, and Shah of Iran, who didn’t need to borrow but US still offers “protection” in exchange for profitable engineering projects for US contracting firm.

This books reads like a James Bond scripts. It has all the money, greed, sex, conspiracy, bad-boy-turn-good elements. Whether this is true, which I believe the majority are, this book answers a lot of my questions in my mind.

Why the 3rd world countries hate us so much? Because we went the economic hit men into their countries and hi-jack their natural resources and enslave them to be subservient to US, the global empire. He went into great details about how he started his job in Indonesia and went on to Panama, Iran, Saudi Arabia, Ecuador, Columbia, and others. He dove into great details about the Panama strong man, Omar Torrijos, who stood up to US (Jimmy Carter) to negotiate the Panama treaty that returned the canal back to Panama and how and why he was allegedly assassinated by CIA because of his stand.

Why we went to war with Iraq? Because Saddam didn’t want to play the game with US to allow US to handcuff him to US policy. The Bush administration is full of people from the oil firms, contractors, engineering firms that would benefit from invading Iraq so they can get their pound of flesh. And US also needs another oil ally from Saudi Arabia to crack the Opec’s grip.

John Perkins compares the modern “corporatocracy” to the British empire back in the 18th century. We are now applying the same behavior/strategy to the 3rd world countries as British had done to US, in the same of capitalism but no less than a outright economic imperialism. This makes other hate us and envy us at the same time.

The fight between Amazon indigenous people and the oil companies who stole the land from them highlighted the greed and anti-environment stands of the oil companies. By continuing to consume the largest share of the oil in the world, we American are perpetuating the bad corporate behavior while jeopardizing the rain forest, the environment, and the survival of the people who live on the land.

Writing this book is probably therapeutic and self-serving to him, allowing him to rid himself of the guilt of being part of the “system” that rape other countries’ natural resources and enslave their people so they would never become self sufficient. On the other hand, I’m suspicious of the “facts” presented in the book. But I applaud his courage in revealing the dirty little secrets.

The author also reminds us that we may be working unintentionally to extend the global empire. Watch out for the corporate policy that you work for and the products you buy from. Cut down our oil consumption. Know the potential consequences of our actions.

Overall, this is a great audio book. Mr. Perkins is a good writer and story teller. I learned quite a few things about how the US political system and world politics work. Some of South America history was very enlightening. I always had doubts about the motivations behind some of the US’ policy toward certain countries. This book answered a lot of my questions.

ehm.jpg

Movie: “The Brave One” by Jodie Foster

A radio talk show host (Jodie Foster) went on a vigilante rampage after being victimized in the Central Park of New York. The plot was simple and quite believable. One can definitely relate to the character and would probably feel the pain of the character.

The pace was slow, allowing time for the character to develop into a justifiable executioner with a steady hand. She was out to find the gang that killed her finance and took justice into her own hand. The surprising part is that the cop went along with her to help cover it up. I don’t know if it’s out of his own love for her or is simply showing his own true color.

Lots of violent scenes – not for the faint of heart. Could have shortened the time by 20 mins or more. Jodie Foster’s acting was fantastic.

Book Review: “The Old Man and the Sea” by Earnest Hemingway

I happened to come across the audio version of the “The Old Man and the Sea” while browsing in the library. The book was short and sweet. Donald Sutherland narrated the entire book. He sounded like the old man with all the emotions, sometimes upbeat, and sometimes sad and despaired. Unfortunately, the words were sometimes hard to resolve in the noisy environment in the car.

The old man, Santiago, had gone 84 days without catching a fish. The boy, the old man’s apprentice, was told by his parents not to fish with the old man because of the aura of the bad luck. Then he went out to the ocean and caught the biggest marlin no one had ever seen. He struggled with the fish to reel him in for several days. When he eventually did, the sharks had a better part of the big fish and the old man came home empty handed.

Symbolically, the big fish was like the old man, enjoying the good long, strong life at the top of the food chain until the fate eventually caught on to him to be caught by the old man and met his death. The fish was calm and gracious/classy, putting up 3 days of fight without showing any kind of panic. Ironically, the old man felt really bad about ending the fish’s life but justified his death by enriching other village people’s life and his with this big fish. Of course, the plan did not work out as sharks had all pecked away the flesh of the fish by the time he returned to the shore. The old man fought gallantly off the sharks and killed a few sharks throughout the trip home. At times apologetically to the fish and at times feeling sorry for himself, the old man finally succumbs to the fatigue and sadly to the defeat. The old man lost a piece of himself, pride and humanity, in the entire journey.

The boy showed tremendous loyalty and respect to the old man in the entire story. The innocence of the boy was the comfort and the pride of the old man – his legacy.

From the art of the war angle, spending all your effort and resource to defeat a major competitor may be the worst thing that could happen. Because it may invite other competitors (like sharks) to come in the market and peck away your profit. Our MBA lesson on Coke vs. Pepsi is exactly that. Duopoly is a huge stabling factor in a mature market.

This story also taught me something about getting old gracefully. Having respect for life and understanding your limitation go a long way.

old-man-and-thesea.png

Searching for a bug in a haystack – cracking the codes of Inventory Management System

My work was in need of a simple inventory management system to keep track of the prototype components. I have been given a small budget to buy one. So I went on Internet to search for a reasonably priced inventory management system. Most of the solutions are a bit too powerful for what we need, thus are too expensive.

Three weeks ago, I came across an open-source inventory management system. So I downloaded the source files (mostly php files) and started running it. I ran into several issues but was able to resolve most of them – due to file/directory privilege and dos/unix file transfer issues. All except one: the default “date” in a part transaction are all showing up as “{NAME}” instead of the numbers on the month/day/year fileds. What’s going on there? This plunged me into the world of php, xml, ajax, css and etc. I borrowed books from library like “PHP/MySQL for dummies” and “PHP 5 Advanced” by Larry Ullman . Both were very nice books in helping me to understand the intricate interaction between PHP and MySQL. I learned a lot of object-oriented programming (OOP) and a little bit on Ajax. But having learned the basic probably helps me to start a small project on my own. Tackling a full-blown sophisticated software like IMS that I downloaded was a totally different story.

By far the worst part about developing or debugging a PHP software/module is the fact that you’re dealing with a software running on a remote host and displaying the output on a browser. It’s difficult to insert variable dumps along the way to keep pace with the program flow because there is no console screen and showing the raw variable values on the browser may screw up your display. Not an easy thing to do. So I searched the net to find a debugger. The most popular debugger is NuSphere’s PhpEd. I downloaded the trial version and started debugging. I never used a debugger before so I needed to get used to the interface plus interrogating the variables values while tracing the program steps. Overall, the software does its job well and is fairly powerful. I don’t think I could have found the bug without its help. I think I’ll buy the software. See below for the exact bug.

After tracing this software code, I was very impressed with the author’s programming style and his modular approach. Modular is nice because it’s readily expandable but it’s very difficult to follow due to the jumping around among the classes/files.

By working with the debugger, I now understands a little bit about how the program works. I was then able to modify the titles and changed the fields slightly to meet our needs. Proudly, I demo’ed the tool to my technician crew who will be using the software to track our inventory. And guess what? They wanted to add a “project” field and a search function. That’ll teach me a lesson to download a freeware. 🙂 I did learn a few things along the way but may end up supporting/expanding the software for the rest of my career 🙁

=======================================================================
Here’s the bug I found around line 122 on “lib/html.php”:

if (is_array($extra_vars[$key])) {
$repl_array = array_merge($repl_array,$extra_vars[$key]); }
/* In the above “is_array($extra_vars)” got changed to “is_array($extra_vars[$key])” by Derek Tsai,
$repl_array kept getting NULL’ed due to array_merge with a NULL variable */

Learn by Blogging (and Sharing) – Derek Tsai's Personal Blog