Skip to content

Instantly share code, notes, and snippets.

@cloudRoutine
cloudRoutine / fsharp_advent_2016_12_10.md
Created Dec 18, 2018 — forked from mrange/fsharp_advent_2016_12_10.md
F# Advent 2016 (English) - December 10 - Implementing a persistent hash map.
View fsharp_advent_2016_12_10.md
@cloudRoutine
cloudRoutine / optimizing_performance.md
Created Oct 12, 2016 — forked from mrange/optimizing_performance.md
Optimizing a simple problem in F# and C++
View optimizing_performance.md

Optimizing a simple problem

I was introduced to a simple optimization problem by one of my interns last week. He was about to participate in a friendly competition where they were asked to find a performant solution to the problem:

The problem

View json_transform.md
@cloudRoutine
cloudRoutine / logo_turtle.fsx
Created Aug 7, 2016
Logo Turtle Computation Expression
View logo_turtle.fsx
namespace CExprs
module LogoTurtle =
type Distance_Unit = STEPS
type Rotation_Unit = GRADATIONS
type Rotation_Direction = | LEFT | RIGHT
let STEP = STEPS
let GRADATION = GRADATIONS
@cloudRoutine
cloudRoutine / github-downloader.fsx
Created Aug 5, 2016
Download Github release files even from behind a proxy
View github-downloader.fsx
open System
open System.IO
open System.Web
open System.Net
open System.Collections.Generic
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
@cloudRoutine
cloudRoutine / user-profile.ps1
Last active Jun 30, 2017
Posh Profile for Portable Cmder with Vim Config Instructions
View user-profile.ps1
# NOTE - If there are weird character errors when trying to load this profile
# resave the file with the encoding `UTF-8 with BOM`
# ┌ ┐
# Setup Environment
# └ ┘
# change to codepage to display symbols properly
chcp 65001 | out-null
View countby performance.fsx
open System.Diagnostics
open System.Reflection
open Microsoft.FSharp.Core
open Microsoft.FSharp.Core.Operators
open Microsoft.FSharp.Core.LanguagePrimitives
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
open Microsoft.FSharp.Collections
open Microsoft.FSharp.Primitives.Basics
open System.Collections.Generic
@cloudRoutine
cloudRoutine / foldparser.fsx
Created Mar 9, 2016
Parser that folds over stream with a state record
View foldparser.fsx
#r "../../../packages/fparsec/lib/net40-client/fparseccs.dll"
#r "../../../packages/fparsec/lib/net40-client/fparsec.dll"
open System
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
open FParsec
open FParsec.Primitives
let (^) = (<|)
@cloudRoutine
cloudRoutine / getUnionFields.fsx
Created Mar 6, 2016
netcore compatible `GetUnionFields`
View getUnionFields.fsx
open System
open System.Reflection
type CLIArguments =
| Working_Directory of string
| Listener of host:string * port:int
| Data of byte []
| Port of int
| Log_Level of int
| Detach
@cloudRoutine
cloudRoutine / construct_toml_ap.fsx
Last active Nov 25, 2015
Active Pattern VS Match When
View construct_toml_ap.fsx
let construct_toml (toplevel:(string*Value)list,
tables:(string*(string*Value)list)[]) =
let addSection (table:Dictionary<string,Value>) (kvps:(string*Value) list) =
kvps |> List.iter (fun (k,v)-> table.Add( keyName k,v ))
let foldtoml (prev:string, nested:string list, acc:Dictionary<string,Value>,toml:Dictionary<string,Value>)
(cur:string, elems:(string*Value)list) =
try
(* add parsed elements to current table *)