Archive for the ‘Computing’ Category

The Codebook

Thursday, March 13th, 2008

I’ve been keeping a journal that I call “The Codebook” for the past four of five years. When people see it for the first time, they usually ask me something like: “So.. are you with the NSA then..?”, and I although cliche, reply with something like: “I can neither confirm nor deny my involvement with the NSA”. Anyway, The Codebook is a notebook that I write down all of my programming ideas, work through technical problems, and keep track of what I’m working on.

The content of The Codebook is intractable. It ranges from C++-pseudo code, and algorithm analysis, to mocked up maps that I plotted out when I did that Legend of Zelda clone I wrote back in college. It’s also organized very poorly. Anybody who looked at it would probably think it’s gibberish Computer Science, or some kind of nerd stream of consciousness piece. For instance, I just found an outline of what my plans for JuiceMUD were, right next to a rather large listing of UNIX programs, and then on the next page there’s some mysterious binary work surrounded by blank paper.

This all leads me to a question: how do you keep your technical thoughts organized?

Codebook Cover Codebook Example Codebook Map

Compiling libpng in Visual Studio .NET {2005}

Saturday, March 1st, 2008

There is very spotty documentation on how to use libpng under Windows. I did find one site that talks about the subject, so you might want to refer to it as well.

1. Libpng Setup:

First, you’ll need to download the latest version of libpng and zlib. Extract them someplace (I placed them within my projects root, in a directory called ‘deps’). The pre-canned Visual Studio settings that come with libpng look for ‘zlib’ rather than ‘zlib-x.y.z’, so rename the directories so that they lack the version numbers.

2. Compiling libpng and zlib

Next go into <projectname>\deps\libpng\projects\visualc71 and open libpng.sln. Go to Build and run ‘Clean Solution’. Now you have a choice, you can either compile libpng as a dynamically loaded library, or a binary blob to statically link into your executable. You can compile either one as a debug or release build. Just make sure that whichever way you compile libpng (debug/release), is the same as what you compile your project. So choose an option, and go to Build -> Build Solution. This will compile both libpng and zlib.

3. Project Setup

Now you’ll need to set your project up to include the libpng and zlib files. Open your Visual Studio project, and go to Project -> <projectname> Properties. Expand Configuration Properties, and then expand C/C++. The top field on the right will read “Additional Include Directories”. Click it and add “C:\<projectname>\deps\zlib;C:\<projectname>\deps\libpng”.

Now close the C/C++ tree and expand the Linker tree, which is directly below it. Roughly 3/4 of the way down is a field called “Additional Library Directories”. Click it and add

“C:\<projectname>\deps\libpng\projects\visualc71\<projecttype>\ZLib;
C:\AnimTester\deps\libpng\projects\visualc71\<projecttype>”.

In my case, I compiled as Win32_LIB_Debug (Statically Linked, Debug Symbols included), so that’s what I set <projecttypeyoucompiledas> to.

Next open the Input node that is in the Linker tree. Under “Additional Dependancies” add libpngd.lib zlibd.lib if you chose to statically link, or libpng13d.lib zlib1d.lib if you compiled it as a dll. If you did compile as a dll, you will then need to copy the dll’s that were generated to the same directory as your executable, or to a directory loaded in PATH.

Now you can implement PNG reading or writing into your project.

4. Troubleshooting

Q: I get a ton of linking errors!
A: Visual Studio cannot find the lib files. Double check that they are compiled (libpng{..}.lib, zlib{…}.lib), that your projects Library dependancies includes the directories that they are in, and that the lib files are included in the Additional Dependancies field.

Q: Visual Studio spits out errors about undeclared identifiers!
A: Make sure you have #include <png.h> in your source. Also make sure that png.h’s path is included under Additional Included Directories in your projects settings.

Xmonad

Wednesday, February 20th, 2008

I’ve been using Xmonad as my window manager under X11 since early December. Xmonad is written in Haskell, a purely functional programming language that compiles down to machine code. Haskell is the most different looking programming language I’ve ever seen; when I started looking at Lisp, the structures made sense, but I’ve been lost looking at Haskell code. I suppose I need to pick up a book on the subject. I digress, Xmonad builds upon a different paradigm than what most users are used to. Most Window Managers (including Windows Explorer, Gnome, Etc.) use co-ordinate based stacks of objects to represent the environment. Think of this as having Firefox or Internet Explorer fullscreen, and you press alt-tab to get to Google Talk or you drag iTunes around the screen. Xmonad deviates from this by implementing what’s known as a tiling window manager. Instead of stacking objects, Xmonad gives applications non-overlapping regions of your monitor. This has the handy effect of putting what you’re using right in front of your eyes.

The way Xmonad handles where it puts the applications is terrific. If you have one window open, it will take up your whole monitor. If you have two, each will get half. But what about if you have three, or more? Xmonad solves this by declaring the left half of your screen as the main workspace, displaying one window there, and divides the right half in twain. Hence your attention can be given fully to your main application, while you switch to the other programs for support. This is quite handy if you’re a programmer and you have GNU Emacs or gVim open as your main application and two terminals open to test your project stacked one on top of the other to the right of it.

There is the obvious issue of “Most of my applications are designed as WIMP interfaces and this will break them!”. Don’t worry, other tiling window managers such as Ion force you into strict tiling, but you can configure Xmonad in its settings file to allow certain applications to float on top of other windows. Everything in Xmonad can also be controlled by the keyboard. Switching between windows is as simple at hitting alt-k. You can switch virtual desktops by pressing alt-<screen_num>(I switched mine to alt-f1 … f9 so as to not interfere with Irssi). There’s also multi-monitor support.

You can find out more about Xmonad at http://xmonad.org. They also have a directory of interesting screenshots, and a wiki full of configurations.

Xmonad In Action

Computing Wiki

Tuesday, May 22nd, 2007

I’ve been working on a Wiki with some friends for the past few weeks. You can find it at Fishcracker. I’m currently in charge of the Emacs tutorial, and I’ve put a lot of work into it. There are also tutorials for other applications I pretty much consider essential: lftp, vim, and screen to name a few.

Programming Font

Monday, May 1st, 2006

I’ve been flipping between two fonts (Courier New and Monaco) for about six months now. Monaco looks good, but there’s always been something about it that annoys me (aspect ratio, maybe). Courier New is fine, but I guess I would prefer something a bit smoother. So, I started looking at ‘programming fonts’ again, finding a lot of same sets as before (profont, proggy, crisp) and a couple new ones (Dina, Coding Font Tobi 1, Pixel Carnage). Dina is based on proggy and incorporates elements from some of these other fonts. So long story short, it’s become my default font. You can find these fonts on Google, or click the download link for Dina.

Dina

Download Dina