Skip to content

Instantly share code, notes, and snippets.

View baronfel's full-sized avatar

Chet Husk baronfel

View GitHub Profile
@baronfel
baronfel / Dockerfile
Created May 16, 2019 23:27
Postgres with plv8 dockerfile
# invoke with `docker build -t TAGNAME --build-arg POSTGRES_VERSION=11 --build-arg PLV8_VERSION=2.3.9 .`
# currently requires a minimum of plv8 2.3.9 to fix build issues
ARG POSTGRES_VERSION
FROM postgres:${POSTGRES_VERSION} as build
ARG PLV8_VERSION
# These deps come from the build instructions at https://plv8.github.io/#building-for-macos-linux
RUN apt-get update \
@baronfel
baronfel / Domain.fs
Last active May 24, 2019 16:03
sharplab example fo F# DUs in C#
type PhoneOS = Android | Apple
type ThingIOwn =
| Car of make: string * model: string * year: string
| Phone of OS: PhoneOS * model: string
let thing = Phone(Android, "Pixel 2XL")
@baronfel
baronfel / dotnet-tools.json
Created July 23, 2019 20:58
worked example of .net core 3 preview 7 local tool manifest
{
"isRoot" :true,
"tools": {
"paket": {
"version": "5.215.0",
"commands": [
"paket"
]
}
}
@baronfel
baronfel / Dockerfile
Created August 8, 2019 19:06
Dockerfile for a profiling container
FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim as sdk_base
RUN curl https://download.visualstudio.microsoft.com/download/pr/c624c5d6-0e9c-4dd9-9506-6b197ef44dc8/ad61b332f3abcc7dec3a49434e4766e1/dotnet-sdk-3.0.100-preview7-012821-linux-x64.tar.gz --output dotnet-sdk-3.0.100-preview7-012821-linux-x64.tar.gz \
&& tar zxf dotnet-sdk-3.0.100-preview7-012821-linux-x64.tar.gz -C /usr/share/dotnet
ENV DOTNET_ROOT=$HOME/dotnet
ENV PATH=$PATH:$HOME/dotnet
# adds in the debugging tools using the newly-installed sdk
FROM sdk_base as debug_tools
@baronfel
baronfel / Auth.fs
Last active March 11, 2020 18:18
Giraffe Auth Handler extensions
module Auth
open Microsoft.AspNetCore.Authentication
open Microsoft.Extensions.Logging
open FSharp.Control.Tasks.V2.ContextInsensitive
open Giraffe
/// Authenticates the request against the given `schemes`.
/// If the request is authenticated, the authenticated identities are added to the current HTTP Context's User.
let authenticateMany (schemes: string seq): HttpHandler =
@baronfel
baronfel / decon.fsx
Last active May 18, 2020 18:56
deconstruct tinkering
type Wrapper() =
let mutable _one = 0
let mutable _two = 0
member _.one
with get () = _one
and set (newValue: int) =
_one <- newValue
member _.two
@baronfel
baronfel / fscheck-for-shapes.fsx
Created July 6, 2020 23:07
quick thing I made to demo generating arbitrary DU shapes for someone on the FSSF slack today
// You'll need to run this in a .net core sdk 3.1.300+ `dotnet fsi` instance, with the `--langversion:preview` flag set.
#r "nuget: FsCheck"
open FsCheck
(* type definitions *)
type Point = { x: int; y: int}
type Shape =
| Square of Point * Point * Point * Point
| Triangle of Point * Point * Point
| Circle of Point * int
@baronfel
baronfel / Directory.Build.targets
Last active April 27, 2021 14:39
Build target for seamless signature file includes
<Project>
<PropertyGroup>
<!-- Provide an escape hatch/opt-in to this feature -->
<AutoIncludeExistingSignatures Condition="$(AutoIncludeExistingSignatures) == '' " >false</AutoIncludeExistingSignatures>
</PropertyGroup>
<Target Name="CollectFSharpSourcesAndSignatures" BeforeTargets="CoreCompile" Condition="$(AutoIncludeExistingSignatures)">
<ItemGroup>
<!-- Cache the current set of compile options -->
<_Sources Include="@(Compile)" />
<!-- clear out the Compile order because we need to insert the sigs before their associated source files -->
type AsyncOptionBuilder() =
member __.Return (value: 'T) : Async<Option<'T>> =
async { return Some value }
member __.ReturnFrom
(asyncResult: Async<Option<_>>)
: Async<Option<_>> =
asyncResult
@baronfel
baronfel / settings.json
Created August 4, 2021 22:10
ionide tokens highlighting
{
"editor.semanticTokenColorCustomizations": {
// note: the keys of this dictionary are your installed themes. you'll have to set these for each theme you want to override.
"[Default Dark+]": {
"enabled": true,
"rules": {
"member.mutable": {
"foreground": "#FF0000",
"fontStyle": "underline",
},