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 | |
VERSION="2.6.2" | |
ARCHIVE=redis-${VERSION}.tar.gz | |
if [ -z "${VIRTUAL_ENV}" ]; then | |
echo "Please activate a virtualenv first"; | |
exit | |
fi |
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
def txt2html(txt): | |
'''将txt以行为单位加上<li></li>标签''' | |
def escape(txt): | |
'''将txt文本中的空格、&、<、>、(")、(')转化成对应的的字符实体,以方便在html上显示''' | |
txt = txt.replace('&','&') | |
txt = txt.replace(' ',' ') | |
txt = txt.replace('<','<') | |
txt = txt.replace('>','>') | |
txt = txt.replace('"','"') | |
txt = txt.replace('\'',''') |
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 sys | |
pid = str(os.getpid()) | |
pidfile = "/tmp/pidfilename.pid" | |
if os.path.isfile(pidfile): | |
print "%s already exists, exiting" % pidfile | |
sys.exit() | |
else: |
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
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$.ajax({ | |
url: "/ajax_url", | |
type: "POST", | |
data: { | |
"dataname": data | |
}, | |
dataType: "json", | |
success:function(data_info){ |
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 config | |
import logging | |
from logging.handlers import TimedRotatingFileHandler | |
logger = logging.getLogger(config.LOG_NAME) | |
logfile = '%s/%s' % (config.LOG_BASE_PATH, config.LOG_FILENAME) | |
fileTimeHandler = TimedRotatingFileHandler(logfile, "midnight", 1) | |
fileTimeHandler.suffix = "%Y%m%d.log" # 设置切分后日志文件名格式 |
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
filename = "%s_attack_report.xls" % file_to_download | |
f = open(filename, "r") | |
self.set_header('Content-Type', 'text/csv') | |
self.set_header('Content-Disposition', 'attachment; filename=' + filename + '') | |
self.write(f.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
crontab -l > cron.tmp | |
echo "0 0 */1 * * /path/to/script.sh" >> cron.tmp | |
crontab cron.tmp | |
rm -f cron.tmp |
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 | |
# chkconfig: 2345 55 25 | |
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and | |
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your | |
# distro. For CentOS/Redhat run: 'chkconfig --add nginx' | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all |
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
/** | |
* 对日期进行格式化, | |
* @param date 要格式化的日期 | |
* @param format 进行格式化的模式字符串 | |
* 支持的模式字母有: | |
* y:年, | |
* M:年中的月份(1-12), | |
* d:月份中的天(1-31), | |
* h:小时(0-23), | |
* m:分(0-59), |
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 | |
# Copyright 2013 Percona LLC and/or its affiliates | |
set -e | |
if [ -z "$3" ]; then | |
echo "rename_db <server> <database> <new_database>" | |
exit 1 | |
fi | |
db_exists=`mysql -h $1 -e "show databases like '$3'" -sss` | |
if [ -n "$db_exists" ]; then | |
echo "ERROR: New database already exists $3" |
OlderNewer