This file contains hidden or 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 os | |
import sys | |
import ctypes | |
def is_loaded(lib): | |
libp = os.path.abspath(lib) | |
ret = os.system("lsof -p %d | grep %s > /dev/null" % (os.getpid(), libp)) |
This file contains hidden or 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 | |
u""" | |
为了省内存,分片将 MySQL 表导出为 CSV 格式。 | |
""" | |
import os | |
import argparse | |
from datetime import datetime |
This file contains hidden or 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
;;;;;;;;;;;;;;; Install Emacs24.4 ;;;;;;;;;;;;;; | |
;; wget http://ftp.gnu.org/gnu/emacs/emacs-24.4.tar.xz | |
;; tar Jxf emacs-24.4.tar.xz | |
;; cd emacs-24.4 | |
;; ./configure --with-x=no --with-x-toolkit=no --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no | |
;; make | |
;; sudo make install | |
(ido-mode) | |
(winner-mode) |
This file contains hidden or 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
######## Based on Debian 7 ######## | |
#### Node.js | |
# > https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager | |
sudo apt-get install curl | |
sudo curl -sL https://deb.nodesource.com/setup | bash - | |
sudo apt-get install -y nodejs | |
sudo npm config set registry https://registry.npm.taobao.org | |
sudo npm config get registry |
This file contains hidden or 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
import time | |
import math | |
# Retry decorator with exponential backoff | |
def retry(tries, delay=3, backoff=2): | |
'''Retries a function or method until it returns True. | |
delay sets the initial delay in seconds, and backoff sets the factor by which | |
the delay should lengthen after each failure. backoff must be greater than 1, | |
or else it isn't really a backoff. tries must be at least 0, and delay |
This file contains hidden or 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
import re | |
VAR_REGEXP = "[_A-Za-z][_a-zA-Z0-9]*$" | |
COLUMN_MARK = 'db.Column(' | |
DB_PREFIX = 'db.' | |
SA_PREFIX = 'sa.' | |
ALEMBIC_OP_NAME = 'op' | |
SQLALCHEMY_NAME = 'sa' | |
INDENT_1 = ' ' # 4 spaces |
This file contains hidden or 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 json | |
import requests | |
class Slack(object): | |
""" | |
References: |
This file contains hidden or 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 pymysql as mdb | |
def read_statement(fd): | |
lines = [] | |
while True: | |
line = fd.readline() | |
if not line: |
This file contains hidden or 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 | |
import sys | |
import json | |
import commands | |
import ConfigParser | |
def supervisor(CONFIG_PATH): |
This file contains hidden or 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 | |
import os | |
import sys | |
def main(wid): | |
arg_dict = {'wid': wid} | |
CMD_XWD = 'xwd -id %(wid)d -out %(wid)d.xwd' % arg_dict |