Skip to content

Instantly share code, notes, and snippets.

@mat-mcloughlin
mat-mcloughlin / gist:6376025
Created August 29, 2013 09:25
A knockout binding handler that formats dates correctly. It requires the use of jquery, knockout and moment Ideally I'd do this without jquery
ko.bindingHandlers.date = {
update: function(element, valueAccessor, allBindingsAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
var allBindings = allBindingsAccessor();
var format = allBindings.format || 'DD/MM/YYYY'; // default format.
if (value && value != 'Invalid Date') {
var formattedDate = moment(value).format(format);
if ($(element).is('input')) {
@mat-mcloughlin
mat-mcloughlin / TurtleModule.cs
Last active December 21, 2015 08:59
A simple Nancy module
using Nancy;
using Nancy.ModelBinding;
public class TurtleModule : NancyModule
{
public TurtleModule() : base("/turtle")
{
// Note: arguments can be named anything.
Get["/"] = arguments =>
{
@mat-mcloughlin
mat-mcloughlin / ioCContainer
Last active December 21, 2015 03:18
A very basic example of an IoC Container
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var container = new Container();
container.Bind<ICar, Car>();