Archive for July, 2007

Please, Thank You, and also Sir and Ma’am.

Kindness can get you a long way.  Lately I've noticed that people are becoming very impolite.  It's been rather bothersome and a source of frustration as of late.  You see, I'm from the south.  We have this thing called Southern Hospitality of which I'm very accustomed to.  Seriously, you should read about us.  I promise you we're not all inbred hicks walking around barefoot.

I try to make it a point to say "Thank You" whenever someone does something for me.  Even if it's something they were supposed to do, it never hurts to display gratitude.  It's my little way of showing that I recognize that someone did something  for me.  Waitress fills my drink: I say "Thank You."  Guy at the drive-thru window hands me my order: I say "Thank You."  My wife fixes dinner;  Once again I say "Thank You."  It's just a respect thing.  You should try it sometime.  I bet you'll notice a little better out of the person you said it to as a side-effect.

Masked Input Plugin 1.0

I finally made it to 1.0! This release doesn't add anything new other than a few minor cosmetic code changes.
So, without further adieu, I present my Masked Input Plugin.

That’s a nice CPU you’ve got there

It's not a pretty thing when non-technical people try to use technical terms.  I understand that they think that using these mysterious words they hear will make communication easier.  In reality it doesn't do anything but confuse us. 

The title of this post is the phrase for discussion.  A coworker walks into the IT office area and points towards a workstation which we use for running long batch jobs.  It's a workhorse that we happen to have decorated with a side window and neon lights.  I can only hope that he was so awestruck by the beauty of the light that he said the wrong thing.  In reality he's just confused and was trying to sound cool so that he could try to engage us socially.  "CPU" sounds way cooler than "computer", right?  Someone should really tell him that technical people tend to be introverted.

Snobbery at it’s finest

Money can't buy intelligence, that's for damn sure.  I'm driving along tonight and I notice this BMW driving along with a VERY low tire.  Being the good natured person that I am, I roll up beside of the car and motion for him to roll his window down.  Little did I know, the universal cranking motion that one uses to notify another person to roll his or her window down also translates to "let's race".  At least it must if you are a dumb kid driving an expensive car that mommy and daddy bought you.  Oh well, I tried to help.  The jokes on him, that car had low profile tires and was basically on it's rim.  I guess it won't kill his parents to buy a replacement wheel for the car once that one gets a taste of the asphalt. 

.NET 3.5 Extension Methods

I can't wait to start using extension methods in production. I've already thought of a few great uses for this. For a while I've been jealous of other languages and their seamless integration of regular expressions. Regular expressions are executed against strings, and so I feel it's appropriate to have them married together. With .NET 3.5, I can get a little bit closer with the following class:

    public static class StringExtensions
    {
        private static Dictionary cache = new Dictionary();
        private static Regex cacheRegex(string r)
        {
            if (!cache.ContainsKey(r))
                cache[r] = new Regex(r, RegexOptions.Compiled);
            return cache[r];
        }

        public static bool IsMatch(this string s, string regex)
        {
            Regex r = cacheRegex(regex);
            return r.IsMatch(s);
        }

        public static MatchCollection Matches(this string s,string regex){
            Regex r = cacheRegex(regex);
            return r.Matches(s);
        }

        public static Match Match(this string s, string regex)
        {
            Regex r = cacheRegex(regex);
            return r.Match(s);
        }

        public static string[] Split(this string s, string regex)
        {
            Regex r = cacheRegex(regex);
            return r.Split(s);
        }

        public static string Replace(this string s, string regex,string replacement)
        {
            Regex r = cacheRegex(regex);
            return r.Replace(s, replacement);
        }
    }

Sure, the caching could actually do something more useful, but the idea is there. Now I can do something like this:

"Josh".IsMatch("^J");

To me that is way better than this:

Regex startsWithJ=new Regex("^J");
startsWithJ.IsMatch("Josh");

Next Page »