Skip to content

Instantly share code, notes, and snippets.

open System
type Machine =
{ program: string
data: byte[]
ip: int
dp: int
output: string
}
@thinkbeforecoding
thinkbeforecoding / gitlab.fsx
Created October 19, 2022 21:52
Yzl for gitlab-ci
#r "nuget: Yzl"
open Yzl.Core
let stages = Yzl.seq "stages" << Yzl.liftMany
let stage = Yzl.str "stage"
let job (name: string) = Yzl.map name
let tags = Yzl.seq "tags" << Yzl.liftMany
let image = Yzl.str "image"
let script = Yzl.seq "script" << Yzl.liftMany
let variables vs = "variables" .= [for k,v in vs -> k .= v]
@thinkbeforecoding
thinkbeforecoding / deciders-dddeu-2022.fsx
Created June 29, 2022 08:21
Deciders implementation
/// +--------------------------------------+
/// | |
/// | Decider |
/// | |
/// | Jérémie Chassaing |
/// | @thinkb4coding |
/// +--------------------------------------+
// A decider is a structure define by 7 parameters:
@thinkbeforecoding
thinkbeforecoding / Bench.txt
Created February 17, 2022 17:53
StackStack
| Method | Mean | Error | StdDev | Ratio | RatioSD |
|-------------- |---------:|--------:|--------:|------:|--------:|
| UseSpan | 241.7 ns | 2.98 ns | 2.64 ns | 1.00 | 0.00 |
| UseCollection | 403.4 ns | 5.58 ns | 5.22 ns | 1.67 | 0.03 |
open System
type LicencePlate = LicencePlate of string
module LicencePlate =
open System.Text.RegularExpressions
let plateEx = Regex @"^[0-9]{3}-[0-9]{3}$"
let parse input =
@thinkbeforecoding
thinkbeforecoding / ApplicativeProfunctor.fsx
Created December 23, 2020 15:35
This is an example of Applicative on a Profunctor.
open System
// this is our basis to define values over time.
// It will be the basis for our data.
// we define a Period with a start and en Time
// start is included, end is excluded (closed on the left, open on the right)
// this way, of consecutive periods px and py we known that px.End = py.Start
type Period = { Start: DateTime; End: DateTime }
@thinkbeforecoding
thinkbeforecoding / EventSourcing.fsx
Created February 28, 2020 17:32
DDDEU Functional Event Sourcing
//------------------------------------------
let title = "Functional Event Sourcing"
let speaker = "Jérémie Chassaing"
let company = "d-edge / Availpro Hospitality Tech"
let twitter = @"thinkb4coding"
let blog = "https://thinkbeforecoding.com"
//------------------------------------------
System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
#load ".paket/load/netstandard2.0/main.group.fsx"
@thinkbeforecoding
thinkbeforecoding / start.ps1
Created October 10, 2016 10:29
Github desktop for PS
. $env:UserProfile\AppData\Local\GitHub\shell.ps1
Function Start-SSHAgent{
param(
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
[string]$socketfile="/tmp/.ssh-socket", # Used as input to ssh-agent, which expects POSIX format paths
[Parameter(Mandatory=$false)]
[string]$pidFile="$env:TEMP\.ssh-agent-pid" # Used as input to Out-File which expects Windows format paths
)
@thinkbeforecoding
thinkbeforecoding / LogaryMetrics.fs
Created September 7, 2016 13:26
Sample to report timing metrics
open Hopac
open Hopac.Infixes
open NodaTime
open Logary
open Logary.Metrics.Reservoirs
open Logary.Configuration
open Logary.Targets
open Metric
module PointName =
@thinkbeforecoding
thinkbeforecoding / gist:11fd14096ccd4c28a4a0
Created March 11, 2016 16:28
Setup GitHub for windows in Powershell profile
. $env:UserProfile\AppData\Local\GitHub\shell.ps1
$r = ssh-agent -s
[regex]::Matches($r,"SSH_AUTH_SOCK=([^;]+);") | % { $env:SSH_AUTH_SOCK = $_.Groups[1] }
[regex]::Matches($r,"SSH_AGENT_PID=(\d+);") | % { $env:SSH_AGENT_PID = $_.Groups[1] }
ssh-add $env:UserProfile\.ssh\github_rsa