Skip to content

Instantly share code, notes, and snippets.

@PaulStovell
PaulStovell / Bootstrapper.cs
Created May 9, 2013 10:03
The Octopus Nancy error handling strategy
protected override void RequestStartup(ILifetimeScope requestContainer, IPipelines pipelines, NancyContext context)
{
pipelines.OnError.AddItemToEndOfPipeline((z, a) =>
{
log.Error("Unhandled error on request: " + context.Request.Url + " : " + a.Message, a);
return ErrorResponse.FromException(a);
});
base.RequestStartup(requestContainer, pipelines, context);
}
@dahlbyk
dahlbyk / gist:1102893
Created July 24, 2011 18:09
Rx Sliding Window
static IObservable<string> CheckForFraud(IObservable<string> logins)
{
return from g in logins.GroupByUntil(l => l, CheckForFraud)
from c in g.Count()
where c >= 3
select g.Key;
}
static IObservable<Unit> CheckForFraud(IGroupedObservable<string, string> g)
{