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
use std::{
io::Read,
os::unix::net::UnixStream,
};
use anyhow::Result;
use test_shared::Test;
fn main() -> Result<()> {
println!("creating stream, connecting...");
@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,
{
description = "A very basic flake";
inputs = {
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs = {
url = "nixpkgs/nixos-unstable";
@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'],
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 / 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 / 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 / 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 / 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 / html.fs
Last active July 14, 2016 17:18
HTML CompEx playground
// Builder
type Builder<'a> (operations: BuilderOperations<'a>) =
member __.Return _ : 'a =
operations.Init ()
member __.ReturnFrom (c: 'a) : 'a =
c