Skip to content

Instantly share code, notes, and snippets.

@mavnn
mavnn / part1.fs
Created October 14, 2013 09:55
Introducing F# Syntax
// Let's send an email!
@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
@mavnn
mavnn / build.fsx
Last active November 28, 2016 15:27
Literate build.fsx
(**
## References
As they aren't part of a project, fsx files need
to reference all of their dependencies within the
file.
You'll always want to reference FakeLib. VersionUpdater
is an inhouse tool we use for handling feature branch
@mavnn
mavnn / csharp.cs
Created September 24, 2013 13:17
C# and F# comparisons of NuGet ProjectSystem implementations. F# code is from https://github.com/mavnn/NuGetPlus/blob/master/NuGetPlus.Core/ProjectSystem.fs C# code is from http://nuget.codeplex.com/SourceControl/latest#src/CommandLine/Common/MSBuildProjectSystem.cs They aren't identical in functionality, but they're pretty similar and implement…
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Versioning;
using Microsoft.Build.Evaluation;
namespace NuGet.Common
{
@mavnn
mavnn / InstallThings.fsx
Created November 28, 2013 16:15
Install NuGet stuff from code with sensible control of options.
(* Get the files in the right places relative to the script by running:
path\to\NuGet.exe install NuGetPlus.Core -ExcludeVersion -Prerelease
*)
#r "FSharp.Core"
#r "Microsoft.Build"
#r "Microsoft.Build.Framework"
#r "System.Xml"
#r "System.Xml.Linq"
// 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 / XmlGen.fs
Last active September 2, 2016 17:03
Really naive xml generator for FsCheck.
open FsCheck
type XmlTree =
| NodeName of string
| Container of string * List<XmlTree>
let nodeNames = ["myNode";"myOtherNode";"someDifferentNode"]
let tree =
let rec tree' s =