|
Movie - The Blue Kite
|
9/18/2005
|
Today is 09/18, a day of humiliation and sadness for most of Chinese to remember by. However, in Chinese lunar year, today happens to be the Moon Festival. When in the bittersweet I skim through some old words I left before, I come across the following writing. It was an article I did exactly two years ago from today, for a movie few of us even know its existence.
Sep 18, 2003
To the Tenth Anniversary of the lonely Blue Kite
It was purely coincidental. I ran into this movie in the BlockBuster a couple days ago. It is a Chinese movie called Blue Kite, but I've never heard of it back when I was in China. Later I asked many of my friends, none of them has any knowledge of this movie. Ten years after its making, it all seems that this kite has long been mothballed.
The movie itself is regarding one of the harsh periods in the annals of China history. Anti-Righty, Great Leap, Culture Revolution, those are always the painful emotional scars that cut deep. But in spite of all the mishaps, our protagonists have never lost faith in life. They uphold what they believe is right and share the spark of joy even in the face of grave adversity. They care about each other, stand together to weather through the most difficult days. They always pledge themselves for a better life no matter what. Maybe that is why after so many defeats and humiliations, we, as a nation, are still able to survive in this harsh world. We are resilient.
The inhospitality placed on this movie and its director is another side of the story, which, along with the period of time it's associated with, is for many to debate, and to contemplate, for long to come.
It happens to be Sep 18 when I write this review, which brings up another painful memory for most of us. I do wish we would never ever have to endure the suffering once again.
|
Briefcase - comb, iComb and brace
|
9/11/2005
|
I once deemed myself as a code stylist 'cause then I was so bewitched with the aesthetical format of my code. However, in the past long while, under the pressure of hectic and erratic schedules, what I did was largely against my conviction of perfect code. In spite of all the wrongdoings, my "soft conscience" still led me to a few tools that I gleaned and tailored during my humble living. For download, please go to Ref[1] for detail.
The first two tools I call them "comb" and "iComb". When I learn the C language the first time, text books often presented code in the so called K & R style, like
if ( a != b ) { ... printf(" a!=b\n"); }
Conversely, there is another commonly used style (I believe there is an official name for it as apposed to K&R, but it slipped off my memory at this hour. That happens a lot lately on an old dog like me. ), more like
if ( a != b) { ... printf(" a!=b\n"); }
The "comb" would tailor the code into my favorite K&R-like style. The "iComb" would turn the code into the style that is more close to the second template. As a matter of fact, I adapted these two tools from the renowned open-source tool "indent", but I changed the settings to fit my peculiarity. Needless to say, "comb" and "iComb" are also open-source. All the kudos to those made "indent" in the first place.
Speaking of "indent", I made another tool from it for the so called "brace law". I coined this phrase to refer to how braces are used on if/while/for statements even there is only one statement follows if/while/for.
e.g. if ( a != b) ... printf(" a != b\n");
I prefer it to be as if ( a != b) { ... printf(" a != b\n"); }
If brace law is enforced, you could use macro definition freely, and you don't need to worry about the inadvertent mistakes you or someone else may introduce when extra code is appended later on.
The usage of brace is as
brace fileName
And the line number of brace law violation will be listed out, such as
### brace rule violation, on line 117 ### brace rule violation, on line 129
The brace can only take one file at a time. To go extra miles, make it handle the whole directory, certain script may be necessary.
One way to do it is through Windows batch file. Actually, due to the limits of Windows' cmd shell, I have to make two batch files, working together to get the job done. (Maybe there is better way to do it with just one batch file)
The first batch file is pauBrace.bat, which simply provides the check the return status of brace.exe. When the file can not pass brace check smoothly, it will simply pause
[pauBrace.bat]
brace %~f1
@if %errorlevel% NEQ 0 pause
========== END OF FILE =============
The second file is dBrace.bat, which will traverse the whole directory and invoke pauBrace.bat for each file. That is the main batch file that should be called upon by user.
[dBrace.bat]
@setlocal
@cd /d %~f1
@if "prefix%~f1" == "prefix" @goto usage
@if /i "prefix%~2" == "prefix/r" for /R %%f in (.\*.c .\*.h) do @pauBrace.bat %%f
@if not "prefix%~2" == "prefix/r" for %%f in (.\*.c .\*.h) do @pauBrace.bat %%f
@goto end
:usage
@echo usage: %~0 directoryName [/r]
:end
@endlocal
========== END OF FILE =============
I strongly believe the code style should be enforced in a certain way to confine those quirky, aberrant programmers who are full of themselves. My understanding is that the whole idea of code style enforcement is not about personal recognition or ostentation, but rather a matter of process and team work so that each and every one's contribution could be splice together seamlessly to pursue the same cause - make the whole project a successful one.
Speaking of process, I would like to wrap up by quoting words from Jack Ganssle's article (Ref[2]):
…Software artistes have missed the "process" boat. Most other industries use various sorts of defined processes to work efficiently. One way to identify an amateur organization of any sort, be they accountants, lawyers, craft shops, or software developers, is a lack of process. By contrast, an efficient company like McDonald's defines a rigorous way to do just about everything. Even a teenager, using Ray Kroc's process, can crank out Big Macs that taste exactly the same anywhere in the world...
References: [1] HAHAHAHA's Briefcase [2] Bailing Frantically, Jack Ganssle, Embedded Systems Programming, 09/11/03
|
...including Iran and China
|
9/05/2005
|
Yesterday when I was watching the NBC11 nightly news, I happened to hear the following on KATRINA relief: "... more than 60 countries have pledged to help, including Iran and China..."
Can't believe China got bonus publicity in this way...
I have always had respect for the people of US, largely out of their wisdom, optimism and perseverance in times of adversity. However, the recent mishap in New Orleans did reveal the other side of their characteristics. In that sense, it probably reflects a tribute that lies in all human beings.
People's moral standard is closely coupled with their instant economical status. When they are deprived of the basic means of living, the contention of scarce staples becomes ferocious all of a sudden. Mob mentality is developed. People begin to ransack stores and kill each other for survival.
Another emotional mode that many people tend to shift into is grumble. People turn cantankerous or dreadful, lay blames on others that are partially or fully responsible for their misery. The mumble could sap their last stamina to recover.
We all carry heavy hearts. We care about those lost everything in this tragedy. However, technically, what happened in New Orleans does show that the best way to cripple a nation probably is not nuclear bombs but to throw a large number of them into extremely harsh condition and let the infighting take its course.
|
Lab Notes - Debug Print and Assert
|
9/01/2005
|
Many embedded application does not have the luxury to hook up source level debugger. Often times, debug print is the only way out. Here are some of the ways to make a debug print macro
*) Easy and Lazy one #define DEBUG_OUTPUT(val) printk(val) #define DEBUG_OUTPUT2(val1,val2) printk(val1,(int)(val2)) #define DEBUG_OUTPUT3(val1,val2,val3) printk(val1,(int)(val2),(int)(val3))
*) if(...). I see it often used in many script language
extern u8 debugPrintOut ; #define DEBUG_PRINT if(debugPrintOut)printf("DEBUG: "); if(debugPrintOut)printf *) works at least for GNU C #define DEBUG_PRINT(fmt, args...) printk("DEBUG: " fmt, ##args)
*) borrowed and tailored from Microsoft DDK example #define DebugPrint(_x_) DbgPrint ("DEBUG:"); DbgPrint _x_;
The drawback for this is that everywhere you invokes this macro, you have to put double braces.
Besides the debug print, assertion is also indispensible. What's interesting is the so called compile-time assertion, which can be found in Microsoft Windows DDK, ntdef.h.
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
The detailed explanation of the above setting can be found in Ref[1]
By the way, there is another useful macro in the ntdef.h for struct alignment
#define TYPE_ALIGNMENT( t ) FIELD_OFFSET( struct { char x; t test; }, test )
References: [1] Catching errors early with compile-time assertions, Dan Saks, Embedded Systems Programming, 07/2005.
[2] Microsoft Windows DDK (3790.1830)
|
|
|
*)
Grand Opening
*)
Why HAHAHAHA
*)
Stay Foolish
*)
Rabbit Hole
*)
Blotter
*)
Notebook
*) Blotter
*) Notebook
*) Rabbit Hole
*) I Love Rei
*) TEXT2PNG
*) China Blog List
*) Bertrand
*) Bruin
*) Bulldog
*) Hua
*) Mas
*) Nimrod
*) Philewar
*) Rodent
*) Samuel
*) Tom
<< Home
|