Skip to content

Instantly share code, notes, and snippets.

@daanl
daanl / gist:3076514
Created July 9, 2012 13:17
Ninject multiple classes one interface
kernel.Bind(
x => x.FromThisAssembly()
.SelectAllClasses().InheritedFrom<IGenre>()
.BindAllInterfaces()
);
public class TestController
{
public TestController(IEnumerable<IGenre> gernes)
using System.Web.Mvc;
using UI.Web.Cultures;
using UI.Web.Localization;
namespace UI.Web.Views
{
/// <summary>
/// Custom web view page
/// Adds CultureService, LocalizationService and Localize to the views
/// </summary>
@daanl
daanl / gist:4594370
Created January 22, 2013 12:42
Simple Javascript app
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
(function(window, $) {
var defaults = {
@daanl
daanl / gist:4703302
Created February 3, 2013 19:34
global js
(function(global, $)
"use strict";
var something = function() {
};
window.something = something;
@daanl
daanl / gist:4756825
Created February 11, 2013 19:17
Dynamic translation service
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication5
@daanl
daanl / c
Last active December 16, 2015 16:59
class Program
{
static void Main(string[] args)
{
var value = GetObject();
if (value is bool?)
{
Console.WriteLine("true");
}
class Program
{
static void Main(string[] args)
{
var store = new EmbeddableDocumentStore
{
DataDirectory = "Data"
};
store.Initialize();
@daanl
daanl / gist:5618733
Created May 21, 2013 10:03
Expressions
using System;
using System.Linq.Expressions;
using NUnit.Framework;
namespace ClassLibrary1
{
[TestFixture]
public class Class2
{
[Test]
public class User : IPrincipal
{
public User(string username, IEnumerable<string> roles)
{
Username = username;
Roles = roles;
}
public string Username { get; private set; }
public IEnumerable<string> Roles { get; private set; }
public class ActionRunner
{
public void Run(Action action)
{
action();
}
}
ActionRunner.Run(
async () =>