start new:
tmux
start new with session name:
tmux new -s myname
| #!/usr/bin/python -u | |
| """ | |
| Python port of PHP serialize() and unserialize() | |
| by Samuel Cochran <sj26@sj26.com> | |
| I couldn't find a nice, fairly efficient implementation of serialize/unserialize for Python... so I wrote one. I didn't use str().partition because I wanted Python <2.5 compatibility. | |
| TODO: Performance review. There's an awful lot of string copying. >.> |
| import aiohttp | |
| import asyncio | |
| async def main(): | |
| session = aiohttp.ClientSession() | |
| ws = await session.ws_connect( | |
| 'wss://ws.example.com/channel') | |
| while True: | |
| msg = await ws.receive() |
| def get_right_img(image): | |
| # https://stackoverflow.com/a/6218425/7403042 | |
| if not hasattr(image, '_getexif'): | |
| return image | |
| image_exif = image._getexif() | |
| if not image_exif: | |
| return image | |
| image_orientation = image_exif[274] | |
| # Rotate depending on orientation. |
| #!/usr/bin/env bash | |
| GIT_WORK_TREE='..' | |
| while read oldrev newrev ref | |
| do | |
| echo "******************** $oldrev $newrev $ref *****************************" | |
| if [[ "$newrev" =~ ^0+$ ]]; then | |
| exit 0 | |
| fi | |
| echo "Commit ref received. Deploying ..." |
| #!/usr/bin/env bash | |
| CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
| echo "crreunt branch is $CURRENT_BRANCH" | |
| if [[ $CURRENT_BRANCH =~ ^[0-9]{2}-[0-9]{4}$ ]]; then | |
| ST=$(git st) | |
| if [[ $ST != *"nothing to commit"* ]]; then | |
| echo "commit and push" | |
| git ci -am "0" | |
| git push | |
| echo "finish push" |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| 解决mac下解压zip文件乱码问题 | |
| 代码参考: | |
| http://stackoverflow.com/questions/9431918/extracting-zip-file-contents-to-specific-directory-in-python-2-7 | |
| http://www.zhihu.com/question/20523036/answer/35225920 | |
| http://stackoverflow.com/questions/4917284/extract-files-from-zip-without-keeping-the-structure-using-python-zipfile | |
| 编码: https://docs.python.org/2.4/lib/standard-encodings.html |
| # -*- coding: utf-8 -*- | |
| import socket; | |
| from contextlib import closing | |
| socket.setdefaulttimeout(0.5) | |
| import socket | |
| from contextlib import closing | |
| def check_socket(host, port): |
| # -*- coding: utf-8 -*- | |
| from flask import Flask, request, abort | |
| app = Flask(__name__) | |
| @app.route('/') | |
| def index(): | |
| return 'Hello World' |