Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View JefClaes's full-sized avatar

Jef Claes JefClaes

View GitHub Profile
@JefClaes
JefClaes / compare.sh
Last active August 18, 2020 13:33
Compare image versions between kubernetes contexts
CONTEXTS=("a" "b" "c")
FILES=()
for CTX in ${CONTEXTS[@]}; do
kubectl config use-context $CTX
FN="$CTX.txt"
kubectl get pods --all-namespaces -o jsonpath="{..image}" | tr -s '[[:space:]]' '\n' | sort | uniq > $FN
FILES+=("$FN")
done
@JefClaes
JefClaes / fast_projectionts.fsx
Last active July 30, 2017 12:14
Fast projections
open System
open System.Collections.Generic
let consoleColor (fc : ConsoleColor) =
let current = Console.ForegroundColor
Console.ForegroundColor <- fc
{ new IDisposable with
member x.Dispose() = Console.ForegroundColor <- current }
let cprintf color str = Printf.kprintf (fun s -> use c = consoleColor color in printf "%s" s) str
@JefClaes
JefClaes / dddeu.md
Created December 2, 2016 22:34
DDDEU

The Breakers

When we design a model, we unwittingly imbue it with our own naïve view of the world. Once it makes its way to the unforgiving real world, we learn that not everyone shares that view. Then your infant model will actively be put to the test. Breakers will scan the model surface for cracks, trying to poke holes in its core properties, finding a way to abuse the assumptions of its creator.

In this series of tales, I'll take you on a journey, visiting various (broken) models at work in the casino world (and in yours), uncovering their weaknesses and possible remedies.

Each time we find ourselves on unknown territory - your core domain, we put ourselves at risk. How do you foster an environment, where a healthy dose of paranoia and misanthropy, ensures that you build a strong enough defense mechanism, keeping those that are up to no good, at bay?

@JefClaes
JefClaes / gist:6dd5ae9401226e112f70
Last active August 29, 2015 14:19
Detecting unused code I
1>C:\Paket\src\Paket.Core\Utils.fs(88,9): warning FS1182: The value 'fi' is unused
1>C:\Paket\src\Paket.Core\Utils.fs(361,46): warning FS1182: The value 'econt' is unused
1>C:\Paket\src\Paket.Core\Utils.fs(361,52): warning FS1182: The value 'ccont' is unused
1>C:\Paket\src\Paket.Core\PackageSources.fs(97,25): warning FS1182: The value 'uri' is unused
1>C:\Paket\src\Paket.Core\RemoteDownload.fs(147,18): warning FS1182: The value 'downloaded' is unused
1>C:\Paket\src\Paket.Core\RemoteUpload.fs(71,16): warning FS1182: The value 'whyIsThisNeeded' is unused
1>C:\Paket\src\Paket.Core\RemoteUpload.fs(85,17): warning FS1182: The value 'progressSubscription' is unused
...
@JefClaes
JefClaes / gist:2ec6d6168353f099102f
Created March 15, 2015 13:33
Scaling promotion codes I
public bool TryRedeem(UserId userId)
{
if (HasAlreadyBeenRedeemedByUser(userId)) return false;
if (NoLongerActive()) return false;
if (Depleted()) return false;
Apply(new PromotionCodeRedeemed(userId.Value));
return true;
}
@JefClaes
JefClaes / gist:3bc0f3a52b8389536846
Last active August 29, 2015 14:15
Playthrough Bonus III
printfn "%A" ( playUntilCleared ( Bonus.Create 10M 30M ) { Payout = 98M; Stake = 0.2M } )
// {Amount = 10M;
// Balance = 4.000M;
// Bets = 300.0M;
// Playthrough = 30M;}
@JefClaes
JefClaes / gist:24f42ef7c715b579711a
Last active August 29, 2015 14:15
Playthrough Bonus II
let rec playUntilCleared ( bonus : Bonus ) settings =
match bonus.Cleared with
| true -> bonus
| false ->
(
let bet = settings.Stake
let win = settings.Stake / 100M * settings.Payout
match bonus.AcceptsBet bet with
| false -> bonus
@JefClaes
JefClaes / gist:fb1a37ae1ca7b3d71bb5
Last active August 29, 2015 14:15
Playthrough Bonus I
type Bonus = { Amount : decimal; Balance : decimal; Bets : decimal; Playthrough: decimal; }
with
static member Create amount playthrough =
{ Amount = amount; Balance = amount; Bets = 0M; Playthrough = playthrough }
member x.Win amount =
{ x with Balance = x.Balance + amount }
member x.AcceptsBet amount =
x.Balance - amount >= 0M
member x.Cleared =
( x.Playthrough * x.Amount ) - x.Bets <= 0M
@JefClaes
JefClaes / gist:315fa7a3b66f10e73089
Created January 18, 2015 16:20
Averages are not good enough (4)
let standardDeviation input =
let avg = input |> Seq.average
let x = input |> Seq.map(fun x -> System.Math.Pow(float x - avg, float 2)) |> Seq.sum
let y = input |> Seq.length |> float
let variance = x / y
System.Math.Sqrt variance
// Average = 45.625; Standard Deviation = 20.87425148
@JefClaes
JefClaes / gist:1229fd20a7f271480b19
Created January 18, 2015 16:19
Averages are not good enough (3)
let frequencyDistribution input =
input |>
Seq.groupBy (fun x ->
match x with
| x when x < 30.0 -> [ 0, 30 ]
| x when x < 70.0 -> [ 30, 70 ]
| x when x < 90.0 -> [ 70, 90 ]
| _ -> [ 90, System.Int32.MaxValue ] ) |>
Seq.map (fun (x, y) -> x, y |> Seq.length)