Skip to content

Instantly share code, notes, and snippets.

View ScottHutchinson's full-sized avatar

Scott Hutchinson ScottHutchinson

  • ICI Services
  • Westlake Village, California
View GitHub Profile
// This is am example of an immediate write / random access cursor for Excel with basic formatting options.
// Implementation is based on a concrete, non generic writer monad with no payload ("do!"" only) (only state).
// Instead of directl writing to excel, an alternatives would be a random acces to a
// copy-on-write list (or even a mutable array) and then bulk-write the result to excel in one shot.
// When only forward access would have been required, a simple seq expression with yields would have been enough.
// Anyway, it is a demonstration on how to "hide" pseudo-mutable state that is passed through a computation.
//
// I personally use it for generating reports based on various data sources.
@pirrmann
pirrmann / Differ.fs
Created March 21, 2018 14:27
Differ
type DifferenceType<'TKey, 'T> =
| Added of 'TKey * 'T
| Removed of 'TKey * 'T
| Modified of 'TKey * 'T * 'T * seq<string * (string * string)> with
member this.Key =
match this with
| Added (key, _)
| Removed (key, _)
| Modified (key, _, _, _) -> key
@movitto
movitto / parallel_tests.sh
Created January 28, 2017 01:49
Parallel Catch - Invokes philsquared/Catch tests in a parallel fashion (https://github.com/philsquared/Catch)
# runs tests in parallel
TEST_CMD="./build/test/run_unit_tests"
JOBS="8"
TAGS="$($TEST_CMD -l | grep Scenario -A 1 | grep -v Scenario | sort -u)"
IFS=' ' read -a SPLIT <<< $TAGS
NUM_TAGS=${#SPLIT[@]}
# so as to round up
PER_JOB=`expr $NUM_TAGS + $JOBS - 1`
@robertpi
robertpi / gist:2964793
Created June 21, 2012 09:18
F# record implementing an interface
namespace MyNamespace
type IMyInterface =
abstract GetValue: unit -> string
type MyRecord =
{ MyField1: int
MyField2: string }
interface IMyInterface with
member x.GetValue() = x.MyField2