Skip to content

Instantly share code, notes, and snippets.

View kolektiv's full-sized avatar
💭
Building myself a secondary brain...

Andrew Cherry kolektiv

💭
Building myself a secondary brain...
View GitHub Profile
@kolektiv
kolektiv / morphisms.fs
Created September 16, 2016 15:06
morphisms, etc.
let record =
{ Ages = "24,56,45,10" }
(* 56 *)
let oldest =
Optic.get recordints_ record |> List.max
(* { Ages = "25,57,46,11" } *)
let record' =
Optic.map recordints_ (List.map ((+) 1)) record
@kolektiv
kolektiv / fileserver.fs
Created September 16, 2016 16:37
Simple File Server Pipeline
open System.IO
open Freya.Core
open Freya.Core.Operators
open Freya.Machines.Http
open Freya.Routers.Uri.Template
open Freya.Types.Http
// Configuration
let fileTypes =
@kolektiv
kolektiv / example.fs
Created October 12, 2016 09:49
Serialize
type Address =
{ Street: string
Number: int }
static member ToJson (x: Address) =
json {
do! Json.write "street" x.Street
do! Json.write "streetNumber" x.Number }
type House =
@kolektiv
kolektiv / machinestyling.fs
Last active April 13, 2017 09:30
Potential Alternative Configuration Styles for Freya Machines
/*
Prompted by discussion in the F# Slack, where it was proposed that reducing the use of CEs
might help people more easily pick up Freya.
Of course, there's no reason why both syntaxes can't be made available if that seems like
the right option.
The basic freya { ... } CE is a genuine monad, and so would always stay as a CE option (though
it can also be expressed using standard combinator operators/named functions already).
@kolektiv
kolektiv / gist:3d28ae35657275ecc29c
Last active October 30, 2017 21:07
A content negotiated resource in Freya
open System
open System.Text
open Freya.Core
open Freya.Machine
open Freya.Machine.Extensions.Http
open Freya.Machine.Router
open Freya.Router
open Freya.Types.Http
open Microsoft.Owin.Hosting
module Data.NonEmptyArray where
import Prelude
data NonEmpty a =
NonEmpty a (Array a)
instance showNonEmpty :: Show a => Show (NonEmpty a) where
show (NonEmpty a as) = "NonEmpty: " <> show a <> show as
@kolektiv
kolektiv / roman.js
Created February 3, 2019 22:38
Roman Numerals
const conversions = [
[1000, 'M'],
[900, 'CM'],
[500, 'D'],
[400, 'CD'],
[100, 'C'],
[90, 'XC'],
[50, 'L'],
[40, 'XL'],
[10, 'X'],
{
description = "A very basic flake";
inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs = {
url = "nixpkgs/nixos-unstable";
@kolektiv
kolektiv / midi_clock_horror.rs
Last active December 6, 2023 12:57
An incredibly hacky but passable midi clock...
use std::{
thread::{
self,
Builder,
},
time::Duration,
};
use midir::{
MidiOutput,