Skip to content

Instantly share code, notes, and snippets.

@Tom-Bonnike
Tom-Bonnike / tiny-serialize.js
Last active November 24, 2020 21:56
Tiny form serialization helper
function serializeForm(form, urlEncode = false) {
const formData = new FormData(form);
if (urlEncode) {
const searchParams = new URLSearchParams(formData)
return searchParams.toString();
}
const serializedFormData = {};
@notwaldorf
notwaldorf / README.md
Last active June 7, 2023 00:21
ServiceWorker code to cache Tensorflow model shards.

ServiceWorker code to cache TensorFlow model shards.

One of the problems I have when testing giant TensorFlow models in TensorFlow.js is that they're huge (like 500 MB) and they take forever to download, every time I refresh the page. This is how I setup my ServiceWorker code so that at least in testing I only have to download the model once, and then it's saved in the cache for the next time.

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs