Skip to content

Instantly share code, notes, and snippets.

include <BOSL2/std.scad>
include <BOSL2/threading.scad>
UNIT="imperial"; // [imperial, metric]
THREAD_LENGTH_INCHES=1.25;
THREAD_LENGTH_MM=31.75;
module broom_thread_internal_mask(length){
INCH=25.4;//mm
//OpenSCAD module to create an ogive of given length for a given circle diameter (gauge)
GAUGE13=2.3;//mm
module ogive(gauge=GAUGE13, length=10){
//gauge -> the DIAMATER of spoke
//length the fin or ogive length FROM THE CENTER of the spoke
gr = gauge/2; //gauge radius
chord = length * 2; //length is 1/2 of a chord forming a right triangle along with large_radius as hypotenuse and (large_radius - gauge radius) as opposite
large_radius = (chord)^2 / (8 * gr) + (gr / 2);
large_d = large_radius * 2;
@K-Francis-H
K-Francis-H / mp42gif.sh
Created January 2, 2024 20:05
mp4->gif
#!/bin/sh
ffmpeg \
-i $1 \
-r 15 \
-vf "scale=320:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
-ss 00:00:00 -to 00:00:01 \
$2
@K-Francis-H
K-Francis-H / reusable_mold_box.scad
Created February 15, 2022 05:19
A reusable 3D printable mold box. Clamp the sides, tape a part to the bottom and mold it with silicone
module mold_base(len, width, height, thickness){
//floor with extra space for the walls, base corners cutout
difference(){
cube([len+2*thickness,width+2*thickness, thickness]);
union(){
cube(thickness);
translate([len+thickness, 0, 0])
cube(thickness);
@K-Francis-H
K-Francis-H / named_seed.scad
Created January 28, 2022 21:11
A poly rolling hash implementation in OpenSCAD. Useful for making procedurally generated 3D objects with named seed values.
function poly_rolling_hash(seed, idx, hash, ppow, p, m) = len(seed) == idx ?
hash :
poly_rolling_hash(seed, idx+1, (hash + (ord(seed[idx]) - ord("a") + 1) * ppow) % m, (ppow * p) % m, p, m);
function seed_from_string(string) = poly_rolling_hash(string, 0, 0, 1, 31, pow(10,9)+9);
//how to use:
rand_val = rands(0, 100, 1, seed_value=seed_from_string("human readable seed") );
function prettySize(bytes){
let index = 0;
let suffixes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
while(bytes > 1000){
bytes = bytes/1000;
index++;
}
return bytes.toFixed(2)+suffixes[index];
}
#!/bin/sh
IPs=$(sudo arp-scan -l -q | awk '{print $1}' | grep -E [0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} )
for ip in $IPs
do
#nmap -O $ip
echo $ip
done
//given a list of 3 element vectors and the size for each node(cylinder diameter)
//this will generate a path going through each point. Especially useful for
//generating models from GPX and KML files for overlaying trail geometry on top
//of terrain
module tracePath(path, size){
for(i=[0:len(path)-1]){
if(i+1 < len(path)){
hull(){
translate(path[i])
cylinder(d=size);
@K-Francis-H
K-Francis-H / uuid.sh
Created August 24, 2018 18:19
UUID generator in BASH
#!/bin/sh
echo $(cat /proc/sys/kernel/random/uuid)
@K-Francis-H
K-Francis-H / display_heightmap.m
Last active February 16, 2017 03:14
GNU Octave script to load SRTM1 and SRTM3 data and print a grayscale image of the data
#!/usr/bin/octave -qf
%usage: ./display_heightmap.m FILENAME FILETYPE
args = argv();
file_name = args{1};
file_type = args{2}; %should be one of {"srtm1", "srtm3"}%
if(file_type == "srtm1")
size = 3601;