Ninjas are deadly. Chipmunk Ninjas are just weird.
About this blog
Marc Travels
Marc on Twitter
JustLooking on Twitter

Marc Wandschneider is a professional software developer with well over fifteen years of industry experience (yes, he really is that old). He travels the globe working on interesting projects and gives talks at conferences and trade shows whenever possible.

My Publications:

My book, "Core Web Application Programming with PHP and MySQL" is now available everywhere, including

My "PHP and MySQL LiveLessons" DVD Series has just been published by Prentice-Hall, and can be purchased on Amazon, through Informit, or Safari


Popular Articles:

Top Tags:

Recent Comments:

cncool wrote:

GLint zeroOpacity = 0;
[[self openGLContext] setValues:&zeroOpacity forParameter:NSOpenGLCPS...
Posted to: Things I've learned about CoreImage (and Quartz, and OpenGL) in two weeks
Jun 10, 2009 | 00:45:58
Embarrassing Admissions #358581
By marcwan

Twice now in the last couple of years, I have needed to know the number of seconds in a year for some code I’ve written (always web-site stuff, it seems).

Twice now, in the last couple of years, I have immediately known that there are 525600 minutes in one year. Because of the musical “Rent”. The most god-awful mind-numbing tediously horrible 2.5 hour nap in my life.

For those of you who haven’t seen it, a quick summary:

  • Everybody has AIDS.
  • They’re homeless bums, but they’re bohemians, so it’s cool.
  • Did I mention everybody has AIDS?

This might very well be a throw-yourself-off-a-bridge kind of admission … I’m overcome with shame.

[Read Rest of Article]
Comments (0) Add Comment | Tags: rent musical kill me now
Jun 08, 2009 | 03:55:59
The changing face of shopping in Beijing
By marcwan

When I first arrived in Beijing in 2006, the city was booming. Everything seemed to be gearing up for the 2008 Summer Olympic games, and the locals couldn’t build fast enough. Part of this insanity was the embracing of everything Western, including Western-style grocery stores. For most of their history, the Chinese have been going to farmer’s markets, or 农贸市场 (nóngmàoshìchǎng) in the local vernacular. The folks here ply their wares selling fruits, vegetables, wheat products such as noodles and bread, or meat, but rarely a mix of them. When I first arrived in the city, we found one lady who wouldn’t rip us off too much, and would sell us vegetables at a fair price so I could cook at home. The arrival of the western-style supermarket looked a direct threat to their existence.

A key example of this was the newly opened 华普超市 (huápǔ chāoshì) or Hypermarket (Huapu is a transliteration of hyper) just up the road from my old house in Beijing’s Soviet neighbourhood. In addition to all the foods that locals were familiar with, there were huge sections carrying new, strange western goods such as cheese, bacon, breakfast cereals, more soda than you could shake a stick at, and candies, candies, candies. There were pretty uniformed girls hawking these goods heavily, and, more interestingly, other uniformed people explaining to the locals just what exactly things were, how you would use them, and why you would use them – “Yes, it’s smoked pigs’ leg. You put it in a frying pan and cook it, and then eat it along with some fried eggs for breakfast”. The locals weren’t sure what exactly they were buying, but with all the hullaballoo in the run-up to the Games, it must be good, so they patiently tried it out.

The French couldn’t open up their massive Carrefour stores fast enough to keep up with demand. All of the locations in Beijing were complete mad-houses on any given weekend, and there too, in addition to roast ducks, pigs feet, or the freshest in local seafood types, were the people helpfully explaining what red wine is and how to drink it, and what the best kind of washing machine and toaster over you should be buying would be.

You can’t touch this

Cue forward three years and one successful Olympic games, and what a difference in Chinese supermarkets today. Not unexpectedly, things have calmed down a lot since the Olympics, and while the local economy hasn’t crashed as hard as those in the west, things are definitely more sedate here now. In nearly all of the supermarkets I’ve been to over the last month, there has been quite the retrenchment in terms of products sold – gone are the breakfast cereals, the huge selections of dairy products and cheeses seen before, and even Carrefour’s wine section seems smaller. Even fruit, produce, and meat all seem to be reduced as well, with the stores now mainly making their money off staples such as rice, pulses, and dry goods (and instant noodles – never forget instant noodles).

The farmer’s markets and fruit stands are doing as well as they’ve ever done, and selling better produce than the super markets. This suits the local’s buying habits well, as they adore haggling over price with the vendors, and the fixed pricing scheme of supermarkets piques the local mindset to no end. Indeed, instead of encouraging the Chinese to adapt to unfamiliar Western dietary habits (sweet? for breakfast?), the large stores have had to really work hard to identify what the produce markets are missing, and focus on those – hence the increase in oils, rice, frozen foods, and cleaning supplies, with a huge decrease in perishable goods.

Does that mean there is no likelihood of the locals’ diets changing any time soon? One clue would be that the size of the soda and candy section at any given supermarket remains large and always looking to expand. Expect larger Chinese children in the near future.

And for those foreigners living in Beijing who simply can’t fathom waking up without a bowl of Frosted Flakes or fresh baguette, there are always the foreign supermarkets catering to them. Just expect to pay Manhattan-like prices for that half-pound of gorganzola cheese.

[Read Rest of Article]
Comments (5) Add Comment | Tags: beijing shopping groceries
May 24, 2009 | 04:07:08
Just another day in Beijing
By marcwan

On Friday night I was at Nánlúogǔxiàng (南锣鼓巷), when the following conversation took place -

The scene: Me, standing around idly playing a game on my iPhone waiting for some friends to finish browsing in the jewelry store, watching the people strolling past.

Chinese guy (very drunk): Ha-looooooooo!
Me (looking up): ?
Chinese guy (getting closer): Ha-loooooooooo!
Me:  Ha-looo?
Chinese guy (still drunk):  Do... you ... uh ... speak ... Chi-neese?
Me:  Yes.
Chinese guy (pointing): 啊太好啦!麻烦你告诉我那边是南边还是北边?
Me: 南边。那边是北边。
Chinese guy: 哈哈哈!我知道了,必须告诉我的女朋友!
Me (smiling)
Chinese guy: Thaaaaannnnk .... you!
(runs off)

Never a dull moment in this city.

[Read Rest of Article]
Comments (0) Add Comment | Tags: beijing chinese english nanluoguxiang
May 23, 2009 | 03:34:50
Crazy Hanzi (Chinese character) Chronicles
By marcwan

One of my favourite restaurants here in Beijing is a place by the name of 黄河水 (huánghéshǔi), or Water of the Yellow River. It’s a Sha’anxi Province (through which the yellow river flows) restaurant, has fantastic noodles, and caters to the locals, which means crazy crowds and lines, simple menus, and low prices.

Most chinese restaurants periodically update their menus and decor with new prices and signs. 黄河水 is no exception, and recently redid their interior. But instead of calling themselves a pulled noodle (扯面) restaurant now, they pulled out the most crazy simplified character any of us have ever seen and started calling themselves a biāngbiāng noodle place. Biāngbiāng is the sound noodles supposedly make when you stretch or pull them, sort of like boing or twang in English.

The character they found for biāng is pictured above. At 42 strokes, it’s hands down the hardest character that I or a Chinese teacher friend of mine have seen so far. None of the dictionaries, computers, or books I have looked at so far have it either. In fact, it’s the only instance of the sound biang I’ve ever seen in Chinese (If you look at all the possible vowel/glide and consonant combinations available in Chinese, a reasonable percentage of them never occur), and is probably made up based on some dialect.

Even nuttier would be that the traditional version, without the simplified radicals, would have at least 10 more strokes, putting it well over 50 !!!

China is currently going through a huge cultural debate as to whether the Simplified character movement of the 50s was a mistake and as to whether they should go back to the traditional characters. As somebody who has learned all of his Chinese in the former, and only had exposure to the latter in the Japanese versions, I will just mention that I’m insanely glad I learned the Simplified ones ….

[Read Rest of Article]
Comments (2) Add Comment | Tags: chinese characters biang biang hanzi
May 21, 2009 | 22:05:36
B-Kappu - A tale of Japanese TV and ... um ... chests.
By marcwan

[Note: This is an article I wrote one day while I was living in Sendai, Japan, in January 2004. I just found it while browsing through my Writing folder and thought I’d post it]

After just over six months of living here in Japan, the question I am most asked is: “How is life in Japan different from back home?”. The other night, at nearly two o’clock in the morning, I stumbled across something on Japanese television that serves as a helpful piece of evidence for my otherwise fumbling and awkward responses.

I was on the phone at the time with my fiancée, who is currently in Seattle completing her studies at the University of Washington. I had been up late reading a linguistics textbook, so it was no problem for her to call as she woke up. Since Japanese apartments are rarely as warm as I’d like them to be, I turned on the TV – as if this would magically make things warmer – before wrapping myself in a blanket and sitting down in the chair next to the telephone.

We chatted about the usual things: the cats, the Korean student living in our house with us, and the problems with the computers that inevitably crop up when the only person with any real knowledge about them leaves for any period of time. As my eyes wandered around the room, they would occasionally settle on the TV screen, where it appeared as though two pairs of males were wandering around with camera crews.

One pair, consisting of a somewhat sumo-like gentleman along with his much skinnier and shorter sidekick (it’s entirely possible that the more petit of the two was of average stature, but it was difficult to say in close quarters), was chasing pretty young Japanese girls around a train station, trying to get them to talk to them in front of the camera. As is normal on Japanese television, a constant stream of text in a funky font would slide across the bottom of the screen, transcribing each utterance they made. Of course, not being very proficient at Japanese, I could only read about 30% of it, and continued to let my eyes wander.

“Oh, and BB (that’s Boutros-Boutros Ghali, our one year old male Egyptian Mau) threw up again. He ate a rubber band, the dumbass,” came the voice over the line, drawing me back into the conversation. Our cats are very cute, but stunningly dimwitted.

The second couple of Japanese men, both of normal stature, also appeared to be spending non-trivial amounts of time running around trying to get pretty young girls to talk to them as well. They were in a bar talking with a girl band with three members. The sumo guy and his sidekick had since walked into a ramen bar, and had managed to get the three girls working there to agree to do something for them, again all helpfully spelled out for me at the bottom of the screen in an alphabet I can only barely read at extremely slow speeds.

“And I managed to get a new network hub, replace all the cables, and plug everything in. And it all works! Aren’t you proud of me?”

I really was, but at that time, strangely more concerned with why the four men were all in a hot-tub that had a rope drawn across the middle to divide them up into their groups. The hot-tubs were, in fact, what they call onsen here in Japan. Being one of the most seismically active countries in the worlds means lots of lava under the earth, which translates into some delightfully hot water coming forth from the ground. The Japanese, being incredibly crafty, harness this hot water and have places where you can go sit in it all over the country. It’s extremely common to see people doing this on evening television variety shows – the only caveat being that, while onsen typically separate bathers by gender and all are naked, on television they are wrapped in a towel.

So, while we were discussing the latest batch of bills that had arrived in Seattle, I was watching a hot tub with four men in towels, an announcer with a scoreboard, and a dividing line keeping the two groups apart. And then, from behind a rice-paper screen, arrive two girls in towels. They look somewhat nervous, smile at the camera, say something in Japanese, and get into the hot tub with the two normal guys. Then arrive three others, who get in to the tub with the sumo and sidekick. This continues until a commercial break, which distracts me and encourages me to pay closer attention to the phone conversation.

When my eyes next return to the screen, after some discussions of exercise (we’re both members of the latest and greatest fad diet: eating less and doing more exercise), there are many girls on both sides of the tub, and the two normal guys have 22 points to sumo and sidekick’s mere 11 points. Something about a bi-kappu flashes across the bottom, but I don’t quite catch it – two year old children are significantly more proficient at this language than I am. Where are those points coming from?

Well, stroll in the three girls from the restaurant, all in towels, again looking shyly at the camera. The camera then proceeds to focus in on two of them, and label the first C-kappu, while the second is B-kappu. C-kappu was worth 3 points while B-kappu was only worth 2. Then it became clear to me: they were getting points for the size of the girls’ breasts. An A-cup was worth 1 point, B-cup 2 points, and a C-cup 3 points. Each group of guys was supposed to go pick out 10 girls, and they would total up the collective breast sizes, and see which group was better at finding the ladies with the mammoth mams, as it were. Sumo and sidekick were down to their last three girls, and, trailing by 10 points, it wasn’t looking good.

But then they struck gold. The third girl, with all the shyness of somebody neither fully comfortable with her body, nor with talking about it in front of a television camera, quietly announced that she was an F-kappu. That was a full 10 points, rocketing sumo and sidekick to 26 points. The television exploded with noise, text scrolling across the bottom, and I couldn’t even really pretend to be fully engaged in my telephone conversation any more.

“Uh honey, I think they’re measuring women’s boobs on the TV here in Japan.” The camera vainly tried to zoom in on her ample bosom, as if to verify their magnitude, but the bulky towel clumsily wrapped around her torso helped them defy measurement. The sudden find meant that the score was now 26-21, with the two normal guys pinning their hopes on their last two girls. In a country known for women of petite stature, they would need some good fortune to win. The last two girls came out, and – the show cut to commercial.

Now it’s worth saying that this isn’t particularly gripping television watching, and thus, in an attempt to ensure my continued status as “engaged”, I returned to the telephone conversation in full. When next my eyes drifted back to the TV, sumo and sidekick had found themselves robbed by a couple of C-cups, who together tipped skinny guys over the top to a 27-26 victory.

And that was pretty much the show. I’d like to say that this was one of those odd shows that come only at two in the morning (like that weird show in Italy we saw in 1999 where girls come out on stage and take their tops off in front of a creepy, leering guy who looks like a 6’ tall Ron Jeremy), but I’d be lying. With other shows where girls sit in the onsen and bad mouth each other before launching violent streams of hot, frothy water at each other with the slam of a button, or guys, in a display of insane frugality, wrestle and catch 40kg octopi and eat frogs, this is pretty normal fare for Japanese television. I’d also like to say that this was a one-shot show, but that also appears to be untrue, as the credits at the end heartily reminded viewers to come back next week, when they’ll be getting pretty young girls to sing in a karaoke bar.

What a strange and wonderful country this is.

[Read Rest of Article]
Comments (0) Add Comment | Tags: b-kappu japanese tv japan
May 20, 2009 | 21:06:38
Armageddon is nigh?
By marcwan

Beijing has been a furnace of late. Over the last three days, the temperature has reached at least 35C (95F) every single day, with some days getting into the 36-37C range.

Thus, it was a bit of a jolt to my system when I want to check out the weather reports this morning and was presented with the graphic you see here. Tonight’s low would be in the -573C (-1064F) range. Never mind that this temperature is, of course, impossible, and well beyond absolute zero (which measures in at a wussy -273C) – it’sa be cold.

Now where is that sweater I packed away for the summer? I might be needing it after all ….

[Read Rest of Article]
Comments (0) Add Comment | Tags: PEK Beijing weather armageddon chilly willy cold
May 10, 2009 | 09:07:35
Input validation in web applications - plain bad programming
By marcwan

It never ceases to shock me the number of websites I run into that will complain when I enter 206.555.1212 or 206-555-1212 for a phone number. Similar things abound for credit card numbers, social security numbers, and all sorts of other structured input. Some designers, in a completely useless attempt to allay users’ anger, will go so far as to put a message above the input box along the following lines:

phone numbers must be entered exactly as (xxx)xxx-xxxx

Others will provide input boxes divided up as follows:

They will then add varying amounts of script to try and help you move between the boxes as you enter input.

These hints and script tricks all completely miss the point, however, and are symptomatic of one simple thing: programmer laziness.

Your users, honestly, just want the following

This lets them type in the required input (here, a phone number) in whatever format they want. 206 555 1212, 2065551212, or 206 555.1212 should all be valid input. All one does when trying to force users to a specific format is risk the chance that they give up and go away. If your site is in the business of trying to get customers to give you money, this is doubly unforgivable on your part: it’s like begging the users to not sign up with you.

The real sad part is that this problem is so trivially avoided. The code required on the server to validate the input and filter out only those values that you want is rarely more than a few lines, and something you should be adding as part of input validation and security any way !

For example, here is how you’d get a 10 digit phone number in PHP:

function phone_num($pn)
    $x = 0;
    $output = '';
    while (($char = substr($pn, $x++, 1)) !== false)
        if (ctype_digit($char)) $output .= $char;

    if (strlen($output) != 10)
        throw new InvalidPhoneNumberException($pn);
        return $output;

Here is something similar in Ruby, which I have never programmed a line of before 10 minutes ago:


# i'm sure there's a way better way to do this.
phone_number = "20    6  555 12 12 "
x = 0
output = ""

phone_number.length.times do
    if phone_number[x, 1] == "0" \
       or (phone_number[x,1].to_i >= 1 and phone_number[x,1].to_i <= 9)
        output += phone_number[x,1]
    x += 1

if output.length != 10
  puts "invalid"
  puts output

And no complaining about the efficiency about either of above the scripts – if input validation of user entered forms is a serious performance bottleneck in your application, you’ve either got serious problems with your hardware or even more serious problems with your application (more likely).

So, do your users, yourself, and your application’s security a huge favour: just write the 10 dang lines of code to be unusually tolerant of input. Chances are, you’ve already got a library of these functions somewhere.

While we’re at it: + is a valid character in email addresses. is a very common and very valid email address. I’m talking to you Fidelity Investments.

[Read Rest of Article]
Comments (0) Add Comment | Tags: input validation programmer laziness security
Apr 10, 2009 | 05:30:12
Really, Facebook? Are you Serious?
By marcwan

I’d like to introduce a new segment to my blog today called: “Really, Facebook? Are you serious?”

Point in question: the facebook logo in the upper-left corner of my Facebook homepage.

More specifically, the shockingly blurry and poorly scaled facebook logo in the upper-left corner of my Facebook homepage. Thousands of employees (supposedly), many of them über-smart people poached from the likes of Google and Microsoft – and that’s the best you can do?

Now, maybe you’re saying this is a browser problem and it’s because Facebook uses a clever and unusual font, but this is the first thing I see with pretty regular Firefox settings, and no other website seems to suffer from this same problem.

But, in all fairness, I am a crotchety old curmudgeon, so maybe my blood sugar is just too low or something.

[Read Rest of Article]
Comments (2) Add Comment | Tags: facebook logo wtf
Mar 22, 2009 | 03:11:35
Trying to get Twitter - FAIL
By marcwan

I’ve been trying to “get” Twitter for a while now. My business colleague Alex got me to sign up some many moons ago, whereafter I wrote a couple of messages and immediately proceeded to forget about it. With the recent hype surrounding it and how it’s the most awesome important thing ever to hit the Internet (evar) – apart from Facebook – I’ve decided, however, to give it another try.

I’m still failing miserably. I find that I can barely get into Facebook more than a few times a week to see how friends and acquaintances are doing via status messages, and most of that is because of the iPhone client that makes it really easy when I’m stunningly bored in a taxi. I find Twitter even more maddeningly frustrating to sift through.

But I continue to assume that it is I who do not get it, so I keep at it. I read one article asserting that Twitter’s advantage lies in its value as a search engine. So, I started to look through it for things that interest me by conducting a bunch of searches. Apart from the fact that half the queries didn’t work or bring any values back at all, looking for things related to interesting TV shows, nethack, Adwords Advertising, and PHP programming all gave me an avalanche of junk, with only the occasional nugget of interesting value.

Perhaps somebody else can mine this data to produce something more interesting, but right now, add me to the list of people who realise they’re watching something major and important unfold in front of them, and are completely baffled by it.

[Read Rest of Article]
Comments (1) Add Comment | Tags: i don't get twitter tweets
Mar 15, 2009 | 19:53:09
A mouse most unmighty indeed
By marcwan

As a child, my parents were very much of the train of thought that if you can’t say anything nice, it’s far better not to say anything at all. This leads me to frequently try to mute my (lack of) enthusiasm about various things I encounter, to varying degrees of success. And so, with the purchase of an iMac a few months ago, I’ve been constantly biting my lip, saying only wonderful things about it. But I can continue this charade no longer. It must be said:

The Apple Mighty Mouse sucks. Spectacularly so. Were it not for the pretense that this is supposed to be a semi-serious blog that semi-serious people will read and use to judge me in my professional activities, the length of the stream of invective that would come forth from my mouth (uh, fingers) would be surpassed only by the creativeness of the language chosen.

This is an assertion that didn’t just come overnight, either. I decided to overlook the fact that the mouse looks and feels like a Mentos suffering from gigantism, as well as the fact that the cable is about as flexible as a three day old corpse, as long as a cotton swab, and has a penchant for sticking up in the most annoying possible ways.

Indeed, even the stunningly annoying right mouse button that requires you to lift your finger from the mouse in an-RSI inducing manner before pressing it again so that it registers as a right click (with a failure rate of about 30%, I’ve found) is something that I was willing to tolerate. I pretended that the two side buttons, which work so poorly that that one scratches one’s head as to why they’re even there, don’t even exist.

The straw that broke the camel’s back? The mouse thumb roller ball. At first, it doesn’t even feel like a ball, but instead some sort of rubber nubbin thing that just registers vibrations and follows the motion. But appearances are deceiving: It’s just a little rubber ball with tiny pins inside that track its motion.

Remember how computer mice used to all have rollers in the bottom before everybody decided they massively suck and moved to optical systems? It wasn’t because of cost or construction – it was because that every single piece of dust, fuzz, or body hair that got within 10 feet of it would immediately be sucked inside the mouse and gum up the rolling pins. Consumers had to spend time every month disassembling their new fan-dangled computer equipment to remove the human detritus that had been gathering on their desk.

So, why did Apple decide to not only include a roller inside their new mighty mouse, but include one so delicately placed and finely tuned that it was guaranteed to gunk up within a matter of weeks? The mind boggles. What’s that? You live in a dusty climate that doesn’t resemble Silicon Valley? Hrm, we hadn’t thought of that one. I lost the ability to scroll vertically after 3 short weeks of ownership.

It gets better! Not only is there a mouse roller ball with pins and loads of goonk inside their mouse that requires constant cleaning, but they made the mouse impossible to open and clean! Yes, they super-glue the assembly together so that the only way to open it is with a very sharp blade, some equipment to pry it open, and the very real risk of serious hand injury. Never mind that you effectively have to destroy your mouse as part of the opening process.

Once you’ve got the thing open, there are two delicately placed cables that require disconnecting – open the mouse too quickly, and they’ll rip. And you’re not done yet! Then there are some screws to remove, and finally a plastic snap-on cover that requires lifting. Pull out the 0.5g plastic pins, clean them, try not to drop and lose them, figure out how to put them back in, and then put the whole thing back together, ignoring the fact that the plastic ring at the bottom is now wrecked and cracked from all the prying you had to do. I didn’t even care that, post repair, only vertical scrolling worked properly and horizontal was acting all weird and wiggly.

Of course, you could take it to the Apple Store (provided you’re lucky enough to live near one) for some service, but – really? Do you really want to have to make a trip to the repair centre (and wait for who knows how long) every few weeks for your computer mouse?

Thus, four weeks later, when my computer mouse once again started acting up and I lost the ability to scroll through pages vertically, I did what I should have done when I first bought the computer:

I went to the local computer market and bought a real mouse. It’s glorious. It just works.

(And apart from that, I love my new iMac. It’s blazingly fast compared to my old laptop, and it’s wonderful having large and fast hard disks again. The only downside is that I suddenly have to worry about power failures again, something I have not thought about in nearly four years.)

[Read Rest of Article]
Comments (2) Add Comment | Tags: apple mac mighty mouse sucks
Mar 10, 2009 | 03:15:56
Chinese Signs, Slogans, and even some Chinglish
By marcwan

While I’m not particularly keen on spending much time posting or talking about Chinglish and bad slogans and signs here in China – there are already plenty of sites on the Internet that do this much better than I – on a recent walk home from having some business cards made, I ran into a number of particularly comical signs, all in the span of a few hundred metres, and all quite chuckle-worthy.

The day started off somewhat surreally as I walked past a local Chinese restaurant, only to have the restaurant name supplemented by “MYSQL”. Buy one bowl of noodles, get an ACID-compliant transactional engine for free?

It turns out that the name of the restaurant is 明月三千里, or míng yuè sān qiān lǐ. Hence, the MYSQL. Still, good fun:

Next, I walked past a massage parlour that advertised “Cupping and scrape measles”. Cupping, or báhǔoguàn (拔火罐), is a reasonably common treatment here in China, which provides topical relief on the skin for various ailments. Scraping, or gūashā (刮痧), is another frequently used treatment for heatstroke and other discomforts involving scraping the back of the neck or upper back. Unfortunately, there is no direct translation like cupping, so when you take the two characters separately, the first gives you scraping, the second gives you “acute ailment”, such as measles or some other virus. Hence, some great sign fun.

Not that it’s a hugely common problem here in China, but I guess the maintainers of this little garden next to a scrool, across the road from the parlour, wanted to make sure that nobody would use their cute little park as a public toilet (there is actually a public toilet about 20m away). Hence this sign asking exactly that:

With the huge fire of the Mandarin Hotel building next to the new CCTV complex on the east Third Ring Road due to unauthorised fireworks, construction sites all around the city are now being extra careful to point out that fireworks are illegal in the city now that Spring Festival (Chinese New Year) is over. This one reminds readers that fireworks are illegal inside the 5th ring road:

And finally, I went to meet a friend for some lunch, and walked past a DVD store with this gem in the window:

Evidence suggests they meant to use the word “painting”, which would also be incorrect. The sign asks you not to write any graffiti on their windows. This is in Sanlitun, a big party area on Friday and Saturday evenings, with huge crowds of drunken foreign kids from 10pm until late.

[Read Rest of Article]
Comments (0) Add Comment | Tags: funny china beijing chinese signs chinglish slogans banners
Feb 21, 2009 | 01:27:14
Economic Slowdown in China?
By marcwan

When visiting the USA last summer for some business, the Beijing Summer Olympics were but 3 weeks away, and the hysteria in the West was at a frenzy: The Chinese are going to take over the world proclaimed seemingly every other news source. Radio shows were filled with people talking about the coming Chinese threat, and how the American way of life was at threat due to the waking dragon 4000 miles to the west. Even in Canada, during my visit there, there was a hefty amount of anxiety about the new world order and how things would never be the same.

One of the nice thing about events such as the Olympics, however, is that they focus the attention for only a short period of time, and talk of China in the West seems to have receded to more normal levels, especially as navel-gazing increases while governments try to solve the messes in their own backyards.

The question I am most frequently asked now is: How is the economic crisis affecting China? Is there evidence of a huge slowdown there? Like most things in China, it’s hard to say: there are few statistics offered by anybody, and those that are offered tend to be heavily manipulated and untrustworthy.

So, without any official data, lets look at the available anecdotal evidence:

  • Newspapers are full of stories of factories closing left and right, especially in the industrial heartland of the Pearl river Delta in Guangdong Province. People are going home en masse to the provinces, and not planning on going back.
  • Politicians are suddenly going out of their way to be seen as friendly to farmers. With so many farmers newly returned to the countryside and not as willing to tolerate a lousy feudal existence, the recent drought plaguing the entire northeast of the country is getting serious attention from all levels of government. Most of the unrest and protests in the country occur in smaller towns and villages, and keeping those people happy will be a priority for the Party.
  • In the big cities, real estate prices are markedly down. In Shenzhen, Nanjing, Hangzhou, and other major cities countrywide, real estate has fallen from 2500$ – 3500$ USD per square metre (purchase price) to well below 2000$ USD/m2. Worse, people who have placed deposits on apartments at the higher prices are demanding money back from developers who, desperate to fill the their units, are selling the remaining ones at hefty discounts.
  • Rents in Beijing are down at least 15%, if not more. At the high end, in apartments that cater to foreigners, rents have sometimes even dropped dramatically. I saw one new building here in the east 2nd ring road that was advertising 1BR units (about 90m sq, or 1000 sq f) for 1200$ USD not six months ago, and is now as low as 700-750$ USD per month. Even in the cheaper, lower glamour units that cater more to locals, rents that were 4000 RMB (575$ USD) per month are now going for, at most, 3400 RMB (490$ USD).
  • Food and restaurant prices are markedly up over the last two years, much more so than one would easily attribute to normal inflation levels.
  • The Chinese stock markets are down – way down – from late 2007 levels, often by over 70%. Locals who used to spend money completely recklessly because the stock markets would make it all back are much more cautious now. A recent 30% surge in the market already seems to be fading.
  • For an “on the street” measure, Yoga studios are hurting. Memberships, which were selling out at well over 8000 RMB a year (1150$ USD or so) are now heavily discounted into the 5500 RMB (< 800$ USD) range and you don’t see as many students being driven up in their chauffeured black Audis as before.
  • And at an even more “on the street feeling” level, fireworks during this year’s Spring Festival – the Chinese Lunar New Year – were the lowest in the three years I’ve seen them. Whereas, two years ago, the first night of spring festival was an insane war zone from 6pm until 3am, this year, it was mildly exciting from 8pm until 1am, but by 1.30am, most of it had died out and I was able to get a good night’s sleep without much interruption. This is a slightly tongue in cheek measurement, as much of the reduction could be attributed to the novelty of fireworks simply wearing out. 2007 was the first year in over 15 years that the central government allowed fireworks.

Evidence that goes against an economic slowdown exists to some degree too, however, and must be noted:

  • Retail spending appears strong. Statistics all point to it being quite robust, and anecdotal evidence shows many of the local shopping malls and department stores doing booming business many days of the week. Whether people are purchasing as much or just browsing more is hard to tell, and there definitely is a lot more heavy discounting in the retail chain.
  • Car registrations here in the country’s capitol continue to accelerate. In the first 45 days of the year, there were nearly 70.000 cars licensed with the city government, or well over 1500 a day.

Talking to people, more and more conversations do seem to involve the words jīngjìwēijī (经济危机), or economic crisis, and most Chinese people I know remain as frugal as they’ve always been, so it’s quite wise that the central government avoided any tax breaks or cash handouts to the locals, as they would simply save it and inject almost nothing into the economy.

Are things slowing here? Definitely? Is the crisis going to be a major disaster for the country and government in particular? Much harder to tell.

A note on the picture above: one of the questions I ask myself about China is why do they constantly design crappy buildings or (in this case) plazas/squares that don’t handle things like drainage (or wind, cold, rain, etc) properly.

The answer: it’s significantly cheaper to just hire people to squeegee away the water than to pay the extra to money solve these problems at design/construction time. This applies in so many situations.

[Read Rest of Article]
Comments (0) Add Comment | Tags: china economic slowdown 经济危机 中国 珠江河
Feb 05, 2009 | 04:51:48
What happened to winter?
By marcwan

Winters in Beijing are noted for being both cold and long, with late-January and early-February promising the most bone-chilling cold temperatures and blustery winds.

So, it has been with no small amount of surprise this week that the weather has been hovering around 9-11C (that’s around 50F in ‘mericun units), with nighttime temperatures barely breaking freezing any more.

Snow? Not even a dream any more in Beijing. Locals will tell you of a time 10-15 years ago when it would snow regularly here in the capitol during winters, but this year we didn’t even get the 1cm dusting that we’ve seen in the last couple of years.

As an absolute lover of both winter and snow, it’s been pure torture to watch all my friends in England upload photos of all the snow there, as well as the crazy-record amounts on the east coast of the US and Canada. Drat!

[Read Rest of Article]
Comments (0) Add Comment | Tags: snow beijing china global warming fiddlesticks
Feb 02, 2009 | 03:37:39
PHP Background Process execution in Web Pages
By marcwan

Executing external programs in PHP isn’t a very big surprise – a decent number of articles have been written about the topic, including one I’ve written. However, getting a process to fire off in the background and carry along on its merry way while the web page continues doing its thing is a bit tricker.

You’ll want to use the system shell’s & operator, which means we’ll use the shell_exec function.

If you tried something like:

shell_exec("/path/to/program &");

you’d probably see that the program fired off okay, but that the web page locks up until the program has finished running.

The trick, it seems, is to make sure there is no output from the program. So, be sure to redirect any output to /dev/null, as follows:

shell_exec("/path/to/program > /dev/null &");

And now you can fire off programs willy-nilly. Just be be aware of the security implications of this:

  • Be outrageously careful if you let user input factor into commands (I never do), as they might inject some malicious shell script.
  • Be prepared for possible denial-of-service attacks using this functionality: Are you prepared to handle the case where the web page is requested hundreds or thousands of times?

Happy Programming!

[Read Rest of Article]
Comments (1) Add Comment | Tags: php execution functions background process
Jan 30, 2009 | 21:24:50
An iPhone bug fix 18 months in the making
By marcwan

A few years ago, I had a Palm Treo, which was a pretty cool device – for 2004. The two big problems were its weight – dropping it would immediately break the glass, something I discovered four times in one calendar year – and its lack of UTF-8 support, which made entering accents and weird (read: Asian) characters impossible.

Fast-forward a few years to the iPhone, and finally you have a handset that is both 100% UTF-8 and actually shipping with a worldwide font so you can view emails and pages in Chinese, Japanese, and Arabic, and even enter contacts with names in those languages.

But there was a bug: Contacts entered in Chinese characters would not be sorted correctly – they were just lumped at the bottom and you just knew to tap “Z” when you wanted to text or email your Chinese colleague or friend.

The iPhone 2.2 firmware finally fixes this. They now sort names correctly, with Chinese names sorted by pinyin. (Oddly enough, Japanese names are still not sorted by romaji.) In fact, they’ve supplemented the UI for contact names so that you can enter (in Latin characters) how the name is pronounced and how it should be sorted.

An already cool device keeps getting cooler.

[Read Rest of Article]
Comments (0) Add Comment | Tags: iphone chinese contacts sorting localization UTF-8
Jan 15, 2009 | 07:05:38
Is China the future of Intellectual Property?
By marcwan
The Chinese sure do love a good Korean soap

Every twelve to eighteen months, the police here in China will swoop into one of the staples of the Beijing shopping scene – the cheap (read: pirated) CD/DVD store – and seize all of the merchandise within. Evening news programs will crow about the continuing victory of law and order, their cameras zooming in on the sullen faces of the shop owners as oficers carry box after box of their stock out to be destroyed.

Look a bit more closely, however, and you’ll see that this, like so many other things here in China, is a carefully choreographed show. It is not a coincidence that these raids occur in the weeks immediately preceeding the visit by an American trade representative with a laundry list of Hollywood’s complaints, or right before major international events, such as the Summer Olympics.

Without fail, however, the stores are operational again in a few weeks with “legitimate” merchandise, and with the regular materials maybe a month or two later. Locals and expats alike who enjoy reduced fare offerings will patiently ride it out and resume watching movies when they return. You see quickly that, in a free market without the West’s strict and particular intellectual property copyright laws, people are unwilling to pay the 10-20$ USD that a film or audio CD will cost them.

All the better reason, industry and trade officials will argue, to encourage countries such as China to join international organisations and start abiding by the same copyright regimes that they adhere to. When asked about the alarming decline in CD and DVD sales currently seen in the West, the ease with which anybody can download content from BitTorrent networks, or the unprecedented power Apple wields over the entertainment industry with its iTunes store, they’ll cough nervously. Ask about the increasingly desperate measures such as file-sharing lawsuits that far too often snare octogenarians or primary schoolers, and you can expect a rapid change in subject.

Looking elsewhere, it only gets worse. In October 2007 Madonna, a money-making brand-name machine, declined to sign a new contract with Warner Brothers, instead opting to sign with Live Nation, a tour promtions company (other big name artists such as U2 and Jay-Z have also signed with them). The move sent shockwaves through the industry, but was merely the latest manifestation of a trend that as already well under way. Here in China, rare is the musician or band that makes any money from CD sales and rarer is the one who expects to. Instead, all understand that the road to making money is though touring and merchandise. Other famous Western acts such as Radiohead or, more famously, Nine Inch Nails, are experimenting with alternative distribution mechanisms and making profits off things such as signed and numbered box sets and low-price online downloads.

Indeed, You see the music industry fighting tooth and nail against any changes that give the consumer more choice; purchasing only individual tracks instead of an entire album, being able to use puchased media on any number of personal devices instead of restricting them to just one, or somehow integrating music listening to the online experience (what’s that, you want to put a song on your YouTube video of your cat Chairman Meow attacking a ball of yarn? Not without paying you won’t!)

no, i am not paying royalties on this image
No, I did not pay for this image. I’m a bad boy.

Ultimately, as it is when any industry fights a tectonic shift as this, it is a losing battle. More and more bands will gradually defect and start trying to make a living in the new world. Eventually, to the great dismay of the others, one of the big record labels will jump ship, and the others will either follow or die. The new world of music will involve some officially free content as well as up-sells and touring.

Well enough, one might say, but what about the movie industry? There’s no touring there to make up for a decrease in theatre ticket revenues. But there are a number of other important factors to consider. Already, merchandising is a hugely profitable enterprise, and there’s no reason not to expect this to continue – kids love their Little Mermaid underwear. Secondly, there are large numbers of people who will pay for higher quality content than the average movie rental or iTunes download. With all of the hi-def TVs in use in the USA, some people will pay for access to better quality versions of their favourite films.

Perhaps the most devastating argument, however, against the status quo in the movie industry is the subtle shift occurring in Hollywood: TV is starting to get good. So good, in fact, that many people await the return of their favourite Television shows far more than they anticipate the arrival of the latest movie blockbuster, which has a high likelihood of being bad and costing a lot of money to go see. With the advent of TiVo-like devices, people no longer even have to be a slave to the schedules of the networks. They can watch their shows whenever they want. And if a show is bad, they’ll very quickly abandon it, encouraging Hollywood to develop better content.

No industry is safe. It gets harder and harder to make any money writing books. Most computer book authors I meet are thrilled to make enough to make a down-payment on a small car. Why purchase a book to learn a new programming language when there are hundreds of free tutorials online, all of which are likely to be more concise and useful. Few and very (very) far between are the Steven Kings of the world. At least in this industry there is recognition of the change at hand, and every possible avenue to survive is being explored – observe the relative success of Pearson and O’Reilly’s Safari book network. As Microsoft is learning, people are also increasingly unwilling to pay a premium for software when all they really want to do is surf the web. Equally few are the software companies making much money any more.

The problem is not that people are not willing to pay for things. It’s just that they want to have a sense that they’re getting good value for their money. Despite what Hollywood would have you believe, the decline in audio CD sales can partly be attributed to the broad perception that a lot of the acts coming out of Hollywood these days are poor, at best. Yet, sales for DVDs of TV shows are doing roaring business, as the Top 100 rankings on will quickly attest. Even here in China, where dubbed Korean soap operas dominate the airwaves, post-viewing DVD sales are significant. And one must not forget that iTunes continues to make Apple Computer – and Hollywood – bundles of money.

Some aspects of intellectual property are likely to remain reletively safe. As much as they rail against the huge number of fakes and rip-offs, luxury good manufacturers are probably not losing that much to piracy. People absolutely can tell the difference between a fake and the real thing, and enough people are still willing to pay for the prestige of the real deal (global economic meltdown aside). A real Burberry scarf is actually a lot nicer than a fake, and the people buying the fakes would certainly not be buying the real thing if there were suddenly no other choice.

But for music and film, which have enjoyed something of a Golden Age for the last half century or so, the glory days are over. They are running out of time to adapt, and this far don’t seem to be doing very well.

And so, as in so many other things, whereas some see the Chinese as rebels and rabblerousers, if you look closer, you’ll see that they just might be ahead of the curve.

[Read Rest of Article]
Comments (0) Add Comment | Tags: china intellectual property copyright law madonna cd dvd sales
Jan 08, 2009 | 18:59:34
Coolness vs. Age: FIGHT! (Hint: coolness loses)
By marcwan

During my third year of university, I took a course in compilers where, essentially, we wrote a pascal (well, Oberon 2) compiler in 3 months. I would wake up at 7am, go to the computer lab and start programming, attend classes as time permitted, and then go back to the lab and program until sometime around midnight. While this upset the girlfriend immensely, I did get a passing grade in the class.

About halfway through the semester, however, a weird thing started happening to my right eye: it was getting slower. I would move my eyes and my left eye would move very quickly to look at whatever I wanted to look at, but my right eye would take a fraction of a section to arrive at the same destination. It made for a very strange blurring / dizzying effect, and completely freaked me out.

I spent the next few months doing the most comical and insane eye exercises constantly. If you’ve programmed a lot, you know the kind: eyes up, eyes down, eyes up, eyes down, eyes left, eyes right, eyes left, eyes right, clockwise circle, three times, counterclockwise circle, three times. repeat ad nauseam, many times daily. People thought I was completely retarded or, at least, quite nutty (now that I back on it, it might not have had anything to do with the eye exercises … hmm).

But it worked: the class ended, the exercises continued for a while, and my right eye got better. A few eye tests showed that I had excellent vision in both eyes and would be fine.

Cue forward many (many) years to the present, where I’ve been working like a mad-man for the last n months on a new startup project, adylitica. My right eye is grouchy again. But this time, I suspect that no amount of eye exercises are going to do the trick – it’s very likely that I’m just getting older. The classic hyperopia that causes old people to tilt their heads at weird angles, pull out their bifocals and read things from as far away is slowly creeping its way into my life. It’s not all that bad yet, and the zany eye exercises have started again, but there’s no denying: I’m getting older.

When I first got into Macs, in addition to the unix underpinnings, I was always impressed with how stylish and well deisgned the UI was compared to other systems. One of my favourite things was the ability to have transparent Terminal windows:

It was super cool and made my computer look more bad-ass geeky (in a completely non-female attracting kind of “bad-ass” way).

Sadly, with the latest developments, I’m back to good ole’ old-folks style Terminal windows:

I’m still not at the point where I need to increase the font-size or do head gymnastics, but that’s coming, I’m sure!

Age: 1. Geekiness: 0.


[Read Rest of Article]
Comments (2) Add Comment | Tags: eyesight age terminal mac coolnesspic
Jan 02, 2009 | 22:15:10
Bringing my iPhone back from the dead
By marcwan

Well, the not-all-that-long saga with my iPhone 3G came to a very happy ending last night with the release of yellowsn0w 0.9.4. Stumbling home from a local bar and still a little wobbly from too much beer, I did a quick refresh of the iPhone Dev-Team blog and saw the latest version of their crack and tried it out, to very quickly be rewarded with the sweet, sweet words “China Mobile” appearing at the top of my handset. After a little under a week of using a very lousy Sony phone, I’ve got all cell phone and EDGE data functionality back on the Apple, much to my great joy.

With the iPhone dev team advertising heavily that you should absolutely not upgrade to the 2.28.00 baseband (the modem firmware installed by the 2.2 iPhone update), I was expecting to have to go get another hardware fix for my iPhone. Since they were going to have to install the new hardware hack, I was just going to let them remove the old one as well.

But the story took an interesting turn this week when the dev-team suddenly announced that they wouldn’t be hacking the 2.11.07 baseband, and instead would only help you get around the 2.28.00. So, now I needed to get rid of the parasite hardware thing, and quickly. Not wanting to wait for a trip down to 女人街, the local hacked phone market, at 11pm on New Years day I did a little bit of research, took a deep breath, got out the little screwdriver set and started pulling it apart myself.

↑ The only real trick is prying off the screen after removing the two screws from the bottom. You just don’t force anything and it comes open reasonably easily.

↑ Here you see the inside with the screen up top and the circuitry underneath. The orange thing in the SIM card slot up top is the hardware hack I have to get rid of. You can also see how dusty life here in China normally is. This was after I’d blown as much of the dust out of the inside as I could.

↑ The main circuit board removed. There are about 6 screws and a few connecters to get it out.

↑ This is everything.

↑ And this the hardware SIM hack strip I removed. I love how it looks like some sort of malicious worm or something. It came off quite easily.

[Read Rest of Article]
Comments (6) Add Comment | Tags: iphone lives yellowsn0w dev-team hardware teardown internals disassembly
Dec 31, 2008 | 11:33:31
My iPhone is dead, long live - no wait, it's just dead
By marcwan

In a reasonably recent article, I chronicled the purchase and subsequent untimely loss (via theft) of my first generation iPhone. While expensive and unfortunate, this had the nice side effect of giving me the chance to buy a second generation – 3G – iPhone to play around with some more.

Having had it for over two months now, I’ve been quite pleased with it, although the battery life leaves something to be desired. The 16G of storage and the better internationalisation support are huge enough sells on their own for me.

Given that the iPhone dev-team hasn’t cracked the 3G baseband yet and that I have been using such a non-cracked phone here in China for many weeks now, I was under the assumption that I was using an unlocked Hong Kong 3G iPhone, and could upgrade it as I wished to use it around the world.

It turns out I was wrong. Spectacularly so. Last night, after upgrading the phone to the 2.2 firmware (and therefore the 2.28.00 baseband), I now have an iPod Touch, with a permanent “No Signal” in the upper left corner. What happened? I do not, it seems, have an unlocked phone, but instead there’s a little shim SIM card inside the phone which does the unlocking for you, but only for specific basebands. While I can’t quite see which one I have, it clearly doesn’t like the 2.2 release’s new baseband, and stopped working entirely.

So, I have two choices:

  1. Given that new 2.2-enabled shim SIM cards are coming out, I can go to the same place I purchased the phone sometime later this week hopefully and get a new shim card to re-enable my China Mobile SIM card.
  2. I can otherwise wait for the dev-team to crack the 2.2 firmware’s 2.28.00 baseband, which will likely take a while, as they’ve only recently cracked the 2.11.07, and haven’t actually released that yet.

I could have avoided all of this by only updating the firmware and not the baseband, but that would have required understanding exactly what I had in my phone. Whoops.

[Read Rest of Article]
Comments (0) Add Comment | Tags: iphone baseband update dead
Dec 29, 2008 | 03:00:51
2008: The year that PHP nearly died
By marcwan

PHP started 2008 out on a roaring positive note. With adoption of PHP 4 finally dropping off to barely perceptible levels (apart from the occasional user complaining about how great things were in the good ole’ days and why do we have to change and – hey, get off my lawn you punk kids), PHP 5 had truly joined the big leagues, and the main complaint about the language shifted from it being be a quirky language with horrific (potential) security holes like register globals and klunky HTTP_POST_VAR arrays to it being a quirky language with crappy Unicode support. Talk about PHP 6, already quite vocal in the second half of 2007, was reaching a fever pitch, and some overly zealous people even started publishing books based on only some white-papers and vague ideas of what it would look like.

Along came March, however, and PHP 6 was nowhere to be seen. At conferences, questions from attendees and developers about rough guestimates for a final release dates were met with awkward coughs, sideways glances, and the inevitable “it will ship when it’s ready” response. When asked what they were working on, many people pointed out how focused they were on PHP 5.3 and near-term releases.

In fact, the more you looked, the farther and farther PHP 6 seemed to get, and the community suddenly got very quiet. As summer rolled around, much of the mindshare and energy seemed to be switching to framework development, as companies such as Zend realised they weren’t going to make money selling PHP and related IDEs alone, and other big name developers found themselves having to work to make money. News on the PHP website was hard to come by and limited largely to conference announcements.

While the rest of the web development community started to get excited about developments in new and exciting languages such as Ruby, Erlang, or even Python, PHP was starting to feel decidedly stale and old. The blogosphere went on one of its periodic “PHP sucks” campaigns, and loyalists found themselves on the defensive, trying to explain the whole needle-haystack / haystack-needle thing again and again. Late in the summer, a pretty alert colleague with whom I develop sites even commented that “PHP’s dying. It might be time to look at other options.” Throw in a non-trivial amount of bad press that MySQL seemed to be receiving after its merger with Sun Microsystems along with the latter’s subsequent mismanagement of employees and community, and it was beginning to look like time to worry about people jumping off the PHP/MySQL platform ship.

As the year grew old, however, and PHP 6 looked like a depressing myth, something interesting happened: PHP 5.3 started to gel together and enter alpha-release. Many features that had originally been planned for version 6 had been pushed forward into this release, including namespaces (including the much-derieded \ syntax), some international support, and some better math functionality.

Indeed, many of the non-vague or extremely optimistic features of PHP 6 will be showing up in this release, and I wouldn’t be surprised at all to see PHP 6 completely rebooted as a new branch and new project based on the current 5.3 line. Looking more closely, you’ll see that there were many of the same people this year quietly working behind the scenes on the project, developing and adding new features, and advocating in favour of the platform. People are still developing for PHP in huge numbers, and the language’s sheer productivity and ease of use make a compelling argument even in the face of sexier or more innovative-seeming languages.

With the arrival of 2009, and the pending release of PHP 5.3, one can feel the excitement in the air. With namespaces, closures, and continually improving i18n support (which is already workable, if not optimal), there is no reason to doubt that PHP will continue to be a dominant platform for years to come. Rest assured the language isn’t dead or dying. It just took a breather for a few months.

Happy 2009 to everybody, whatever platform you use!

[Read Rest of Article]
Comments (0) Add Comment | Tags: php is dead, long live php 5.3 php6
<< Previous Page   Next Page >>
Copyright © 2005-2008 Marc Wandschneider All Rights Reserved.