Alex's Alliterative Adventures

Thoughts on Programming, Life, and Travel

Archive for the 'Geek' Category


I recently discovered that spam comments have been building up on my photo gallery for over two years. I just ran a spam filter on my photo site, and I deleted over 20,000 spam comments.

I’m so sorry, internet. I’m so very, very sorry.

No comments


If your non-trivial C++ code hasn’t been statically analyzed, you’re missing out. Your codebase is likely to contain subtle bugs. Fortunately, static analyzers can expose a large number of bugs without breaking a sweat.

Static analyzers scan your code for suspicious patterns that almost always lead to bugs. Reading from uninitialized local variables, passing polymorphic objects by value, probable buffer overflows, and other things that can easily escape your notice. The best of the bunch is widely accepted to be Lint (more specifically, PC-Lint/Flexe-Lint). These tools don’t come cheap (389 USD Windows / 998 USD *nix), but they’re arguably the best investment a programmer can make (since there are lots of free compilers available). PC/Flexe-Lint can also be used to clean up your source code by identifying unneeded header files, reporting on comment style, or enforcing const correctness.

PC-Lint is even smart enough to understand Visual Studio project files. Unfortunately it doesn’t understand solution files, so that’s where LintProject comes in. LintProject is a free, open source program that parses solution files and spits out a fancy html report. Unlike its counterpart, Visual Lint, it doesn’t integrate with Visual Studio, but it’s much easier on the wallet and it gets the job done. My patch to make LintProject do more parsing when reading incremental build directories was accepted a few weeks ago and will be included in version and later, so it will soon be one step closer to perfect.

No comments

Land of the cheap

To ease my transition to Frankfurt, I grabbed a prepaid ja mobil SIM card from the local grocery store. Wireless internet from ja mobil costs €0.35/MB, which is about $0.53 Canadian. In comparison, Rogers (Canada’s only GSM cell phone provider) charges $0.05/KB without a plan. There are 1024 KB in a MB, so that works out to $51.20/MB. That’s right, wireless internet is almost 100 times cheaper in Germany than in Canada.

Hot damn.



How I spend most of my time

As a self-professed gamer and windows-zealot, this is a big deal for me. My laptop certainly spends more time booted into Ubuntu than into Windows. While it gets the job done, I really, really miss my visual studio.

1 comment

Visual studio 2005 can put that dual-core to good use

Visual Studio 2008 has a fancy new feature, the /MP build flag, that makes it compile multiple files in parallel. This can result in huge speedups in the compiliation phase on a multicore machine, since it’s pretty common for compilation to dominate a project’s build time.

For those of us who are still toiling away with Visual Studio 2005, there’s still a way to unlock this potentially huge speedup. Visual Studio 2005 actually supports the /MP flag, although it’s officially undocumented. I flipped the switch on all of my projects as soon as I read Herb Sutter’s words of wisdom, and it seemed to work perfectly. A full rebuild used to be spent using only one of my two cores for the majority of my build, but now I’m chugging away with every ounce of computation this computer can muster.

No comments

Copying files with ssh

My partner and I now code our CS 452 assignments exclusively in Eclipse. Its Auto Build feature lets us write code, save, and see all of our errors almost instantly. I have a very low pain threshold for build times, so when I’m working from home, this is pretty much a perfect coding environment.

Working from school is different, since I typically run our code on the fancy servers, which means I have to get the code off of my laptop. Read more


Upgrading to Boost 1.35

This post is for geek eyes only. Pregnant programmers and people with weak stomachs for C++ templates should steer clear.

I decided to take the plunge tonight and upgrade my copy of Boost to 1.35. I had to fight through a couple of bugs when compiling with Visual Studio 2005, so I thought I’d share them here with the world.
Read more

No comments

Making an ELF in a bochs

My partner and I just spent far too many hours getting the toolchain for Waterloo’s CS452 (Real-Time Programming, aka the trains course) working on Linux. A few tears and a lot of grumbling later, we’re compiling like a bat out of hell, running bochs natively, and posting to the Eos remotely. Here’s how we did it:

