Skip to content

Instantly share code, notes, and snippets.

@wendal
wendal / reflect.py
Created October 25, 2013 07:42 — forked from huyng/reflect.py
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@wendal
wendal / cmd5.go
Last active September 2, 2016 07:19
在golang中使用cgo调用openssl库的md5方法
package main
// #include <stdlib.h>
// #include <openssl/md5.h>
// #cgo LDFLAGS: -lcrypto
import "C"
import (
"fmt"
"unsafe"
)
@wendal
wendal / gist:6342015
Last active December 21, 2015 17:39
配置私有的golang库地址 : 添加到$GOROOT/src/cmd/go/vcs.go 然后编译golang
// git.xwoods.org
{
prefix: "git.xwoods.org/",
re: `^(?P<root>git\.xwoods\.org/(?P<p>.*))$`,
ping: false,
repo: "[email protected]:{p}.git",
vcs : "git",
},
@wendal
wendal / FuckJob.java
Created August 21, 2013 15:37
演示通过nutz的@SetupBy启动quartz
package net.wendal.quartz;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class FuckJob implements Job {
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
@wendal
wendal / nginx.conf
Created August 8, 2013 14:55
通用的redis订阅接口, nginx+lua+redis
location =/subscribe {
send_timeout 365h;
content_by_lua "
local redis = require \"resty.redis\"
local red = redis:new()
red:connect(\"127.0.0.1\", 6379)
red:subscribe(ngx.var.arg_key)
local res, err = red:read_reply()
if res then
ngx.say(res)
@wendal
wendal / gist:5812060
Created June 19, 2013 06:27
通过NutType构建复杂的Json反序列化对象
Map<String, List<Province>> map = (Map<String, List<Province>>) Json.fromJson(NutType.mapStr(NutType.list(Province.class)), new FileReader("city.min.js"));
List<Province> provinces = map.values().iterator().next();
System.out.println(Json.toJson(provinces));
@wendal
wendal / gist:5682733
Created May 31, 2013 03:03
nutz ioc注入一个map
{
"xXX": {
"type" : "org.nutz.ioc.meta.map.XXX",
"fields" : {
"fuck" : {"age": "28", "abc": "kkkkk"}
}
}
}
/*fuck字段的类型是Map<String,String>*/
@wendal
wendal / gist:5627360
Created May 22, 2013 13:00
nginx lua模块下的 id转特殊路径
function id2path(IN)
local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
local now = 0
local len = 0
while IN>0 do
if len > 0 and math.mod(len,2) == 0 then
OUT="/"..OUT
end
I=I+1
IN,D=math.floor(IN/B),math.mod(IN,B)+1
@wendal
wendal / gist:5589738
Created May 16, 2013 06:19
查找同网段的linux主机
#!/usr/bin/python
'''
Created on 2013-4-20
@author: wendal
'''
import socket, threading, time
def main():
@wendal
wendal / gist:5319463
Last active July 21, 2018 02:22 — forked from anonymous/gist:5319452
golang,在windows下获取磁盘空间数据
package main
import (
"log"
"net/http"
"syscall"
"unsafe"
)
func main() {