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
# http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Transaction | |
from sqlalchemy import create_engine | |
engine = create_engine("postgresql://scott:tiger@localhost/test") | |
connection = engine.connect() | |
trans = connection.begin() | |
connection.execute("insert into x (a, b) values (1, 2)") | |
trans.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
# 查找出当前文件夹中以 x 开头的文件,文件名作为参数传给 python 脚本,然后放到后台执行 | |
for i in x* | |
do | |
python t.py $i & | |
done |
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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl -L https://www.npmjs.org/install.sh | sh |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" 测试 Python 在什么情况下会输出 Unicode 字符串 | |
需要首先理解在 Python 中 Unicode 类型和 Unicode 字符串指的不是同一个东西。 | |
Unicode 字符串是 str 类型,但它的值的表现形式是 Unicode 编码形式。 | |
""" | |
def printt(str): |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import logging | |
def get_logger(): | |
# Get a logger, default is the root logger. | |
logger = logging.getLogger('mylogger') |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" Child threads with join | |
Main thread wait unit all child threads terminate. | |
""" | |
import threading | |
from time import sleep |
NewerOlder