Sunday, December 31, 2006

Old Shirt

Time to be sentimental: this shirt has followed me a long way. From US and back, then to Ireland, Hong Kong, and most recently, Singapore. I usually keep it in my luggage and bring it everywhere I go. However after this Singapore trip, I think it will be kept in the luggage for a long time, if not forever.

This is the closest I can get.

New Year Clean Up

A few people asked what I am up to for the new year eve. I replied "Clean up my room, and do some planning and thinking for the new year."

The response may sound cheesy, however I am serious in reducing the complexity in all fronts of my life. More specifically, I set out to reduce entropy as much as possible.

"A picture tells a thousand words", so the idiom goes. Here I have 4K-words worth of pictures:

Cleaning the book rack



Books everywhere

During the height of my reorg, all drawers unpacked

Done!

Forrest Gump has a metaphor of life is like a box chocolate, you never know what is inside until you open it.

My metaphor is as follows:

Life, is like a Windows machine: you never know when it will crash.

Happy New Year

Internet and My Daily Life

Recently the earth quake in Taiwan had caused a world-wide havoc: it torn off the communication links connecting Asia and US.

For days the Internet was excruciatingly slow, or downright dead upon loading. I heard news reports of some Internet users started to get irascible, uneasy, and even sleepless for lost of Internet connection. Typical symptoms of addiction.

For me initially that was some discomfort as my periodic goofing off had come to an end. But after some time I found out I am more productive and can actually think more without Internet.

To start with I am not a big fan of using the modern tech devices, especially handphone and TV. After finding out I can actually live with minimal Internet usage, imagine how much time I can save on this?

To celebrate this new-found reality, I rushed out and bought two books from the Borders. Ok ok, I said I won't buy books anymore, but hey, this is eventful enough to warrant some books. No?

Tuesday, December 26, 2006

New Year, New Resolutions

I am back from the Singapore. It was quite a pleasant trip which let me to uncover a lot of things about myself, Malaysia, and Singapore. I shall list these one by one.

My original plan was to visit Mr. Snail and hopefully, MAK. No doubt I met snail and he was alive and kicking. My first gratitude goes to him who has played host for the entire duration and survived my MAK-induced mood-swings these few days. Anyway, I will leave this topic alone for the mean while.

Now we have the topic of Malaysia vs. Singapore. There isn't much room to argue in term of positive metrics: economics, competiveness, or competency. One of the items kept echoing in my head has been: why stay in a place where you are not likely to fully utilize your potential? The pressure is there, and I am sure it will be tougher to work in Singapore. Regardless the result, myself, my parents, my PC, and even my cat in heaven will be proud of the fact of at least I have given it a try, and mind you I am confident I am as good as any engineer out there with comparable experience and education level. So just bring 'em on.

Before I sign off, here are some pics of Singapore. :)

Modern art in the exhibition center




Taken from Esplanade

Thursday, December 21, 2006

Cuppa Chai - On Vacation

I will go to Singapore to visit Snail and hopefully, MAK (hello, you there?)

Most probably no update until Dec 26, 2006.

Merry Christmas!

Little Wonder

The yellowish stuff on the floor are steamers, made from bamboo for steaming food. These utensils are used to cook and warm the food during 'yum cha' (Hong Kong style breakfast with hot chinese tea and special dishes).

Penang is still keeping Chinese traditions on bay.

Life consists of little wonders that we come across daily. =)

Tuesday, December 19, 2006

Another Day in Fire Fighting Mode

It's yet another day in my in-job fire fighting.

Exhausted but have learned a lot on hardware and in particular, labview programming. My Christmas vacation is getting closer and naturally, I am looking forward to it.

Saturday, December 16, 2006

Other People's Problem

OPP stands for "Other People's Problem", unlike Other People's Money (OPM), OPP isn't something you will enjoy. However in life sometime you are unlucky enough to get trapped in OPP and have to clean up others' mess.

I got this thought after working for the whole Saturday in office, troubleshooting and testing a shit created by other people. The funny thing is the guy who started all this mess didn't come to office. Adding insult to injury is I still got to get back on Sunday. Duh.

