Skip to content

Instantly share code, notes, and snippets.

@wwgist
wwgist / singleton.py
Created June 11, 2014 14:44
PYTHON: singletons
# -*- coding: utf-8 -*-
# При вызове метода __new__ каждый раз возвращается один и тот же объект.
# Хранится объект в классовой переменной.
# переопределение __new__ (поверхностно)
class C(object):
instance = None
def __new__(cls):
if cls.instance is None:
@wwgist
wwgist / mysql_hint.txt
Created July 2, 2014 15:27
MYSQL: usage hints
# MySQL hints
mysql [OPTIONS] [database]
mysqladmin [OPTIONS] command command....
-u > user
-p > password
-D > database
-h > host
-P > port
@wwgist
wwgist / psql_hint.txt
Created July 2, 2014 15:51
PSQL: usage hints
# PostgreSQL hints
psql [option...] [dbname [username]]
-U > username (default=unix_user) VEVAR=PGUSER
-W > password
-w > no-password
-d > dbname VEVAR=PGDATABASE
-h > hostname (default=unix_socket/localhost) VEVAR=PGHOST
-p > port (default=default)
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms