Skip to content

Instantly share code, notes, and snippets.

@mavnn
mavnn / graph.js
Created Sep 21, 2020
Mini-mini-graph library for JS
View graph.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)) {
View urls.txt
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/
View BlackBelt.Domain.Logic.fs
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
A simple F# Trie with stored values
View Trie.fs
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
View AggregateAPI.fs
// 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 Sep 1, 2016
Hopac supervisor using proc
View supervisor.fsx
#!/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 Mar 22, 2016
Logary.Obnoxious
View Program.fs
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 Dec 17, 2015
Extendable Json schema
View Schema.fs
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 Jul 8, 2015
Monadic build for the win
View build.fsx
#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 Jun 24, 2015
Sometimes it's nice to be able to both experiment in FSI - and also build an executable for others to use.
View Validate.fsx
#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)
You can’t perform that action at this time.