1) Using your package manager, install the “flex” and “bison” packages. (We’re not sure about this step, but it can’t hurt)

2) If you don’t already have it, use your package manager to download and install gcc 3.x. (We couldn’t compile everything with gcc 4.x) You’ll also need libc6-dev.

3) Download the following 3 files from some random website (try google):
gcc-3.3.3.tar.bz2 (We used 3.3.3 instead of the recommended 3.3.4, since the school machines run 3.3.3)

4) Open up a terminal window and set the CC environment variable to point to gcc 3.x (which you just installed)

5) Use gcc 3.x to follow the steps at the course toolchain setup guide.

1) Download the bochs source, bochs-2.3.tar.gz

2) Download X Windows libraries, xorg-dev

3) Configure bochs with whatever options you want.
If you want your installation to match the school’s, this is my current best guess:
./configure --enable-debugger --enable-disasm --enable-apic --enable-cpu-level=6 --enable-sse=2 --enable-sep --enable-guest2host-tlb --enable-repeat-speedups --enable-icache --enable-fast-function-calls --enable-ne2000 --enable-vbe --enable-usb --enable-pci --enable-readline --enable-show-ips
(I did this on a fresh ubuntu install, so I had to grab a copy of g++ to do this)

4) Compile bochs.

5) Modify 452mkemu and 452postemu so all of the directories are pointing to the right place on your machine. Our files now set different directories based on whether you’re running linux and which user is logged in. You’ll also need to copy any files these scripts reference (like grub.img, or the bochs BIOS) to your machine somewhere and point the scripts at them
EDIT June 13 14:58: After wasting a lot of time, we figured that bochs would start panicking once we checked our BIOS into CVS. This was, of course, because CVS decided that our BIOS was too big, and it graciously decided to take off two bytes for us. Solution: they’re not in CVS anymore! Thanks, CVS.

5) Run 452mkemu. You’ll need to change any directories in the file to match your machine’s setup, and you’ll also need to install mtools.

6) Emulate to your heart’s content. If you get a message saying that menu.lst is not found, just rebuild your kernel.

Symbolic debugging
I can’t stress enough how useful the bochs debugger becomes once you get symbolic debugging working.
We followed the instructions to generate a symbol file for bochs,  and now our makefile generates a bochs symbols file whenever it posts. I had to install gawk to make this work on linux. Here’s the secret ingredient:
nm -n $1 | grep -v '\( [aUw] \)\|\(__crc_\)\|\( \$[adt]\)' | awk '{print $1, $3}' > $2

The 452post script needs to lock a file on the school servers, and since my Linux-fu is weak, I don’t know how to make that happen remotely. I do know how to copy files to the school servers, though, and execute commands remotely. A few lines of script later, your linux install will post to the Eos machines.

That’s right, I went there. Sort of. Earlier today I set up an eclipse CDT project that compiled our code, start to finish. There were a few hitches: Eclipse thought that having to generate dependency files was a critical error. There were a few other similar snags. I hope we’ll be able to get it working soon so we  have a real IDE to code in, but it can still be a useful tool as a souped up text editor and CVS GUI.
EDIT June 13 15:33: Eclipse works. It’s beautiful.

The only thing that’s even mildly annoying with this whole process is that with my current setup, I’m prompted to enter my password every time I connect to the school machines, which happens 5 times when I post. If the rumours are true, I can tell SSH to connect with a stored key instead of a prompted password, which will be icing on the sweet, sweet cake.
EDIT June 13 11:41: I don’t have to enter my password anymore.

If there are more cool tricks to make coding a kernel a little bit easier, please leave a comment.


Math you can use

If you’re reading this on facebook, you’re missing out on the pretty pictures. Click “View original post” at the bottom of the page.

I’m taking CS370 this term. It covers lots of useful stuff, including interpolation with natural cubic splines, which is the math nerd’s game of connect the dots.

You start with an image:

Pick the dots you want to connect:

And let the math do its magic:

I’ve been comfortable with being a computer geek for years, but a math nerd? This will take some getting used to…

No comments