Skip to content

Instantly share code, notes, and snippets.

@akre54
akre54 / clean_svg.js
Last active November 29, 2025 11:53
TouchDesigner SVG to SOP and After Effects Bodymovin / Lottie to TD-friendly SVG
const fs = require('node:fs');
const cp = require('node:child_process');
const path = require('node:path');
const { optimize } = require('svgo');
const renderSvg = require('lottie-to-svg');
const paper = require('paper');
const { JSDOM } = require('jsdom');
const svgFlatten = require('svg-flatten');
@PaulFurtado
PaulFurtado / usb_reset.py
Last active June 22, 2024 22:44
Reset USB device from python
"""
Example code for resetting the USB port that a Teensy microcontroller is
attached to. There are a lot of situations where a Teensy or Arduino can
end up in a bad state and need resetting, this code is useful for
"""
import os
import fcntl
import subprocess
@jboner
jboner / latency.txt
Last active December 30, 2025 18:49
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@gregburek
gregburek / rateLimitDecorator.py
Created December 7, 2011 01:51
Rate limiting function calls with Python Decorators
import time
def RateLimited(maxPerSecond):
minInterval = 1.0 / float(maxPerSecond)
def decorate(func):
lastTimeCalled = [0.0]
def rateLimitedFunction(*args,**kargs):
elapsed = time.clock() - lastTimeCalled[0]
leftToWait = minInterval - elapsed
if leftToWait>0: