Skip to content

Instantly share code, notes, and snippets.

View anshuman-singh-93's full-sized avatar
🏠
Working from home

Anshuman Singh anshuman-singh-93

🏠
Working from home
View GitHub Profile
@anshuman-singh-93
anshuman-singh-93 / generate-pushid.js
Created June 28, 2017 16:48 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@anshuman-singh-93
anshuman-singh-93 / latency.txt
Created March 25, 2017 18:55 — 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
@anshuman-singh-93
anshuman-singh-93 / introrx.md
Created March 20, 2017 19:20 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing