Skip to content

Instantly share code, notes, and snippets.

(*
Towards verifying message-passing protocols.
Protocol typically involves two parties, let us call Client and Server,
a number of states and state transitions involving passing of messages.
Client has agency - non-deterministic process in process calculi.
Server is deterministic, but it should handle all possible clients.
Ideally, we would take a DSL for the protocol, and spit out F# code that
@jbtule
jbtule / build.fsx
Last active March 24, 2020 16:06
Crossplatform FSharp Makefile Bootstrapper
#!/bin/sh
#if run_with_bin_sh
# Doing this because arguments can't be used with /usr/bin/env on linux, just mac
exec fsharpi --define:mono_posix --exec $0 $*
#endif
(*
* Crossplatform FSharp Makefile Bootstrapper
* Apache licensed - Copyright 2014 Jay Tuley <jay+code@tuley.name>
* v 2.0 https://gist.github.com/jbtule/9243729
open System
open System.Globalization
open System.Json
open System.Collections.Generic
open ReadOnlyCollectionsExtensions
let (|JArray|JObject|JNumber|JBool|JString|JNull|) (o: JsonValue) =
match o with
| :? JsonArray as x ->
let values = (x :> JsonValue IList).AsReadOnlyList()
@shawnbot
shawnbot / README.md
Created December 20, 2013 19:04
d3 voronoi interpolation!
@mausch
mausch / gist:7706117
Last active December 29, 2015 17:39
Draft/pseudocode for HTML type provider
// https://twitter.com/mausch/status/406420573518970880
// compiles to ModelLayout -> XElement where ModelLayout = { title: string; script: XAttribute; bodyAttrs: XAttribute list; body: XElement }
type Layout = HTML<"""
<html>
<head>
<title><x:text id="title"/></title>
<script x:attr="script"></script>
</head>
<body x:attrs="bodyAttrs">
type Proc<'T> =
| P of ('T -> option<Proc<'T>>)
exception Bleep
let def f =
P (fun x -> try Some (f x) with Bleep | MatchFailureException _ -> None)
let rec ( <||> ) (P a) (P b) =
let f x =
#r @"packages\FAKE.2.1.309-alpha\tools\FakeLib.dll"
#r @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Build.Client.dll"
#r @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"
open Fake
open Microsoft.TeamFoundation.Client
open Microsoft.TeamFoundation.Build.Client
open System
@gregoryyoung
gregoryyoung / gist:5917423
Last active December 19, 2015 07:18
Proof that httplistener does not use http.sys kernel caching
From HttpListener source code
http://www.dotnetframework.org/default.aspx/DotNET/DotNET/8@0/untmp/whidbey/REDBITS/ndp/fx/src/Net/System/Net/HttpListenerResponse@cs/2/HttpListenerResponse@cs
line 525
UnsafeNclNativeMethods.HttpApi.HttpSendHttpResponse(
HttpListenerContext.RequestQueueHandle,
HttpListenerRequest.RequestId,
(uint)flags,
@mathias-brandewinder
mathias-brandewinder / gist:5558573
Last active September 8, 2026 20:14
Stub for F# Machine Learning Dojo
// This F# dojo is directly inspired by the
// Digit Recognizer competition from Kaggle.com:
// http://www.kaggle.com/c/digit-recognizer
// The datasets below are simply shorter versions of
// the training dataset from Kaggle.
// The goal of the dojo will be to
// create a classifier that uses training data
// to recognize hand-written digits, and
// evaluate the quality of our classifier
@diegofrata
diegofrata / FSharpAop.fs
Last active March 22, 2016 07:46
SheepAspect + F# + INotifyPropertyChanged = Joy.
namespace FSharp.Windows
open System.ComponentModel
[<AbstractClass>]
type Model() =
let propertyChangedEvent = Event<_,_>()
interface INotifyPropertyChanged with