Skip to content

Instantly share code, notes, and snippets.

drunkcod / fake-vs-stub.cs
Created November 27, 2016 19:21
Supersimple Mock/Fake Proxy vs handrolled
View fake-vs-stub.cs
/* using FakeItEasy and Cone */
interface ICandy { }
interface ICandyShop
ICandy GetTopSellingCandy();
void BuyCandy(ICandy candy);
class SweetTooth
drunkcod / table-emptying-order.sql
Created October 5, 2014 19:43
SqlServer - list tables in delete/truncate order.
View table-emptying-order.sql
with tab(object_id, level, ref_id) as (
select t.object_id, 0, null
from sys.tables t
where t.type = 'U'
union all
select fk.parent_object_id, level + 1, t.object_id
from tab t
inner join sys.foreign_keys fk on fk.referenced_object_id = t.object_id
View ACE-Bio
Torbjörn is a organizational debugger, developer, architect, hugger and
collector of ideas.He has a deep belief in the untapped potential of folks
and the power of mutually meeting needs to improve the way work works.
Manager by day @drunkcod by night.
drunkcod / EntitySupport.cs
Created September 3, 2013 15:18
So I wanted a general enough way to get the id columns from my entities. This is either Paula Bean brilliant or glorious. I don't know which.
View EntitySupport.cs
static class EntitySupport
class IdentityGetter<TEntity>
public readonly static Func<TEntity,int> Instance = GetIdentityGetter<TEntity>();
public static Func<TEntity,int> GetIdentityGetter<TEntity>()
var id = typeof(TEntity).GetMembers()
drunkcod / gist:4488313
Last active December 10, 2015 20:28
a rough but workable way to "inject" contract tests into a NUnit fixture
View gist:4488313
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace NUnitBehavesLike
public interface IThingamabob
drunkcod / gist:2351063
Created April 10, 2012 12:32
Dynamically add 'require' to any function
View gist:2351063
function addRequire(target) {
while({ target =; }
function requireArguments() {
var args = requireArguments.args;
for(var i = 0; i != args.length; ++i) {
require(arguments[i], args[i]);
return, arguments);
requireArguments.args = /\((.*?)\)/.exec(target.toString())[1].replace(' ','').split(',');