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
#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
#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
#!/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
#!/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
#include<stdio.h> | |
typedef unsigned char * byte_pointer; | |
int showBigOrLittleEnd() | |
{ | |
int i = 0x01; | |
byte_pointer bp = (byte_pointer) &i; | |
if (bp[0] == 0x01) | |
return 1; |
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 gevent import monkey | |
monkey.patch_all() | |
import os | |
import tornado | |
import logging | |
import tornado.wsgi | |
import tornado.httpserver |
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 | |
def bubble_sort(sort_list): | |
length = len(sort_list) | |
while length > 1: | |
for i in range(1, length): | |
if sort_list[i] < sort_list[i-1]: | |
sort_list[i], sort_list[i-1] = sort_list[i-1],sort_list[i] |
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 | |
def quick_sort(sort_list): | |
if len(sort_list) <= 1: | |
return sort_list | |
m = sort_list[0] | |
return quick_sort(filter(lambda x: x<=m, sort_list[1:])) + [m] + \ | |
quick_sort(filter(lambda x: x>m, sort_list[1:])) |
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 | |
def insert_sort(array): | |
if len(array) <= 1: | |
return | |
for i in range(1, len(array)): | |
j = i |