Skip to content

Instantly share code, notes, and snippets.

View deviousasti's full-sized avatar
🏡
Working from home

Asti deviousasti

🏡
Working from home
View GitHub Profile
let createComparer (map) =
{
new EqualityComparer<_>() with
override this.Equals(a, b) = Unchecked.equals (map a) (map b)
override this.GetHashCode(a) = Unchecked.hash (map a)
}
module Seq =
let exceptWith map first second =
Enumerable.Except(first, second, createComparer map)
@deviousasti
deviousasti / Rpc.fs
Last active August 23, 2022 15:04
Fast inter-process RPC using shared memory
open SharedMemory
open MBrace.FsPickler
module Rpc =
type RpcContext<'command, 'message> =
{ name: string; buffer: RpcBuffer; post: 'command -> Async<'message>} with
interface IDisposable with
member this.Dispose() = this.buffer.Dispose()
let createHost name (handler : 'command -> Async<'message>) =
@deviousasti
deviousasti / add-couch.yml
Last active September 7, 2020 09:36
Install CoucbDB in Ansible
- name: Add the CouchDB repository
apt_repository:
repo: deb https://apache.bintray.com/couchdb-deb bionic main
state: present
update_cache: no
- name: Install the CouchDB repository key
apt_key:
keyserver: keyserver.ubuntu.com
id: 8756C4F765C9AC3CB6B85D62379CE192D401AB61
@deviousasti
deviousasti / KahanSum.fs
Created January 11, 2021 06:45
Kahan Sum Float Error
// @mdl
let rec kahan_sum_aux (xs : float list) (sum : float) (c : float) =
match xs with
| [] -> sum
| x::xs ->
let y = x - c in
let t = sum + y in
let c = (t - sum) - y in
kahan_sum_aux xs t c