November 13, 2007

I look less leet around campus because I dual boot Vista

A few weeks back I got a brand new X60 tablet... to replace my relatively new X41 tablet. What can I say? I'm a sucker for high resolution screens... Lots of code and documentation needs to be viewed in parallel, and the X60 has a beautiful SXGA+ (1400x1050) configuration on its little 12" display (let's just say it's a good thing I'm near-sighted). [*] I'm planning on giving the X41 tablet to my sister for the start of her college career, since it's fully functional, in good condition, and sells for under $800 on ebay.

The Operating Systems Practicum that I'm taking (CS415, my CS project course) forces us to use Microsoft Visual Studio by having a huge, ugly, Windows API-based codebase. I tried to port the first project to make it POSIX compliant, but I couldn't figure out how to manipulate the stack pointer in gcc assembly — this was necessary to port their user-level threading library implementation. The whole mess was terribly x86 dependent to begin with.

As a result, I need to use Microsoft Visual Studio this semester, and so I decided that I would just squeeze the NTFS partition that Lenovo graciously provided to me, as opposed to obliterating it the first chance that I got. [†] I now dual boot, and many people believe that my leetness level has dropped considerably. To compensate, I did a::

% sudo apt-get install compizconfig-settings-manager

and turned my minimize effect to::

Burn @ 200ms @ (type=Normal|Dialog|ModalDialog|Utility|Unknown)

Which made all my windows go up in flames. Of course, this made me totally leet... for about five minutes, at which point I turned compiz off because I didn't want Xorg using up unnecessary resources. [‡]



My one gripe is that it shipped with a single pixel that's stuck bright green — single pixels aren't covered under Lenovo's pixel replacement policy. Argh!


Not-so-graciously charging me the Windows Tax for an OS that I can get for free through MSDNAA.


More evidence that I'll probably never be a Mac OS user.

Home row, sweet home row

I a no u esed in the hoe o o oa

Translation: I am now fully versed in the home row of dvorak.

It's level 9 on the dvorak7min application. I even type with proper form!

This is all pretty exciting for me since I learned how to type qwerty ad-hoc. I starting using computers long before anybody wanted to teach me how to type properly, so I learned where all the keys were through finger-muscle memory (at 70-80 words per minute). I'm not totally sure what learning how to type properly gains me, but I hope that it'll help me avoid all the problems in the WRULD.

ImageMagick is amazing

Back in freshman year, not knowing any better, I scanned all of the handouts I received as JPEGs. My Automatic Document Feeder (ADF) got me a bit over-excited, so exploring the crustier portions of my filesystem, I find directories full of things like this:

CHEM211 - Prelim 1 - Practice Problems 01.jpg
CHEM211 - Prelim 1 - Practice Problems 02.jpg
CHEM211 - Prelim 1 - Practice Problems 03.jpg

Ad nauseam. Seeing these, I thought to myself: It be awesome if there were a utility that would take all these and bind them together in a PDF.

Meet ImageMagick's "convert" utility. It blows my mind.

convert 'CHEM211 - Prelim 1 - Practice Problems'*.jpg 'CHEM211 - Prelim 1 - Practice Problems.pdf'

Done. The resulting PDFs are pretty big, but convert can also manipulate images in just about every way imaginable — I'm just too lazy to figure out how to downsample right now.

I highly recommend checking it out. In Ubuntu's repositories you can find it using:

sudo apt-get install imagemagick

Apples and Deadlocks...

For some reason I find this to be a really suiting characterization of deadlock:

As you'll recall, Snow White took a bite of the poison apple. This particular poison is an agent with known uses in biological warfare, and puts you to sleep until your true love kisses you awake. Cursing bioterrorism's name in her last few moments of consciousness, Snow White fell asleep indefinitely.

Prince Charming finds Snow White asleep after some time, but before he kisses her he decides that he's really hungry and would like a bite to eat. He sees a tasty looking apple conveniently located on a nearby table, and takes a bite. Unfortunately, as you may have guessed, it is the poisonous apple, which hasn't moved from its original location. [*] Prince Charming also (tragically) falls asleep indefinitely. As consciousness fades away, he clutches Snow White's limp body, and they stay, deadlocked, in each other's arms for all eternity.

Awww. [†]



I should also mention that the apple has several preservatives which prevent it from decaying, but are also known to cause cancer in lab animals.


Note that this story implicitly assumes that true love is a characteristic that exhibits one-to-one correspondence; a premise whose truth value is acknowledged to be unknown.

Two postfix operations in a single statement in GCC

#include <stdio.h>

int z = 11;

int main()
    printf("%d\n", ((z++) * (z++)));
    printf("%d\n", z);
    return 0;
$ gcc -o postfix_test.o postfix_test.c; ./postfix_test.o

Surprised? I sure was. It looks like gcc interprets two postfix operations in a single statement as a single postfix increment request. I guess this makes sense if you consider the postfix operator to mean, "Wait for this statement to complete, then have the variable increment." Assuming this specification, the second time that you postfix-increment the compiler says, "Yeah, I’m already going to have the variable increment when the statement completes — no need to tell me again."

On the other hand, prefix increment does work twice in the same statement. Maybe this is a decision that’s left up to the compiler? It’s not specified in K&R as far as I can see, but I haven’t checked any of the ANSI specifications.


2007/09/26 Here’s what Java has to say!

class DoublePostfixTester
    public static void main(String[] args)
        int z = 11;
        System.out.println(((z++) * (z++)));
$ javac
$ java DoublePostfixTester

Which is what I would have expected in the first place. Bravo, Java — we’re more alike than I thought.