June 29, 2006
Posted by geoffreyzheng under Programming
Leave a Comment
I was asked the question during interview, and later found Meyers & Alexandrescu’s great article C++ and the Perils of Double-Checked Locking, one of the references in this greater Wikipedia page. DCLP is listed as one of anti pattern.
The essence of why DCLP doesn’t work is that compiler may rearrange instruction order, so another thread may reference a not-fully-initialized singleton. On a multiprocessor platform, cache coherence may also lead to problem where another thread on another processor gets a bad singleton.
Meyers offers several solutions:
- Use multithread library, not simple synchronization construct like mutex.
- Client code caches singleton instance locally
- Use eager initialization for singleton, i.e. instantiate at startup
June 20, 2006
Posted by geoffreyzheng under Living
Leave a Comment
US Open Golf.
Wimbledon in 2 weeks.
Yankees always on.
Do you need any reason, as if you ever need one, to get an HD DVR?
The last straw was the French Open final last weekend. We had to go to Ikea early to buy cabinets so I setup a timer recording on VCR. The first tape I put in was rejected twice as the tape got tangled up inside. We watched the tape on Monday, but didn’t go beyond the first set because of the alternating poor quality of playing from both Nadal and Federer, and the poorer quality of video.
I called Comcast and found we can get a DVR for about the same price as the Starz premium channel that we hardly watch (heck we’ve hardly watched any TV this year). Installer came surprisingly quick and early and we’ve been in sports heaven ever since.
The DVR is a beauty. It’s not as good as TiVo (whose HD unit should be coming out soon), but I can’t complain about 13 hours of HD recording, dual tuner, continuous recording/instant replay, series recording, full program guide…
Just imagine never to miss another World Cup game. In HD.
Anyway I want to talk about US Open in particular. We watched the last 15 minutes live, and the last 3 holes from DVR. What a spectacular meltdown!
No I’m not even talking about Phil Mickelson. He didn’t deserve to win, with only 2 fairway hit all day (“all over Westchester County”, as Daily News put it), none in back 9. His 17th drive hit a garbage can, 18th off a tent. The funny thing is that NBC completely lost his 2nd shot. The camera kept panning between his perplexed face and the rowdy crowd, then showing the 3rd shot as a seemingly replay.
Monty was in identical situation at 18th: par to win, bogey to playoff; though he didn’t know it since he’s in the third last group before Ogilvy and Mickelson. But he deserves so much to win, at 43 years old, no major win, and such legendary Ryder Cup performance. And what a worthy major championship shot would the miracle 40-foot curved birdie putt at 17th have been!
Padraig Harrington could’ve won if he didn’t bogey the last 3 holes.
Jim Furyk could’ve got a playoff if he didn’t bogey the 18th.
Kenneth Ferrie could’ve hang on to his 3rd round lead at +2 if he didn’t bogeyed 6 holes in the last round.
Tiger Wood could’ve broken Jack Nicklaus’ 39 consecutive cut streak at major championship if he didn’t score +6 on both days.
Of course, Ogilvy couldn’t have won if he didn’t chip in for birdie at 17th, his own worthy championship moment, or if he didn’t save par on 18th after 2 bad breaks. He hang on while others faltered–but all others? That’s got to be some luck.
Golf is weird. Less is more. Frustrating. Up against yourself. World’s best players make similar mistakes as 40 handicappers like us.
It’s just a game, and it’s just human nature. I won’t miss any of it any more on our HD DVR.
June 16, 2006
Posted by geoffreyzheng under Science and Technology
First, Scoble is leaving the building to be a VP at a startup doing podcast. How many times do you see a company’s homepage welcoming a new employee?!
Then, a manager posted, pulled, reposted, repulled, rereposted (or more cycles) “Broken Windows Theory” on why Vista keeps slipping.
Now Bill Gates is also getting out, albeit slowly and partly. If you can bear reading only one comment about this, read Joel Spolsky’s. In vintage Joel style, he recount the time when Bill read his 500-page spec for VBA overnight and asked tons of questions, and the final killer question about date/time function, for which Joel happened to find out one esoteric thing about Excel’s date due to compability with Lotus 1-2-3.
And this paragraph completely overturned my impression on Bill, that he’s mostly a businessman, very smart, very aggressive, sometimes evil, but never a great programmer, which probably 99% of the world also believed:
“Bill Gates was amazingly technical. He understood Variants, and COM objects, and IDispatch and why Automation is different than vtables and why this might lead to dual interfaces. He worried about date functions. He didn’t meddle in software if he trusted the people who were working on it, but you couldn’t bullshit him for a minute because he was a programmer. A real, actual, programmer.”
Ray Ozzie did create Notes, and M$ did buy DOS from Seattle Computer Products. But that doesn’t mean Bill is a lame programmer. There’re some good reasons why he’s the richest man in the world.
June 15, 2006
Posted by geoffreyzheng under Reading
Leave a Comment
This just out, another great piece from the Hacker/Painter. The central thesis is that to clone Silicon Valley, meaning a tech startup hub, you only need a significant amount (total 10,000) of two types of people: nerds, and startup investors who are rich and adventurous and mostly likely used to be nerds and ran startups.
One interesting thing he says is that the ideal startup hub should be a historical place with an old town center intact, and people can live in/around town center, instead of in sprawling suburbs.
A few days later he has a follow up on why tech startup condenses in US.
Here comes another one on the more philosophical aspect of startup, or business or even life in general, where “outsider” (marginal people) creates and contributes. Sometimes it sounds a bit like Innovator’s Dilemma, but Paul’s writing is good as always. Some notable quotes:
… history suggests it’s dangerous to work in fields with corrupt tests. You may beat the insiders, and yet not do as good work, on an absolute scale, as you would in a field that was more honest.
If most of your ideas aren’t stupid, you’re probably being too conservative. You’re not bracketing the problem.
Lord Acton said we should judge talent at its best and character at its worst.
If you’re an outsider, don’t be ruled by plans. Planning is often just a weakness forced on those who delegate.
As an outsider, you’re just one step away from getting things done. A huge step, admittedly, and one that most people never seem to make, but only one step. If you can summon up the energy to get started, you can work on projects with an intensity (in both senses) that few insiders can match. For insiders work turns into a duty, laden with responsibilities and expectations. It’s never so pure as it was when they were young.
June 15, 2006
Posted by geoffreyzheng under Living
Leave a Comment
A brain teaser? Not for someone who buys cabinets from Ikea and carries them home.
We wouldn’t have started it if we had known it’s such a hassle to renovate a kitchen. We decided to get Ikea cabinets for its price and selection, and that’s the easy part. We went there several times to find the style and form we like, have our plan checked, and asked tons of questions for parts and installation issues. I used the Ikea Kitchen Planner to create 3 versions of the plan, circumventing lots of stupid bugs. Last Sunday we went there before the store opened (as suggested by an Ikea kitchen guy), and ordered almost $3000 stuff, using the 0% card just received on Saturday.
I made an item list using info from the Kitchen Planner. We want 4 base cabinets, 1 high cabinet (floor to ceiling), and 9 wall cabinets. The order list has 79 pieces: frame, door, shelf, drawer (several pieces per drawer), leg, toe kick, moulding, rail, etc. We only found one extra piece and one missing piece while loading.
The guy at the warehouse counter told me it may take 1.5 hours and I asked why that long, and he showed me that total weight is more than 500kg, which filled up about 3/4 of two SUVs.
Total time: 6 hours
Warehouse: 11am-1pm (went to Jersey Garden for about an hour)
The saga continues. We’ve been to Ikea 6 times in the last month, and will need to go even for more. First 2 times were for investigation, 3rd time was the above, 4th time for the huge 3’x8′ cover panel, 5th time for an extra suspension rail, 6th time for cabinets to fill in corners. The last time we opened every single cabinet on display (there must be more than 100) to check out their details.
One of the biggest problem of our kitchen is that it has a cut corner (two 135 degree angles), for aesthetic reason or to leave room for pipes I don’t know. But it makes it difficult to put cabinets, and leaves two almost unusable corner spaces. While planning I thought we can just use filler pieces to cover them up. When cabinets are in place, we realize a lot of space is wasted, the biggest being the right of the sink base. I flipped through the catalog many times, and found a edge base cabinet with a 45-degree cut corner–and it fits like a miracle!
We also plan to cut a Benno CD shelf to two halves to fill in the two corner spaces between wall cabinets, and we’ll see how that goes. Our contractor advised us to use a edge wall cabinet similar to the edge base cabinet for the larger corner, and cover up the smaller corner. It’ll look much better and give us more space.
Another issue is exhaust pipe. We found out that the pipe outlet is not simply on top of the stove, but on the sink wall a few feet away, and that’s probably why a hanging box was built in the first place to cover it up. We want to use tall wall cabinet that goes to the ceiling to get more space, so we had to run the exhaust pipe through several cabinets. Fortunately the pipe comes in 4″ diameter, much smaller than the original 6″, but still effective in terms of letting enough air through, so we didn’t have to drill too big a hole on the cabinets.
Regardless of how ridiculously hard it is sometimes to use the kitchen planner software, the best thing it does is to upload your plan to Ikea server so that you can open it in Ikea stores. A simple sharing goes a long way.
The sequal never ends! The countertop guy came last Wednesday but couldn’t make template because the island cabinets weren’t secured to the wall, base cabinets not even enough, and stove without support. We asked the contractor to come on Saturday to do these, and we went to Ikea for the 7th time to get edge wall cabinet and other stuff. I installed all but a few handles because I don’t think there’s enough time for the contractors to put on back splash tile, moulding, toe kick, edge wall cabinet, etc., and when they’re time pressed they’d do a terrible job. I’ll also try to patch the ceiling above the wall cabinets, because the new ones are a bit shallower than the old ones, and since we tore down the hanging truss box, the bare ceiling is visible now.
June 2, 2006
Posted by geoffreyzheng under Sports
Leave a Comment
A nice little piece about where the name came from.
We thought about visiting it while we’re there, but it’s so down the wish list that we may not even have time for it for our next visit (god knows when that’s gonna be).
On a related subject, I read an article about René Lacoste a while ago, and it’s the first time I got to know where the whole Crocodile brand started (in 1929), not long after Chanel’s first perfume No. 5 in 1921. That’s light years before Jordan and Tiger have their names in merchandise.
Lacoste is obviously a master on clay, in 5 consecutive French Open finals (25-29), winning 3 odd-numbered years. Now let’s see if Federer can get any inspiration from that…
June 1, 2006
Posted by geoffreyzheng under Movie
Leave a Comment
I saw most part of it a while ago when channel surfing and thought it’s hilarious. Last night it happened to show again and we saw it almost from the beginning. I thought J would think it’s too gross or something, but she seems to like it as well.
There’re some out of whack and gross-out moments, like the leopard carrying them away (maybe it has some drug connotation) and the diarrheal twins. But for the most part it’s outrageously funny with parody on cliche and stereotypes. The one-sentence plot is as stale as it gets: after a bizarre evening searching for a White Castle store, a Korean Wall Street junior analyst finds his courage, and an Indian dope lover finds his calling to become a doctor like his dad and older brother. The fun is in the process, though. The South Asian Club in Princeton is such a good laugh. And Harold’s dream lover is hot!
IMDb says the sequel Harold and Kumar Go to Amsterdam is in production will be released in 2007. Boy they’re gonna have some serious fun there!