Skip to content

Instantly share code, notes, and snippets.

View AlexZeitler's full-sized avatar
👷‍♂️
Building stuff

Alexander Zeitler AlexZeitler

👷‍♂️
Building stuff
View GitHub Profile
@AlexZeitler
AlexZeitler / App.fs
Created June 12, 2020 12:43 — forked from aspnetde/App.fs
Feliz – MVU with React Function Components
module App
open Elmish
type State =
{ CurrentUser: string option }
type Msg =
| SignIn of string
| SignOut
@AlexZeitler
AlexZeitler / event-sourced-user.fsx
Created December 29, 2020 15:34 — forked from akhansari/event-sourced-user.fsx
F# : Event Sourcing in a nutshell
// ========= Event Sourcing in a nutshell
(*
FriendlyName: string
Aggregate friendly name.
Initial: 'State
Initial (empty) state we will start with.
Decide: 'Command -> 'State -> 'Event list
@AlexZeitler
AlexZeitler / Readme.md
Created January 4, 2021 15:35 — forked from skorfmann/Readme.md
Stub Lambda Functions in your CDK Stack

Stubbing Lambda Functions in your CDK Stack

Given you have a stack with one or more Lambda functions (e.g. as part of a Step Functions state machine), it can be pretty useful to stub long running parts with a known response.

This makes use of cdk Aspects, which allows modifying all or a filtered subsset of resources for a given scope (Stack, Construct).

In addition this leverages raw overrides to remove the original code of the Lambda function.

Please note, that the stub has to be in Python or NodeJS, since inlining code is only supported by those runtimes.

namespace Infrastructure
open System.Text.Encodings.Web
open System.Text.Json
open System.Text.Json.Serialization
[<RequireQualifiedAccess>]
module JsonSerializer =
let private setupOptions (options: JsonSerializerOptions) =
options.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
@AlexZeitler
AlexZeitler / SCU.fs
Created May 15, 2021 23:25 — forked from JordanMarr/SCU.fs
JSON.NET SCU Converter
// Single case union
[<Struct>] type MHPI = MHPI of double
// An entity that contains SCU
type Entity = {
Foo: string
Bar: MHPI
}
// JSON.NET Converter
@AlexZeitler
AlexZeitler / idiomaticjsonserialiser.fs
Created May 15, 2021 23:25 — forked from isaacabraham/idiomaticjsonserialiser.fs
This JSON.Net converter handles F# discriminated unions with more "idiomatic" JSON than what is generated by the current version of JSON .NET. Option types and single case DUs are transparently handled, and tuple-style properties are used rather than array notation.
namespace Newtonsoft.Json.Converters
open Microsoft.FSharp.Reflection
open Newtonsoft.Json
open System
type IdiomaticDuConverter() =
inherit JsonConverter()
[<Literal>]
@AlexZeitler
AlexZeitler / HttpClient.FSharp.fs
Created May 30, 2021 19:57 — forked from jhewlett/HttpClient.FSharp.fs
Functional wrapper around System.Net.Http.HttpClient. Inspired in part by Http.fs (https://github.com/haf/Http.fs) and FSharp.Data (https://fsharp.github.io/FSharp.Data/library/Http.html)
namespace HttpClient.FSharp
open System
open System.Net.Http
type HttpMethod =
| Post
| Put
| Delete
| Get
@AlexZeitler
AlexZeitler / CloudAgent-1.fs
Created June 13, 2021 20:38 — forked from isaacabraham/CloudAgent-1.fs
Local Mailbox Processor
// Our simple domain model
type Priority =
| Low
| Normal
| High
type Message = {
Text : string
Priority : Priority
}
@AlexZeitler
AlexZeitler / set-keycloak-client-secret.groovy
Created July 11, 2021 19:02 — forked from goeh/set-keycloak-client-secret.groovy
Inject client secrets from a local file into a Keycloak Realm Export (JSON) file
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
def jsonSlurper = new JsonSlurper()
def secrets = jsonSlurper.parse(new File(args[1] ?: "secrets.json")).clients.inject([:]) { map, c -> map[c.client] = c.secret; map }
def realm = jsonSlurper.parse(new File(args[0]))
for(client in realm.clients) {
if(secrets[client.clientId]) {