Though ranting as I am, this company is at least doing more right things than the wrongs compared to 'Company I' which screws up in every way imaginable. I wonder if Sir Murphy has significant stake in it.

As a corollary of my hypothesis: "when a good employee joins a bad company, usually the latter reigns", I truely belive this applies not only to companies, but also to countries equally well.

Thursday, December 14, 2006

GnuCash 2.0.3 Bug Fixing

(gnucash:12739): GLib-CRITICAL **: g_date_set_month: assertion `g_date_valid_month (m)' failed

(gnucash:12739): GLib-CRITICAL **: g_date_strftime: assertion `g_date_valid (d)' failed
I had seen the error messages above so often that after 10 minutes, I decided to fix them.

I searched for the error messages and soon landed at the month_name function in src/gnome-utils/gnc-dense-cal.c

#define MONTH_NAME_BUFSIZE 5
/* Takes the number of months since January, in the range 0 to
* 11. Returns the abbreviated month name according to the current
* locale. (i18n'd version of the above static character array.) */
static const gchar *month_name(int mon)
{
static gchar buf[MONTH_NAME_BUFSIZE];
GDate *date;

memset(buf, 0, MONTH_NAME_BUFSIZE);
date = g_date_new();
g_date_set_month(date, mon);
g_date_strftime(buf, MONTH_NAME_BUFSIZE-1, "%b", date);
g_date_free(date);

return buf;
}
The comment above has it: the variable mon will be from 0 to 11 and the number 0 is what choked glib. This is done.

Next, the error message on strftime is cryptic. I went online and searched for what actually g_date_strftime expects and what g_date_new does. From a reliable source, it seems g_date_new creates a new date which is invalid, to make it valid we can use the function g_date_new_dmy.

With all these, let's whack the bugs:

#define MONTH_NAME_BUFSIZE 5
/* Takes the number of months since January, in the range 0 to
* 11. Returns the abbreviated month name according to the current
* locale. (i18n'd version of the above static character array.) */
static const gchar *month_name(int mon)
{
static gchar buf[MONTH_NAME_BUFSIZE];
GDate *date;

memset(buf, 0, MONTH_NAME_BUFSIZE);
/* date = g_date_new();*/
date = g_date_new_dmy(4, G_DATE_JULY, 2006); /* initialize to sane value */
/* printf("%s: setmonth is %d \n", __func__, mon); */ /* Debug statement */
g_date_set_month(date, mon+1);
g_date_strftime(buf, MONTH_NAME_BUFSIZE-1, "%b", date);
g_date_free(date);

return buf;
}
GnuCash developers have my permission to incorporate this fix into the project if they wish.

Upgrading GnuCash

Gnucash 2.0.3 is out. Since there are some weird stuff in 2.0.2, I did an upgrade to see if the bugs are fixed.

Compilation was really a breeze because the Gnome environment is already up (I am using garnome). All I have to do is to issue the following commands:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:[path to gnome pkgconfig directories]

export PATH=$PATH:[path to gconftool-2 directory]

./configure --prefix=[path you want]

make;make install
My build was done without any errors after about 20 minutes. During execution there were some warnings from Glib on illegal parameters for the date functions.

I grep'ed the code and opened up a few C files which had the matching string.

The programming style is certainly not defensive: return values not checked, shabby handling of pointers, use of magic numbers, etc.

Some people argue on the ground that checking all these will slow the program down and add overhead. Well, this argument is only valid in very few corner cases where timing is very critical and computing resource is extremely tight. I don't see these conditions exist for most projects, including this one.

Given these folks are working on this project for free, and the fact that some salaried programmers are writing even crappier codes. I can't complain.

Wednesday, December 13, 2006

Tenacity

Found these plants amazing. They survive and thrive under such bad condition. Note this is a tennis court at a 5-storey building top. The soil is the accumulation of debris and dusts carried by wind over the years.



So, our upcoming motto: fight like a plant (or does 'veggie' sound better?)

Monday, December 11, 2006

QueensBay Mall and Question on Homegeneity


Tata, here you go: QueensBay Mall, the latest and supposedly the greatest place in Penang to burn your money shop.

