Zhanga: January 2008

Entries have their own pages now. Click the date to see the entry by itself with its comments.


Thursday, January 31, 2008 (1 comment)

Ok, it's that time of year again, when poor, helpless CS students are just beginning to look for help but it's not yet late enough into the semester that they've been beaten with the clue stick yet.

Let's look at a simple counting loop:

int count = 0;
for(int i = 0; i < something; i++) {
   if(something else) {
      count++;
   }
}
return count;

Simple, right? So I was helping this girl with a small programming assignment. She opened a file containing 25 or 30 lines like this:

int low = ..., high = ...;
...
String y = "";
while
   for
      if
         y += "E";
      if
         y = null;
return y.length();

Let's forget about the fact that this problem can easily be done in 3 lines, no loops, and one if. And let's forget about the other horribly ugly mistakes I saw in the code, just to be nice to her.

Let's just focus on the variable y. I've shown you all four places this variable is used. Is she seriously using a string as a counter? Why are we appending E's to the string instead of just adding 1 to an integer? And why does it sometimes get set to null? (Luckily, her broken while condition ensured that the loop never ran, preventing a NullPointerException.)

Interestingly, to solve a problem that requires no loops, she used a nested loop. The inner loop looked like this:

for(int i=0; i < 100000; i++)

Why 100000? Dunno. She pulled it (incorrectly) out of her ass. I was just relieved it didn't look like this:

for(String z=""; z < "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"; z += "E")

The semester has officially begun. She has been hit with the clue stick.

(Side note: I think I'm getting better at this "being tactful" thing. When I first saw the code I was vomitting in disbelief, but I managed to keep the vomit internal and got her to get rid of that ugly code without mentioning it at all. I guess that's why I'm letting it out here...)

9:45PM


Sunday, January 27, 2008 (15 comments)

I remember one day in fifth (third?) grade, a bank representative from a local commercial bank came to talk to the class and try to brainwash us all into feeding money to him and his bank.

He asked us, "How much do you think this dollar today will be worth a hundred years from now?" People raised their hands and started giving random guesses, like $5, $50, $200, etc. I raised my hand and, ever the optimist, told him two cents (or similar).

This asshole laughs at me and listens to a few more guesses before making up some absurd number in the $100-200 range (at 5%/year, you get $131.50). I had serious beef with this because:

  1. First of all, he didn't say the dollar was making interest...
  2. "How much is X worth" implies its real value, not its nominal/face value. A dollar today is worth more than a dollar in a hundred years. The most important factor here is obviously inflation, which he conveniently ignores. At 3% inflation, your dollar becomes 4.8 cents after 100 years.
  3. The rate on savings accounts these days is 0.20%. Don't believe me? This is well below inflation, which means you lose money by putting it into a savings account. (And that's only counting explicit costs. If you include opportunity costs, it gets even worse.) At 3% inflation and 0.20% savings, you've gained 22 cents on the dollar, but your $1.22 is only worth 5.8 cents after inflation.

Plus, you and your kids are dead after that hundred years anyways, and now the tax man wants his nickel out of the 22 cents you passed on to your grandkids.

You're probably wondering why this became a blog post. I'm preparing for finance interviews, and it just reminded me of this incident, I guess.

In the end, I can't say I was too displeased with the man. He gave everyone in the class a dollar. He thinks my dollar is worth $2 now, but I think it's lost under my mattress or something. (Did he remember to include that risk in the discount rate?)

God, this is like one of my computer posts, except it's nerdy in a different direction. I just can't get away from being a nerd. Actually, I find the Wall Street Journal to be pretty funny sometimes -- the articles will frequently talk about tech things and try to explain them in terms of financial or investment concepts. Last week, they explained domain name front running by relating it to insider trading, which I found fairly amusing. I guess it's because I'm used to reading explanations of non-computer-related fields in terms of computer things, not the other way around. It's a fresh perspective.

For the record, I still think nerdy computer jokes are way funnier than nerdy econ/finance jokes.

4:04AM


Friday, January 25, 2008 (1 comment)

The annoying girls in my Chinese class are gone! No more burying my face in my arms to avoid listening to their nonsense. No more getting my meat stolen.

2:03AM


Wednesday, January 23, 2008 (2 comments)

Let me tell you why I hate DRM.

Vault has a bunch of pretty informative industry and employer guides. The problem is that they distribute them as encrypted PDFs.

In Linux, I usually use kpdf, which I like a lot. So I tried to open the file, but it asked me for a password. I tried a bunch of strings for the password, but none of them worked. Then I tried the other 2 PDF readers that I have installed, and of course they didn't work either. (There is no "password.")

So I booted up my Windows XP virtual machine, and installed the official Adobe Reader from adobe.com. I opened the file again, and Adobe told me that it didn't have some security plugin required to read this file. Vault.com actually has an entire section of their site dedicated to problems with their stupid DRM. Isn't that a wake-up call that the DRM sucks?

I read that section but couldn't find anything about any plugin. It did say that Adobe Reader 8 has problems reading these encrypted files. So I installed Adobe Reader 7, which runs on Linux, so I didn't have to fiddle with the virtual machine and its slowness. I got a similarly worthless and vague error about some plugin.

So then I finally gave up. I rebooted into a real Windows installation and found a copy of Adobe Reader 7. I installed it, and opened Internet Explorer to go to vault.com. Turns out that I couldn't login using IE7, but there was no mention of this on the site. I would push login and would just get redirected to the home page without an error. So then I had to install Firefox (I know, I know, what am I doing without Firefox to begin with) just to login.

After downloading the file, it finally opened (after trying 6 PDF readers). But do I really want to boot into Windows just to read a PDF? I can't use email, IM, or really anything but games in Windows. So I tried to print the encrypted PDF to a PDF printer (standard way to create PDFs), but that just kept giving me errors, which I guess is by design so you can't get rid of the DRM.

Without further detailing my frustration, the solution was to print about 200 dead-tree pages. I'm pretty sure that's more pages than I've printed in the previous two and a half years at Duke. DRM kills babies.

11:57AM


Tuesday, January 15, 2008 (3 comments)

BREAKING NEWS: DRAGOS ILAS IS ALIVE!

An unconfirmed, unauthenticated "dragos2005" reports the following:

icydog1: where have you been?!
dragos2005: in hiding
icydog1: everyone thought you were dead!
dragos2005: lol
icydog1: people called you and left messages
dragos2005: the fbi was after me i couldnt take the risk

And with that, he disappeared again, perhaps to reappear for 45 seconds in another two years' time.

5:41PM


Older posts can be viewed through the links to the left, under the main menu.
338 hits since February 5, 2008.