Skip to content

Instantly share code, notes, and snippets.

View damianh's full-sized avatar
💥

Damian Hickey damianh

💥
View GitHub Profile
title Command Handling, Pessimistic Concurrency
actor User
boundary Handler
boundary Repository
entity BarInstance
database EventStore
autonumber
User -> Handler : Set Foo = 2 on Bar\nwhere version = Y
Handler -> Repository : Get Bar
title Command Handling, Standard Concurrency
actor User
boundary Handler
boundary Repository
entity BarInstance
database EventStore
autonumber
User -> Handler : Set Foo = 2 on Bar
Handler -> Repository : Get Bar
@damianh
damianh / ChaosMiddleware.cs
Created July 30, 2015 20:06
ChaosMiddleware
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Owin;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
using MidFunc = System.Func<
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>>;
public static class ChaosMiddleware
namespace ClassLibrary2
{
using System;
using System.Reactive;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
using MidFunc = System.Func<
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>>;
public static class RebuildablePipeline
@damianh
damianh / ChaosMiddleware.cs
Created June 23, 2015 07:48
Middleware that trolls front end devs. Use in conjunction with LimitsMiddleware and FakeReverseProxyHost to emulate real-world scenarios. Mwhahahahah!
namespace Chaos
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Owin;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
using MidFunc = System.Func<
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>>;
namespace LibLog.Logging
{
using System;
using System.IO;
using System.Runtime.CompilerServices;
using YourRootNamespace.Logging;
public class Foo : IDisposable
{
private static ILog s_logger = LogProvider.For<Foo>();
DROP TABLE dbo.Events
DROP TABLE dbo.Streams
CREATE TABLE dbo.Streams(
StreamId CHAR(40) NOT NULL,
StreamIdOriginal NVARCHAR(1000) NOT NULL,
StreamIdInternal INT IDENTITY(1,1) NOT NULL,
IsDeleted BIT NOT NULL DEFAULT ((0)),
CONSTRAINT PK_Streams PRIMARY KEY CLUSTERED (StreamIdInternal)
);
using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using Microsoft.Owin;
using Nowin;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
internal class Program
{
@damianh
damianh / NancyAndNowin.cs
Last active March 8, 2016 06:41
Using Nancy with Nowin (without MS.Owin or IAppBuilder).
namespace NancyAndNowin
{
using System;
using System.Net;
using System.Threading.Tasks;
using Nancy.Owin;
using Nowin;
public class Program
{
@damianh
damianh / AutoFollowRedirectHttpMessageHandler.cs
Last active August 29, 2015 14:15
An HttpMessageHandler that automatically follows redirects
private class AutoFollowRedirectHttpMessageHandler : DelegatingHandler
{
public AutoFollowRedirectHttpMessageHandler(HttpMessageHandler inner) : base(inner)
{ }
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var response = await base.SendAsync(request, cancellationToken);
while(response.StatusCode == HttpStatusCode.Moved || response.StatusCode == HttpStatusCode.Found)