Skip to content

Instantly share code, notes, and snippets.

View acken's full-sized avatar

Svein Arne Ackenhausen acken

View GitHub Profile
@acken
acken / gist:892133
Created March 29, 2011 10:19
Clever use of interfaces
private void setInitialUsedSpace()
{
_sizeCalculator.Calculate().ToList()
.ForEach(calculation => DecreaseUsedSpaceForVolume(calculation.Key).With(calculation.Value));
_volumes.ForEach(x => logInitialSize(x));
}
private void handle(UploadFinishedMessage message)
{
var task = message.Task;
@acken
acken / gist:1245569
Created September 27, 2011 16:42
Rabbit enqueue
using System;
using RabbitMQ.Client;
using RabbitMQ.Client.MessagePatterns;
using RabbitMQ.Client.Framing.v0_9;
using System.Threading;
using System.Text;
namespace SladrehankEnqueuer.Core
{
public class Enqueuer
{
@acken
acken / gist:1245668
Created September 27, 2011 17:17
Rabbit dequeuer
private Func<string, bool> _itemHandler;
private IConnection _connection;
private IModel _channel;
private QueueingBasicConsumer _consumer;
private bool _stop = false;
public Dequeuer(Func<string, bool> itemHandler)
{
_itemHandler = itemHandler;
}
@acken
acken / MsgDispatcher.cs
Created October 27, 2011 08:04
Message dispatcher
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace MinimalMessaging
{
public class MessageDispatcher : IMessageDispatcher
{
@acken
acken / commandments.md
Created November 29, 2011 12:17 — forked from oc/commandments.md
Ashcroft commandments
  1. I am the class being tested. Thou shalt not test any other class but me.
  2. You shall not make for yourself a mock of an API that you don't own.
  3. You shall not call a system or integration test a unit test.
  4. Your unit test suite shall not take all week to run.
  5. [father and mother]
  6. Thou shall not kill the runtime environment.
  7. [adultery]
  8. [steal]
  9. You shall not bear false witness against your neighboring tests.
  10. You shall not covet your system's files, you shall not covet your system's threads, or his sockets, or his graphics environment, or his environment variables, or anything that is part of your system.
@acken
acken / gist:5442592
Created April 23, 2013 10:46
Sublime vim windows navigation
import sublime, sublime_plugin
class VimWindowNavigateLeftCommand(sublime_plugin.WindowCommand):
def run(self):
next = 0
active = self.window.active_group()
if active > 0:
next = active - 1
@acken
acken / Program.cs
Created October 25, 2013 08:55
ContinuousTests headless engine using the ContinuousTests.ExtensionModel.dll
using System;
using System.Linq;
using ContinuousTests.ExtensionModel;
using ContinuousTests.ExtensionModel.Arguments;
namespace test
{
class Program
{
static void Main(string[] args)
@acken
acken / gist:8520086
Created January 20, 2014 13:44
Output from rake mono (nancy)
Version: 0.21.1
Main project does not update assembly info
D, [2014-01-20T14:40:52.948831 #27329] DEBUG -- : Executing xBuild: "xbuild" "src/Nancy.sln" /p:configuration="MonoRelease" /p:TargetFrameworkProfile="" /p:TargetFrameworkVersion="v4.0"
XBuild Engine Version 2.10.8.1
Mono, Version 2.10.8.1
Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2011.
Build started 1/20/2014 2:40:53 PM.
__________________________________________________
Project "/home/ack/src/Nancy-0.21.1/src/Nancy.sln" (default target(s)):
@acken
acken / gist:9675693
Created March 20, 2014 22:49
OpenIDE reactive script for automatically adding and removing .cs files as they are created/deleted
#!/usr/bin/env python
import os
import sys
import subprocess
def runProcess(exe,workingDir=""):
if workingDir == "":
workingDir = os.getcwd()
subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=workingDir)
@acken
acken / gist:c9656c84111fe59f1e98
Last active August 29, 2015 14:02
CQRS pattern thingie
#r "/home/you/src/thisthing/lib/JSONNet/Newtonsoft.Json.dll"
open System
open Newtonsoft.Json
// Identifier type
type Id = System.Guid
module EventStore =
type VersionedEvent = int * string