My Rambling Thoughts

Quote:

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Brian W. Kernighan

Quote:

If you ride a motorcycle often, you will be killed riding it. That much is as sure as night follows day. Your responsibility is to be vigilant and careful as to continue to push that eventuality so far forward that you die of old age first.

Unknown source

News:

Date: . Source: .

COE price has peaked

transport

That is because I have just renewed my COE at $19,331. I lost 1.5 years of my current COE, valued at $2,613, making my total cost $21,944.

Last April, the cat A PQP (Prevailing Quota Premium) was only $3,864. Even losing 2.5 years of COE ($4,304), it would have costed "just" $8,168.

I paid an extra $12k — after factoring in the additional year.

What was I thinking last April that prevented me from renewing the COE? The recession was expected to be deep and long. I thought the PQP would hover around $10k.

April proved me wrong when LTA reduced the quota drastically. This year, LTA not only cut the quota by a further 30%, but also changed the formula: the quota is now based on actual deregistrations instead of (in their words, optimistic) projections.

Also, I underestimated the demand for cars. I thought everyone who wanted a car has one already. And, traffic conditions are so bad during peak hours and parking is always so hard to find, who wants to drive? It turns out that public transport is worse. Think being packed like sardines.

It is pretty much given that the COE price will hover around the $30k mark in the short term. It is already widely expected that the secondhand car dealers are unlikely to deregister the cars to lower the COE quota to force the COE price to go up so that more people will buy secondhand cars.

The PQP will come down in the long run, but do I have the time to wait for it? I don't want to take the risk.

Want to stay alone? A reality check

finance

My brother has bought a flat to enjoy martal bliss with his wife. Due to the housing prices wrt to his earning power — and being prudent — he bought one in an ulu place. It was close to both his and his wife's workplace, though.

I have always shared a room or flat with my brother. Even at home, we share the same study room and bedroom. (Why not one room each? You have to ask my parents.) For the first time in my life, I will live alone. Or will I? Alone means my rent will double. That's not prudent.

I have five options:

  • Move in with my brother
  • Find a flatmate
  • Give up the flat and stay in a room
  • Stay in a room with a roommate
  • Stay in JB

Staying with my brother is the most prudent choice. We have paid rent for many years. That is enough. However, his flat is very far from my workplace — I estimate 45 minutes on clear roads (6 am).