This gigantic building houses hundreds of shops selling branded goods (read: one piece of underwear will cost you a fortune kind of shop) and a variety of eateries. The greatest news is: once inside, it looks almost the same (forgive my obsession to use the word 'isomorphic') as any shopping malls in this world. The ad flyer claims Penang has become a relatively advanced place because the world renown brands have established their outlets here.

Wait, did I say the QueensBay Mall is isomorphic to all other shopping malls in the world? If it is isomorphic, then it is not unique. But aren't we cherishing creativity, individualism, and therefore uniqueness? Looking like others is first of all not 'cool', maybe downright boring. If not cool and not unique, we are not an 'advanced' entity in any measure. If we are not cool not advanced, then we are not Boleh!

This finding is more disturbing than finding out monkeys in fact is the devolution of some brain-dead politicians instead of the other way round. (Ok, this statement is awful. I apologize. I know, I shouldn't insult the monkeys)

(Boleh is a Malay word meaning 'can' as in 'can-do'. Usually this is mainly used in the term 'Malaysia Boleh!', chanted proudly after numerous expensive record-breaking but useless projects like building the largest cake in the world, tallest tower made from pokers, biggest malaysian flag made with 1 cent coins, etc. Exact rationales please contact your nearest zoo which has monkeys)

We have a problem it seems. Let's step back and think. Is modernisation really bringing uniqueness and individualism? At the surface it sounds true, you can dress and do whatever you like, as long as you are within the legal bound (or you don't let others see it, or you live in BolehLand).

I want to argue that modern society is more homogenous than it seems, especially now information travels almost instantaneously.

The latest fashion in Milan today can be bought the next day in Woman Street in Hong Kong with only fraction of the pricetag and if you are nice to the sales-girl, she may give you a pair of socks for free. Fashion is definitely contagious and homogenous in this sense. If you don't look like the norm, others will chide at you "Oh my god! You are so out of date!" Heck, so where is the uniqueness?

Look again at what we read and more generally, what we know. We go to similar news sites and read similar news. For any questions, we automatically google for the answers and land on basically the same pages, no matter you are from US, India, Antartica or Singapore. It is not surprising to see more and more people in different geographical regions have similar thoughts and world views, because they are exposed to the same information.

The upcoming challenge is no longer about insufficient information, in fact, what we are critically lacking of is the critical thinking skills to differentiate, filter, absorb, and apply the barrage of information on time while maintaining our own identities.

May the power with you to make you as Boleh as possible, but not more Boleh. Meow.

Sunday, December 10, 2006

StarWalk and A Look At Our People

StarWalk is an annual event held by the Star Newspaper in Penang and is considered a pretty grand event. Today was my first time to participate in this 10Km walk competition. The walk started at 7 morning and there were people all over the place.

I was late for almost 7 minutes because the police seemed to block all the entrances to the starting point. I had to park my car around 2 Km away and walked.

It was a decent day for this event: the sky was clear, wind was gentle, and not much birds flying around, which meaned less bird shits from above. Good.

Near the starting point

The walk, by definition involves walking, which is the alternate mechanical movements of legs. Other parts of body were pretty free and therefore, bored. Since all my friends joined the non-competition section (aka admit-as-loser-before-competition-starts section), I was walking alone.

Nothing much interesting on the way, until we hit a stall giving out drinks using paper cups. All walkers rushed to the stall like hungry wolves. What followed was memorable: there were paper boxes beside the road acting as trash bins, but for some reason, Malaysians just like to throw to places like drains, by the roadside, on the pedestrian cross, someone's house compound, and virtually anywhere and everywhere, except into the very trash bins. In fact I checked and most of those were less than half filled.

Note the boxes by the road side, those _are_ for trash disposal. The stall is at the far end

This picture was taken at the same location as the previous one, except I made an 180 degree rotation

I could see many people just threw the cup anywhere so naturally as if it were the right thing to do. I was both amazed and embarrased. Advanced country? I doubt it. At least the mindset isn't.

Saturday, December 09, 2006

Organic Store War, The Movie

Store war is a short movie about organic food using Star War's theme. The making is clever and well-thought-of.

At a deeper level, we should rethink what we humans have done to land ourselves into this state: Not long ago before the industrial revolution, all food were organic and in fact, there was no other alternatives anyway. In less than one hundred years, we have screwed ourselves so badly that we have to pay much higher prices for organic produces; pay for something that initially belonged to us.

Now buying drinking water is already common in a lot of countries. Most probably a couple of decades down the road we will have to buy fresh air in canisters. This isn't funny.

CEO in Commercials

Steve Wozniak is one of the Steve's who founded Apple.

I came across a TV commercial he starred for Datsun (here).

This commercial fits him quite well though.

It will be entertaining to see:

  • Bill Gates selling safe
  • Michael Jackson promoting plastic surgery or diaper
  • George Bush Jr. promoting world peace
  • Chen Sui Bien (president of Taiwan) promoting the virtue of honesty
  • Bin Laden selling medicine
Any other suggestions? :)



Thursday, December 07, 2006

StarWalk 2006

I just got my goody bag for the upcoming StarWalk this Sunday.


The goody bag has a whole array of free stuff that are absolutely random in nature. The gamut spans from a candy bar to a tube of petroleum jelly (by the way, the jelly has coagulated in an ugly way. I wonder if it has expired)

My first biggest challenge will be to get up early (enough) on Sunday.

Wednesday, December 06, 2006

Computer Languages Overflow

The unprecedent improvement in hardware processing speed not only spawns a lot of new programming languages, but also resurrects a lot of dead ones. Needless to say, without those dual, quad or upcoming octo cores which offer higher and higer processing power, these languages are basically useless 5 years ago.

Well, maybe a little bit exaggerated but recently there are a hell lot of programming languages out there. Here I count distinct languages (not the implementations though) instead of family of language, ergo even OCaml is a dialect of ML, I count them separately.

Here is a list that I can think of:
  • C
  • C++
  • Common Lisp
  • Scheme
  • OCaml
  • Haskell
  • Python
  • Perl
  • ML
  • Ruby
  • Visual Basic
  • Parrot
  • C#
  • Ada
  • Cobol
  • Smalltalk
  • Erlang
  • Java
  • Fortran
The list can go on and on, but these are what I have read about recently.

For some reason, a lot of people tend to take a particular language (usually it is the language they love) and hail it as _the_ language by having language shoot out, functional comparison, or comparing on the ground of aesthetic beauty. I have seen some paper heralding a particular language X and to show the comparison is 'fair', language Y and language Z are included.

Some points to ponder upon:
  1. Each language is designed with a certain domain in mind, Fortran is mainly for numerical computing, while C is more of a low-level, system programming. No language can excel in everything.
  2. When you have a hammer, all problems will look like nails. If you are used to programming in C with the weakly typed system, the strongly typed system in ML will most likely drive you to smash your monitor and chew on the debris. Each language has its own caveats.
  3. When writing test programs in different languages, not many people can fully utilize the power of each language in question. Even if you invite so called experts to join the fun, the problem definition most probably will already give some languages an unfair advantage. Having the unfair advantage usually doesn't imply that language is superior, just the problem on hand matches its design domain (cf #1 above).

Having this rant after reading a paper on a multi-threading model built on top of scheme and was compared against the god-daddy of reliable and multithreading language, Erlang.

If you force a dog to meow, you get a lousy cat, and a very unhappy dog.

Luckily I am a cat person. Meow... Wait, someone calls me a wolf??? Hmm...

Monday, December 04, 2006

Book Mark File

Once upon a time circa year 1996, bookmark files were plain ASCII html files. Things were simple and straight-forward. I always liked to edit the bookmark files using my good-old vim to reorganize things.

This evening I was trying to sync my laptop bookmark with the one in my home pc. To my horror, the diff just gave me a ton of junk. Upon inspection, it seems nowadays the browser even embeds the site's icon images into the bookmark files.

This approach is hideous. What are the advantages? Save some bandwidths in retrieving the icons? The saving will be minimal because the icons are in the order of less than 1 kb.

The verdict is out: Whomever came out with this idea should be locked in a smelly toilet for 3 weeks, with no internet access, of course.

It is time to write some scripts to parse the bookmark and remove all the icon data. Duh.

Saturday, December 02, 2006

