Skip to content

Instantly share code, notes, and snippets.

@icejoywoo
icejoywoo / latency.txt
Created January 21, 2022 07:25 — forked from jboner/latency.txt
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
@icejoywoo
icejoywoo / Google protobuf installation on Mac
Last active August 21, 2019 07:31 — forked from rajkrrsingh/Google protobuf installation on Mac
Steps to Install google protobuf on Mac
# version 2.5.0
$wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.bz2
$tar xvf protobuf-2.5.0.tar.bz2
$cd protobuf-2.5.0
$./configure CC=clang CXX=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++ -O3 -g' LDFLAGS='-stdlib=libc++' LIBS="-lc++ -lc++abi"
$make -j 4
$sudo make install
$protoc --version
# version 2.4.1
@icejoywoo
icejoywoo / Forcomptran.md
Created August 3, 2018 03:10 — forked from loicdescotte/Forcomptran.md
Scala for comprehension translation helper

Scala for comprehension translation helper

"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.

yield keyword is used to aggregate values in the resulting structure.

This composition can be used on any type implementing this methods, like List, Option, Future...

@icejoywoo
icejoywoo / Expr.scala
Last active January 12, 2016 16:38 — forked from anonymous/Expr.scala
expression problem in week 4 (progfun-005 cousera)
trait Expr {
def eval: Int = this match {
case Number(n) => n
case Sum(e1, e2) => e1.eval + e2.eval
}
}
case class Number(n: Int) extends Expr
case class Sum(e1: Expr, e2: Expr) extends Expr
case class Prod(e1: Expr, e2: Expr) extends Expr
case class Var(x: String) extends Expr
"""
This module adds Redis Sentinel transport support to Celery.
Current version of celery doesn't support Redis sentinel client, which is must have for automatic failover.
To use it::
import register_celery_alias
register_celery_alias("redis-sentinel")
celery = Celery(..., broker="redis-sentinel://...", backend="redis-sentinel://...")
* Generate classes like WhereNot automatically with class decorator?
* Haskell style deconstruction, perhaps like:
@pmatch
def count(first_arg=Match(x=Head, *xs=Rest)):
print x, xs
Will require some nasty hacks like https://github.com/smcq/python-inject
* Implement boolean operators for stuff like:
@pmatch