Skip to content

Instantly share code, notes, and snippets.

@matthid
matthid / ComparablePrimitives.cs
Created February 21, 2022 23:54
Simple wrappers to make Lists and Dictionaries comparable.
using System.Collections;
using System.Collections.Immutable;
using System.Runtime.CompilerServices;
namespace UnorderedCollectionComparison;
public interface IFullComparer<in T> : IEqualityComparer<T>, IComparer<T>
{
}
@matthid
matthid / build.fsx
Created March 5, 2020 20:23
FAKE Standard Input
#r "paket:
nuget Fake.Core.Target
nuget Fake.Core.Process
nuget Fake.IO.FileSystem prerelease
//"
#load "./.fake/test.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#r "Facades/netstandard" // https://github.com/ionide/ionide-vscode-fsharp/issues/839#issuecomment-396296095
// Runs in https://fable.io/repl/#
open System
type Intermediate = { Digit : int; Flow: int; LastWasZero : bool }
let t = [ 1 .. 9 ] |> List.map (fun i -> { Digit = i; Flow = 0; LastWasZero = false })
let nextRound (intermediate) =
let sum = intermediate.Digit * 2 + intermediate.Flow
let digit = sum % 10
let nextFlow = sum / 10
@matthid
matthid / ReactErrorBoundary.fs
Created September 20, 2018 17:41
React error boundary for rendering issues with fable, designed to be used with elmish architecture
module ReactErrorBoundary
open Fable.Core
open Fable.Import
open Fable.Helpers.React
type [<AllowNullLiteral>] InfoComponentObject =
abstract componentStack: string with get
[<Pojo>]
@matthid
matthid / StreamReaderNUnitSpiderMonkeyFailure.cs
Created April 12, 2013 15:14
This gist shows a strange behaviour when using spidermonkey from within an NUnit Testcase.
// ----------------------------------------------------------------------------
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
// ----------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Threading;
using NUnit.Framework;
namespace NUnitFail