Skip to content

Instantly share code, notes, and snippets.

View makoConstruct's full-sized avatar

mako yass makoConstruct

View GitHub Profile
@makoConstruct
makoConstruct / tractrixpull.py
Last active November 8, 2025 22:15
tractrix-based framerate independent exact adjustment of a vector of limited length
# this is an algorithm written for keeping of a running average of a vector, or more precisely, for adjusting a vector that has a length limit, which is often needed for UI stuff, and probably for games as well. It's a perfect, framerate-independent method, where an imperfect method is often good enough. It's slightly unfinished, and untested, I decided to just use the more common inexact method of adding each delta v and renormalizing each frame. But this is all the code you'll need to do it the perfect way if you wanted to. I've done the research for you (my finding was "use a tractrix curve").
# unlike most tractrix models, it is a slack tractrix, where pushing towards the dog wont push the dog away.
# good for keeping track of the average bearing of something over time, using a single vector.
# it models the average bearing as a vector that can't exceed a certain length. You could approximate this by having a high framerate, adding the acceleration vector times the delta to it each frame, then renormali
@makoConstruct
makoConstruct / random-seek.lua
Last active October 3, 2025 20:09
Convert any movie into an experience of pure aesthetics by cutting it up and playing it in a random order
--[[
Plays a movie in random order, jumping every 5 seconds or so to a random position. Convert any movie into a purely aesthetic experience. Potentially useful for creating ambience in the background of something, a party for instance, less distracting than just playing the movie normally, though still a bit distracting.
how to use this: get mpv, put this script in its config/scripts dir
invoke mpv with a command like this:
mpv --script-opts=random-seek-enable=yes,random-seek-seed=393 video/dl/Legend.1985.DC.1080p.BluRay.x265-RBG.mp4
the options include
random-seek-enable: must be set yes for the extension to work
@makoConstruct
makoConstruct / flake.nix
Created November 15, 2024 01:05
mako's nixos config
{
description = "mako's nixos config";
inputs = {
nixpkgs = { url = "github:NixOS/nixpkgs/nixos-23.11"; };
# we want some packages to be more recent
nixpkgs-unstable = { url = "github:NixOS/nixpkgs/nixos-unstable"; };
@makoConstruct
makoConstruct / nis.md
Last active January 6, 2024 20:52
proposal of the Nix syntax, Nis

I propose "Nis", a new syntax for Nix.

Nix's syntax has a couple of issues. Its function invocation syntax breaks in arrays, which is fairly serious. It also involves a lot of semicolons. Neither of these things are necessary.

Nix version:

{
  outputs = inputs: let
    username = "mako";
    defaultHostname = "yoga";
@makoConstruct
makoConstruct / bench_copy.rs
Last active September 13, 2021 06:16
using criterion to benchmark copy and copy_nonoverlapping
[package]
name = "toying"
version = "0.1.0"
edition = "2018"
[dependencies]
[dev-dependencies]
itertools = "0.8.2"
criterion = "0.3.5"
@makoConstruct
makoConstruct / gist:5e27e47a5c2f9bb3e8d5f9929451f8a9
Created September 11, 2021 00:09
performance of various overlapping and nonoverlapping mem copies in rust
Benchmarking copy_maybeoverlapping_1: 3.6362 ns 3.6482 ns 3.6601 ns
Benchmarking copy_maybeoverlapping_2: 3.6623 ns 3.6684 ns 3.6748 ns
Benchmarking copy_maybeoverlapping_4: 4.2384 ns 4.2447 ns 4.2508 ns
Benchmarking copy_maybeoverlapping_8: 5.6183 ns 5.6267 ns 5.6350 ns
Benchmarking copy_maybeoverlapping_16: 7.4764 ns 7.4959 ns 7.5211 ns
Benchmarking copy_maybeoverlapping_32: 49.636 ns 52.097 ns 54.614 ns
Benchmarking copy_maybeoverlapping_64: 69.645 ns 69.900 ns 70.167 ns
Benchmarking copy_maybeoverlapping_128: 144.11 ns 144.32 ns 144.53 ns
Benchmarking copy_maybeoverlapping_256: 280.74 ns 281.18 ns 281.64 ns
Benchmarking copy_maybeoverlapping_512: 582.23 ns 583.35 ns 584.48 ns
@makoConstruct
makoConstruct / sitegen.rs
Created May 6, 2020 10:57
the little ... script? (can it be a script if it's a compiled language? It felt like writing a script) that generates the html at aboutmako.makopool.com from a termpose tree of markdown
// extern crate tinytemplate;
extern crate comrak;
extern crate wood;
use wood::Wood;
use std::{path::Path, fs::{read_to_string, write}};
use comrak::{markdown_to_html, ComrakOptions};
fn indent_level(d:&Wood, indent:&mut String, out:&mut String){
out.push_str(indent);
out.push_str("<div class=\"level\">\n");
@makoConstruct
makoConstruct / metrica.rs
Created January 28, 2020 06:33
a battery of tests for comparing different mathematical specifications of comparison aggregation
trait MetricaWire {
fn sign(&self)-> f32;
// fn controversy(&self)-> f32;
// fn certainty(&self)-> f32;
fn negate(&self)-> Self;
fn zero()-> Self;
fn unit()-> Self;
fn of_strength(v:f32)-> Self;
}
@makoConstruct
makoConstruct / fauns_criteria.rs
Last active January 22, 2020 03:15
tests whether a graph rank aggregation (referred to as "rank") satisfies some necessary features of large collaborative curation processes
#[cfg(test)]
mod fauns_criteria {
use super::*;
fn mapping(results: Vec<(f32, str&)>)-> HashMap<String, f32> {
results.into_iter().map(|(score, name)| (name.into(), score)).collect()
}
fn equalish(a:f32, b:f32)-> bool {
abs(a - b) < 0.00001
// o o o o . . .
// o o o o o . .
// o o o o o o .
// o o o o o o o
// . o o o o o o
// . . o o o o o
// . . . o o o o
v2 hexify(v2 v){ return v2{v.x+v.y/2, v.y*SQRTTHREEQUAR}; } //from square to hex