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
def ziprec(parms, vals): | |
if isinstance(parms, list): | |
for p, v in zip(parms, vals): | |
yield from ziprec(p, v) | |
else: yield parms, vals | |
class Env(dict): | |
__slots__ = ["parent"] | |
def __init__(self, l, parent): | |
super().__init__(l) |
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
import java.util.Arrays; | |
import java.util.Optional; | |
import java.util.Map; | |
import java.util.Iterator; | |
import java.util.AbstractMap.SimpleImmutableEntry; | |
public class Hamt<K, V> implements Iterable<Map.Entry<K, V>> { | |
static <K> boolean equals(K left, K right) { | |
return left.equals(right); |
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
from warnings import catch_warnings, filterwarnings # this is always nice to see at the top of a file | |
class Primitive: | |
__slots__ = ["args"] | |
def __init__(self, *args): self.args = args | |
def __await__(self): return (yield self.args) # also a fun sight to see | |
async def eof(): return await Primitive("eof") | |
async def munch(): return await Primitive("munch") | |
async def choice(*args): return await Primitive("choice", args) |
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
#!/usr/bin/env python3 | |
# requires `pip install pyaudio` | |
import pyaudio | |
# most DSP software on the market uses floats -1 to 1 | |
# we instead use ints 0 to 255, due to a quirk of pyaudio | |
single_rotation = [int(i * 255 / 99) for i in range(100)] | |
# or: |
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
{ | |
"plugin": "Stoermelder-P1", | |
"model": "Stroke", | |
"version": "2.0", | |
"params": [], | |
"data": { | |
"panelTheme": 1, | |
"keys": [ | |
{ | |
"button": -1, |
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
#!/usr/bin/env python3 | |
# bake.py - score a poem with colourized ANSI codes | |
# Type a poem at stdin, print the colourized poem at stdout. | |
# Requires at least 256-color support from the teletype. | |
import sys | |
def ansi(*codes): | |
return "\x1b[" + ";".join(map(str, codes)) + "m" | |
def color(nib): |
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
def modifyat(ls, ix, fn): | |
return ls[:ix] + (fn(ls[ix]),) + ls[ix + 1:] | |
def global_counter(): | |
code = global_counter.__code__ | |
global_counter.__code__ = code.replace(co_consts = modifyat(code.co_consts, len(code.co_consts) - 1, (1).__add__)) | |
return 0 |
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
; wavetables | |
(def andW (make-wt 8000 | |
(fn [x] (if (> x 0.5) 1 -1)))) | |
(def xorW (make-wt 8000 | |
(fn [x] (if (< (abs x) 0.5) 1 -1)))) | |
(def bufferW (make-wt 8000 | |
(fn [x] (if (> x 0.01) 1 -1)))) | |
(def notW (hardsat -10)) | |
; waveshapers |
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 <stdlib.h> | |
#include <string.h> | |
int main() { | |
int acc = 0; | |
int buf = 0; | |
char *data = NULL; | |
char *start; | |
struct { |
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
(define (slurp f . args) | |
(let loop () | |
(define head (apply f args)) | |
(if (eof-object? head) | |
'() | |
(cons head (loop))))) | |
(define (classify ch) | |
(case ch | |
[(#\#) #t] |
NewerOlder