Tuesday, April 29, 2008

My First Week in Ubuntu

Overall I'm very happy with my Ubuntu experiment. I have been able to do just about everything I need to for work without having to touch my windows machine. However there have been some small idiosyncracies that have annoyed me. Some I have found work arounds for while others seem to be unavoidable.


  • Backspace Button in Firefox - By default in Firefox 3 Beta 5 in Ubuntu the backspace button does nothing! However, a quick visit to about:config and a simple setting change and now my backspace button does what it should - move me back in my session history!
    browser.backspace_action=0

  • Citrix Client Intermittenly Drops "Shift" key - this is just something I have to deal with. I am pretty much constantly on the citrix client to our biggest current customer and the broken shift key is really, really annoying. Nobody else seems to have this problem. My shift key is fine in all other applications so I have to assume it has something to do with citrix.

  • No MediaMonkey - MediaMonkey is, in my opinion, the best application I have ever used for managing large (and I mean really, really large) music collections. I have converted endless albums and cd's into MP3's and none of the linux apps work as well as I would like. Amarok is OK but it is a far cry from MediaMonkey. My biggest gripe is how slow they all are in letting me browse and search through my collection. I typically listen by genre and none of the linux apps I have tried can display 2000+ songs at a time very quickly. I also miss the amazon lookup feature of MediaMonkey which makes it very, very easy for me to finish tags and download album art.

  • No Quick Menu - This was something I had in my geoshell. Basically, via the right mouse click on the desktop I could launch all of the apps I use regularly. It may be possible to do this in Ubuntu but I don't know how. Any ideas?

  • Limited HotKeys - I also had a lot of hotkeys in geoshell to launch apps even faster. However, as far as I can tell I can only configure 12 hotkeys via the clunky hotkey editor in compiz fusion. Am I missing something?

  • Gnome-Do - I love the idea of this app but it started doing some weird CPU consumption stuff and I couldn't figure out how to make it startup when Ubuntu did. Any ideas? I was thinking the CPU consumption might have had to do with the amarok plugin but I haven't tested this theory yet.

  • FireFox 3 Beta 5. I wish they didn't ship with the beta by default. While I like the beta a bunch of sites that work in FF2 don't work correctly in FF3 B5 (ESPN Fantasy Baseball for instance). Also, a lot of plugins don't work such as my most used FireBug. Is there a way to force some of these plugins to work?

  • Volume Controls - When I mute the main volume Amarok should not continue to make noise but it does. It continues to play in a weird single channelesque muffled sound. When I'm at work I need MUTE to work as expected. WTF is up with this?

Saturday, April 26, 2008

I Heart Hardy

Well, I'm not entirely sure I love Hardy Heron but I did like the install process - it couldn't be any easier. I downloaded the iso, burnt a cd, and did a quick install. Once it was done installing I logged in and BAM! everything worked. I'm amazed at how far Linux has come.

The first time I ever tried Linux (Slackware) was in 1995 on a POS (not point of sale) Compaq I had bought while in the Army. It installed but man was it a pain to get working. In fact, at the time it was so shaky that I was offered a Job with an ISP in Portland Oregon if I could successfully get the machine connecting to the net within Linux (using the built in dial-up). You would think that was an easy task but I basically would have had to hand crafted the drivers for my modem (something I knew nothing about at the time).

Now, here I am 13 years later on a Dell XPS laptop (M170) and I had to click 2 buttons and provide minimal information (my name, a username, and my timezone) and the whole thing was installed. I didn't have to figure out partitions or tweak an odd boot loader to get things running. Instead it just did. Very nice.

The first thing I have done so far is post this blog post. Next I'll muck around with customizing the environment and getting my development environments running (Apache, Eclipse, PHP, CF, Ruby for fun) and see where I go from there. If I can get the secure remote desktop working with one of our clients then perhaps this will become my primary dev machine over my windows box.

To be honest I don't mind windows in general. I'm comfortable in it. I use an alternate shell (GeoShell with Launchy). The only thing I might miss from windows is Media Monkey. I haven't found a music library manager I like nearly as much.

After I get everything installed that I need I'll let you know what I think.

Tuesday, April 22, 2008

A Confessional

I regularly feel like I don't know anything. I have been working as a software developer for around 8.5 years and I feel like a green newbie who just came out of University. The internet serves as the greatest asset to my professional life but also the greatest ego bruiser I have ever known.

