Skip to content

Instantly share code, notes, and snippets.

@ali1234
ali1234 / offset.scad
Created August 13, 2023 01:58
OpenSCAD rounding with offset
// Animation showing what the 4x offset rounding trick does.
$fs = 0.1;
$fa = 0.1;
function clamp(x) = min(max(x, 0), 1);
module timed_offset(t) {
a = clamp(t-1);
@ali1234
ali1234 / config.scad
Created July 25, 2023 12:35
OpenScad keyboard layout generator
/*
Keyboard data
*/
row_space = 2.1;
key_space = 1.8;
surround = 0.6;
key_colour = [0.1, 0.1, 0.1];
shell_colour = [0.5, 0.5, 0.5];
@ali1234
ali1234 / factors.csv
Created October 24, 2022 14:22
Prime factors of the first 2000 numbers as csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 2 columns, instead of 3 in line 2.
2, 2
3, 3
4, 2, 2
5, 5
6, 2, 3
7, 7
8, 2, 2, 2
9, 3, 3
10, 2, 5
11, 11
@ali1234
ali1234 / click_help_all.py
Created August 10, 2022 00:35
Click subcommand recursive help output example
@click.group(invoke_without_command=True, no_args_is_help=True)
@click.version_option()
@click.help_option()
@click.option('--help-all', is_flag=True, help='Show help for all subcommands.')
@click.pass_context
def yourcommand(ctx, help_all):
"""This group will print all help pages for subcommands."""
if help_all:
print(yourcommand.get_help(ctx))
@ali1234
ali1234 / talkie.py
Last active July 10, 2022 01:41
talkie.py
# https://github.com/going-digital/Talkie ported to Python
import queue
import random
import numpy as np
class BitReader:
def __init__(self, data):
Convexity
---------
Explanation for mathematicians:
1. Every object in OpenSCAD must be closed. An object is closed if it partitions space into two regions:
"inside" (the object itself) and "outside" (the rest of the empty space that the object does not occupy).
For the purposes of understanding convextity, we can ignore positions that lie exactly on the object's surface,
and say that any arbitrarily selected position in space must be either inside or outside the object - never both.
@ali1234
ali1234 / hypersudoku.py
Created January 8, 2022 00:33
Find orthogonal solutions for hypersudoku
#!/usr/bin/env python3
from collections import defaultdict
from itertools import combinations, permutations
from math import isqrt
from subprocess import check_call
def inner(n):
return range(1, n+1)
@ali1234
ali1234 / infinite.py
Last active November 27, 2021 19:41
Blender Infinite Backups
bl_info = {
"name": "Infinite Backups",
"author": "Alistair Buxton <[email protected]>",
"version": (1, 0),
"blender": (2, 80, 0),
"doc_url": "https://gist.github.com/ali1234/415c5ac863c5649c41a22fe061351a22",
"tracker_url": "https://gist.github.com/ali1234/415c5ac863c5649c41a22fe061351a22",
"category": "System",
}
// [ 56.0, 4*62.0, 48.0, 0.6 ], // WHAM 5.04 outer side large
// [ 56.0, 2*62.0, 48.0, 0.6 ], // WHAM 5.04 outer side small
// [ 56.5, 63.5, 48.0, 0.6 ], // WHAM 5.04 inner
// [ 56.5, 62.5, 48.0, 0.6, [0.125, 0.5, 0.25, 0.125] ], // WHAM 5.04 outer
$fs = 0.1;
module fillet(r) {
@ali1234
ali1234 / SoundMgr.cpp
Created March 10, 2021 12:41
Wave sound playerback manager for 32Blit
// hpp
#pragma once
#include <cstdint>
#include "32blit.hpp"
enum Sound {
BlockSmash,