Interfaces – The Good and The Ugly

(there is no bad…just pros and cons)

I want to start off this with a positive spin. Interfaces are great. They help make your life much easier. Using interfaces is real easy too:

public interface IEntity
int Id {get;set;}
DateTime DateCreated {get;set;}
DateTime DateUpdated {get;set;}
string CreatedBy {get;set;}
string UpdatedBy {get;set;}
bool Enabled {get;set;}
int DisplayOrder {get;set;}

Continue reading Interfaces – The Good and The Ugly

WordPress new install on Windows IIS 7 with 500 Internal Server Error

Wasted 3 hours of my night working on this.  I was asked by a friend to install WordPress for them so that they can do everything.  Sounds like very little work for me.  Sounds like money for old rope.  No problems I thought. BOOM!  500 Internal Server Error. Continue reading WordPress new install on Windows IIS 7 with 500 Internal Server Error

Tables not aligning center in some mail clients

Another one of those pesky email clients not working properly.  With the advent of MailChimp and cool CSS stuff, you kinda get lazy.  I did and forgot to add the old school version of layouts on tables.  I only added the style=’margin: 0 auto’ but Hotmail web based client actually stripped that out!

The Solution

Add align=’center’ as well as the style=’margin: 0 auto;’.  Another simple thing I know I will forget – hence adding it here.

Remove jQuery validation on specific button

So you’ve just built what is the best form ever! It has 1 set of fields, 3 buttons – save, delete, cancel. Pixel perfect styling as per the designers Photoshop file, and the CSS that anyone would dream of. And then it stops working! You click the cancel button! It validates the form!! NO! It’s a cancel button. It should stop what you are doing. Really simple fix, and am just writing it down here because I will forget.

The Solution

Add a css class of cancel on to your button. That’s it. Simple!

IIS, Trailing Slashes, and HTML extension

I hate URLs that don’t end in something.  I do.  I REALLY do.  That’s why most of the website I have built end in .html or for the MVC ones, a trailing slash.  But don’t you just hate it when a search engine or user somehow picks up a URL that doesn’t have the trailing slash? e.g. /my-lovely/url/without-a-slash ARGH!  I see it a lot on WordPress sites because of the amount of sharing going on.  I would have thought this would have come up more often, but it seems people don’t mind it.  I mind.  I think I have trailing slash and .html OCD.  I found this post on stackoverflow which was great but as always it didn’t work – too many blogs saying it does, when it does.  So for posterity here is what I did: Continue reading IIS, Trailing Slashes, and HTML extension

Email lists and duplicates

Just came across a really nasty problem which we have all faced from time to time.  Well the past couple of days it was my turn.  And email list of ~16,000 but each row having slightly different content, except the email address.  The names could be slightly different e.g. concatenated in 1 field, not there, or in the 2 correct fields (people stop have a “Name” field with first and surname  in it!). Continue reading Email lists and duplicates

ICO European Cookie Law

Many of you will know the ICO cookie deadline will hit the shores of the UK in May 2012. What’s funny is the ICO website developers are a bit crap at their job.

1. Go to :
2. Accept their cookie thingy at the top.
3. If you can, change the value of the cookie they set
– it’s called “ICOCookiesAccepted”
– change the value from “true” to “false”
4. See how their website still has Google tracking on it even though your cookie says false?!

Could that be breaking the law?

Add Facebook App to Facebook Page Tab

You may have noticed recently that Facebook removed the ability to add your Facebook application directly to your Facebook page (for unknown reasons!). So to save my self some pain each time I created this file that I upload to the domain the Facebook page tab will be hosted on. (remember to change the file to have you own Facebook App Id in it…)

Saves sooooo much time! If you have multiple apps running off 1 domain, you add more buttons with the different App Ids.

Pixastic Desaturate images with jQuery on mouseover, mouseenter, mouseleave

Had another great morning wangling my way around 4 browsers (7 if include each version of IE). The client had a requirement an image would have a black and white version and this would flip when the user moused in, over, out, etc.

Problem was we couldn’t rely on the client loading a black and white image, or know how to create one…these are clients after all! And having them contact us each time to create the black and white version each time is not going to happen (unless they paid…).

Enter Pixastic.

This is one of the coolest widgets I have the pleasure to work with. It plays with your images soooo nicely and seems to be completely cross browser compatible. Nice work boys! However…

The Problem

When you apply Pixastic’s desaturate code to the image the image disappears out the DOM and a Canvas element replaces it. So if you have done the standard $(image id or class).hover() with jQuery (or mootools or whatever) then when you mouse over it works, but is instantly remove from the DOM so you straight away get a mouse out event being fired. Damn! Not what you want! Worse still the image now reappears causing a mouse over event which, yes you guessed, it flips it back. You get a nice wee flicker happening – not good if you don’t like flash photography!!

The Solution

I won’t go into the depths of what I did. I will just add the code so you get back to your day job and make tonnes of money.

$(window).load(function () {
    $("div.parent").each(function (index, obj) {
        $("#" + $(obj).attr("data-image")).pixastic("desaturate"); // make it black n white

    $("div.parent").mouseenter(function (e) {
        var self = document.getElementById($(e.currentTarget).attr("data-image"));
        Pixastic.revert(self); // make it colour

    $("div.parent").mouseleave(function (e) {
        // make it black n white again (yes I should refactor this...)
        $("#" + $(e.currentTarget).attr("data-image")).pixastic("desaturate");

However what you will notice is instead of the code being in the $(document).ready() function call, it’s in the $(window).load(). Images are not fully loaded at $(document).ready() in Webkit (Chrome and Safari). As Pixastic checks to see if the image is loaded with “this.complete” before processing it (otherwise it could try to process something that isn’t there…) then your code needs to be in this function call.

But once you do that, it works a treat! Check out my demo to prove that it works!