I can also find a flatmate. My rent will be slightly higher because it is not equal sharing. (Yup, I'm taking advantage of my brother now. :-P) However, I expect it to be tough to find a compatible flatmate. When you live with someone, sometimes even the smallest fault can tick you off.

If I'm going to give up the flat, I may as well just rent a room closer to my workplace. That will save much travelling time. I will only save a little on the rent because room rental rates are pretty high.

Even more economical is to share a room with a roommate. However, this is even harder than finding a flatmate as this requires very high compatibility and trust.

The most economical is to stay in JB. However, it is stressful to be in the checkpoint jam everyday. (If I can find someone to chauffeur me, then that's different.)

Some comments on the Changi Airport

Some comments and thoughts after walking the entire T1, T2 and T3:

  • T1 and T2 have staff canteen. Does T3 have one?
  • T1 has no viewing gallery. The T2 and T3 galleries are not flushed against the glass, so it is hard to see out, especially at night. The view is very lackluster. Also, why do I want to see the transit area?
  • There is an intercom area in T3. Looks like the one used in prisons. Do people actually use it?
  • Why is the arrival hall always below the departure hall?
  • The displays don't show info for the other terminals. They are supposed to, but they don't.

Most corny banter overheard in a park

Most people go to the park to enjoy some tranquility. Others go there to hear such corny banter:

  • He: I'm your knight.
  • She: What about in daytime?
  • He: Then I'm your date.

Can I park here?

transport

A friend called me to ask if he is allowed to park on a 3-lane carriageway with dotted white lane markings without any markings by the side of the road.

The answer should be yes, but it is rare to find such roads in Singapore — which was why my friend called me.

I asked him the most simple question: "Are there any cars parked there?"

The answer was "yes, a lot", so it was obviously allowed. :lol: (If not, at least he can take comfort that 'all die together'.)

How to be happy

To be happy with a man you must understand him a lot and love him a little. To be happy with a woman you must love her a lot and not try to understand her at all.

Helen Rowland
English-American writer, 1876 – 1950

Timeless wisdom, valid 100 years ago, now and forever.

The 25th floor is really high

finance

News: Bras Basah flat sets record

Date: 26 March 2010. Source: ST.

A TAIWANESE couple have paid $650,000 for a four-room flat in Bain Street - smashing Housing Board (HDB) records and reflecting the strength in the red-hot resale market.

The sale price works out to be $736 per sq ft (psf) for the 30-year-old flat on the 25th floor of a block at Bras Basah.

That is the highest psf price paid for an HDB property and is on a par with prices of private homes in suburban areas.

I find even the valuation at $580k to be very high. Well, some people like to live in the heart of the city.

And it is just a 82 sq metre flat... it is pretty small.

Check before renting out your car

transport

News: Man jailed 42 months for car rental scam

Date: 11 March 2010. Source: CNA.

A 22-year-old man has been jailed for 42 months by a district court over a car rental scam.

Allen Tan Wei Loon posted his services on car websites.

He lied that he has cars to rent out or claimed that he would be renting their cars.

A few things come to mind when I read this. First, I thought he is pretty young, and is quite the entrepreneur, but in the wrong direction.

The second thing is, judging from the amount involved, he must have scammed some 60+ people. So many people wanting to rent their car out? Hmm...

A fluke or a trend?

transport

News: COEs for all vehicle categories surge in latest bidding exercise

Date: 24 March 2010. Source: CNA.

COE prices have shot up by as much as S$14,000 in the latest bidding exercise.

The market appears to be reacting to an expected reduction in the supply of COEs next month.

I'm not going to think about it anymore. In Singapore, just pay and pay.

How to get your pillion rider to hug you

I was told that this works:

  • A: you can hug me more tightly if you are cold.
  • B: I'm not cold.
  • A: Then I shall go faster.

True or not, I have no idea. Try at your own risk. ;-)

I am looking for this girl

My "Big Sweep" (sister-in-law) once asked me what kind of girl I like — she was trying to narrow down a suitable date for me. I was tongue-tied. Liking a person is not a simple checklist. Sometimes, one x-factor is enough to offset all other weaknesses.

But today, I am able to answer the question.

I am looking for this girl: she must be the quiet type; she must like to read; she must like quiet places, yet like outdoor excursions. She must be low-maintenance; she must be non-local; and she must be pretty.

Other than the last criteria, that's pretty common, my sister-in-law said. As for the last criteria, she asked me to look at the mirror first. :lol:

Let's add more then. :-D

She must be a thinker; she must be interested in general knowledge (as opposed to fashion trends and celebrity gossip); she must be able to speak her mind; she must be proactive; she must be the hands-on type; and she must be willing to ride on a motorbike.

And should this girl be sensitive or is easily jealous, I'm fine with it. I like everything about her. :love:

Why the weather is so cold these days

Overheard at the airport:

  • He: your hands are so cold! Let me warm them up.
  • (No effect after while) He: you're cold-blooded! Is your heart as cold as your hands?
  • She: my heart is warm because someone is inside keeping it warm.

No wonder the weather is so cold these days.

What do you live for?

Life must be lived forward, but can only be understood backwards.

Kierkegaard, Soren
Danish philosopher, 1813 – 1855

What are your goals in life? This is a question everyone must ask himself — early, so that he can spend as much time as possible to pursue them.

Do you spend a lot of time at work? Think about this: no one would wish that he had spent more time working on his deathbed. Rather, he would lament he did not spend enough time with his family.

Everyone must find their own mission in life.

Some people have very simple goals: to have three square meals, a roof over their heads and being able to provide for their family.

I've always found that a bit underwhelming.

Most people at least have some ambitions: the 5Cs and the endless quest for materialism, for example. I've nothing against that, but I can't help but think that is the wrong direction in the grand scheme of life.

There are several things I want to do in my life, but I haven't even started with them yet — and I'm halfway across my lifespan.

On my deathbed, there are three questions I would ask myself:

  • Have I lived a full life?
  • Do I regret not doing something?
  • Have I contributed to the advancement of Mankind?

I have to answer them today.

The only certainty in this world

In this world nothing can be said to be certain, except death and taxes.

Benjamin Franklin

Be strong.

Nothing about the US surprises me anymore

finance

From a cynical guy online:

You're going to get a health insurance plan written by a committee whose Chairman has publicly stated that he doesn't understand it, passed by a Congress that has literally not read it but yet has made damn certain to exempt themselves from it, to be signed by a President that also has not read it, with funding administered by a Treasury Secretary who cheated on his income taxes, all to be overseen by a Surgeon General who is obese, and financed by a country that is $14 trillion in debt to begin with and adding $2 trillion a year more in red ink per year BEFORE this bill adds even more red ink to it.

And it will be delivered to you by a House of "Representatives" that won't even actually vote on it, headed by a Speaker who is on record saying that they'll have to "pass it to see what's in it."

That's the country you live in, folks. Don't let anybody tell you any different.

The end, in sight.

Will my brother make good use of my camera?

I received an SMS from my brother 2 am in the morning that he has reached Rome. I was too sleepy to reply.

When I woke up, I was thinking whether to send "My camera's going places!" or "Take care of my camera!". I sent the latter. I don't expect the camera to survive the trip — it came back with a scratched LCD screen the last time I lent it to him for a one-day trip.

My brother borrowed my camera because he didn't have a decent one. But, a sightseeing honeymoon using the Sony DSC-T50? :shake:

Anyway, I told him to set the camera to 'P' mode with auto-ISO, and use high-sensitivity mode only in dim places. (I told him to use high-sensitivity mode by default before he left.)

I had changed the camera from center-focusing to multi-focusing. I prefer to lock-n-recompose, but non-photographers don't understand this concept.

I also set the camera to auto-preview. I turned it off because sometimes I want to take consecutive shots quickly.

I gave him these instructions:

  • Download the photos to his notebook every day. 2 GB (7.2 Mpx; 3 MB/photo) can last a few days, but not with videos.
  • Keep video clips short — 20s or shorter. Videos chew up space for breakfast (1.2 MB/s; not a typo).
  • Charge the battery every night. A full charge can last 1.5 days of intensive use, but don't take the risk.
  • The battery must be charged separately. When charging, leave the battery door open so that he won't forget about the battery! (I have made this mistake before.)
  • I also passed him my lens pen and asked him to clean the lens every night. It is vital to keep the small lens clean to ensure the best quality.

I wonder how many can he remember.

When will they quarrel? Place your bets!

On the way to the airport, my sister-in-law pondered when they would have their first quarrel. She said all their married friends bet it would happen during the honeymoon! :lol:

But seriously, I don't think I've seen my brother lost his temper. When he is upset, he will be very silent and non-responsive. Any attempt to provoke him is futile. Believe me, I've tried. :devil:

I'm usually in a good mood, but I find myself more and more emotionally unstable these days. Sometimes a small trigger is enough to push me over.

I must count to ten more often.

Going through a dark passage in life

I'll be there in your hour of need, always.

A special day for my brother

A check for NHS

Thus, a special check for him too. I don't think anyone can trump this. :lol:

(Details are blotted out.)

Like my father, I have waited a long time for this day. Never count your chickens until they are hatched. This is especially true for my brother.

The tao of photography

photography

Photography has many rules. First, you must know them. Then, you must break them.

Does equipment matter? Yes, but only in the sense that they constrain your ability to take certain shots. You can make up for the lack of equipment with skills — or creative compositions — for most parts.

Times when equipment matter: wildlife (600/4), sports (300/2.8), macro (1:1) and low-light (f/2). Without the proper equipment, you are at a distinct disadvantage and will miss most of the shots.

Otherwise, there are no fixed rules. You can take portraiture with a wide-angle lens and landscape with a telephoto lens.

For me, I shoot to tell stories — I'm a photo-journalist. Every shot that I take, I already have a caption ready, so I know what and why I'm shooting.

Is this camera calling out to me or what?

photography

The newly launched Sony CyberShot TX5:

  • 10 Mp – more than sufficient
  • 25 mm – wide angle!
  • ISO 3200
  • High Dynamic Range (HDR)
  • Intelligent Sweep Panorama – gimmicky, but it works
  • 720p video
  • Waterproof!

It is a worthy successor to my venerable T50, which is still going strong after 3+ years. However, it may be time to replace it as I have used the camera at its low-light limit more and more often and the technology has improved significantly since then.

The two features I most look forward to: the wide-angle focal length and the supposedly reduced noise at ISO 3200 (new innovative technique used). I like to take available-light street photos, so these are important to me.

Sweep Panorama is nice, but I doubt I will use it often. (It is hard to display as well.) Being waterproof is also just a nice-to-have. I used my T50 in the rain, even though it is not waterproof.

The TX5 is a lower-end version of the slightly older TX7, but I'll give the TX5 the edge due to its waterproofness.

Take my breath away

Today is a pretty memorable day. I met someone who took my breath away — literally.

(This is half the story. The full version is more down-to-Earth. :-D)

His best show by far

News: 2nd woman claims tryst

Date: 8 March 2010. Source: ST.

HE WOOED her with the promise of grooming her into 'Fann Wong No. 2', and even booked a hotel room so they could get to know each other better.

This claim was made by a second woman who has decided to speak out on Singaporean filmmaker Jack Neo, just days after a 22-year-old freelance model Wendy Chong broke the news of her two-year fling with the Cultural Medallion recipient.

You know the saying, "When a man has money, he goes bad...".

Anyway, Jack Neo's action does not change my views on his shows — I still don't like them. They depict very stereotypical Singaporean way-of-life and are laced with overly strong social messages (as with most Singapore productions).

What a rip-off: $45 for 1/2 day MC

Appreciate your doctor if he gives you two days MC. I got lazy and visited my neighbourhood doctor. He declined to give me a 2nd day MC. The mere mention of it turned his face black.

Fine, I thought, I'm not coming back.

When I was waiting for my medicine, the patient before me asked for her MC. "No MC", the receptionist said. She immediately went to confront the doctor. No luck. Later, I could see her outside the clinic, trying to figure what to do. Should she spend more money and see another doctor, or apply her own annual leave?

I bet she's not coming back either.

It costed me $45 in total. Wow, fees sure have gone up. I was given a bunch of pills — which would promptly go to the bin. I don't need pills for the common cold. I need time to rest. Plus, it was effectively only a 3-hour MC. I was not pleased, to say the least.

Is it really that difficult to give a 2-day MC? Panel doctors, I can understand. They seemed to have very strict instructions not to give MC. That is one reason why I didn't opt for the clinical plan.

No, I'm going back to my regular doctor, where he asks you if you need a 2-day MC. Once, when I declined, he gave it to me anyway, saying I could always go back to work if I felt better. Now, that is how it should be.

CB400F is a hot bike

transport
CB400F radiator leak

Literally.

My CB400F started to leak coolant yesterday. At first, I thought it was water, because I washed the bike in the morning, but it leaked too much to be so. Later, I heard hissing sound and realized it was leaking from a pipe.

(It must have gotten worse that day because I didn't see such an obvious leak before.)

I decided to risk it and rode 15 km to my workshop. I must have rode at least 30 km with the leaking pipe! The radiator light did not turn on. However, I don't know if it is working or not.

The leak must have started a while back. My exhaust pipes had reddish stains for some time. I thought it was rust because I didn't use my bike often, but now that I think of it, it could be evaporated coolant! (However, I thought my coolant was green.)

So, my bike is either a write-off or everything is still fine because the bike was sufficiently cool due to the air intake. (I was never stuck in traffic jams).

New Sony prime lenses!

photography

Oh ho, Sony is releasing two new prime lenses: the 24 mm f/2 SSM Carl Zeiss lens and the 500 mm f/4 G lens!

Sony is expensive. Carl Zeiss is exclusive. The combination is lethal. I am interested in the 24/2 lens :drool:, but I'm not planning to get it.

I must say that Sony is unlikely to release any more Minolta vintage lenses. Sony would rather use Carl Zeiss designs. I like Minolta lenses even though they are inferior — the best Minolta lenses are often said to be a poor man's Carl Zeiss lenses. However, they are good enough for me.

There are two reasons why I am not that interested in a 24/2 lens — and this is coming from someone who wanted to get a Canon camera just to use the 24/1.4L lens.

First, I'm very weak at the 24mm focal length. 28mm is easy to use and so far, I'm okay with 20mm too. I find it very easy to introduce distortions at 24mm, so I need to compose the photos very carefully.

But more importantly, I feel SLR is a dying system. With ultra-fast sensors, there is simply no need to have 35mm-format lenses anymore. 24/2 is a street lens. A lens that isn't carried isn't used — hence wasted. Portability is important. These days, you can get 24/2 on a compact: the Panasonic LX-3. This is the path forward, I guess.

The SLR makers can see this too. Sony has announced a new line of mirrorless cameras with a new line of interchangable lenses. The existing lenses can be used via an adapter, but I suspect some functionality will be lost. (Or how is Sony going to get you to buy the new lenses?)

We may be entering a turbulent transitional period like the MF-to-AF period again. Time for fortunes to rise and fall again.

What's so special about the 50mm lens?

photography

As I mentioned before, the 50mm lens is often the cheapest lens in the lens lineup, yet it gives very good quality pictures that often only the high-end f/2.8 zoom lenses can exceed.

The lens is also small and light, not to mention "fast". When photographers talk about fast lenses, they are not talking about focusing speed. They are talking about the light-gathering ability: the faster the lens, the more light it can gather. Even the slowest 50mm is typically f/1.8. That's 1-1/3 f/stop faster than f/2.8. One f/stop = twice as much light = half the exposure time.

With higher ISOs (even ISO 1600 is usable now compared to ISO 400 in the past; that's 2 stops) and Anti-Shake (another 2 stops), fast lenses do not have much appeal left — f/2.8 is a perfectly reasonable fast aperture. The only reason why you want something faster is extremely shallow depth-of-field.

The 50mm focal length

When people ask about the 50mm lens, they usually want to know why the 50mm focal length is special, not the lens.

50mm falls into the so-called "normal" focal length, meaning the perspective is just as our eyes see it. (It depends on the reproduction ratio and viewing distance too, so it is only true if typical values are assumed.)

(What is perspective? You can think of it as the spacing between the foreground and background objects. For wide-angle focal lengths, the background looks very far away. For telephoto focal lengths, the background look closer — usually called compressed.)

Technically, a normal lens is one with a focal length equal to the diagonal size of the film or sensor format. For 35mm film format (24x36mm), that means 43.3mm. Lenses from 40mm to 50mm are considered normal.

Note that while the perspective is "normal", the field-of-view is much narrower than what our eyes can see. This is why people have a lot of trouble with the 50mm lens — they cannot fit their subjects into the frame.

Not the lens you are looking for

The 50mm lens should not be your first prime lens, especially on a DSLR with 1.5x FLM. It is cheap and good, but it is often not suitable.

Lusting over two lenses

I passed by a used camera shop and saw the Minolta 16/2.8 fisheye lens and the Minolta 200/2.8 lens. It is quite rare to find one such lens (they are OOP), much less both of them side-by-side. My guess is the fisheye costs $800 and the telephoto $1,500.

I have always wanted these lenses to "complete" my lens lineup (from 16 to 200mm), but I couldn't justify them. Fisheye is almost useless outside of creative shots and I prefer to shoot wide-angle, not telephoto.

The fisheye

It is said the fisheye lens should be borrowed and not bought because there is only a small set of photos to take with them.

The fisheye can be "un-distorted" to give an ultra wide angle lens (of 12-13mm?). However, I haven't even explored the 20mm focal length much.

Also, Sony has an updated version of this lens. The main difference is a new coating on the rear element that reduces flare for digital sensors. That is important.

The telephoto

The 200mm lens is very small — compared to its longer siblings — so it is very portable. The attraction is that I can even reach 280/4 coupled with a 1.4x extender. (I feel this is better than getting a dedicated 300/4 lens.) However, I seldom even need the 135mm focal length. (And given a choice, I would opt for 135/2 over 200/2.8.)

The lens is sharp, as expected, but supposedly has very noisy AF.

Sony does not have this lens, and I doubt it will come out with it as prime lenses are not popular.

To buy or not to buy

Should I get them? And what if I can only get one of them? Which should I choose? Or should I get something else?

Let's see, I don't shoot macro, so a 100/2.8 macro lens is out. I do want to take tilt/shift shots, so the Nikkor 85/2.8 T/S lens would be very attractive to me.

A look at PCSX dynamic recompiler

programming

What I describe here applies only to the x86 dynamic recompiler (ix86). I have not looked at the others.

How it works

I have written before how the recompiler works. I'll just point out some things I've found out since.

Each PSX pc can start its own native block of code (that usually ends at a branch). The native blocks are distinct, so there can be some duplication. In practice, only branch and call targets will start a native block of code.

The native blocks must be distinct due to optimizations and the one-pass recompilation process. (It doesn't know/identify branch/call targets.)

What this means is that self-modifying code will usually fail to work (unless it modifies a branch/call target).

What it does well

The recompiler handles constant propagation, which helps tremendously with MIPS's heavy use of LUI (load into upper 16-bits) and r0 (always 0). The values are updated to the PSX registers at the end of the basic block.

It updates the PSX pc, cycles and even clear the physical stack just once per basic block.

It also eliminates accessing the memory LUT for constant memory locations. (Happens about 25% of the time.)

What it doesn't handle

The recompiler does not do any physical register allocation at all.

It uses the interpreter to handle possible branch delay conflict when the delay instruction is a load. When this happens, the branch delay and the first target instructions are interpreted. Otherwise, it does try to use native code for branching.

The recompiler does not optimize most GTE calls except for the moves. It just calls the C functions. We can clearly see the remnants for other instructions that do the same. I suppose they were used when the recompiler was still incomplete.

Possible bug?

In iJump():

MOV32MtoR(EAX, PC_REC(branchPC));
TEST32RtoR(EAX, EAX);
j8Ptr[1] = JNE8(0);
RET();

x86SetJ8(j8Ptr[1]);
RET(); // should not be here, otherwise the test has no purpose
JMP32R(EAX);

Is it a bug or a bugfix? It was not commented.

How to improve the recompiler

  1. It should identify the basic blocks better and not generate overlapping code for them.
  2. It should work for all self-modifying code.
  3. It should do physical register allocation.
  4. It should analyze code at a function level. It has to do this to do global register allocation, which is necessary because each basic block is simply too short.

(My opinion. YMMV.)

Don't touch my hifi!

Don't touch my hifi!

Heng Wei's 2nd daughter was hyper-active! She went around touching and grabbing stuff all over Fook Yuan's house. It was amusing to watch her mother chase after her.

Well, she can touch everything, just not the hifi!

But don't worry. Even if she breaks something, Heng Wei can afford to pay it back. :lol:

(We are talking about a $12,000 CD player — used — here. :-O)

What I want to say

I thought you were joking when you said that. I was shell-shocked when I received your SMS.

I got lost on my way home. So if you said you have no effect on me, you are wrong.

I've said this and I'll say this a million times: I want to see you. I want to see you again. And I want to see you again and again.

Give the PCSX interpreter a speed boost!

programming

It is possible to wring some speed out of the PCSX interpreter.

General

  1. Improve the memory access functions. For example, psxMemRead32() checks for h/w registers region first, then for valid memory regions. If we swap the order, we would have saved a comparison most of the time. Memory load/store accounts for some 20% of the instructions based on my unscientific profiling.
  2. Use __fastcall for key short but non-inlined global helper functions that takes in 1-2 arguments. This generates much better code — always check the disassembly. Note that this may break the x86 recompiler.
  3. Use a static allocated array instead of dynamic memory for the LUT and PSX memory. This is a big win on x86-32 because it frees up a register. With dynamic allocation, the pointer has to be loaded into a register first. (Again, check the disassembly.)
  4. The branch test checks for the next event and whether an interrupt has occurred. This can be collapsed into one check. (This is not a big deal as it occurs 1 in 10-15 instructions.)

The interpreter

There are a few things we can do to speed up the interpreter:

  1. It goes through the memory LUT to convert the PSX pc to a pointer for every instruction. The pointer can be reused until pc is changed non-linearly.
  2. It increments the PSX pc on every instruction. We can convert the pointer back to pc at the end of a basic block.
  3. It increments the cycle on every instruction. Again, we can do it once per basic block.

And?

I got a <10% speed increase. These are the low-hanging fruits. It is difficult to make the interpreter go much faster. There are three main reasons:

  1. Decoding effort - need to decode over and over again
  2. Multi-stage decoding - need nested calls
  3. Delayed branch - not difficult to handle, but introduces overhead

If we want to keep to an interpreter approach, we need to deal with these issues.