Skip to content

Instantly share code, notes, and snippets.

@44100hertz
44100hertz / most_tactile.csv
Last active November 16, 2024 22:06
List of most tactile switches from database
Name Depth First half work (gfmm) Second half work (gfmm) Difference
Clickiez 40g Tactile deep 155.694 75.6585 80.0355
Clickiez 40g Tactile 3 medium 121.874 56.3675 65.5065
Clickiez 40g Tactile 2 medium 122.076 59.1035 62.9725
Clickiez 75g Tactile 2 medium 146.176 86.085 60.091
Clickiez 75g Tactile 3 deep 167.4465 107.4575 59.989
Clickiez 75g Tactile deep 169.1445 109.454 59.6905
Clickiez 40g Clicky 3 medium 91.5005 52.5485 38.952
Clickiez 40g Clicky 2 medium 84.8565 48.4355 36.421
Clickiez 75g Clicky 2 medium 119.916 84.3455 35.5705
@44100hertz
44100hertz / most_tactile.lua
Last active November 16, 2024 21:19
Find the most tactile switch within the database at https://github.com/ThereminGoat/force-curves
local basedir = "/tmp/analyze-forces/"
os.execute("mkdir -p " .. basedir)
local function list_dir(path)
local date = os.date()
local listing_path = basedir .. date .. ".txt"
os.execute(string.format('ls "%s" > "%s"', path, listing_path))
local out = {}
for line in io.lines(listing_path) do
out[#out + 1] = line
@44100hertz
44100hertz / parserModify.md
Created February 11, 2024 19:24
Modifying Parsers to work with structure editors

General

Conventional parsers must be modified to create an effective structure editor.

Most parsers create an AST (abstract syntax tree), but structure parsers create a CST (concrete syntax tree). This is because the parser must take note of things that affect the code appearance and not just the code output.

The parser should provide error feedback, but should NEVER give up when creating structure. Instead, it should use sane fallbacks as to always create an editable CST, within reason. Every CST should correspond almost 1:1 with corresponding code, whether that code is valid or invalid.

@44100hertz
44100hertz / Linear-GammaCorrect.glslp
Created November 10, 2023 22:17
Linear Gamma Correct Retroarch Shader
shaders = "2"
feedback_pass = "0"
shader0 = "shaders_glsl/linear/linearize.glsl"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
@44100hertz
44100hertz / fir.ts
Created September 4, 2022 04:13
hand-rolled FIR sinc filter
const WINDOW_SIZE = 4; /* Determines how much of normalized sinc function is sampled
1 = Just the center spike (-Pi/2 thru Pi/2)
*/
const SAMPLE_POINTS = 63; // Determines quality of output
const MIN_FREQ = 20; // Determines buffer length
const MAX_FREQ = 20000; // Determines shutoff frequency
const coefficients = Array(SAMPLE_POINTS).fill(0).map((_,i) => {
const thru = i / (SAMPLE_POINTS-1);
const pos = thru * WINDOW_SIZE - WINDOW_SIZE / 2.0;
@44100hertz
44100hertz / shortNum.js
Created August 9, 2022 10:47
Number shortener
function shortNumber (num, desiredDigits) {
if (num < 0) {
// Negative
return '-' + shortNumber(-num, desiredDigits-1);
} else if (num === 0) {
// Zero is problematic
return '0';
}
function standardNotation (num, desiredDigits) {
scanr_rec :: (a -> b -> b) -> b -> [a] -> [b]
scanr_rec _ acc [] = [acc]
scanr_rec f acc (x:xs) = let next = scanr_rec f acc xs in f x (head next) : next
scanr_fold :: (a -> b -> b) -> b -> [a] -> [b]
scanr_fold f acc = foldr scanFold [acc]
where
scanFold x acc = f x (head acc) : acc
scanl_rec :: (b -> a -> b) -> b -> [a] -> [b]
@44100hertz
44100hertz / phoneticspell.lua
Created March 11, 2022 06:09
Takes espeak output, makes it into sort-of-readable phonetic language inspired by Sayspel
local input =
[==[
Put Your input text here.
]==]
local phonemes = {}
do
local h = io.popen('espeak -w /dev/null -x "' .. input .. '"')
phonemes = h:read('*a')
h:close()
@44100hertz
44100hertz / degrade.sh
Created April 23, 2021 21:11
deep fry images (requires imagemagick)
#!/bin/bash
convert $1 $2
for i in {1..8} # number of passes
do
case $(( $RANDOM % 22 )) in # set to 23 to enable swirl effect
1)
convert $2 -resize 75% -filter point -quality 15 $2
echo "resized 75%";;
@44100hertz
44100hertz / ideology.lua
Created November 20, 2020 02:11
Ideology Generator
local function create_ideology (_vocab)
-- Output ideology (array of strings)
local id = {}
-- Take random entries from vocab
-- Consumes entries to reduce redundancy
local vocab = {}
local function getv ()
if #vocab == 0 then