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
@mingrammer
mingrammer / boto-cloudfront-manager.py
Created June 20, 2016 08:44
Python script for AWS Cloudfront with boto api Raw
# -*- coding: utf-8 -*-
import StringIO
import time
import boto
from boto.cloudfront.distribution import Distribution
class CloudFrontManager(object):
@mingrammer
mingrammer / symlink.md
Created September 10, 2016 09:50
Use the setting files across multiple machines
@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
; 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.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",
# 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.example
{
"DEFAULT": {
"SECRET_KEY": "...",
"ADMIN_NAME": "...",
"AWS_DEFAULT_REGION": "...",
"MAX_IMAGE_SIZE": 5242880
},
"TEST": {
"TEST_TMP_DIR": "tests",
# /opt/settings/config.py
DATABASE_CONFIG = {
'host': 'localhost',
'dbname': 'company',
'user': 'user',
'password': 'password',
'port': 3306
}
# main.py
# Provisioning script
...
cd /opt/settings
git clone git@github.com/company/config.git
cd /opt/app
git clone git@github.com/company/api-server.git
...
>>> 2 * 3
6
>>> 2 ** 3
8
>>> 1.414 * 1.414
1.9993959999999997
>>> 1.414 ** 1.414
1.6320575353248798