Kona puppy stole my shirt

2010 March 12
by Nick Lamb

Kona puppy stole my shirt

Toms, the latest scam in shoes

2010 March 8
by Nick Lamb

There’s a scam going on in the shoe world.  The person perpetrating it? Tom.  He’s selling people pieces of rubber with various types of cloth attached.  There’s canvas, or denim or wait for it…burlap!  I love the thought of a nice strip of burlap rubbing on my toes all day long!  The shoe names are as creative as the fabrics. “Villiage Vegan Classics” For only $54, yes please.  Someone should tell Tom that his idea was taken long ago when someone invented the slipper.

Worst Shoe Ever

Launching Briarwood Billiards

2010 March 5
by Nick Lamb

I’ve been trying to hone some of my web design skills lately and got the opportunity to work on a new e-commerce store for Briarwood Billiards.  The site is using Shopify’s platform to host everything.  Hop on over and check it out

Briarwood Billiards New E-Commerce Site

Briarwood Billiards New E-Commerce Site

Fun with LINQ

2009 October 20
tags: , ,
by Nick Lamb

I’m working on a form that needs three dropdowns for a user to input a date like this:

Rather than get out my ctrl+c, ctrl+v skills, I thought it’d be fun to play with LINQ in C#. First off, I’ll say that I know this is not the most efficient code, yes I know there’s hidden loops when it calls ToList() and Enumerable.Range() I was going for very succinct code that looked pretty, not performance.

The thing that makes this so nice is Enumerable.Range(int start, int count); This gets a continuous range of numbers with very little typing. And with each of those numbers just select a new ListItem. Another nice thing is to have quick ordering capabilities. I needed only the last 5 years from this year in descending order, that was easy with LINQ too. Once all the ListItems are created, it’s just a matter of converting the IEnumerable to an IList so we can call ForEach on it to add items to the dropdown all in one line of code.

        protected void LoadDateDropdowns()
        {
            var months = from i in Enumerable.Range(1, 12)
                         select new ListItem()
                         {
                             Text = new DateTime(1900, i, 1).ToString("MMMM"),
                             Value = new DateTime(1900, i, 1).ToString("MMMM")
                         };

            var days = from i in Enumerable.Range(1, 31)
                       select new ListItem()
                       {
                           Text = i.ToString(),
                           Value = i.ToString()
                       };

            var years = from i in Enumerable.Range(DateTime.Now.Year - 5, 5)
                        orderby i descending
                        select new ListItem()
                        {
                            Text = i.ToString(),
                            Value = i.ToString()
                        };

            // add the months to the dropdown
            months.ToList().ForEach(i => ddlManufactureMonth.Items.Add(i));

            // add the days to the dropdown
            days.ToList().ForEach(i => ddlManufactureDay.Items.Add(i));

            // add the years to the dropdown
            years.ToList().ForEach(i => ddlManufactureYear.Items.Add(i));
        }

New Music Season

2009 September 23
by Nick Lamb

When I was buying my car a few years ago there were two options for sound systems.  Option 1, a single cd player with an external audio jack on the front, plus 4 dinky speakers using 50 watts total.  Or option 2, a 6 disc mp3 cd player with no external audio jack, plus 8 speakers and a subwoofer using 465 watts.  Well needless to say I went for the 465 booming watts, plus bone rattling bass.  At the time I was seduced by all the speakers and the letters ‘mp3′ in the name, forgetting about the missing external audio jack.  Little did I know that small little jack would come back to bite me.  So for the past few years I’ve been burning mp3 cd’s with music on them, usually about 8 albums per cd.  That music only lasts so long and I tire of it.  Why not just burn more cd’s, you say? Well, I’m lazy.  And now I have an iPhone.  I’m wishing I had the audio jack now.  My wife bought me one of those FM tuners to play audio from the iPhone in the car, but let’s be honest here, FM tuners suck.  They always have and always will, no matter how many times I try them.  This is no fault on my wife’s part, she did a good thing trying to feed my iPhone habit. 

Anyways, that brings me to the point of this post.  It’s that time of year when I break through my laziness and burn a new mp3 cd and move on to some new music.  So here’s what I’ll be listening to for the next 6-12 months in the car.  It’s an eclectic mix of sounds.

Worst Code Ever!

2009 June 16
by Nick Lamb

First take a look at what the offending code that I have to maintain looks like, then I’ll explain.

public IList<Product> ListProducts(string filter)
{

IList<Exception> exceptionResults = new List<Exception>();

List<List<Product>> products =

handlerMultiCaster.Handle<List<Product>>(out

exceptionResults, “TRD.LISTPRODUCTS”, distributionPoint, filter);

if (products.Count == 1)
{

return products[0];

}
return
null;

}

So the first thing to notice about this code is that there are two main concepts, a “multi caster” and a “handler”.  “Handlers” have only one method called Handle() and you pass a magic string telling it what exactly to “handle”. This in itself is terrible because a developer has no idea what the possible values of what they should pass are unless they dig down into the Handle method to find where the other magic strings are stored.  “Handlers” are configured through an arcane configuration framework that loads .dlls with concrete implementations of the Handler that have such methods as Invoke() and DoHandle().

Now it gets even better with the “multi caster”.  In an application there may be any number of “Handlers” configured and since these handlers get invoked dynamically(something any other dependency injection framework could have done better) the best thing that the “multi caster” can do is to loop over all configured handlers and call Handle on ALL of them(whether they’re actually going to work or not).  This is the really hilarious part where the IList of Exceptions comes into play.  Since the multi caster just calls all the handlers blindly most are bound to fail and throw exceptions(there goes performance), so it returns a list of all those exceptions.  What to do with all those exceptions is anyone’s guess.  What’s worse is when the so called multi caster rips through each handle method some of them could get part way through execution and then throw leaving multiple handlers in an unkown state, perfect!  The last part is just really annoying, if you only need one list of products, why return a list of lists of products and then just to add salt to the wound by only grabbing the first list out of the list of lists.

There are so many anti-patterns here it makes my head spin, but nobody else seems to think it’s a backwards way to accomplish something.

The Big Picture

2009 January 26
by Nick Lamb

If you’re like me and like to see big pictures, you need to check out this blog from the boston globe http://www.boston.com/bigpicture/ It’s definitely one of my favorites.

Emails!

2009 January 9
by Nick Lamb

Our company recently switched email domains, so to keep my old email address forwarding correctly I have to maintain the old account also.  The problem is that I haven’t looked at it in a couple months.  To my surprise I logged in today and found this:

My inbox after 2 months

Close to 60,000 emails!  Granted, lots are error emails from our systems, but that’s still a lot of crap to sift through.  Which reminds me of a great article about email I read recently at coding horror. I may never get out from under the pile.

Cat riding a Roomba

2008 November 20
tags: , ,
by Nick Lamb

Although my wife would disagree, this is why cats are awesome.

Great CSS Tool

2008 November 17
by Nick Lamb

I was alerted of this great tool last week that helps when you’re having problems with CSS based layouts.  Check it out http://giveupandusetables.com/ It’s a timer that tells you when you’ve spent too much time trying to get your css layout to work in all browsers.