Skip to content

Instantly share code, notes, and snippets.

View ddneat's full-sized avatar
👋
hello

David Neubauer ddneat

👋
hello
View GitHub Profile
@ddneat
ddneat / sutherland–hodgman.js
Created December 2, 2022 18:32 — forked from alenaksu/sutherland–hodgman.js
Sutherland–Hodgman algorithm
function isInside(p, [a, b]) {
return (b[0] - a[0]) * (p[1] - a[1]) > (b[1] - a[1]) * (p[0] - a[0]);
}
function getEdges(polygon) {
let edges = [];
for (let i = 0; i < polygon.length; i++) {
let edge = [polygon[(i + polygon.length - 1) % polygon.length], polygon[i]];
@ddneat
ddneat / latency.txt
Created November 16, 2017 15:04 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
# Flatten a transparent image with a white background:
convert -flatten img1.png img1-white.png
# Make an image transparent
convert -transparent '#FFFFFF' nontransparent.gif transparent.png
# convert an image into tiles
convert -size 3200x3200 tile:single_tile.png final.png
# making a montage from a collection of images