Skip to content

Instantly share code, notes, and snippets.

View JohnDowson's full-sized avatar
🎹
writing a synthesizer

Ivan Chinenov JohnDowson

🎹
writing a synthesizer
View GitHub Profile
@JohnDowson
JohnDowson / catenary.rs
Last active November 30, 2023 08:10
Get N point catenary approximation given attachment points, tension and mass per length unit
pub fn catenary(start: Pos2, end: Pos2, h: f32, m: f32, n: usize) -> impl Iterator<Item = Pos2> {
fn find_t0(k: f32, c: f32) -> f32 {
if c == 0.0 {
return 0.5;
}
let a = k.cosh();
let b = k.sinh();
let d = 1.0 - (a - b);
import subprocess
import sys
files = sys.argv[1:]
probe_args = [
"-v",
"error",
"-select_streams",
"v:0",
class Ast():
kind: str
def __repr__(self):
return f"{self.kind}: {self.child()}"
class BinOp(Ast):
def __init__(self, lhs, op, rhs):
self.kind = "binop"
fn main() {
use std::sync::mpsc;
let handles: Vec<(std::thread::JoinHandle<()>, mpsc::Sender<()>)> = (0..2)
.map(|_| {
let (tx, rx) = mpsc::channel::<()>();
(
std::thread::spawn(move || loop {
let work = rx.recv().unwrap();
work
}),
class ConfigParam():
def __init__(self, param_name, param_type, default):
self.param_name = param_name
# get parameter from config
_param = param_from_config()
if param_type:
# cast it to required type
self.value = asWhateverType(_param)