Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am sgoguen on github.
  • I am sgoguen (https://keybase.io/sgoguen) on keybase.
  • I have a public key ASB7lHbtpeTVKV_POAjX-YXpSjuk3i7VMIMeAKJ0cFCrOgo

To claim this, I am signing this object:

@sgoguen
sgoguen / PathReflection.fs
Created February 5, 2018 15:32
FSharp - Functions as Paths
open Microsoft.FSharp.Reflection
let rec listTypes(t:Type) =
[
if FSharpType.IsFunction(t) then
let(a,b) = FSharpType.GetFunctionElements(t)
yield a
if FSharpType.IsFunction(b) then
yield! listTypes(b)
else
@sgoguen
sgoguen / treemap.fs
Created February 5, 2018 15:34
F# Tree Maps
module TreeMaps
type Map<'k,'v> =
| Map of ('v -> 'k -> 'v)
[<Struct>]
type ShallowMap<'k,'v,'c> =
| ShallowMap of value:'v * lookup:('k -> 'v -> 'c)
@sgoguen
sgoguen / LoadServer.fsx
Created January 24, 2019 19:01
How to cancel an agent
// 1. Create a project and add Steego.FsPad as a Nuget dependency
// 2. Build your project and set this folder to your output
#I "bin/Debug/net461/"
#r "FSharp.Core.dll"
#r "Suave.dll"
#r "Steego.FsPad.dll"
module Watcher =
@sgoguen
sgoguen / wheel.fsx
Created February 13, 2019 04:04
Wheel of Fortune Solver
// First, clone the word list project here: https://github.com/dwyl/english-words.git
// Then save this file in the same folder and run!
open System.IO
// Ok... Here's how it works...
// First, we load all the words from the Moby text fil
let allTheWords = File.ReadAllLines("words.txt")
let items = [
"1 1/2 cup onions, diced"
"1/4 tsp coriander"
"1 medium carrot"
"1.5 oz olive oil"
"two lemons"
"mint"
]
let tokenize(s) = [ for t in Regex.Split(s, "\\b") do
@sgoguen
sgoguen / movie-list.txt
Created August 16, 2019 17:50
Movies for Robert
Full Metal Jacket
@sgoguen
sgoguen / movie-list.txt
Created August 16, 2019 17:50
Movies for Robert
Full Metal Jacket
@sgoguen
sgoguen / anagram.fs
Last active December 12, 2019 05:15 — forked from pragdave/anagram.fs
/// <summary>
/// Builds a map where the keys are word signatures and
/// each value is the list of words that share that signature.
/// The signature of a word is simply a string containing
/// the word's letters, sorted. Thus "dog" and "god" will
/// both have the signature "dgo", and the entry in the map
/// with that key will be those two words.
///
/// This let's us quickly find anagrams
/// </summary>
@sgoguen
sgoguen / jeff-atwoods-can-accept-answer.ts
Created February 26, 2020 18:36
Typescript Translation of Jeff's Snippet
enum TrustLevel {
None,
AcceptAllSolutionsTrustLevel
}
class SomeComponent {
private authenticated = false;
private isStaff = false;
private currentUser = {
id: 123,