This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(load "pmatch.scm") | |
(define eval-expr | |
(lambda (expr env) | |
(pmatch expr | |
[,n (guard (number? n)) n] | |
[,x (guard (symbol? x)) | |
(env x)] | |
[(lambda (,x) ,body) | |
(lambda (arg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const numWithOpacity = (nums, by) => | |
"#" + | |
nums.map((x) => Math.round(x + (255 - x) * (1 - by)).toString(16)).join(""); | |
const hexWithOpacity = (rgbHex, by) => | |
numWithOpacity( | |
[rgbHex.slice(1, 3), rgbHex.slice(3, 5), rgbHex.slice(5, 7)].map((hex) => | |
parseInt(hex, 16) | |
), | |
by |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell, LambdaCase, BlockArguments, GADTs, FlexibleContexts, TypeOperators, DataKinds, PolyKinds, ScopedTypeVariables, TypeApplications #-} | |
import Polysemy | |
import Polysemy.State | |
data Teletype m a where | |
ReadTTY :: Teletype m String | |
WriteTTY :: String -> Teletype m () | |
SetState :: Integer -> Teletype m () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
#include <alsa/asoundlib.h> | |
int main() { | |
snd_pcm_t *pcm; | |
snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK, 0); | |
snd_pcm_hw_params_t *hw_params; | |
snd_pcm_hw_params_alloca(&hw_params); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Deeply casts interfaces to type aliases | |
*/ | |
export type DeepImplicitIndex<I> = { | |
[P in keyof Pick<I, keyof I>]: Pick<I, keyof I> extends Record<any, any> | |
? DeepImplicitIndex<Pick<I, keyof I>[P]> | |
: Pick<I, keyof I>[P]; | |
}; |