Monday, 7 July 2008

The Rain!

It's 9:00am, Julia left for work 2 hours ago, and I'm listening to the morale-building going on outside one of the real-estate offices across the street. The workers in the office building kitty-corner to us often file out and do calisthenics in the parking lot early in the morning. But every morning these real-estate agents line up in two rows (one of men, one of women) on the sidewalk and do cheerleading routines involving chants, clapping, singing, and hand gestures, often to music.

The heat and humidity are already up; the former due mostly to two rare days of clear skies over the weekend. I no longer trust my key-chain thermometer as I have long suspected that it always reads between 27 and 29 degrees. I attribute this defect to the photograph I took of it maxed out at 50 degrees in northern Australia nearly 3 years ago. Google, however, says it is 27 degrees and 74% humidity right now... not bad for nine in the morning. It's amazing to me that a place can be this humid in the summer (wait for August!) and so dry in winter. If the heat doesn't dehydrate you here the air conditioning will and I wake up every morning with a dry throat.

The clear skies this weekend probably came thanks to the rain on Friday (rain seems to settle the fine particulate pollution). Julia and I met for dinner after work on Friday and then decided to go to a movie. As we emerged from the restaurant, it began to rain lightly. As we emerged from the taxi and sprinted to the cinema, it began to rain heavily. Forty minutes later, as our film was about to start, they informed us that Cinema 6 was being shut down because of water flooding into it and that we could get our money back. Upstairs, parts of the street were now flowing like rivers as the rain alternately poured and paused in 5-minute cycles. After half an hour trying to find a taxi that was (a) empty, (b) willing to pick us up (not sure why this is a problem), and (c) closer to us than to somebody else looking for the same thing, we gave up and walked to the subway. Unfortunately the subway was closed, due (as far as we could tell) to flooding. Tiring of waiting, we crossed the street and attempted to decipher the bus system. We did eventually manage to get close enough to home that we could walk the rest of the way, having become wet enough by then that we'd given up caring about staying dry anyway. In total, it took us two full hours to get home... this city doesn't deal well with heavy rain.

Friday, 4 July 2008

I bowled a 162!

For as long as I've known Julia I've been trying to get her to go bowling with me. It's not like I bowl often but it's fun occasionally. Well we finally had the opportunity last weekend at a social event organized by Julia's company and while I couldn't knock down more than 9 pins to save my life in the first game, I managed nearly all strikes and spares in the second as I found my stride. People said I had "good form" which I guess I can only attribute to a few years of regular curling; I did feel pretty consistent.

Sunday was a busy day for us. Julia had uniform measurements and team building with her hospitality staff, then we had lunch and bowling, and then we had a few hours to kill before she and I went to a noodle and dumpling cooking class. Unfortunately, we really only had a demonstration and a little practice of the noodle pulling so I still can't claim to have successfully mastered the art but at least I have an idea how the dough should feel. The dumplings, or jiaozi, were quite successful: pork-and-celery and egg-mushroom-and-bok-choi. And I had left overs for lunch!

In other news, I'm currently struggling under the weight of decisions regarding employment, flights out of here, and their destinations so more to come once those are settled. I won't go into all the details of the complications of obtaining a Russian visa but, after a frustrating experience with the Russian embassy in Kuala Lumpur coloured by view of Russian hospitality, I have essentially decided to put off my trans-siberian trip for another occasion.

We're nearly within a month of the Olypmics here now so the pace is accelerating. Julia is busy at work, we have our spare room rented out, and I have an accreditation that removes the need for me to leave the country one last time. The new subways are nearly open and construction sites are racing to get their landscaping done and their walls down before the construction ban kicks in a few weeks from now. Should be interesting times ahead...

Friday, 27 June 2008

RSS Feed Change

Just a quick note to anyone (Steve) who may be reading the feed for this blog: I've decided to start using FeedBurner, mostly just to provide email subscription for people who don't know what RSS means but also because I'm curious. I've been told that many news aggregators don't follow redirects, so you may need to update your feeds to the new URL: http://feeds.feedburner.com/BlogDotFitzellDotCa

And for anyone who would rather receive an email when there are new posts, use this link: http://www.feedburner.com/fb/a/emailverifySubmit?feedId=2122389&loc=en_US

