Skip to content

Instantly share code, notes, and snippets.

View kafaichoi's full-sized avatar
🍃

KaFai kafaichoi

🍃
View GitHub Profile
@jboner
jboner / latency.txt
Last active May 13, 2025 17:54
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
@tkellen
tkellen / gist:2003309
Created March 8, 2012 20:41
determining number of weeks between date range in postgres
-- First attempt:
EXPLAIN ANALYZE SELECT count(DISTINCT date_trunc('week',s)) FROM generate_series('1900-01-01'::date,CURRENT_DATE,interval '1 day') AS s;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=12.51..12.53 rows=1 width=8) (actual time=72.552..72.553 rows=1 loops=1)
-> Function Scan on generate_series s (cost=0.01..10.01 rows=1000 width=8) (actual time=24.495..27.619 rows=40975 loops=1)
Total runtime: 73.005 ms
(3 rows)
SELECT count(DISTINCT date_trunc('week',s)) FROM generate_series('1900-01-01'::date,CURRENT_DATE,interval '1 day') AS s;
@svnlto
svnlto / install.md
Created December 12, 2011 22:59
Setup OS X 10.7 w/ homebrew, oh-my-zsh, rvm, nvm

Setup new Mac with OSX Lion from scratch

These commands are good as of 2011-07-27.

Install Xcode 4

The download/install takes a while so start it first. When it finishes downloading you will still need to run it to complete installation.

Really the nicest choice for a terminal on OSX right now, especially with Lion style full screen support.