Skip to content

Instantly share code, notes, and snippets.

View ohlawdie's full-sized avatar
😟

Ohlawdie ohlawdie

😟
  • Michigan
View GitHub Profile
@ohlawdie
ohlawdie / GenericMemoization.fs
Created February 18, 2020 23:50
#FS #memoization
let memoize f =
let cache = System.Collections.Generic.Dictionary<_,_>(HashIdentity.Structural)
fun x ->
let ok, res = cache.TryGetValue(x)
if ok then res
else let res = f x
cache.[x] <- res
res
let inline (>>) f g x = g(f x)
Which reads as: given two functions, f and g, and a value, x, compute the result of f of x and pass that result to g. The interesting thing here is that you can curry the (>>) function and only pass in parameters f and g, the result is a function which takes a single parameter and produces the result g ( f ( x ) ).
@ohlawdie
ohlawdie / FSExtensionMethod.fs
Created February 19, 2020 17:29
#extension #BCL #fs
type System.String with
member this.StartsWithA = this.StartsWith "A"
@ohlawdie
ohlawdie / ValFS.fs
Created February 19, 2020 22:39
valfs
[<Struct>]
type Foo =
val mutable bar: string
member self.ChangeBar bar = self.bar <- bar
new (bar) = {bar = bar}
let rangeCounter start stop =
let mutable current = start
fun () ->
let this = current
current <-
if current = stop then
start
else
current + 1
this
/// Structural inference for HTML tables
module FSharp.Data.Runtime.HtmlInference
open System
open System.Globalization
open FSharp.Data.Runtime
open FSharp.Data.Runtime.StructuralInference
open FSharp.Data.Runtime.StructuralTypes
type Parameters = {
https://stackexchange.com/search?q
https://www.youtube.com/results?search_query=%s
https://github.com/search?q=%s
https://stackexchange.com/search?q
https://www.youtube.com/results?search_query=%s
https://github.com/search?q=%s
@ohlawdie
ohlawdie / AllInOne.ps1
Created July 5, 2020 20:32 — forked from NateLehman/AllInOne.ps1
F# PowerShell Module Scaffold
dotnet new sln -o DotnetCoreProj
cd DotnetCoreProj
dotnet new classlib -lang 'F#' -o src/MyPSModule
dotnet sln add src/MyPSModule/MyPSModule.fsproj
cd src/MyPSModule
dotnet add package PowerShellStandard.Library
@'
namespace MyPSModule
open System.Management.Automation
@ohlawdie
ohlawdie / Deploy.md
Created July 9, 2020 23:05 — forked from alfonsogarciacaro/Deploy.md
Deploying an F# ASP.NET Core app (Giraffe) to Azure

Deploying an F# ASP.NET Core app to Azure

Last week I spent a lot of time trying to deploy an F# ASP.NET Core app (a Giraffe app, specifically) to Azure because the information to complete all the steps was scattered in several places. So I'm writing this hopefully it will save the pain to others :)

Preparation

The following steps are mostly taken from this guide and it's only necessary to do them once:

  1. Create an account in Azure (or use an existing one)
  2. Create a resource group (or use an existing one)