Skip to content

Instantly share code, notes, and snippets.

View baronfel's full-sized avatar

Chet Husk baronfel

View GitHub Profile
@baronfel
baronfel / Library.fs
Last active December 22, 2021 16:32
MSBuild targets for easier native resource handling
namespace blah_lib
module Say =
let hello name () =
printfn "Hello %s" name
@baronfel
baronfel / recipe.txt
Created September 18, 2021 21:31
Sesame Pork Tenderloin
2 (3/4 lb) pork tenderloins
1/2 c soy sauce
1/3 c honey
1/4 c dry sherry
1/4 tsp garlic powder
1/4 tsp ground ginger
2 Tbsp dry mustard (sauce)
1/3 c sesame seeds, toasted
@baronfel
baronfel / fsc_functions.sh
Created August 12, 2021 13:44
sample shell script for compiling an fsx file
#! /usr/bin/env zsh
# call like `devCompile <path to fsx> <other compiler flags>`
# note that I've got my locally-built compiler here for fsc.dll, for normal use you'd want to use the one from
# <SDK_ROOT>/FSharp/fsc.dll
function devCompile () {
file=$(realpath $1)
shift
base=$(basename $file .fsx)
/usr/local/share/dotnet/dotnet \
@baronfel
baronfel / Directory.Build.targets
Created August 6, 2021 16:13
Targets to discover and set README and PackageIcon based on Item metadata
<!--
If no PackageReadmeFile is present and there's a _PackageFiles with the metadata node `PackageReadmeFile="true"` set,
use its resolved PackagePath as the `PackageReadmeFile`
eg. <None Include="../../README.md" Pack="true" PackagePath="\" PackageReadmeFile="true" />
-->
<Target Name="_SetPackageReadmeFileByConvention"
DependsOnTargets="_GetPackageFiles"
BeforeTargets="GenerateNuspec"
Condition="'$(PackageReadmeFile)' == ''">
@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",
},
type AsyncOptionBuilder() =
member __.Return (value: 'T) : Async<Option<'T>> =
async { return Some value }
member __.ReturnFrom
(asyncResult: Async<Option<_>>)
: Async<Option<_>> =
asyncResult
@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 -->
@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 / 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 / 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 =