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/env lua | |
local phone_dat = "phone.dat" | |
function getPhoneType(a) | |
if a == 1 then | |
return "移动" | |
elseif a == 2 then | |
return "联通" | |
elseif a==3 then |
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/env lua | |
function byteToUint32(a,b,c,d) | |
local _int = 0 | |
if a then | |
_int = _int + bit32.lshift(a, 24) | |
end | |
_int = _int + bit32.lshift(b, 16) | |
_int = _int + bit32.lshift(c, 8) | |
_int = _int + d |
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 time | |
__author = 'haifang' | |
def count_function_time(): | |
def wraps(function): | |
function.CUR_TIME = time.time() | |
def log_time(point): |
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 | |
# http://stackoverflow.com/questions/2719017/how-to-set-timeout-on-pythons-socket-recv-method | |
# http://stackoverflow.com/questions/16745409/what-does-pythons-socket-recv-return-for-non-blocking-sockets-if-no-data-is-r | |
import select | |
import socket | |
def receive(s): |
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 | |
default_user="vpn" | |
default_password="123456" | |
read -p "Input VPN username:(default is ${default_user})" user | |
read -p "Input VPN password:(default is ${default_password})" password | |
if [ $user=="" ];then | |
user=$default_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
import sys | |
def producer(): | |
while True: | |
line = sys.stdin.readline() | |
yield line | |
def consumer(p): | |
line = p.next() |
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/local/bin/lua | |
function producer() | |
return coroutine.create(function() | |
while true do | |
local line = io.read() | |
coroutine.yield(line) | |
end | |
end) | |
end |
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/local/bin/lua | |
local socket = require "socket" | |
function receive(c) | |
c:settimeout(0) --> 不阻塞 | |
local s,status,partial = c:receive(2^10) | |
if status == "timeout" then | |
coroutine.yield(c) | |
end |
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 os | |
## block cc攻击 的ip | |
CMD = "netstat -ntup | grep -v SYN |awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr" | |
MAX_CONN = 50 | |
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 | |
from tornado.web import RequestHandler | |
import redis | |
def getRedisObj(rdb=0): | |
pool = redis.ConnectionPool( | |
host='127.0.0.1', password='', port=6379, db=rdb, socket_timeout=3) | |
r = redis.Redis(connection_pool=pool) |