Skip to content

Instantly share code, notes, and snippets.

/**************************************
* Header Counters in TOC
**************************************/
/* No link underlines in TOC */
.md-toc-inner {
text-decoration: none;
}
.md-toc-content {
@RexKang
RexKang / tools.py
Last active October 24, 2015 11:48 — forked from akhenakh/tools.py
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
raise ImportError
import datetime
from bson.objectid import ObjectId
from werkzeug.wrappers import Response
@RexKang
RexKang / get_sys_info.sh
Created April 28, 2014 00:23
获得机器信息的脚本
#!/bin/bash
#
#检测是否是root用户
if [ `id -u` -ne 0 ]
then
echo '请使用root用户启动该脚本!';
exit 11;
fi
@RexKang
RexKang / apache_log_analyze.sh
Last active August 29, 2015 14:00
Apache日志统计脚本
# 统计访问次数最多的前十名IP
awk '$0 !~/::1/&&$0 !~/127.0.0.1/{ip[$1]++}END{for(i in ip){print ip[i],i}}' access_log|sort -rn|head
# 统计访问次数最多的URL
awk '$0 !~/::1/&&$0 !~/127.0.0.1/{a[$7]++}END{for(i in a){print a[i]":"i }}' access_log|sort -rn|head
@RexKang
RexKang / commonlib.py
Last active August 29, 2015 13:57
Common functions for Python
#!/bin/env python
# -*- coding=utf-8 -*-
def is_ip(ip_str):
import re
pattern = r"\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9] \
|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25\
[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
if re.match(pattern,ip_str):
return True