Stupid Bug

The other day as I was tracking down a bug, I almost kicked myself when I saw the problem. The code was something like:

int i = 0;
int count = [array count];
for (i = 0; i < count; i++)
{
	if ([[array objectAtIndex:i] intValue] == 3)
	{
		[array removeObjectAtIndex:i];
	}
}

The problem with this code, if you’re a Cocoa programmer, should be obvious. If any of the elements are equal to 3, then when you get to the last or near the last element, there are no objects left in the array and it blows up. The proper way to do this, of course is:

int i = 0;
int count = [array count];
for (i = count - 1; i >= 0; i++)
{
	if ([[array objectAtIndex:i] intValue] == 3)
	{
		[array removeObjectAtIndex:i];
	}
}

By counting down instead of counting up, the problem is solved. What annoys me about this code I wrote is that I’ve done something similar many times. You’d think I’d learn by now.

The end of 2 good years

PowerBook G4

It’s time for me to sell my PowerBook G4. It has been a good machine for the last 2 years, but as technology changes, I need to keep up as my customers and users have already done so. Like all the machines I have owned, I use them a lot, but don’t abuse them. My PowerBook has been my main machine for the last 2 years and it has served me well. We’ll see if anyone is interested in it. There are still a few reasons to own a PowerBook as opposed to a MacBook or MacBook Pro (PCMCIA slot, runs Photoshop, Word, etc. faster as those applications aren’t designed for Intel, yet, and it can still run Classic which the new Intel machines can’t). I’m not a great salesman as I can’t honestly say that I’d purchase this machine over a new MacBook, but that’s just me and I don’t need to run non-Intel native applications all that often.

Effective meetings

Being self-employed and working at home have many benefits. First, being self-employed means that every meeting I have to attend (except for initial client meetings), I get paid to be there even if nothing gets accomplished or I don’t say anything. So you’d expect people to sparingly invite me to meetings. Second, working from home means that most of my meetings are on the phone; good thing there is a mute button so I can be working on something else.

I’m not sure why people like meetings so much, but when I worked for a rather large company, there were days where I’d have 3 or 4 one hour long meetings. So half my day was shot in meetings. Did anything really come out of the meetings? I don’t recall. It seems that many meetings could be eliminated in business if people were more efficient at using email and were more concise. For me, if something goes into a long explanation of something, I usually get it in the first few words, so the rest of the words is wasted on me.

Do people feel important setting up a meeting? Does it make people feel like they’re working? I’m not sure about others, but I absolutely hate meetings and do what I can to avoid them.

Diagnosing network problems

Yesterday turned out to be one of those days that makes me hate technology. First it started (actually left over from the previous week) where I could only sometimes access a server I use for my job. I no longer run that server, so all I could do was figure out the problem and tell the person in charge of it to fix it. Unfortunately or fortunately, I have the knowledge to figure out the problem. Turns out that the 2 DNS servers that are used for that server were returning different values, so depending on which DNS server got my request, would determine if I could connect to the server. Very frustrating, but at least I figured out the problem. The second major network problem had to do with my dad’s network. He had turned off all his equipment when he left on a trip and when he turned it back on, weird things started happening. His entire network uses DHCP, so it should have just worked, but I believe a bug in the firmware of his router (a Linksys WRT54g) was assigning the same IP address to 2 machines and his iMac was complaining. So after some futzing and me helping him, my dad updated the firmware on the router, restarted everything and was almost in business (I had to help him secure his wireless access point). He wanted me to teach him what I was talking about so that he wouldn’t have to call again, which I appreciate, but it seems that networking has a lot of vodoo in it, especially when you deal with a very mixed environment. He has a Windows XP Home edition PC, and iMac (OS X 10.4), an iBook (OS 10.3.9) connected via 802.11b, a Linux box running the SlimServer software (connected via ethernet), and a Squeezebox (connected via 802.11b). Since I helped him setup a bunch of the pieces, I end up being the only person that can diagnose the network.

Luckily the Linux box requires no user interaction and I set it up to use Zero Configuration so that it doesn’t matter the IP address of it so my dad can update his music and the Slimserver software also uses it, so it is easy to configure. The problem in this type of DHCP environment is sharing files. It would appear that Windows needs to know the IP address of the Mac in order to share files as my dad’s network has no master domain browser. This makes things extremely problematic if the IP address of the Mac changes. I could setup the Mac to use DHCP with manual addressing, but that didn’t seem to work. I have no idea what the problem was, but if I get a few hours, maybe I’ll re-investigate it. I wish things were easier, but they aren’t.

