Skip to content

Instantly share code, notes, and snippets.

@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 <[email protected]>
* 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 August 12, 2024 14:10
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
@bamboo
bamboo / ReactiveServiceStack.cs
Last active May 11, 2019 16:00
Using ServiceStack* together with Reactive Extensions** to reduce the latency before the client can start processing the elements of an array response. The service sends elements to the client as soon as they become available through the magic of AsyncServiceBase, IStreamWriter, IObservable<T>.ToEnumerable() and careful use of WriteLine() and Fl…
using System;
using System.Collections.Generic;
using System.Disposables;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using Funq;
using ServiceStack.Common.Web;
using ServiceStack.Service;