Skip to content

Instantly share code, notes, and snippets.

@zvodd
zvodd / svg_transform_resize_folder.py
Created January 22, 2025 21:04
Resize SVG folder in/out; via viewbox and corresponding transform element wrap
import xml.etree.ElementTree as ET
import argparse
import sys
import os
from pathlib import Path
def resize_svg(input_file, width=None, height=None):
"""
Resize an SVG by wrapping its contents in a transform that scales to new dimensions
while preserving aspect ratio.
@zvodd
zvodd / svg_transform_resizer.py
Created January 22, 2025 20:50
Resize SVG; via viewbox and corresponding transform element wrap
import xml.etree.ElementTree as ET
import argparse
import sys
def resize_svg(input_file, width=None, height=None):
"""
Resize an SVG by wrapping its contents in a transform that scales to new dimensions
while preserving aspect ratio.
Args:
@zvodd
zvodd / fontforge_export_glyphs_as_svgs
Created January 15, 2025 13:23
Export a selection of glyphs as SVG using FontForge
##
## In FontForge( https://fontforge.org ) with font of choice open press Ctrl + . to open the script dialog, paste and run.
## You will be asked to save a file. Font will be put in the selected folder with the prefix of the name entered.
#
## Recommend: Symbols NerdFont at https://www.nerdfonts.com/font-downloads
##
import os
import pprint
@zvodd
zvodd / day4.py
Created December 12, 2024 18:06
AoC_2024 day4 python - I think I missed a trick with part 1?
def parse(lines):
width = len(lines[0])
height = len(lines)
for ypos, line in enumerate(lines):
for xpos, c in enumerate(line):
if c != "X":
continue
@zvodd
zvodd / dns_checker.py
Created December 3, 2024 22:07
Check a list of domains from a text file. To see if they resolve.
from collections import OrderedDict
import socket
import sys
import re
def extract_first_hostname(text):
"""
Extract the first hostname from a given string.
Args:
@zvodd
zvodd / havok_wasm_physics_sim.ts
Last active November 3, 2024 04:25
Do physics sim asynchronously / not locked to renderer. Absolutely borked way to use havok_wasm.
import HavokPhysics, {
HavokPhysicsWithBindings,
Result, HP_ShapeId
} from "@babylonjs/havok";
// Global variable to store the initialized Havok physics engine
globalThis['HK'] = (await HavokPhysics()) as HavokPhysicsWithBindings;
const HK : HavokPhysicsWithBindings = globalThis.HK;
// Define helper functions for common physics types (Vector3, Quaternion, etc.)
@zvodd
zvodd / GridVertexSnap.py
Created October 12, 2024 03:39
Blender Operator + Panel: Snaps selected vertices to virtual 3d grid.
import bpy
import bmesh
from mathutils import Vector
from bpy.props import BoolProperty, FloatVectorProperty
from bpy.types import Operator, Panel, PropertyGroup
#######################
# Props
#######################
@zvodd
zvodd / loadenv.bat
Last active October 3, 2024 15:23
load a dotenv file in windows cmd line - doesn't support values containing `=`
@echo off
if "%~1"=="" (
set "ENV_FILE=%CD%\.env"
) else (
set "ENV_FILE=%~1"
)
if not exist "%ENV_FILE%" (
echo Error: %ENV_FILE% file not found
exit /b 1
@zvodd
zvodd / 3d-graphics-spaces-and-matrices.md
Last active September 9, 2024 09:50
3D Spaces and Matrices in Godot 4 Shaders

Vertex and Fragment Function Spaces

  1. Vertex Function:

    • Input: Model Space (Local Space)
    • Output: Clip Space
  2. Fragment Function:

    • Input: View Space (Camera Space)

Coordinate Spaces

@zvodd
zvodd / geom_node_instance_positions.py
Last active September 8, 2024 19:35
Blender 4 instance enumeration - Including unrealized Geometry Node generated instances.
import bpy
# https://docs.blender.org/api/current/bpy.types.Depsgraph.html
# https://docs.blender.org/api/current/bpy.types.DepsgraphObjectInstance.html
def report_instances(obj):
"""
Reports the instances under an object in the Blender scene.
Including unrealized Geometry Node generated instances.