I’ve been doing computer networking of sorts for the last decade, so I have a lot of random knowledge about how things work and how to set things up. My own personal network is several times more complex than any home network because I run my own DNS server, use DHCP with static addressing (most machines on my network get the same IP address based on MAC address), and other weird stuff. I have more than a dozen devices on my network; sometimes I’m amazed that everything works.

Parallels is becoming very solid

In a previous entry, I commented about that lack of polish in Parallels. I’m pleased to report that in the latest release candidate, they have fixed the 2 items I pointed out. The release also appears to run much faster. My only outstanding issue is that it has an issue with my Garmin ForeRunner 305 over USB. I’d like to be able to use Parallels to update the 305 when firmware updates are released as well as use it for the Garmin Training Center (to backup my data) until Garmin releases the Mac version. Hopefully this issue will get fixed; the Parallels team has done an amazing job at fixing issues and I applaud them for an excellent product.

All politicians are corrupt

I know people will say that not all politicians are corrupt, but based on what has been in the news lately, it is hard to believe. Let’s start with William Jefferson. Those that bribed him have admitted (or plead guilty, I can’t recall) to bribing him, but Jefferson says he wasn’t bribed despite the $90,000 in cash found in his freezer. Then you have other congressmen upset that the FBI searched his office. Are politicians above the law? The shouldn’t be, but sure act as they are. Why should congressmen have places that can’t be searched by the FBI with a search warrant? They shouldn’t.

Next, let’s take the case of congressmen flying on corporate jets and only paying first class airfare which obviously doesn’t come anywhere near the cost to operate the jet. That is corruption in my book. The problem with all this corruption is that congress makes up their own ethics rules and then “follows” them.

I used to say that I was apolitical (is that really a word?) in that I didn’t care much about politics. Now I can honestly say that I’m anti-political. I have a strong dislike for politicians and politics. A politicians main job is to get re-elected, so what incentive does he (or she) have to serve their constituents? Very little.

I just don’t understand traffic

Yesterday my wife and I went up to Anaheim and I usually dread the trip to Orange County as it is completely unpredictable as to how long it will take. The traffic can be just awful or we can breeze right through. The trip yesterday was an easy 90 minutes each way; going up, we saw several backups and several accidents which, if we were caught in that, would have easily added 30-45 minutes to the trip. All my worries about the drive will be eliminated when I get my personal flying machine.

Is there an upside to May gray?

May and June are very depressing months in San Diego due to the weather. There is a marine layer that hides the sun for much of the day; it’s a bit clearer away from the coast where I live, but still the overcast makes it kind of depressing. (May is called May Gray and June is June Gloom). However, this year my attitude is a bit different. The marine layer keeps it cooler and makes it easier to run. A slight increase in temperature wears me down quickly when running. Less than 2 weeks until the marathon and I actually hope is it kind of overcast for it otherwise I’ll be going real slow the last few miles!

I’m not a super dork

I think that the Apple stores are pretty neat, well designed, and promote a good shopping experience. However, I can’t say that I’d wait in line overnight like these dorks just to be some of the first people to goto the Apple store in New York. Some customers came from Texas, Scotland, and California to the opening. I sure hope they didn’t come just for the store opening, but the video clip sure makes it sound like they are king dorks. Do I care if I see Steve Jobs? No, he may run a company that has cool products, and he may be a good speaker, but I could care less if I see him in person.

Apple always blames bad RAM

As I was talking to the guy at The Chip Merchant, we both said that Apple (and the Apple store) immediately say that bad third party RAM is to blame. While it is quite easy to blame RAM, it is such a cop out. For awhile now, my PowerBook’s DVD drive has been flakey, probably due to dust on the lens. However, I’ve needed the machine all the time, so I never sent it in for repair. Now that I have a spare machine, I decided to clean off the PowerBook and reinstall the OS. Due to the flakey DVD drive, it took a lot of tries and attempts at blowing the dust out of the drive to get the computer to read the install DVD. So, I called up AppleCare to see about replacing the DVD drive. They had me do the usual BS steps of using Disk Utility to repair the disk and repair permissions and then zap the PRAM. Of course, I knew this wouldn’t help as I probably already cleaned out the crap for now. The next thing they asked was if I had extra RAM in the machine. As I’m not one to lie, I said yes, knowing full well that RAM was not the cause of this problem. The lady on the phone was nice enough to send out the repair box anyway and let me “test” the machine without the RAM to see if the problem persisted. Yeah, sure the problem is caused by faulty RAM that I’ve had in the machine for almost 2 years.

I’ll send the machine in for repair when I get the box as it is still covered under AppleCare and the DVD drive either needs to be replaced or cleaned. I realize that the support reps work from a script, but given the age of the machine (almost 2 years old), isn’t it quite possible that the drive needs a cleaning?