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
#!/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
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
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
-- 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
#!/usr/bin/env python | |
#coding: utf-8 | |
#author: shiweifu | |
#mail : [email protected] | |
import logging |
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
UA_LIST = [a.split("\n")[0].strip() for a in open("user_agent", "r").readlines()] | |
random_value = lambda lst: random.randint(0, len(lst)) | |
def down_page(url): | |
global UA_LIST | |
headers = { "User-Agent" : random_value(UA_LIST)} | |
req = urllib2.Request(url, headers=headers) | |
response = urllib2.urlopen(req) | |
the_page = response.read() |
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
w3m/0.4.1 | |
Emacs-w3m/1.4.4 w3m/0.5.1+cvs-1.946 | |
Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; MSN Companion 2.0; 800x600; Compaq) | |
DonutP; Windows98SE | |
MoonBrowser (version 0.41 Beta4) | |
Moonbrowser - IE based browser (Japan) | |
Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; MSN Companion 2.0; 800x600; Compaq) | |
Mozilla/1.1 (compatible; MSPIE 2.0; Windows CE) | |
Mozilla/1.22 (compatible; MSIE 2.0d; Windows NT) | |
Mozilla/2.0 (compatible; MSIE 2.1; Mac_PowerPC) |
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
-- trim implementations | |
function trim1(s) | |
return (s:gsub("^%s*(.-)%s*$", "%1")) | |
end | |
-- from PiL2 20.4 | |
function trim2(s) | |
return s:match "^%s*(.-)%s*$" | |
end |
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 main() | |
regex = [[false"><a title="(.-)"%starget=".-"%shref="(.-)%.html"]] | |
f = io.open("test.html", "r") | |
html = f:read("*a") | |
f:close() | |
s_idx, e_idx, title, url = string.find(html, regex, 0) |