Skip to content

Instantly share code, notes, and snippets.

@mavnn
mavnn / graph.js
Created September 21, 2020 12:45
Mini-mini-graph library for JS
const create = () => {
return { nodes: new Set(), edges: new Set() }
}
const addNode = (graph, node) => {
graph.nodes.add(node)
}
const addEdge = (graph, [node1, node2]) => {
if (graph.nodes.has(node1) && graph.nodes.has(node2)) {
http://localhost:8001/api/v1/namespaces/default/services/kibana:ui/proxy/
http://127.0.0.1:8001/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/
@mavnn
mavnn / BlackBelt.Domain.Logic.fs
Created November 29, 2017 10:44
BlackBelt Domain Logic
module BlackBelt.Domain.Logic
open BlackBelt.Domain.Types
/// This match requires sorted cards
let (|IsNormal|_|) cards =
match cards with
| [Normal { Suit = Defend; Value = v }] ->
Some { Speed = v
Damage = 0
@mavnn
mavnn / Trie.fs
Last active May 22, 2017 10:53
A simple F# Trie with stored values
module Trie
type Trie<'item, 'value when 'item : comparison> =
| Node of ('value list) * Map<'item, Trie<'item, 'value>>
| Values of 'value list
member x.values =
match x with
| Node (v, _)
| Values v -> v
// Fakes to make things look nice
type Category = Category
type Id = Id
type ReCQSettings = ReCQSettings
type EsAction<'a> = EsAction of 'a
type Version = Version of uint32
type ExpectedVersionUnion =
| Any
| Specific of uint32
| NoStream
@mavnn
mavnn / supervisor.fsx
Last active September 1, 2016 13:13
Hopac supervisor using proc
#!/usr/bin/env fsharpi --exec
#I "packages/Hopac/lib/net45"
#r "Hopac.Core.dll"
#r "Hopac.dll"
#r "Hopac.Platform.dll"
open System
open Hopac
open Hopac.Infixes
type Policy =
@mavnn
mavnn / Program.fs
Last active March 22, 2016 16:28
Logary.Obnoxious
module Logary.Obnoxious
open Logary
open Logary.Configuration
open Logary.Targets
open Hopac
open Hopac.Infixes
open Hopac.Job.Global
open Hopac.Extensions.Async
open Hopac.Extensions.Async.Global
@mavnn
mavnn / Schema.fs
Created December 17, 2015 10:57
Extendable Json schema
type PropertyName = string
type Schema =
{ title : string option
description : string option
``type`` : JsonType option
items : Schema option
properties : Map<PropertyName, Schema> option
extensions : Map<string, Json> }
@mavnn
mavnn / build.fsx
Created July 8, 2015 13:24
Monadic build for the win
#load "Fake.Shake.fsx"
#r "packages/FAKE/tools/FakeLib.dll"
open System.IO
open System.Text.RegularExpressions
open Fake
open Fake.FscHelper
open Fake.Shake
open Fake.Shake.Core
open Fake.Shake.Control
open Fake.Shake.DefaultRules
@mavnn
mavnn / Validate.fsx
Created June 24, 2015 10:03
Sometimes it's nice to be able to both experiment in FSI - and also build an executable for others to use.
#if INTERACTIVE
#r "System.Xml"
#endif
open System.Xml
open System.Xml.Schema
let readAndValidate (schema : string) (file : string) =
let schemaSet = XmlSchemaSet()
schemaSet.Add("http://15below.com/PASNGR", schema)