Ruby One Liner to Sort and Run Length Encode a String

December 30th, 2008 Programming, Ruby, Technical

I'm not a Ruby programmer but I thought this was kind of cool. While poking around on Stack Overflow the subject of storing letter frequency for words came up. While there may be a better solution, the idea of alphabetizing the word and storing letter frequencies of 3 or over as the number of occurrences followed by the letter seemed like a passable solution. For instance, "mississippi" is alphabetized to "iiiimppssss" and the multiple occurrences are further reduced to result in "4impp4s". Seems simple enough and in the case being discussed it would result in very little impact on the storage mechanism or the code around it.

The whole thing turns out to be pretty easy as a Ruby one liner:

"mississippi".split( // ).sort.join.gsub(/(.)\1{2,}/) { |s| s.length.to_s + s[0,1] }

That can probably be made a lot better by a Ruby expert. The regular expression finds any character followed by the same character two or more times and then passes the matching string to the following block as a parameter s. It then returns the replacement string which will be the length of the matched string (the character count) followed by one of characters from the matching string. It executes this as a global substitution on the original string. Wha-bam!!! I wonder if there's an odd edge case where this breaks.

Share

Street View, Baby!

December 10th, 2008 Random Thoughts

I just got through reading a post that Google doubled its Street View coverage. I will admit that I know roughly zero about the inner workings of Google but this gave me an idea that I can in no way use to my benefit.

What if the setup for equipping a car with the "Street View hardware" was sufficiently unobtrusive that you could easily mount it on your rental car? Would it be worth it for Google to partner with a rental car company and offer a $5 or $10 per day discount on your rental fee? Or better yet, what about partnering with U-Haul? Would the information be too redundant (everyone driving around in the same locations) or just plain useless (like empty stretches of interstate highways)?

Just a random thought.

Share

Linux in the (Wannabe) Enterprise

December 10th, 2008 Business, General, Technical

The footholds of Linux in small Windows shops are skunkworks projects and discarded hardware. Inevitably the old mail server or the equivalent is considered woefully underpowered and gets replaced. The old hardware sits in a corner of the server room and collects dust. That is until I need a "no money down" VMWare solution.

Of course the downside of this is that you will find yourself installing on frequently inadequate, old hardware that may or may not work–no one ever seems to be sure. When something goes wrong it's Linux's fault. Such was the case when I had to install on an old Dell PowerEdge 600SC. Of course, the install didn't work right off the bat.

The install hung with the last message being "Uniform CD-ROM driver Revision: 3.20". I randomly upgraded the BIOS hoping it's some weird problem with the on-board IDE and see the same problem. Then I noticed that the CD-ROM is attached to the tertiary channel. I can't recall ever having that setup before so I moved the CD-ROM drive from the tertiary to the secondary channel (by accident because the order of the IDE connectors from bottom to top of the motherboard appears to be secondary, primary, tertiary).

After the install it appears that I can't get either DHCP or a static IP to work. Everybody assures me that it's not the IP address they gave me or our DHCP server. I try a different network card with the same effect. Finally, I figure out that it is in fact the network of the IP address they gave me that is to blame (and our DHCP server seems to have crapped out at the same time, and no it isn't running on Linux). But, people stubbornly insist that it's Linux's fault until I waste my time proving otherwise. While I'm gathering evidence they make a point of wandering by my desk and asking why I'm not just using Windows. When society collapses they've got a special place on my post apocalyptic TODO list.

I finally get it all working with a fresh install of VMWare 2.0 (hate the new management web app, by the way) and a migrated VM from my desktop that has a copy of Zenoss Core happily monitoring our new production environment on EC2. Everything in that setup is new from the point of view of this organization. Of course while I'm patting myself on the back over a job well done, someone asks how to get to the desktop UI. Although it probably won't help them much I go ahead and install GNOME, VNC, and Webmin on the box even though I consider it a waste.

Now I get to sit back and eagerly await the opportunity to bask in the criticism the next time anything goes wrong with the box. I'm sure it'll be the fault of that darn Linux.

Share

Flat Organization: Job Interview

November 20th, 2008 comic, Humor

I just don't feel funny this week.

Share

Flat Organization: It's an Art Form

November 12th, 2008 comic, Humor

Share

Flat Organization: The "Lost" Episodes

November 6th, 2008 comic, Humor

Before I started putting the comic directly on my blog, I had a few other episodes of Flat Organization. Since many people never click through to my BitStrips page I'm going to lump all of the "missing" episodes into this one post. I could post them individually but that seems more annoying and like it would require more effort. Apologies to those that have already seen these.

Share

Nobody Paints Baby in a Corner

November 5th, 2008 comic, Humor

Unfortunately this week's comic just feels like I'm getting more and more bitter. Maybe the next one will be funny.

Share

Clearing Cached Authentication Info in Windows

November 4th, 2008 General, Technical

This comes up every now and then for me and I can never remember how to do it so I'm sticking it here to make it easier for me to find. The problem happens when I'm using Windows Explorer to open or browse a Windows share / Samba share / SMB mount point / etc. Windows Explorer has a tendency to cache the authentication information for the share and doesn't re-present the opportunity to provide authentication information in the event that the cached credentials have become invalid. This happened to me again today when the account I had used in the past had become disabled. You can find and clear the cached authentication(s) by doing the following:

Click Start, Run and type Control keymgr.dll
Remove the entries from the list

OR

Click Start, Run and type Control Userpasswords2
Click Advanced, Manage Passwords

The information is also in the Registry but these worked well enough for me to not go poking around in that rat's nest.

Share

Gracie Cameo in The Incredible Hulk

November 4th, 2008 Humor

There are quite a few little cameos in The Incredible Hulk but the one I was happiest at having spotted was Rickson Gracie. Remember in Portuguese that 'R' sounds like an 'H', so it's pronounced "Hickson." Unfortunately they've listed him as an Akido instructor despite the fact that he's a bad ass in the family business of Brazilian Jiu Jitsu. I know it doesn't sound like it, but that's a colossal fuck up in martial arts land. Besides that it's a fair movie but after all the rumors about heavy editing changing the nature of the film I'd really like to see what the original "Norton" version was like. Maybe 25 years from now we can have 8 versions of it like Blade Runner.

Share

Flat Organization: Have Laptop, Will Travel

October 24th, 2008 comic, Humor

Yeah, I'm not doing so well at sticking to the new "publish once a week" experiment. I either need a new rule allowing overflow or need to be more willing to stockpile these crappy jokes.

Share