Blog posts

  • Disable navbar collapse in Bootstrap 3

    August 28, 2014 | Tags: CSS, Snippet

    If you don't want the navbar to be collaspeable in Bootstrap 3 it's pretty easy to disable it using LESS.

    Open the file variables.less and locate @grid-float-breakpoint, it will look something like this:

    @grid-float-breakpoint: @screen-sm-min;

    To disable collapse just change the value to zero:

    @grid-float-breakpoint: 0;

    And the navbar will not collapse ever again!


  • .NET Image Library has moved to GitHub

    August 27, 2014 | Tags: Image Library, Open source

    In order to make the project more collaborative it has now been moved to GitHub and is now found at https://github.com/fschultz/NetImageLibrary. Migration has been done with all history included.


  • HybridConf 2014 rocked!

    August 24, 2014 | Tags: Inspiration

    I had the great privilege to attend HybridConf 2014 held in Stockholm August 21-22. It was by far one of the best conferences I've been at. Nice friendly atmosphere and a lot of great speakers ranging through a wide variaty of topics.

    Some of the speakers that I really enjoyed - and that I recommend anyone who has the chance to hear - was Tom Soderstrom - IT CTO at NASA Jet Propulsion Laboratory, Scott Hanselman - Principal Program Manager Lead at Microsoft,  Dan Rubin Partner at Webgraph, Hampton Catlin - creator of Sass and Haml and Andrew Nesbitt - developer at Github.

    You can find a couple of Scott Hanselman's talks from other events online. I truely recommend listening to his talk about effectiveness and efficieny. Dan Rubin's talk about roles and communication was also an interesting one.


  • How to set this when calling a javascript function

    February 04, 2014 | Tags: Javascript, jQuery, Snippet
    Ever wondered how the this entity was set in a function like for instance a jQuery event handler? Or maybe even needed to invoke that event handler from code passing the object that would be accessed through this within the function? The secret is to use the call-function that is available on every function in JavaScript.

    If you for instance have an event handler setup in jQuery like the one below:
    function buttonClickHandler(e) {
    $(this).addClass('clicked');
    }

    $('a.btn').click(buttonClickHandler);
    ..that you would like to invoke from code and passing the object that would be accessed through this within the function, using the call-function on your event handler function will do the trick:
    var btn = $('#button1');
    buttonClickHandler.call(btn);

    The syntax of the call-function is: call(thisArg[, arg1[, arg2[, ...]]]). The first parameter you pass is what will be accessible through the this entity. Then follows optional parameters that will be passed as parameters to the function being called in the given order.

    If you which to pass an object as this to a function that takes two parameters (lets say showName(firstName, surName)) you would do it like this:
    function showName(firstName, surName) {
    $(this).val(firstName + ' ' + surName);
    }

    var element = $('#element');
    showName.call(element, 'alice', 'cooper');

  • How to combine URLs/URIs in C#

    February 03, 2014 | Tags: C#, Snippet
    The file system have the Path.Combine method to combine paths but how to combine a base URL with an absolute or relative URL/URI?

    The answer is to use the System.Uri-constructor to combine the URL:

    public static Uri CombineUri(string baseUri, string relativeOrAbsoluteUri) {
    return new Uri(new Uri(baseUri), relativeOrAbsoluteUri);
    }

    public static string CombineUriToString(string baseUri, string relativeOrAbsoluteUri) {
    return new Uri(new Uri(baseUri), relativeOrAbsoluteUri).ToString();
    }

    ..

    // Results in "http://www.my.domain/relative/path"
    var a = CombineUriToString("http://www.my.domain/", "relative/path");

    // Results in "http://www.my.domain/absolute/path"
    var b = CombineUriToString("http://www.my.domain/something/other", "/absolute/path");