This file contains hidden or 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
-- author: shiweifu | |
-- mail: [email protected] | |
cjson = require("cjson") | |
function load_json_db( db_name ) | |
local f = io.open(db_name) | |
local s = f:read("*a") | |
f:close() | |
return cjson.decode(s) |
This file contains hidden or 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
LANG="zh_CN.UTF-8" | |
LC_COLLATE="zh_CN.UTF-8" | |
LC_CTYPE="zh_CN.UTF-8" | |
LC_MESSAGES="zh_CN.UTF-8" | |
LC_MONETARY="zh_CN.UTF-8" | |
LC_NUMERIC="zh_CN.UTF-8" | |
LC_TIME="zh_CN.UTF-8" | |
LC_ALL= |
This file contains hidden or 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
local upload = require "resty.upload" | |
local cjson = require "cjson" | |
local resty_md5 = require "resty.md5" | |
local chunk_size = 4096 -- should be set to 4096 or 8192 | |
-- for real-world settings | |
local form = upload:new(chunk_size) | |
local data = "" |
This file contains hidden or 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 python | |
import os | |
import sys | |
#cmd = """curl http://localhost:8082/apiv1/msgadmin --data \"title=%s&content=content&desc=%s&icon=http://a1.phobos.le/b7/3f/8b/mzi.hztheuez.100x100-75.jpg&type=1&action=add&type_data={\"data\": {\"sort\": \"1\", \"title\": \"Naruto\", \"vip\": \"0\", \"tag\": \"pp_naruto\", \"icon\": \"http://a1.phobos.apple.com/us/r1000/010/Purple/b7/3f/8b/mzi.hztheuez.100x100-75.jpg\"}, \"content_type\": 1}&appname=%s\"}\"}\"""" | |
cmd = """curl http://localhost:8082/apiv1/msgadmin --data \"title=%s&content=content&desc=%s&icon=http://a1.phobos.le/b7/3f/8b/mzi.hztheuez.100x100-75.jpg&type=1&action=add&type_data={\\\"\"data\\\"\": {\\\"\"sort\\\"\": \\\"\"1\\\"\", \\\"\"title\\\"\": \\\"\"Naruto\\\"\", \\\"\"vip\\\"\": \\\"\"0\\\"\", \\\"\"tag\\\"\": \\\"\"pp_naruto\\\"\", \\\"\"icon\\\"\": \\\"\"http://a1.phobos.apple.com/us/r1000/010/Purple/b7/3f/8b/mzi.hztheuez.100x100-75.jpg\\\"\"}, \\\"\"content_type\\\"\": 1}&appname=%s&lang=ja\"""" |
This file contains hidden or 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
function objToString (obj) { | |
var str = ''; | |
for (var p in obj) { | |
if (obj.hasOwnProperty(p)) { | |
str += p + '::' + obj[p] + '\n'; | |
} | |
} | |
return str; | |
} |
This file contains hidden or 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
function isUrl(s) { | |
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ | |
return regexp.test(s); | |
} |
This file contains hidden or 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> | |
#include <time.h> | |
int main(int argc, const char *argv[]) | |
{ | |
/*time_t t = time(NULL);*/ | |
time_t t = 1346122873; | |
printf("%s\n", ctime(&t)); | |
return 0; |
This file contains hidden or 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 randstr(l): | |
s = ["chr(randint(65, 90))", #A-Z | |
"chr(randint(97, 122))", #a-z | |
"str(randint(0,9))"] #0-9 | |
return "".join([eval(s[randint(0, len(s)-1)]) for x in xrange(l)]) |
This file contains hidden or 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 python | |
#coding: utf-8 | |
#author: shiweifu | |
#mail : [email protected] | |
import os | |
def fork_process(cmd, args, env): | |
child_pid = os.fork() |
This file contains hidden or 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 functools | |
from urllib2 import * | |
TEMPLATE_PATH = ['./', './views/'] | |
TEMPLATES = {} | |
#------------------------------------------utils------------------------------------------ | |
def tob(s, enc='utf8'): | |
return s.encode(enc) if isinstance(s, unicode) else bytes(s) |