Friday, 20 June 2008

Bash: using the read command

While I normally use awk or sed to pull a piece of information I want out of a line of text, it doesn't work as well when you need multiple pieces of information. Well it works fine for displaying multiple pieces of information, but if you want them in variables to use later?

I once wrote a script that used declare to do the equivalent of this:
declare `w | head -1 | 
awk '{ print "DAYS=" $3 " " "USERS=" $6 }'`
# now do something with $DAYS and $USERS

Ewww... Now I know there's a better way: the "read" command. You could do something like this:
w | head -1 |
(read -a FIELDS
#do something with ${FIELDS[2]} and ${FIELDS[5]})

You can also do like so:
ls -l | tail -1 |
(read perms dunno user group \
size month date year file
echo "$user: $file")

You can even loop over all the lines of input. Let's take the /etc/passwd file as an example. Since that file uses a colon as a separator, we first need to set the IFS variable which determines what characters are used as field separators.
cat /etc/passwd | (IFS=:
while read user pass uid gid desc theRest; do
echo "$user: $desc"
done)

As pointed out here, this is also one way to deal with a file containing a list of filenames that may have spaces in them:
cat list | while read f; do
ls -l "$f"
done

Monday, 16 June 2008

Teenage Voting

I was reading an article on ChangeThis.com about the education system in the US and there was a quote that read:
Our educational system is the only major institution in our country that officially recognizes autocracy (in contrast to democracy) as its principle type of government.
I don't think that's correct. Rather, the education system is one of the few major institutions to deal essentially entirely with children; and children are dealt with pretty much universally as if they were living in an autocracy. That got me thinking about engaging teenagers in democracy. I wondered if there mightn't be some forward-looking European nation that included the under-18's somehow in the process.

The only case I can find is a BBC article stating the the Isle of Man has lowered their voting age to 16. This seems a reasonable enough action to me, despite the call by others (one example from a Maclean's article parodied here) that the age should be raised to 21 because "young people today have essentially tuned out". Yeah, preventing them from voting will really help them tune back in.

New York City apparently proposed a bill to lower the voting age to 16 and so have California and a number of other states, but as far as I can find, none have yet passed. The arguments in favour include: getting teenagers used to voting; that they pay sales and, often, income tax without any control over where the money goes; that they can be tried for crimes as an adult after 16 but can't affect the laws; that 18 is a bad age to start voting because students are heading off to college and have too much other stuff on their plates; and (most important to me) that they have more invested in the future than anyone else. I'm not even that old and I already have a slight trepidation at trusting "kids today" to cast a vote, but I'm still young enough to remember that I had perfectly valid and rational opinions in highschool.

I don't even know if you need to lower the voting age. The Californian bill initally proposed that "each 16- or 17-year-old's vote count as half an adult vote and each 14- and 15-year old's vote a quarter" (reference) but that was dropped before the bill was floored. Or what if, for example, everyone over 12 but under the voting age (whether it be 16 or 18) was invited to the polling stations and given a different ballot to cast. It would have the same choices but would only be advisory: the results would be reported, which would provide feedback to government, engage youth, and introduce them to the voting process. If you're concerned about children just voting randomly or following their parents (not that it really matters: adults do the same anyway) there could be a place on these ballots for written comments. They're informational anyway and what better way to get feedback from interested youth. I don't know... just a wild idea.

My favourite quote was in an article discussing a California bill to preregister 16- and 17-year-olds so they would automatically be ready to vote when they turn 18. A Republican assemblymam who was against the bill says:
The truth is, when you're young you tend to think like a liberal. As you get older and wiser … you tend to become more conservative.
Ha! So we shouldn't even help register young people to vote because they'll be liberals! The article goes on to say that Democrats killed legislation to require voters to show photo ID, and that Republicans killed legislation to allow citizens to register on voting day.

This makes me want to start my normal rant on party politics and career politicians, but I won't. In the end, though, the issue isn't so much specifically about youth. It's about politicians who have been elected by the current system being reluctant to change it. Whether the issue is proportional representation, holding polling days on weekends, or reducing the voting age (all of which could potentially increase voter turn out and the accurate reflection of their vote), the status quo seems just too tempting.

Bash: printing the alphabet

(Sorry for the geeky topic, non-geeky readers)

Most have probably run across the "seq" command that will let you generate a list of numbers:
$ seq 1 4
1
2
3
4
But you can do similar with "echo" for a list of letters:

$ echo {a..d}
a b c d
$ echo {a..d}{a..d}
aa ab ac ad ba bb bc bd ca cb cc cd da db dc dd

Wednesday, 11 June 2008

Think work sucks?

globeandmail.com: Think work sucks?
Actually, yes. Yes, I do.

Ok, let's be clear here: I like doing work but I don't really like the "traditional" work environment (an ironic term given the short length of time we've been working this way). Sarah forwarded me this article on ROWE (Results Only Work Environment) and all I can say is "Yes! Exactly! Has someone finally clued in?". Well, and also "Who came up with that name?". Maybe administrators love the name...

The idea is that you stop defining an employee's work in terms of hours in the office (or even hours worked, period) and start defining and measuring in terms of results. I've been lucky that most of my career so far has allowed me flexibility around the hours I work: a late morning here, a long day there, a banked day from working on the weekend, and so on. And I've always taken the attitude that, if I'm getting the job done, I don't need to feel too guilty if I spend a few minutes looking at a friend's photos while at work. But I've still always had to count hours because ultimately that's what I'm being paid for.

The difficulty with implementing a system like this, of course, is that it's easy to see if someone is sitting at their desk but much harder to determine whether they've achieved what you asked them to do. Plus you have to make sure your employees know what they're being asked to do. This may take more effort from managers to define tasks, set goals, and establish metrics. You might have to actually have those performance review sessions and dust off the 360 degree evaluation forms. But isn't this what managers are supposed to be doing anyway?

The end result is that there is just no excuse for not getting work done. As far as I can tell everyone wins, except possibly the guy in the back corner who hasn't done any actual work in 20 years. Maybe he gets motivated and actually finds himself happier? Maybe that's wishful thinking...

P.S. I don't think this ideas at the root of this are new or particularly insightful but if it's being adopted at all (and apparently Best Buy uses it) then that seems new.

P.P.S. What happens when employees start to feel like they're just being given a "harder" task than their co-workers?

Tuesday, 10 June 2008

Lipograms

Wandering through the bookstore at the airport in Kuala Lumpur, I came across this book. What caught my eye was not the title, but the claim on the front cover that the book was a lipogram and contains no E's. No E's?!! E is the most common letter of the alphabet. You can't even use "the" or "we" or "me" or "he" if you can't use E. How can you possibly write an entire novel without the letter E? At first I thought it was a joke but a quick skim certainly didn't turn up any occurences. Apparently the author wants to write one book for each letter of the alphabet... sheesh.


Tuesday, 27 May 2008

Two-way traffic

A few weeks ago we hired a driver and drove for two and a half hours (on the first day of a holiday weekend, no less) to one of the Great Wall sites. We thought we had negotiated a price that included road tolls so I was surprised to find us on small toll-free highways in so much traffic. I spent a good portion of the way there looking at sometimes-solid-sometimes-dotted expressway markings on the map that seemed to be running largely parallel to our route and telling myself that perhaps it just wasn't open yet. But the expressway isn't really the point of this story.

On several occasions, I've observed a certain traffic phenomenon here and this trip provided a good illustration. In China, you see, when someone or something on the road is in your way, you just... go around. Even if it means moving into an empty space in the oncoming lanes. Ignoring the danger of an accident, it seems reasonable enough at first glance: save yourself some time, keep the traffic flowing.

An hour or more into the trip we came along a particularly heavy patch of traffic and, as we inched along, I began to suspect what had happened: you see, this section of road had five lanes of traffic in total but there were four lanes going our way. Not a normal distribution. Sure enough as we moved along we came to a point where there were suddenly four lanes going the other way and ours all merged into one. Can you picture this? There was now one through-flowing lane in each direction and, in the middle, three lanes of traffic coming each way facing head-on into each other.

You can picture how this would happen: one direction slows up for some reason, someone darts around into a gap but doesn't make it back in because the traffic is moving slowly and there are no gaps. This blocks the traffic coming the other way and cars further back in that line, in frustration, dart around the stopped traffic ahead and find they can't get back in because the traffic has stopped. This is similar to the effect known as shockwave traffic, which produces traffic jams from something as simple as one car slowing too quickly in heavy traffic. Scientists in Japan recently managed to recreate this effect in a controlled environment. If you've never heard of this, check out the video mentioned in the above article or check out this computer simulation (click on "1: Ring-road" once it loads). Then you'll understand why that huge traffic jam you're stuck in often has no obvious cause when you get to the end of it. If you want to read more, check out here and here.

So, as the traffic keeps backing up, cars keep trying to go around and end up blocking more and more lanes. If the cars would only cooperate, they'd all get where they're going faster. Because everyone's trying to maximize their own forward progress, however, they end up in near gridlock. This kind of greedy algorithm reminds me of the Prisoner's Dilemma.

On our way home, we came upon the same patch of road and came to a complete stop for 15 minutes. Eventually, somebody opened a side street that had been blocked off and we were able to begin diverting around the stalled traffic into the countryside. As we moved our way forward, guess what I saw laid out in front of us?

Yup, 5 lines of traffic all pointing in the same direction...

Tuesday, 20 May 2008

Midnight Turf

It's midnight and I can't sleep. I'm lying listening to the rumble of trucks outside our window (open because it's getting to hot to sleep with it closed and we're still resisting A/C). "Turf?", I wonder?

Sure enough, a quick look out the window confirms the arrival of four large trucks carrying turf to be laid outside our apartment. The landscaping has been an ongoing project since we moved in nearly three months ago. Most of the time, the workers deliver their materials during the day using three-wheeled bicycle carts but some activities including including larger deliveries and a large loader shoveling bricks and other debris into dump trucks seem to occur in the middle of the night. Turf was laid on about half the area several weeks ago but much of was over-watered, died, and was finally pulled up again this week. Hence my hunch about the delivery.

Why the late hour? Apparently large trucks are prohibited within the 3rd or 4th ring road during the day without special permission; I hadn't noticed the nearly complete absence of trucks until someone mentioned it to me. Perhaps I should take a midnight walk one of these days and see what other trucks are driving around...

Monday, 19 May 2008

3 Minutes of Silence

At 2:28pm today, one week since the disastrous earthquake in Sichuan, people all over China maintained 3 minutes of silence for tens of thousands of victims who were killed. I stood watching from my apartment window as the office workers emerged from their buildings and the migrant workers planting flowers stood from their work. Everyone appeared to face southwest as car horns across the city began to blare continuously and in unison. What would normally be one of the most irritating noises imaginable, this time proved strangely moving...

Wednesday, 14 May 2008

The case for generalists

Seth Godin makes a case against being a generalist.

The problem is, I think the metaphor breaks down. Sure I want the best possible surgeon to fix my heart but I don't want to pay that surgeon to look at my sprained ankle or listen to my chest cough: there's a trade off there between specialization and cost. Also, I don't want a plumber, no matter how good he or she may be, to build my house for me. For that task I want a really good GENERAL contractor. Someone who knows just enough about all the parts of the house to make sure everything is done correctly and in the right order. A contractor who is good enough to know when to bring in other experts when necessary.

It seems to me there's a huge need for people who know enough about enough different things to communicate with and coordinate the specialists. Contractors, project managers, integrated health practitioners, and so on...

I've been thinking recently about companies hiring consultants. They bring in "specialized" consultants who throw buzzwords around and tell them what they Need To Do. The problem is that often nobody at the company knows enough to know what the consultants are talking about. What you almost need to do is hire another consultant (a generalist) for just long enough to talk to your other consultants and find out if what they're suggesting makes sense. I met a computer programmer type who did an internship (not specifically computer-related I think) with the airport authority in Beijing. In meetings, he was the only one with enough knowledge to really evaluate much of what the contractors were saying so they hired him on after his internship for quite a large sum of money to continue filling that role of "translator".

Now Seth also seems to suggest that the general contractor might even be considered a specialist role itself but then... what role isn't?

Monday, 12 May 2008

How did I not feel that?

News agencies across the world are reporting that a 7.8 magnitude earthquake hit central China this afternoon. It seems I was running on the elliptical machine at the gym at the time and didn't feel a thing.

I did notice construction workers streaming out of a tall building across the street and it seemed like people in the street (and even some of the gym staff) were looking up at something on the building. I even stopped running for a moment and turned off the mp3 player to see if there was a siren but couldn't for the life of me figure out what was so interesting.

Upon getting home I found two text messages on my phone asking if I had felt the earthquake and, having smelled a slight gas smell in the lobby on my way in, decided to grab our documents and head over to a coffee shop for a few hours just to be safe. The coffee shops at the business park near our house all seem busier than usual and I've overheard a few snippets from people who felt some significant shaking. I think people must have left their office buildings after the quake and many decided just to stay in the coffee shops.

Early reports suggest damage in Chengdu, the closest major city to the epicentre, is minimal though there seem to be some deaths and injuries in the smaller towns; I'm pretty sure there won't have been any damage in Beijing where it was apparently felt as a 3.9 magnitude tremor.

Saturday, 10 May 2008

Edelweiss

Awoke this morning to the sound of "Edelweiss" (from The Sound of Music). What's particularly strange is that this is the second time I've heard this song here this week (we came across about 20 couples waltzing to it outside the Workers' Stadium last weekend). At first I thought it was our new neighbour upstairs who seems to practice the piano, the violin, the saxophone, and what someone more generous than I might call "singing" (even calling it karaoke would be gracious) throughout the day. Turns out it was a brass band playing for what looks to be a shop opening... how did this song get so popular over here?

Update:
Now I've got it stuck in my head again... gah!

Thursday, 8 May 2008

Olympic flame summits Mt. Qomolangma

I turned on the TV this morning just as the Olympic flame was being carried up the last 100m of Mt. Qomolangma (the Tibetan name for Mt. Everest), the world's highest peak. The media here has been anticipating this for weeks, probably since the torch relay began. While it seemed like a good gimmick I have to admit to a little bit of apprehension: it was hard to imagine the climbers calling of the summiting attempt, no matter how bad the weather was. How could you fail after building it up so much?

Luckily the weather looked good and they made great time to the top. And watching the footage I had to admit it was a fairly powerful image and pretty memorable achievement.

In looking into the torch relay, I discovered I had missed this leg of the Sydney torch relay: another unique gimmick.

Olympic Tickets

Looks like we've successfully obtained two tickets to see Beach Volleyball at the Olympics. I've been cursing myself for not getting on top of this earlier and picking through the scraggly tickets left at the various official national tickets sellers for which we could possibly qualify (Canada, Ireland, Germany). Not much left, let me assure you...

Then we caught wind on the news on Sunday that the 3rd round of Chinese sales would begin Monday morning, and as luck would have it Julia qualified on account of her visa type. The selection was still somewhat limited and I spent 5 hours or so Monday repeatedly clicking and waiting for the inevitable "Sorry, we are unable to process your request at this time" which was the result of the huge load hitting the servers. I finally got an offer of two beach volleyball tickets shortly after lunch. Because of a rather complex, bureaucratic payment process, I was unable to acquire any more but at least I'll get to see something (and the tickets were only $7.50 or so each!). Some people, having failed to get tickets in the first two rounds, apparently trekked across the country to line up for tickets at Bank of China branches in Beijing the night before. Olympic fever is building...

Wednesday, 7 May 2008

A Beijing Expat Wife

People here often ask what I'm doing here. I used to say I was looking for work or that I was doing contract work or thinking of taking some classes. Or I'd give the long spiel about how my girlfriend was doing an internship, blah, blah, blah. Now I just say "I'm an expat wife" and pause for the double take. Hence the new title for the blog: "A Beijing Expat Wife: Excuse the facial hair..."

Friday, 25 April 2008

Asterisk on VMWare

Many people have reported problems with Asterisk running on VMWare and having just decided to play with Asterisk I ran into them myself. First, here's what worked for me (using CentOS 4.6):

  • On the VMWare host machine, edit the .vmx config file for your image and add:
host.noTSC = "TRUE"
ptsc.noTSC = "TRUE"

  • In your CentOS image, disable the cpuspeed process:
chkconfig cpuspeed off

It actually worked fine for me without the extra kernel parameters but the CPU usage seemed to be slightly lower at idle with them added so I left them. The issue seems to be the default clock rate (1000Hz) used by most 2.6 kernels which can't be adequately serviced in the VM guests. The kernel-vm kernel is built with the clock rate at 100Hz.

Apparently CentOS 5 has a new kernel that allows you to specify divider=10 clocksource=acpi_pm to the kernel which tells it to run at 1/10 the clock rate it was compiled with.

Some links:
http://communities.vmware.com/message/762010#762010
http://bugs.centos.org/view.php?id=2189
http://communities.vmware.com/thread/101492?start=0&tstart=0
http://communities.vmware.com/thread/101406

Wednesday, 23 April 2008

Adjusting MTU to improve ADSL performance

So here I am in China, being driven mad by the number of dropped packets I'm seeing. Mostly it's not too bad until I make a VPN connection and then I'm seeing somewhere in the neighbourhood of 10% packet loss on a ping.

Well, after much, much debugging and internet searching I think I've finally found my problem: the MTU setting. MTU is the Maximum Transmission Unit or maximum size of an individual frame being sent on a network. Ethernet has an MTU of 1500, which is usually set as the default value for connections (at least in MS Windows). But other network equipment along your route may not be using Ethernet and may have a lower value. This is ok in theory; the equipment will break up larger frames into smaller ones and combine smaller frames into larger ones as the data is transferred between different networks.

The problem usually comes when your ISP's equipment is using an MTU slightly lower than your value. Apparently PPPoE connections always have a lower MTU than Ethernet (usually 1492) but Windows XP already accounts for that by reducing the MTU for PPPoE connections to 1480. In my case, though, China Telecom seems to be using equipment with an MTU of 1398.

What happens is that I send out 1480 bytes of data and China Telecom sends the first 1398 bytes and then holds onto the remaining 82 bytes until it gets some more data from me. Let's say I send another 1480 bytes. Now the first 1316 bytes of that frame are added to the 82 bytes from my first frame and sent and the remaining 164 bytes are held onto. This is slightly inefficient and can make the connection seem "bursty" because data is being held up before being sent. It also tends to get a lot worse if your connection is flaky (which mine is); I think this is because a lost frame along the way may hold part of the data for 2 or more of my original frames, all of which now need to be retransmitted. VPNs (because of the way TCP packets are being embedded into TCP packets) apparently amplify these effects further.

So how do we solve it?

Finding the Correct MTU

First, you need to find out what MTU setting your ISP is using. This MS KnowledgeBase article describes how to do this. Basically, you pick a host as close as possible to you on your routing path and run the following command:

ping -f -l size

The -f marks the packet as non-fragmentable and the -l size parameter specifies the number of bytes to include in the ping packet.

Start with a value of 1472 for size. If the ping is successful, your ISP's MTU is 1500. If you get the error Packet needs to be fragmented but DF set then decrease the value of size and try again. Once you find the highest value that allows a successful ping, that value plus 28 (20 bytes for the IP header and 8 for the ICMP header) is the correct MTU value.


Adjusting the MTU Value in Windows XP

Follow this KnowledgeBase article to set the MTU value for PPPoE (also seems to affect all VPN connections - not sure if there's a way to avoid that). Basically you want to set the following registry keys (all values are DWORD type):

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NdisWan\Parameters\Protocols\0]
ProtocolType = 0x00000800
PPPProtocolType = 0x00000021
ProtocolMTU = 1480

Obviously you would adjust the MTU value as desired and make sure to choose "decimal" when inputting the value. You probably have to reboot.

You may alternatively be ale to specify the MTU for the PPPoE interface here:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{Adapter-id/GUID}]
MTU = 1500

but I haven't tested it yet (again, adjust the MTU as desired and choose "decimal" when entering the value).

UPDATE: I tested setting the MTU for just the one PPPoE interface as above and it seems to work fine. I set the MTU value for NdisWan back to 1480 and will probably test removing that section from the registry altogether to see if it still works.

Other possibly helpful links:
http://www.speedguide.net/read_articles.php?id=157
http://www.speedguide.net/analyzer.php