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] |
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 __future__ import annotations | |
from dataclasses import dataclass | |
def prod(args): | |
out = 1 | |
for i in args: | |
out *= i | |
return out |
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
pipe_types = { | |
"-": [(-1, 0), (1, 0)], | |
"|": [(0, -1), (0, 1)], | |
"7": [(-1, 0), (0, 1)], | |
"F": [(-1, 0), (0, -1)], | |
"J": [(1, 0), (0, 1)], | |
"L": [(1, 0), (0, -1)], | |
} | |
def nbrs(pos): |
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 Control.Arrow ((&&&)) | |
trapolate :: ([Integer] -> Integer -> Integer) -> [Integer] -> Integer | |
trapolate f ls | all (== 0) ls = 0 | |
| otherwise = f ls $ trapolate f (zipWith (-) (tail ls) ls) | |
main :: IO () | |
main = ((sum . map (trapolate ((+) . last)) &&& sum . map (trapolate ((-) . head))) . map (map read . words) . lines <$> getContents) >>= print |
NewerOlder