Skip to content

Instantly share code, notes, and snippets.

fn quick-sort [li]{
if <= (count $li) 1; then
put $@li
else
quick-sort [(each { if <= $0 $li[0]; then put $0; fi } $li[1:])]
put $li[0]
quick-sort [(each { if > $0 $li[0]; then put $0; fi} $li[1:])]
fi
}
@lilydjwg
lilydjwg / mynetns_run
Created May 13, 2016 14:27
mynetns_run: Run a program in a seperate network namespace
#!/bin/bash -e
NETNS_FILE=/var/run/netns/mynet
MNTNS_FILE=/var/run/ns/mynet_mnt
if [[ ! -f $NETNS_FILE ]]; then
ip netns add mynet
ip link add mynet0 type veth peer name mynet1
ip link set mynet0 up
@willurd
willurd / web-servers.md
Last active April 25, 2024 09:21
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jboner
jboner / latency.txt
Last active April 25, 2024 01:18
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