Skip to content

Instantly share code, notes, and snippets.

@tnishimura
tnishimura / generate-jwt-with-fsharp.fsx
Last active September 5, 2023 10:00
This is an F# interactive script to generate a JWT. You can use it as a reference for when you are generating JWT on your server for a client, for example. It is hard coded for symmetric signing (HS256), but can be modified for asymmetric signing RS256, see notes in code.
(*
This is an F# interactive script to generate a JWT. You can use it as a reference for when you are generating JWT on
your server for a client, for example. It is hard coded for symmetric signing (HS256), but can be modified for
asymmetric signing RS256, see notes.
*)
#r "nuget: System.IdentityModel.Tokens.Jwt"
open System
open System.Text // for Encoding
open System.IdentityModel.Tokens.Jwt // For JwtSecurityToken (Install it from Nuget)
open System.Security.Claims // For Claim, ClaimTypes
@AlexeyRaga
AlexeyRaga / ChatSession.md
Last active February 26, 2023 03:17
ChatGPT: F# Aggregate

Show me an implementation of an Organisation Aggregate in F# that can handle "Register", "Suspend" and "ChangeAddress" commands


Here is a simple implementation of an organization aggregate in F# that can handle the "Register", "Suspend", and "ChangeAddress" commands:

type Address = {
@Savelenko
Savelenko / Facility.fs
Created May 26, 2022 09:35
Error builder
module Facility
/// A facility which admits visitors (or does it?).
type Facility =
| BlackMesa
| DeathStar
| TeaHouse
(*
@ninjarobot
ninjarobot / RoadToFSharp.md
Last active June 2, 2020 09:21
How I ended up as an F# developer.

My Road to F#

I came from the OOP world, most of my professional work was in Java or C#. The languages were similar, and I could use them interchangably as I built software in each of them for several years. With enough experience in both, I was comfortable with either ecosystem and could generally be productive in either. Sometimes the job required one or the other. Sometimes the target OS constrained my choice to Java, which frustrated me a bit, because the languages were so similar, why would the runtime try to restrict a choice? I enjoyed writing server applications on Unix in college, and Linux afterwards, because the machines were so easy to configure compared to Windows machines that took a few hours to install and configure to get my software running. On Linux, I could type a handful of commands into a newly installed system and be up and running.

Sometime around 2005, Java had stagnated while C# was flourishing. They both released generics, but then C# came out with new features like