pip install autopep8 chmod a+x
vim .git/hooks/post-commit
chmod a+x .git/hooks/post-commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# method 1 | |
x = [2, 3, 4, 5, 6] | |
y = [] | |
for v in x: | |
y += [v*5] | |
assert x == [2, 3, 4, 5, 6] | |
assert y == [10, 15, 20, 25, 30] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# method 1 | |
x = [2, 3, 4, 5, 6] | |
y = [] | |
for v in x: | |
if v % 2: | |
y += [v * 5] | |
assert x == [2, 3, 4, 5, 6] | |
assert y == [15, 25] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# method 1 | |
x = [2, 3, 4] | |
y = [4, 5] | |
z = [] | |
for i in x: | |
for j in y: | |
z += [i + j] | |
assert x == [2, 3, 4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
YOUR_DB='mydb' | |
NEW_OWNER='new_owner' | |
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" $YOUR_DB`; | |
do | |
psql -c "alter table $tbl owner to $NEW_OWNER" $YOUR_DB; | |
done | |
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" $YOUR_DB`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
from PIL import Image, ImageDraw, ImageFont | |
def name_printer(type, attending=None, surgery=None, date=None): | |
if type == 'adm_plan': | |
adm = Image.open('con_1.jpg') | |
font_file = os.path.join("/System/Library/Fonts/", '儷黑 Pro.ttf') | |
wfont = ImageFont.truetype(font_file, size=24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
a = { | |
:category => { | |
:mongo => "mango", | |
:python => "python snake", | |
:fruit => { | |
:password => "apple" | |
}, | |
:animals => ["dog", "cat", "fish"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# check git unstaged and auto commit | |
DIR=$( cd "$( dirname $(readlink $BASH_SOURCE))" && pwd ) | |
for d in $DIR/*/ | |
do | |
(cd "$d" && | |
! `git diff --quiet --ignore-submodules HEAD &>/dev/null` && | |
pwd && | |
git ci -am 'update' && | |
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from os import path | |
import geoip2.database | |
ips = """ | |
223.143.56.227 | |
101.8.221.38 | |
1.34.73.244 | |
42.70.123.135 | |
14.0.209.138 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import env, local, run | |
def vagrant(): | |
env.user = 'vagrant' | |
env.hosts = ['127.0.0.1:2222'] | |
result = local('vagrant ssh-config | grep IdentityFile', capture=True) | |
env.key_filename = result.split()[1] | |