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
class Host(db.Model): | |
__tablename__ = 'hosts' | |
host_id = db.Column(db.Integer, primary_key=True, autoincrement=True) | |
_ip = db.Column("ip", db.Integer, nullable=False) | |
port = db.Column(db.Integer, nullable=False) | |
user = db.Column(db.String(64), nullable=False) | |
_password = db.Column("password", db.Text, nullable=False) | |
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/bash | |
process_pool(){ | |
# | |
if [ $# -lt 3 ]; then | |
echo "$0 process_num command [args]" | |
return 1 | |
fi | |
_process_num=$1 | |
shift |
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/python | |
# encoding=utf-8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf-8') |
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
openssl genrsa -des3 -out ca.key 2048 #生成跟证书私钥 | |
openssl req -new -x509 -days 365 -key ca.key -out ca.crt #生成根证书 | |
openssl genrsa -des3 -out ${name}.key 2048 #生成私钥 | |
openssl req -new -key ${name}.key -out ${name}.csr #生成证书请求文件 | |
openssl x509 -req -in ${name}.csr -out ${name}.crt -sha1 -CA ca.crt -CAkey ca.key -CAcreateserial -days 365 #自签名 |
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
import os | |
import fcntl | |
import subprocess | |
def non_block_read(output): | |
fd = output.fileno() | |
fl = fcntl.fcntl(fd, fcntl.F_GETFL) | |
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) | |
try: | |
return output.read() |
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
if val, ok := dict["key"]; ok { | |
// do some things | |
} |
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
stop slave; | |
set global sql_slave_skip_counter=1; | |
start slave; |
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
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM information_schema.TABLES WHERE TABLE_SCHEMA='${database_name}' AND TABLE_NAME='${table_name}'; |
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
function flatten(target, opts = {delimiter: '.'}) { | |
let output = {}; | |
function step(object, prev = '') { | |
Object.keys(object).forEach(key => { | |
let value = object[key]; | |
let outKey = prev.length > 0? `${prev}${opts.delimiter}${key}`: key; | |
if (typeof value === 'object') { | |
return step(value, outKey) | |
} |
OlderNewer