Star Wars Haikus

The Star Wars Trilogy is obviously the pinnacle of cinema — it’s just too bad that George Lucas never made more than three. That’s right, he never made more after Episodes IV – VI, nor did he ever digitally enhance them after the fact. That, at least, is what I will tell my kids. It will be a little like telling them Santa Claus is real: one day, some jerk at school will tell them the socially-accepted truth, and thus introduce them to a world a little less magical.

Anyways, you know I enjoy reading and writing funny haikus, so what could be more irresistable than a page of Star Wars haikus? Check it out.

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.”

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?