Skip to content

Instantly share code, notes, and snippets.

Ruben Bartelink bartelink

View GitHub Profile
View keybase id
### Keybase proof
I hereby claim:
* I am bartelink on github.
* I am bartelink ( on keybase.
* I have a public key ASBsuiXja6_19Fq_ZG-VmuGchBYVYRFszqzRoRoy4vDl4go
To claim this, I am signing this object:
bartelink / TickSpecXunit2FeatureAttributeAndDiscoverer.fs
Created Nov 17, 2016
Stash of a spike to grab TickSpec Scenarios during the xUnit 2 discovery phase in order to surface the Scenarios as individual Tests in the VS Test Runner list. AFAICT this will never work as it will require all of TickSpec's object model and more (the compiled code) to be serializable
View TickSpecXunit2FeatureAttributeAndDiscoverer.fs
namespace TickSpec
open System
open System.Reflection
open System.Threading.Tasks
open Xunit
open Xunit.Abstractions
open Xunit.Sdk
module Impl =
bartelink /
Last active Aug 23, 2016 — forked from eulerfx/
The relationship between state machines and event sourcing

A state machine is defined as follows:

  • Input - a set of inputs
  • Output - a set of outputs
  • State - a set of states
  • S0 ∈ S - an initial state
  • T : Input * State -> Output * State - a transition function

If you model your services (aggregates, projections, process managers, sagas, whatever) as state machines, one issue to address is management of State. There must be a mechanism to provide State to the state machine, and to persist the resulting State for subsequent retrieval. One way to address this is by storing State in a key-value store. Another way is to use a SQL database. Yet another way is event sourcing. The benefit of event sourcing is that you never need to store State itself. Instead, you rely on the Output of a service to reconstitute state. In order to do that, the state machine transition function needs to be factored into two functions as follows:

bartelink / NesGateway.fs
Last active May 7, 2017
Dump of ProtoBuf serialization spike for
View NesGateway.fs
module FunDomain.Persistence.NEventStore.NesGateway
open FunDomain.Persistence.Serialization
open NEventStore
open NEventStore.Persistence
open NEventStore.Persistence.Sql.SqlDialects
open Microsoft.FSharp.Reflection
open System
bartelink / AutoControllerData.fs
Created Mar 21, 2014
Port of C# equivalent in SO answer by @nikosbaxevanis :-
View AutoControllerData.fs
module WebApi2Helpers
// Port of answer by @nikosbaxevanis :-
open System
open Ploeh.AutoFixture
open Ploeh.AutoFixture.Kernel
open Ploeh.AutoFixture.Xunit
open Ploeh.AutoFixture.AutoFoq
open System.Web.Http.Hosting
bartelink / WarmupCustomization.fs
Created Feb 5, 2014
F# wrapper for having AutoFixture perform post-processing on AutoFixture Specimens of a given type
View WarmupCustomization.fs
type TypeThatIsARequestSpecification<'T>() =
interface IRequestSpecification with
member this.IsSatisfiedBy request =
match request with
| :? System.Type as requestType -> typeof<'T>.IsAssignableFrom( requestType)
| _ -> false
type PrepareSpecimenCommand<'T>( action) =
interface ISpecimenCommand with
member this.Execute( specimen, context) =
let instance = specimen :?> 'T
View gist:8720521
public static TRes Match<T,TRes>(this FSharpOption<T> opt, Func<T,TRes> some, Func<TRes> none)
if (FSharpOption<T>.get_IsSome(opt))
return some.Invoke(opt.Value);
return none.Invoke();
bartelink / Consolidate-VSFindInFilesSpec.ps1
Last active Jan 4, 2016
Ugly hacky script to generate a VS Find in Files uber-Filter
View Consolidate-VSFindInFilesSpec.ps1
# TODO dig out of registry instead of cutting and pasting from VS!
# strip *.
$all = $x.Split( ";") | % { $_.Replace("*.","") }
#xml fins too much junk in obj dirs
bartelink / DiagnosticFeatures.fs
Last active Dec 24, 2015
My TickSpec.xunit boilerplate (just add .feature files as EmbeddedResources and group them into XXXFeatures.fs as in the example DiagnosticFeatures.fs file)
View DiagnosticFeatures.fs
open TickSpec
open Features
module DiagnosticFeatures =
let ConnectivityFeature () =
generateScenariosFromEmbeddedFeatureFile "Connectivity"
bartelink / gist:5671464
Created May 29, 2013
Ninject Scoping Learnings and Tests to accompany
View gist:5671464
public static class NinjectScopingLearning
public static class InParentScope
public static void WorksIffParentScopeAllWayUp()
var kernel = new StandardKernel();
You can’t perform that action at this time.