Skip to content

Instantly share code, notes, and snippets.

View monklof's full-sized avatar

Chao Liu monklof

View GitHub Profile
@monklof
monklof / latency.txt
Created September 5, 2017 09:35 — 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
@monklof
monklof / gist:917f4e4cdb1cd304d537df6cc62c35c7
Created April 8, 2016 04:21 — forked from mfenniak/gist:2978805
An extension of Flask that adds file hashes to static file URLs built by url_for("static"...)
import os.path
import contextlib
import hashlib
from flask import Flask
from flask.helpers import safe_join
# Injects an "h" parameter on the URLs of static files that contains a hash of
# the file. This allows the use of aggressive cache settings on static files,
# while ensuring that content changes are reflected immediately due to the
# changed URLs. Hashes are cached in-memory and only checked for updates when
{
"province": [
{
"code": 110000,
"name": "北京市",
"py": "beijingshi"
},
{
"code": 120000,
"name": "天津市",