The Chinese Model

Well, I just went out and bought myself a new cell phone! It’s a pretty exciting moment, because my previous phone was the cheapest and crappiest one available, and this new one is quite a step up.

The main reason I bought a new phone is because I really wanted to have a decent camera always in my pocket. I can’t count the number of times I’ve cursed myself for forgetting my camera at home, and on the few times I do remember to bring it along, it’s big, bulky, and ugly. So I bought this camera phone. It’s got one of the best cameras on the market, and even better, it’s got a xenon flash. For my daily life in China, it will be incredibly convenient, because the most picture-worthy moments are never anticipated, and now I will be properly armed to handle them.

The phone is more than that — it’s also a smart phone with WiFi and 3G capabilities. How cool is that? Very cool, if you don’t happen to live in China.

I had just pulled out my new phone and was looking to connect to the office WiFi network … but wait a minute, where was the WiFi  manager? For the life of me, I couldn’t find it. So, doing what I always do when confronted with a problem of a geeky nature, I consulted Google.

Well, I should have done this before I bought the phone. (I actually spent about two weeks reading reviews of various cell phones, so it’s not like I bought it blindly). It turns out that of all the dozens of different versions of the N82, the Chinese version has no Wifi or 3G! My stomach dropped. What kind of stupidity is this?

I again turned to Google. After some incredulous reading, I learned this: for a phone to be legally sold in Mainland China (e.g. not Hong Kong), it must have the WiFi and 3G disabled. What? But why? Well, as for the 3G, the Chinese government has apparently developed its own homegrown high-speed protocol, and wants to promote that and stifle 3G. To use a 3G network, royalties must be paid to the copyright owners, all of whom I assume to be American. I guess you can see why the Chinese government is opposed to this.

And as for WiFi, apparently the two main mobile carriers in China (China Mobile and China Unicom) are concerned that WiFi will cut into the income gained from data transfer and international calls. For example, you could use Skype to call internationally, and the carrier wouldn’t get a penny (but you also wouldn’t be using any of their infrastructure). Also, you could surf the internet and download data without being charged to your SIM card. Never mind the fact that these are the only two companies that provide internet (it’s all ADSL here)! Anyways, I guess the government listened to this, and outlawed WiFi on mobile devices.

I was hoping that it was disabled on the software level, and I could just flash the phone and get the functionality back. But a quick look at the schematics proved me wrong: the wireless antenna had a big red circle around it with the label “This section not assembled in RB-314.” The RB-314 — or the crippled version — is sold only in China. FRUSTRATION!

I don’t think I’ll be able to take the phone back, because they’re technically nothing wrong with it. So here I am. I should have bought it in Hong Kong, but live and learn, I guess. And really, these two features were just icing on the cake: there’s no 3G in China yet, and it’s not like I really need the WiFi. I bought the phone for the excellent camera (which really is quite excellent). It’s just not a phone I will have for a long time (as I had originally planned).

This is where Jamie chimes in: “Such is life.”

The Chinese Time Zone

Of the four largest countries in the world (Russia, Canada, America, and China), what sets China apart? Well, many things, but for now I don’t mean those things — as the post title reveals, I mean the time zones.

I don’t need to explain why we have different time zones, or why the world thinks they are a good thing. What I do want to talk about is why China has only one time zone. Isn’t that strange? Any country with a tolerable East-West span has multiple time zones — Russia has no less than ten — and China is certainly longitudinally hefty enough to qualify. But nope, the China Time Zone ostentatiously interrupts the nice North-South bands of color on the time zone map.

Is it a coincidence that China's color is yellow?

The China Time Zone

As you can see, China spans five of Russia’s time zones. I personally find that quite incredible. So, being in a position such as I am in, I took the opportunity to ask some of my students about why this is so.

Like every time I bring up a subject like this to my students, I’m immediately greeted by the CBSOD (Chinese Blank Stare of Death — I’ll write a post about it one of these days). So I elaborated. I explained why time zones exist, and why many people in the world think they are a useful convention.

“But it’s not useful,” they insisted. “How is your country not in total chaos, what with Toronto three hours ahead of Vancouver? Isn’t it extremely inconvenient to do business or talk to your relatives?”

I must admit, I hadto concede this point. It can be inconvenient, occasionally. But then I counter:

“So, since the Chinese time zone is based on Beijing time, what about those unlucky millions living in Western China? If the sun rises in Beijing at 6 o’ clock, it won’t rise in Urumqi until almost 10! And it won’t get dark until at least 1 in the morning! What are these people supposed to do? They can either spend the first few hours of morning in the pitch black, and go to bed when the sun is still high in the sky, or they can align their sleeping hours to the light/dark cycle. The former sounds like a hellish way to live, and the latter results in the Western China working hours being unsynchronized with Beijing — which is essentially what time zones do.”

I waited for enlightenment, but I only recieved the CBSOD. For all intents and purposes, the conversation was over.

I have some ideas of why China throws the world-ratified time zone convention to the winds. Perhaps it is due to the centralized nature of the government: one people, one standard. Or perhaps it is because the Western provinces are much poorer and sparsely populated than the overflowing East, and is generally looked down upon by the Eastern public. But I don’t really know, nor, I think, do the Chinese people.

What are your ideas?

A Customisable Command-Line Password Generator

One of my earliest Python exercises was creating a command-line password generator. Over time I’ve been tweaking and improving it, and I feel that now it’s ready to share with the greater world.

The program allows you to create random passwords of a specified length. The randomizing algorithm goes beyond a simple random.choice() call, due to the inherent limitations of Python’s random number generator. Here’s the algorithm I worked out:

The result of the current Unix time and the argument is divided by a random number determined by random.random(). This is then Base64-encoded, and the chosen punctuation marks are appended, if applicable. Finally, the required number of characters are chosen via random.choice().

I realize I only really escape the random module the one time, by seeding with the current Unix time. However, I hope the various convolutions make up for that.

By default no punctuation marks are included, but there is are options to either include all punctuation marks, all the punctuation marks minus the user’s choice, a reduced set of punctuation marks (no quotes or brackets/braces/parentheses), or a user-defined custom set. I’m debating whether to make the reduced set included by default with an option to have no punctuation, rather than having punctuation by default turned off.

There is also an option to create a leet (a.k.a. 1337 or l33t) password. This is sometimes a good way to create an easy-to-remember password, but it is actually considered to be somewhat insecure, for the same reason that using a dictionary word as a password is insecure. Password-cracking programs have grown in sophistication so as to now be able to handle common character substitutions. However, you can choose to include some special characters if you choose, though they must be hard-entered (i.e. you must pass any special characters in your submitted string, and they will not be randomized).

The next improvement I have planned is adding a key-press timer for another random seed: either the user holds a key down for a random time, or waits a random time and hits a key to stop it. This will either be default or invokable by command line flag.

Anyways, let me know what you think, and let me know about any bugs or ways I can improve the code!

Download Passgen!

EDIT: I’ve decided that I’m going to try to implement this program in C++ . . . one day. Not only will it be a lot faster (not a big concern), but it will also be much more cross-platform. I will also try to implement a simple GUI . . . again, one day. Any other suggestions?