Steamed Design

Jan 31

Look what ReSharper just taught me

You can rewrite:

var result =  object.Where(m => m.Id == id).FirstOrDefault()

as

var result = object.FirstOrDefault(m => m.Id == id);

Thank you ReSharper

Jan 20

Jan 16

Anonymous said: if i ask a question, where does it go and how do i see the answer? is this powered by a magic 8 ball?

Reply hazy, try again

Dec 20

Why using test coverage as a metric is stupid

Adding a useless test to increase test coverage check.

[TestMethod]
[ExpectedException(typeof(NotImplementedException))]
public void AddUsersToRolesTest()
{
    Roles.AddUsersToRoles(new string[] { }, new string[] { });
}

Nov 16

Easter eggs jQuery plugin

I decided that a project I was working in needed more monsters so I created a quick jQuery plugin to add them, have fun.

//Change image
//<div data-swapcss-value='url("imageurl.png")'>

//Full options
//<div data-swapcss-property='background-color' data-swapcss-value='red'  data-swapcss-count="3">
var swapCssConfig = {}
var swapCssConfig.currentCount = 0;
(function ($) {
    $.fn.swapCSS = function (options) {

        var settings = jQuery.extend({
            clickCount: 6,
            property: 'background-image'
        }, options);

        var currentElement = this;

        currentElement.click(function () {
            warningClickCount++;
            if (swapCssConfig.currentCount > (settings.clickCount - 1)) {
                currentElement.css(settings.property, settings.value);
                currentElement.unbind('click');
            }
        });
    };

    $(document).ready(function () {
        $('[data-swapcss-value]').each(function (index) {
            var item = $(this);
            var options = { value: item.attr('data-swapcss-value') };

            if (item.attr('data-swapcss-count') !== undefined)
                options.clickCount = item.attr('data-swapcss-count');   

            if (item.attr('data-swapcss-property') !== undefined)
                options.property = item.attr('data-swapcss-property');

            item.swapCSS(options);
        });
    });

})(jQuery);