FD Formula on GnuCash

In my previous post on GnuCash, I showed the steps to install GnuCash on Slackware 11.

It is not trivial, but doable.

These few days I have been busy setting up GnuCash with intention to dump MS Excel. As usual, the journey wasn't smooth-sailing.

The first problem I encountered was there doesn't seem to be any way to automatically manage FDs (Fixed Deposits, it is called Certificate of Deposit, CD in other countries).

Scenario: I have a amount p of money as FD. The FD will mature every n month and interests generated will be reinvested at the prevalent rate.

What I want: GnuCash to automatically renew the entry at the maturity date. As long as the FD is valid, GnuCash should take care of that until being told otherwise.

As usual, good news and bad news:

Bad news:
Surprise surprise, it seems GnuCash can't do this by default. There are druids to calculate mortgages and loans, but none for savings and FDs. (I checked the wiki and help files on gnucash.org, to no avail. In fact, the formula gnc:computerInterestIncrement on the wiki FAQ is wrong). You can verify it with any financial calculators.

Good news:
The underlying toolchain is written in scheme. This makes GnuCash very flexible and hacking possible. What follow are some pointers.

Assumptions:
  • You have read the GnuCash help files and know the concept of debit and credit
  • You know how to create accounts under GnuCash
  • You already have at least one FD account under Assets and one under Incomes. If your bank charges you on this, add one more account under Expenses and the following steps need some adjustments.
Steps to Fix:
  1. Exit GnuCash
  2. Edit fin.scm (inside /usr/local/share/scm if you use the default configuration)
  3. Add the following at the start of the file, right under the comments (comments are lines starting with semicolons ';').
  4. Note: Blogspot has broken some of the comment lines, please fix those by yourself.
  5. ;
    ; By HKC Dec 02, 2006
    ;
    (define (futureValue p r n i)
    (let ((rate (/ r 100)))
    (* p (expt (+ 1.0 (/ rate n)) i))))

    ;;
    ;; This function calculates the interest yield for the i-th month.
    ;;
    ;; Example: With principal of 10000, interest rate 10%, and interest ;; is calculated and reinvested
    ;; monthly at the same rate, we want to know how much money we ;;can get during the 8-th month.
    ;;
    ;; Invoke (gnc:interestYield 10000 10 12 8) and you should get 88.31767424426289
    ;;
    ;;
    (define (gnc:interestYield p r n i)
    (let ((this-val (futureValue p r n i))
    (prev-val (futureValue p r n (- i 1))))
    (- this-val prev-val)))

    ;;
    ;; This function calculates total interest accrued, assuming all ;;interests are reinvested at the same rate.
    ;;
    ;;
    (define (gnc:interestAccrued p r n i)
    (define (sum-it sum i)
    (if (= i 0) sum
    (sum-it (+ sum (interestYield p r n i)) (- i 1))))
    (sum-it 0 i))

  6. Start GnuCash, and Actions->Scheduled Transaction Editor. Click on 'new'.

  7. Enter a name and set the date according to the maturity of your FD.
  8. Under 'Template Transactions', enter a description, then click on the 'Enter' icon. We need 2 action items: one for debit and one for credit. If you are not sure about this concept or how to do all these, please refer to the GnuCash help files.
  9. At the debit field, enter 'interestYield(p:interest_rate:compound_number:i)' where p is your principal amount, interest_rate is the current rate entered as-is (if it is 3.3, just enter 3.3, my function will do the conversion accordingly), compound_number refers to how frequent interest is compounded (monthly -> 12, quarterly->4, semi-annually->2, annually -> 1), i is the i-th occurence of the compound event. This variable can be entered as-is and no need to substitute it.
  10. Examples: Suppose I have principal amount of 1000 to invest. Interest rate is 5% and will be compounded monthly. Hence I would enter:
    interestYield(1000, 5, 12, i). If the interest is compounded yearly, then I would have entered interestYield(1000,5,1,i). The rest is similar.
  11. Enter the same formula for the credit field.
Upon the maturity specified, Gnucash will automatically credit your account and you never need to worry about it anymore.

I wrote this in quite a rush. If there is something unclear, please let me know and I will be happy to clarify.