Skip to content

Instantly share code, notes, and snippets.

View mingrammer's full-sized avatar
🧗
learn, code, and grow

MinJae Kwon (Miti) mingrammer

🧗
learn, code, and grow
View GitHub Profile
# Provisioning script
...
cd /opt/settings
git clone [email protected]/company/config.git
cd /opt/app
git clone [email protected]/company/api-server.git
...
# /opt/settings/config.py
DATABASE_CONFIG = {
'host': 'localhost',
'dbname': 'company',
'user': 'user',
'password': 'password',
'port': 3306
}
# main.py
import os
from myapp import app
secret_key = os.environ.get('SECRET_KEY', None)
if not secret_key:
raise ValueError('You must have "SECRET_KEY" variable')
app.config['SECRET_KEY'] = secert_key
// config.json.example
{
"DEFAULT": {
"SECRET_KEY": "...",
"ADMIN_NAME": "...",
"AWS_DEFAULT_REGION": "...",
"MAX_IMAGE_SIZE": 5242880
},
"TEST": {
"TEST_TMP_DIR": "tests",
# main_with_ini.py
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
secret_key = config['DEFAULT']['SECRET_KEY'] # 'secret-key-of-myapp'
ci_hook_url = config['CI']['HOOK_URL'] # 'web-hooking-url-from-ci-service'
# main_with_json.py
// config.json
{
"DEFAULT": {
"SECRET_KEY": "secret-key-of-myapp",
"ADMIN_NAME": "administrator",
"AWS_DEFAULT_REGION": "ap-northeast-2",
"MAX_IMAGE_SIZE": 5242880
},
"TEST": {
"TEST_TMP_DIR": "tests",
; config.ini
[DEFAULT]
SECRET_KEY = secret-key-of-myapp
ADMIN_NAME = administrator
AWS_DEFAULT_REGION = ap-northeast-2
MAX_IMAGE_SIZE = 5242880
[TEST]
TEST_TMP_DIR = tests
TEST_TIMEOUT = 20
# config.py
class Config:
APP_NAME = 'myapp'
SECRET_KEY = 'secret-key-of-myapp'
ADMIN_NAME = 'administrator'
AWS_DEFAULT_REGION = 'ap-northeast-2'
STATIC_PREFIX_PATH = 'static'
ALLOWED_IMAGE_FORMATS = ['jpg', 'jpeg', 'png', 'gif']
# config.py
DATABASE_CONFIG = {
'host': 'localhost',
'dbname': 'company',
'user': 'user',
'password': 'password',
'port': 3306
}
# main.py
@mingrammer
mingrammer / latency.txt
Created February 25, 2017 03:29 — 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