I have worked for the same small company since my senior year in University. I have worked on projects developed in Ada, PHP, ColdFusion, Java, C#, VB 6, VB.Net, ASP, ASP.Net, and javascript/ecmascript. I've worked on projects that store data in MySQL, SQL Server, and Oracle including writing stored procedures, functions, and endless queries.

I've messed around with Ruby and Ruby on Rails. I've screwed with Perl a little. I've made some bad flash applications and participated in a couple small open source initiatives. Yet, through all of this I basically feel like I don't know much at all.

I read a lot of blogs written by some smart people who seem to have done so much more with their careers and I wonder what I'm doing. I like the company I work for and I work with some very smart and talented people. I wonder, though, if some of those guys feel the same way I do at times - that we aren't really advancing our knowledge. I wonder what it would have been like to have worked with some of the guys I read online. How much might I have learned and how much better would the software I write be?

I really love writing code yet I know the code I write could often be so much better. I'm not looking for a job but, when I see a want ad, I feel like I don't know much. Even though I've not run into a single problem I haven't been able to solve I still feel like an incompetent when reading the blogs of so many of these people.

So why do I keep reading them? Because I want to learn. I want to be better and dammit, like the shoe commercial says, I want my better to be better than theirs.

This isn't ego but a sincere desire to be much better at what I do. I want to have a better understanding of how to structure different applications, I want to be able to write better code that is easier to maintain and is more performant. I want to have a better understanding of the core fundamentals of software development.

Right now I view these blog authors as my virtual mentors. I am trying to learn vicariously via their experiences. However, in a lot of ways this is a pretty poor way for me to learn. I learn best by doing and then discussing what I have done with others. The traditional "peer review" is, for me, the greatest learning tool I have encountered so long as I have a peer who can review the work; and therein lies the crux of my problem. I don't really have people I can review things with.

I work for a small company and the people I most feel like I can learn from are also the busiest.

The difficultly, of course, is that rarely do I need someone to review something trivial. Instead I would like bigger more complex things to be reviewed. How do you do that though? How can you express a big complex idea concisely so that someone external to the project can get on board to the point where they can provide constructive feedback about your solution? I don't know but I'd love to find a good answer.

Tuesday, April 15, 2008

DPC - Deferred Procedure Calls

First I need to retract my statement that Flock was causing all of the DPC issues I was having. It wasn't - instead it was a much more subtle problem and I'm still not entirely sure what to do about it.

DPC's or Deferred Procedure Calls have been intermittently bringing my laptop to its proverbial knees over the past few weeks. Initially I had blamed the social browser, Flock. After I removed it the problem persisted though (this was a pretty intermittent problem) and I have waited until know to admit I was wrong becuase I wanted to know what the heck was going on.

This morning the DPC situation arose again. I was cruising along getting some work done when suddenly my machine became unusable. ProcessExplorer told me the DPC's were back eating up 60-80 of my CPU and there was nothing I could do to stop it short of a reboot but I really didn't want to reboot.

I keep all of my music on an external USB harddrive and I had some background processes going that were converting some songs from one format to another but when I stopped them the DPC issue didn't go away. I tried to disconnect the USB drive but it wouldn't let me - windows said it was in use. WTF? I wasn't using it.

One of my office mates was though. He was copying the install for Open Office off my share. I didn't know that however so I just turned off the drive. Instantly the DPC problem disappeared. I started the drive back up and the DPC problem didn't resume for a bit but then, suddenly, it was back. After stopping the drive again and then having my friend ask what was up with my drive I put 2 and 2 together. His access of the drive was causing the DPC's.

My initial thought was that maybe there was something wrong with my external harddrive. So I copied the OpenOffice file to my internal harddrive, shared it, and then my friend tried to copy it from the new location. DPC Spike! What a pain!

I don't know why copying stuff off of my computer would cause a CPU usage spike on my machine but for the time being I am now off the local net with my share. If anyone knows what might cause the DPC usage and how I can alleviate it while still helping out my co-workers I would greatly appreciate it!

My Dell Story Cont.

Yesterday I noticed a voice mail message on my work phone from Dell. It was telling me that my replacement machine had been shipped. About 2 hours later I saw a box with my replacement being delivered. Speedy (definitely under the 12-14 day window I was told to expect).

The new machine has a larger harddrive in it (300+ GB compared to 250) but I don't really get to take advantage of that since the old harddrive has stuff on it I want to keep. I suppose I could install both in the new machine and then copy over the files.. But I'm not sure it is worth it. This computer is for my 7 year old daughter and I'm not sure she needs anything close to 250 GB of storage.

The "new" machine isn't really new though. It is refurbished. I guess I'm not surprised but I am a tad bit disappointed. I can't really complain since this machine does work I just figured I would get a new one since the old one is only fairly new and it was still under warranty. Refurb is the way things go now-a-days I guess.

I need to ship the old computer back to Dell now (within 10 days) so I need to get it loaded back up in the box and back to the office so DHL can pick it up. I wish I could keep the RAM that was in the old one (and the other harddrive) since all that stuff still works!

CTRL+SHIFT+S

Hey, some I'm a little (ok a LOT) slow. But I accidentally discovered the keyboard shortcut of "CTRL+SHIFT+S" inside Firefox with the web developer toolbar installed.

Quick, before you look - what do you think it does? If you guessed view the current pages style sheets in a new tab then you're a winner! Sorry, no prizes though.

I have probably used that feature of the toolbar hundreds of times in the past - but I never really noticed the keyboard shortcut.

I love looking at the CSS for any page that looks really good. I almost always learn something (even if it is that I am not as good at CSS as I'd like to be) and, now, thanks to a fat fingered "Copy" I am able to see the pages style faster than ever before.

Friday, April 11, 2008

Data Structures and Algorithms in 8 Languages

I just came across a link to a Ruby version of the web book "Data Structures and Algorithms" which looks very promising. However, what is even better is that the author, Bruno Preis, has written the same book in 8 different languages: C++, Java, C#, Python, Ruby, Lua, Perl, and PHP.

Sure, for the CF readers here he is leaving you out - but it is pretty easy to translate PHP code into equivilant CF code; plus you can always just use the Java if you want. Hopefully some of you find this educational and, better yet, interesting!

Thursday, April 10, 2008

Weighted Arrays in ColdFusion

I stumbled across a blog today that takes a more mathematical look at most problems than I do (and I really like math). The problem he was looking at dealt specifically with randomly selecting items from a weighted array.

A weighted array is basically an array where any item in it has a predefined % chance of being selected if you randomly select an object from it. A standard array full of distinct items is evenly weighted. However, let's say you have a 10 item array where 8 of the items are "dog" and 2 are "cat" then you have a 20% chance of randomly picking "cat" and an 80% chance of picking "dog". Obviously though it is pretty ineffecient to have an array with a bunch of duplicated items in it.

In PHP you can create an array that is weighted so that you only list each object one time along with an accompanying percent weight for each objects chance of being selected:


$weights = array(
"one" => 0.09,
"two" => 0.11,
"pie" => 0.05,
"fish" => 0.15,
"dog" => 0.30,
"oink" => 0.25,
"foo" => 0.05);


In ColdFusion however there are no such things as indexed arrays (at least by that name) so we have to use a Struct to emulate this (using CFSCRIPT):


weights = StructNew();
weights["one"] = .09;
weights["two"] = .11;
weights["pie"] = .05;
weights["fish"] = .15;
weights["dog"] = .3;
weights["oink"] = .25;
weights["foo"] = .05;


Basically, what I have done from here on out is just a syntactic translation of the PHP code provided at the aforementioned link into a ColdFusion interpretation. I can't really claim any credit for anything presented here.

The core of the solution is found in this function which basically returns a random key from the provided structure - where the randomness is affected by the keys predefined weight:

<cffunction name="w_rand" returntype="string">
<cfargument name="weights" type="struct">

<cfset var r = RandRange(1,1000) />
<cfset var offset = 0 />
<cfset var k = 0 />

<cfscript>
for(k in arguments.weights){
offset = offset + arguments.weights[k] * 1000;
if(r LTE offset){
return k;
}
}
</cfscript>

</cffunction>



However, What I can say is that PHP is much, much faster and dealing with this in really large chunks. For instance let's say you are iterating over the struct 200,000 times. Each iteration in PHP takes apx 0.008ms while in CF it takes 0.028ms - over 3x slower! Ouch.

I'm not bringing this up to knock CF - I love CF; particularly when it comes to dealing with databases. However, it does serve as a good reminder that each language available to you has it's own strengths and advantages; never discount one language simply becuase it isn't good at everything - pick the right language for the task at hand.

Finally, just as a little bonus - becuase I wanted to mess with Ruby a little here is the same function in ruby. By the way, the Ruby performance is comparable PHPs at apx 0.008ms per iteration:


def w_rand(weight)
r = 1 + rand(10000)
offset = 0

weight.each { |k, w|
offset += (w * 10000)
if(r <= offset)
return k
end
}
end


It would be nice, really, if I had a good way to share the full source of each file. I'm not really sure how best to share the full demo file here on blogger. If I come up with a solution to it (that doesn't involve me hosting the files elsewhere) I'll update this post.

Tuesday, April 08, 2008

Dell Support is Highly Illogical

I bought a low end Dell PC late last year for my six year old daughter and, about 1-2 months later, it stopped working. You could try to power it up and the power button would light up (solid amber), the fans would spin on, the harddrive would spin up, the DVD player would eject, but the system wouldn't do anything. No BIOS beeps, no signal to the monitor, nothing. It was just dead. Seemed like an obvious failure in the motherboard to me.

So I tried to contact Dell Support. I have used their phone support before and been disappointed so I decided to just use the chat support so that my frustration wouldn't come through to clearly. The first time I contacted them they barely were able to help because I wasn't sitting at the broken computer. The second time I made sure I had the broken machine with me and the ensuing process illustrated to me a huge gaping hole in the logic of their support system.

As I stated the system wouldn't boot. I explained all of the symptoms to the tech in chat and he of course entered straight into his script. Unplug, replug, disconnect external peripherals, unplug, replug, try again. etc. None of that worked of course so then he had me open the machine and remove all of the internal peripherals including the IDE modem, the RAM, the hard drive, the DVD drive, the fans, and to reseat all of the cables between the power supply and the mother board. The only thing he didn't have me do is remove the CPU and reseat it. As you might have guessed that didn't fix the problem either.

Now, remember, the power supply could power up everything in the system except the motherboard. However, after all of this invasive troubleshooting the tech declared the power supply was bad. He said that is what the solid amber light indicated and, since we removed everything else and the mother board still wouldn't power up it had to be the power supply! WTF? It struck me that more than likely we had confirmed the motherboard had a problem not the power supply but I figured, who knows maybe I'll be surprised - it wouldn't be the first time. So he tells me he will ship out a powersupply. I said, "Cool, I'll just install it when it arrives. But, what if the system still doesn't work with the new power supply?"

His response, "Oh, you can't install the power supply. If you break something in the system while installing it your warranty will be voided." What the hell was I going to break that he hadn't already authorized me to manually remove from the system? I was sitting there with all of my computers innards layout in neat little clusters on my desk but I couldn't remove the power supply? What? Are they serious?

Clearly I was getting annoyed so I just said, "OK, so this guy will come out, replace the power supply. Then what if it doesn't fix it." The tech's response? Pure, unadulterated optimism, "It will fix the problem." I laughed and told him I appreciated his positive outlook and looked forward to my computer being fixed.

Today marked the day the tech showed up to replace the power supply and, unsurprisingly, the system still doesn't work so now they are going to send me an entirely new computer. All of the components in the old one work (with the exception of the motherboard) but they are going to ship out an entirely new system. Great, now I only have to strip off windows and re-install Linux. What a freaking waste of time and money. They couldn't just send the tech back with the correct part. What a joke (maybe he isn't allowed to change that part?)

Monday, April 07, 2008

Map Reduce - Reduced For Simplicity

Sure this post is late to the game - but c'est la vie. Really, this isn't a post anyway - it's just a link to someone else's post - a post that clearly and simply explains what MapReduce is and why it is useful. If you are already familiar with map reduce - move along there is nothing to see here. However, if you only have a vague notion about it - or don't understand it at all - then please proceed to "MapReduce for Mere Mortals"

Wednesday, April 02, 2008

Wordpress What's Your Problem With OpenID?

I use wordpress as my primary blogging platform. Sure, this blog is hosted at blogger - but my family blogs are all on wordpress (hosted by me). For a while I was using an OpenID plugin to provide authentication on those wordpress blogs but with the recent release of Wordpress 2.5 the plugin no longer works.

Not only does it not work it is totally busted due to the changes in the security framework of Wordpress. I'll be lucky to see any OpenID integration for quite a while and that, to me, is pretty unacceptable at this point in time.

Wordpress claims to be a platform that is dedicated to it's users and extending blogging yet they refuse to support OpenID and I can only think it is due to pettiness. One of Wordpress's main rivals in the blogging business is Moveable Type. Moveable Type seems to keep it's guns aimed on Wordpress market share and even tries to hype itself by contrasting its features versus those of Wordpress. Moveable Type is also created by "Six Apart" which is one of the initial groups that helped develop OpenID (I'm thinking OpenID was their idea in fact but I'm not sure).

So, I can't help but wonder, is Wordpress refusing to support OpenID just because it's a Moveable Type initiative? I certainly hope not.