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 | |
cd /opt/nginx-1.4.0/logs/ | |
#分解旧日志 | |
mkdir -p mysite | |
gawk '{ | |
dt=substr($4,2,11); | |
gsub(/\//," ",dt); | |
"date -d \""dt"\" +%Y%m%d"|getline dd; | |
print $0 >> "mysite/mysite.access.log-"dd |
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
#生效 | |
#nginx -s reload | |
log_format sess '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for" "$var_sessid"'; | |
server { | |
listen 80; |
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
#添加用户ryan,Samba不依赖于系统用户 | |
#gpasswd -a ryan | |
#生效 | |
#/etc/init.d/smbd restart | |
[global] | |
workgroup = WORKGROUP | |
server string = Smaba %V | |
hosts allow = 192.168.0. | |
security = user |
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/rsync -vzrtopg --progress /home/ryan/apps/* \ | |
# [email protected]::apps --password-file=/home/ryan/bin/rsync.pass | |
pid file = /var/run/rsyncd.pid | |
port = 873 | |
address = 192.168.1.23 | |
uid = root | |
gid = root |
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
" 粘贴模式 | |
set paste | |
" 设定配色方案 | |
" colorscheme molokai | |
" 显示行号 | |
set nu | |
" 突出显示当前行 | |
" set cursorline | |
" 用浅色高亮当前行 | |
autocmd InsertEnter * se cul |
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
# -*- coding:utf-8 -*- | |
#CPython | |
def get_mac_addr(): | |
""" 获得本机网卡物理地址 """ | |
import uuid | |
node = uuid.getnode() | |
mac = uuid.UUID(int=node) | |
addr = mac.hex[-12:] | |
return addr |
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
# -*- coding:utf-8 -*- | |
#用于Python List类型的去重复,并保持元素原有次序 | |
def unique_list(seq, excludes=[]): | |
""" | |
返回包含原列表中所有元素的新列表,将重复元素去掉,并保持元素原有次序 | |
excludes: 不希望出现在新列表中的元素们 | |
""" | |
seen = set(excludes) # seen是曾经出现的元素集合 | |
return [x for x in seq if x not in seen and not seen.add(x)] |
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
# -*- coding: utf-8 -*- | |
""" | |
需要存放IP段起止地址的二进制文件cnips.dat | |
""" | |
import os, os.path | |
from IPy import IP | |
def binary_search(total, callback, *args): |
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
<?php | |
/* | |
需要存放IP段起止地址的二进制文件cnips.dat | |
*/ | |
/** | |
* 二分(折半)查找算法 | |
*/ | |
function binary_search($total, $callback) | |
{ |
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
# -*- coding: utf-8 -*- | |
import hashlib | |
def md5hex(word): | |
""" MD5加密算法,返回32位小写16进制符号 """ | |
if isinstance(word, unicode): | |
word = word.encode("utf-8") | |
elif not isinstance(word, str): |
OlderNewer