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 / Decider.py
Last active September 25, 2024 02:20
Decider Pattern in Python
# You need the following packages: dataclasses-json, esdbclient
import uuid
import json
from esdbclient import EventStoreDBClient, NewEvent, StreamState, RecordedEvent
from esdbclient.exceptions import NotFound
from typing import Callable, Generic, List, TypeVar
from dataclasses import dataclass
from dataclasses_json import dataclass_json
Amuse
No Wallet
Give wallet to player -> Got Wallet
Got Wallet
Put bonus coins in wallet -> Got Wallet
Put gained coins in wallet -> Got Wallet
Take coins out of wallet -> Got Wallet
Deposit coins in wallet -> Got Wallet
Withdraw coins from wallet -> Got Wallet
Exchange wallet -> Exchanged Wallet
@yreynhout
yreynhout / Example.csproj
Created October 3, 2018 14:20
Little HAL
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.1" />
@yreynhout
yreynhout / FunWithBaskets.cs
Created June 8, 2018 11:09
How can I use child entities?
public class Basket : EventSource
{
private int Id;
private List<Item> Items = new List<Item>();
public Basket()
{
On<ItemAddedToBasket>(e => {
var item = new Item(@event =>
### Keybase proof
I hereby claim:
* I am yreynhout on github.
* I am yvesreynhout (https://keybase.io/yvesreynhout) on keybase.
* I have a public key ASBOIjadZDfe7txFECcB6kg9Ar-IQirADJFzByx9TDZwcgo
To claim this, I am signing this object:
@yreynhout
yreynhout / EventStoreCollection.cs
Last active May 9, 2020 20:45
Recipe for an EventStoreFixture using Docker.DotNet
using Xunit;
namespace TheDukesOfDocker
{
[CollectionDefinition(nameof(EventStoreCollection))]
public class EventStoreCollection : ICollectionFixture<EventStoreFixture>
{
}
}
@yreynhout
yreynhout / Position.fs
Created September 21, 2016 19:35
Did you get that one?
// Value objects à la F#
type Position =
struct
val Value : int64
new (value) = { Value = value } then
if value < 0L then invalidArg "value" "The value must be greater than or equal to 0."
member this.Next =
if this.Value = Int64.MaxValue then
invalidOp (sprintf "There's no next value beyond %d" Int64.MaxValue)
new Position(this.Value + 1L)
open System
module PlayerAccount =
//PlayerWasInvited
//PlayerAcceptedInvitation
//PlayerRejectedInvitation
//PlayerInvitationWasCancelled
//
type ProfessionalOccupation = Employee | Independent | Labourer | Other
@yreynhout
yreynhout / FrojacMeetsSql.fsx
Created April 24, 2016 15:34
F# Projac meets Sql
#r "packages/Paramol/lib/net45/Paramol.dll"
open System
open System.Data
open System.Data.Common
open Paramol
open Paramol.SqlClient
type PortfolioCreated = { PortfolioId: Guid; Name:String; When: DateTimeOffset; }
type PortfolioRenamed = { PortfolioId: Guid; Name:String; When: DateTimeOffset; }
@yreynhout
yreynhout / KickIt.cs
Last active December 22, 2015 14:52
System.Runtime.Caching meets Projac.Connector
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Caching;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using KellermanSoftware.CompareNetObjects;
using Newtonsoft.Json.Linq;
using NUnit.Framework;