Skip to content

Instantly share code, notes, and snippets.

type AgeBrand = {
readonly Age: unique symbol
}
const Age = t.brand(
t.number, // A codec representing the new type, here it's a number
(n): n is t.Branded<number, AgeBrand> => n >= 0, // A type guard
'Age' // The name of the codec
)
// pipe is a utility function that passes the result of previous step to the next
// pipe(a, b, c) === c(b(a))
pipe(
// This function returns an array of messages for chat completion
getTurnPromptMessages(state, action),
// This turns an array into the CC request object
mkCCRequestFromMessages,
pipe(
// flow returns a function that combines passed functions into it
// flow(a, b, c) = (x) => c(b(a(x)))
@golergka
golergka / 1.cs
Last active August 29, 2015 14:05 — forked from cuppster/1.cs
/*
modified from original source: https://bitbucket.org/mattkotsenas/c-promises/overview
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Promises
@golergka
golergka / preprocessor_fun.h
Last active January 3, 2016 23:49 — forked from aras-p/preprocessor_fun.h
Malloc fun!
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@golergka
golergka / .gitignore
Last active December 31, 2015 02:59
Basic class for every monobehavior. It can provide singleton capapilities, automatically set up component properties of the same GameObject and check that setupable fields are not null.
*.meta