Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / spring.scad
Created March 27, 2025 16:43
flat spring
module spring(width, id, od, count) {
for(i = [0 : count]) {
translate([-width/2, i*(od+id)]) square([width, od-id]);
if (i < count) {
mirror([i%2, 0, 0])
translate([-width/2, (i*(od+id))+(od)])
difference() {
circle(od);
circle(id);
translate([0, -od*1.5]) square(od*3);
from evdev import UInput, ecodes as e
import time
cap = {
# we have to have some buttons and X, Y otherwise
# xfce doesn't recognize it as a mouse
e.EV_KEY: [e.BTN_LEFT, e.BTN_RIGHT],
e.EV_REL: [e.REL_X, e.REL_Y, e.REL_WHEEL, e.REL_WHEEL_HI_RES],
}