Skip to content

Instantly share code, notes, and snippets.

View yreynhout's full-sized avatar
👔
ceci n'est pas une cravate

Yves Reynhout yreynhout

👔
ceci n'est pas une cravate
View GitHub Profile
@yreynhout
yreynhout / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
//FromAsync variant that can be used with APM across M<arshaling boundaries (you make your own TArgX overloads, please)
static class MarshalTask
{
public static Task<TResult> FromAsync<TArg1, TArg2, TResult>(Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginFunc, Func<IAsyncResult, TResult> endFunc, TArg1 arg1, TArg2 arg2)
{
var cp = new Completer<TResult>(endFunc);
var tcs = new TaskCompletionSource<TResult>();
cp.TaskCompletionSource = tcs;
  1. General Background and Overview
Task flushingTask = null;
public override Task FlushAsync(CancellationToken cancellationToken)
{
Interlocked.CompareExchange(
ref flushingTask,
Task.Delay(200, cancellationToken).ContinueWith(
async (t) =>
{
await write.FlushAsync(cancellationToken);
[Test]
public void ConstructorSucceeeds()
{
var id = new ConcertId(Guid.NewGuid());
new ConstructorScenario(() => Concert.New(id))
.Then(ConcertEvents.Planned(id))
.Assert();
}
@yreynhout
yreynhout / gist:4716699
Last active December 12, 2015 04:48 — forked from JefClaes/gist:4716622
using System;
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Subjects;
namespace NaiveEventSourcing {
class Program {
static void Main(string[] args) {
var travelerRepository = new AlwaysNewTravelerRepository();
var travelerService = new TravelerService(travelerRepository);