jQuery: Validate Minimum or Maxium Date

Add a minimum (or maximum) date validator to jQuery Validate
/* include this after jquery.validate* */
$.validator.addMethod('mindate', function (v, el, minDate) {
    if (this.optional(el)) {
        return true;
    }
    var selectedDate = new Date($(el).val());
    minDate = new Date(minDate.setHours(0));
    minDate = new Date(minDate.setMinutes(0));
    minDate = new Date(minDate.setSeconds(0));
    minDate = new Date(minDate.setMilliseconds(0));

    return minDate <= selectedDate;
}, 'Date is less than {0}.');

$.validator.addMethod('maxdate', function (v, el, maxDate) {
    if (this.optional(el)) {
        return true;
    }
    var selectedDate = new Date($(el).val());

    maxDate = new Date(maxDate.setHours(0));
    maxDate = new Date(maxDate.setMinutes(0));
    maxDate = new Date(maxDate.setSeconds(0));
    maxDate = new Date(maxDate.setMilliseconds(0));

    return selectedDate <= maxDate;
}, 'Date is greater than {0}.');
Implementation
$("form").validate({
    rules: {
        'DueDate': { required: true, mindate: new Date() }               
    },
    messages: { // optional message
        'DueDate': {
            mindate: 'Due date must be on or after today'
        }
    }
});
Helpers:
function GetDate(days) {
// get a date sans time plus or minus {days}
    var _today = new Date();
    if (days != null && days != 0)
        _today = new Date(_today.setDate(_today.getDate() + days));

    _today = new Date(_today.setHours(0));
    _today = new Date(_today.setMinutes(0));
    _today = new Date(_today.setSeconds(0));
    _today = new Date(_today.setMilliseconds(0));

    return _today;
}

Knockout.js: Starter Template

Tired of trying to remember this:
function ViewModel() {
    var self = this;
}

$(function(){
    ko.applyBindings(new ViewModel());
});

ASP.NET: Enumerate Server Variables

<table class="table table-striped table-condensed">
    <thead>
        <tr>
            <th>Key</th>
            <th>Value</th>
        </tr>
    </thead>
    <tbody>
@foreach(string key in Request.ServerVariables) {
        <tr>
            <th>@key</th>
            <td>@Request.ServerVariables[key]</td>
        </tr>    
}
    </tbody>
</table>
...with bootstrap styles

ASP.NET MVC: Download File or Display Inline

public FileResult View(string fileName, bool inline = false)
{
    var rootPath = "c:\\some.path.on.your.server";
    var filePath =  Path.Combine(rootPath, fileName);
    var fileBytes = System.IO.File.ReadAllBytes(filePath);
    var mimeType = System.Web.MimeMapping.GetMimeMapping(fileName);
    var cd = new System.Net.Mime.ContentDisposition
    {
        FileName = fileName,
        Inline = inline,
    };
    Response.AppendHeader("Content-Disposition", cd.ToString());
    return File(fileBytes, mimeType);
}

LESS/CSS: Manual visibility of elements

Set visibility of elements manually as part of responsive design (notes only)
Use .visible-xx where xx = size (xs, sm, md, etc.) for bootstrap, or define the following:
@screen-md:1199px;
@screen-sm:991px;
@screen-xs:749px;

/* xs */
@media(min-width: @screen-xs){
    .visible-xs { display: none; }
    .hidden-xs { display: normal;}
}

@media(max-width: @screen-xs){
    .visible-xs { display: normal; }
    .hidden-xs { display: none;}
}

/* sm */
@media(min-width: @screen-sm){
    .visible-sm, { display: none; }
    .hidden-sm { display: normal;}
}

@media(max-width: @screen-sm){
    .visible-sm { display: normal; }
    .hidden-sm { display: none;}
}

/* md */
@media(min-width: @screen-md){
    .visible-md { display: normal; }
    .hidden-md { display: none;}
}
@media(max-width: @screen-md){
    .visible-md { display: normal; }
    .hidden-md { display: none;}
}

jQuery: Toggle a list of checkboxes

Behavior: Default the toggle to the value of the first checkbox. Changing the toggle will toggle all checkboxes to the toggle state.

HTML
    <table>
        <thead>
            <tr>
                <th><input type="checkbox" id="toggle" /></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><input type="checkbox" checked="checked" /></td>
                <td>descriptive info a</td>
            </tr>
            <tr>
                <td><input type="checkbox" /></td>
                <td>descriptive info b</td>
            </tr>
            ...
        </tbody>
    </table>
Javascript
    document.ready(function() {
        toggleInit("table thead input[type=checkbox]", "table tbody input[type=checkbox]");
    });

    function toggleInit(toggle, inputs) {
        toggle = $(toggle);
        inputs = $(inputs);

        var first = inputs.eq(0);
        var checked = first.checked;
        toggle.prop('checked', checked);
        toggle.change(function() {
            inputs.prop('checked', this.checked);
        });
    }

TSQL: Get DATE from DATETIME

There are a dozen articles with the comparisons... all I wanted was the most performant one:
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))