Tuesday, July 15, 2008

Be the change you want to see in the world

This will be a quick one:

I've been getting fairly 'musical' lately and actually writing songs again. Part of that includes coming up with crap to write about. One idea I have is kind of a response to John Mayer's "Waiting" or whatever it may be called.

One thing I noticed is that it's all good and well to see tragedy in the world and take notice. It's another to sit on your rump, and 'wait' instead of doing something about it. Obviously there is plenty of hatred in the world, but I go with the mindset there is nothing I can do to change somebody else, but I can mold myself into who I want to be. So, the above quote is apropos and I've been thinking about it lately and how I might turn the idea into a song.

I stumbled across this blog post and thought I'd share. Enjoy?

Nerd times

So far this summer, I've not really had to use my personal laptop for more than browsing the Internet or listening or recording music. This seemed like too light a task load to depend on Windows Vista as my only operating system. I really don't have a big problem with Vista. I think if you're intelligent about the way you use a computer it should suit the needs of most, albeit slowly in some cases. So I decided I wanted to give dual-booting a try.

I had installed Ubuntu on an old Compaq PIII a few years ago and I loved picking around with it and seeing what it could do. Linux is great for squeezing functionality out of aging hardware, and I definitely put it to good use in school. I always wondered how Linux would do if I gave it a more powerful platform to play with. My laptop had a 110GB drive on it that I wasn't even close to filling, so I decided I'd give it a shot.

The first step was to carve out some extra space because the Vista partition occupied the entire drive. The cool thing Vista has is a non-destructive partitioning tool. I was able to use it to reduce the partition by 15GB to create some room for a new OS. The "Disk Management" tool can be found by right-clicking on "My Computer" and selecting the "Manage..." option. From there, I used the "Disk Management" tool to reduce the partition by a given amount of space. There are plenty of resources for how to do this on the Internet, but that wasn't really the difficult part.

Once that was done, I had to figure out what flavor of Linux to use. I had been toying with Puppy Linux for a while. The disk image was only 90MB, which fits just fine on a mini CD. The really cool thing about Puppy Linux is that it loads itself from the CD into your computer's RAM and runs completely from there. That being said, it is ridiculously fast. Granted, a distribution that is only 90MB is going to be pretty stripped down. It wasn't the prettiest thing, but it had all the basics to do what I wanted. The only thing I didn't like was the package manager wasn't incredibly intuitive, and I was so used to Aptitude from Debian/Ubuntu.

So, I started with Puppy Linux and used the tools on the CD to reformat the previously freed hard drive space. It took me a while to figure out Linux likes the ext2 format (I had always just let the Ubuntu install dialog do that for me), but once I did, I was able to burn the image to the disk. The tricky part came when I tried to figure out how to pull off dual-booting.

After some research, I thought I'd try keeping Vista's boot loader and use it to manage both operating systems. Upon further research, I learned that the Vista boot loader is new to all other Windows operating systems, and thus didn't have as much documentation or examples to help me get started. One thing I did find was a tool called Bcdedit.exe. This tool is supposed to allow you to edit the master boot record (MBR), import new entries, and manage the order. Turns out that with as much research and preparation I put into making that work, I still broke everything.

The basic strategy is that from the Linux partition, you are supposed to install GRUB in and only in the Linux partition. It needs to be isolated to that partition and unaware of the intended parent loader on the Vista side. From there, the next step is supposedly to extract boot information to some transportable media--a USB makes the most sense--and boot back into Vista. After copying that content into the Vista partition--recommended destination: the C: Drive I guess--you would use Bcdedit.exe to generate an entry in the MBR given the Linux boot information. Upon successful completion, the Vista boot loader would give you the option to boot Vista or the Linux entry. Upon selecting the Linux entry, the boot loader would then fire up GRUB and it would in turn boot up Linux in a chain-loader fashion.

The problem is that none of this worked and my biggest success was corrupting my MBR. Puppy Linux still worked from the CD though! As I'm sure you're aware, that's nice but still fairly useless. In order to get Vista back up to speed, I had to track down my Vista DVD and use the start-up repair to get it back working. That got me to be able to boot back into Vista, but it still had issues. Thankfully, I used bcdedit's export function to create a backup of the MBR before I broke it, so I was able to use the import function to put it back together. Moral #1 of the story: backups are cool.

Once Vista was fixed, I opted to go for a more mature Linux distribution to take advantage of the more intelligent installer, and the added firepower. I chose Xubuntu because I like the minimalism of the Xfce desktop manager and I have always been a fan of the Ubuntu/Debian community. I burned a LiveCD and used the installer to reformat the 15GB and install the new OS. This time, I opted to let Linux install GRUB into my MBR and let it manage all booting tasks. GRUB automatically found my Vista partition and put it in as an entry in the boot window. So now my computer boots into either operating system just fine and I'm having lots of fun with it. I went ahead and installed Compiz on my machine since I had more powerful hardware and I wanted to "geek" the thing out. All in all, it looks pretty cool--and dare I say, pretty?

I went nuts yesterday and tried installing a bunch of sound production and creation software. I don't have the list on me now, but I didn't think Audacity was quite enough. I've been entertaining the idea of using a MIDI controller to run a synthesizer emulator. I'd also like to be able to run a loop station on my laptop. Apparently, most of this software relies on a small server called JACK. As advertised, it's supposed to manage sound and data connections among inputs, outputs, and clients (or software). Unfortunately, it seems to have broken ALSA or whatever it is that pumps sound out to my sound card. Guess I'll have to fix that later.

There are no screen shots, but I'm sure you've seen a desktop before. Mine is nothing special. The important part is I had a geek idea and I made it work. Moral #2: challenging yourself and trying new things is a great idea and essential to personal growth in my opinion.

Monday, July 7, 2008

All that learnin' paid off

A couple posts back, I wrote about this horrendous script I had to make for work. To sum it up, I had to iterate through, make comparisons, and write data when I found matches. Doing it iteratively, I ended up with nested loop 3 levels deep. Needless to say, the script was really slow and inefficient. I knew enough to recognize the fact, but I really could not think of a way to improve upon it.

Over the weekend, the problem got shoved to the back part of my mind that works on things without me really thinking about it. Finally the idea struck me that I could use a better data structure to perform the task. In my algorithm design and analysis class, we learned about hash functions and how to use a special table of keys and values to figure out the location of the desired data. I used something similar to that with VBScript's dictionary data structure.

Using the same assumption that I was dealing with pre-sorted data, I was able to make a dictionary for storing each first occurrence of a Supervisor ID in the data and the Excel row number as the value. I had the program create a dictionary of this information for both the Members sheet and the Addresses sheet. By using the dictionaries, the script could just jump to exactly where the desired data resided and write data that way. It took me ten minutes to do this morning what it took me nearly a week to do last week. Too bad I hadn't thought of it earlier.

Moral of the story: either pay attention to data algorithms classes, or at least know enough about it to look things up or ask a good friend.