Skip to content

Instantly share code, notes, and snippets.

View fanzeyi's full-sized avatar

Zeyi (Rice) Fan fanzeyi

View GitHub Profile
@fanzeyi
fanzeyi / ses.py
Created January 11, 2012 16:46
session for tornado
import os
import uuid
import marshal
import binascii
import tornado.web
def Session(func):
def warpper(self, *args, **kwargs):
" VIM配置文件
" 设置语言及编码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set enc=utf-8
" set fencs=utf-8,ucs-bom,gbk,gb18030,shift-jis,gb2312,cp936
" 常规设置
set nocompatible " 关闭vi兼容模式
@fanzeyi
fanzeyi / example.rb
Created January 28, 2012 09:09
Fanfou OAuth SDK Ruby Ver.
# -*- coding: utf-8 -*-
require 'fanfou'
a = Fanfou::Fanfou::new('xxx', 'xxx')
a.get_authorize_url
a.get_access_token(a.request_token.token, a.request_token.secret, VERIFIER) # get from authorize url
a.fanfou_request '/statuses/home_timeline'
a.fanfou_request('/statuses/user_timeline', args = {:id => 'fanzeyi'})
a.fanfou_request('/statuses/update', post_args = {:status => 'Hello'})
@fanzeyi
fanzeyi / awesome.lua
Created February 12, 2012 05:03
awesome
-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
naughty.config.default_preset.width = 400
```C
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Hello!");
return 0;
}
```
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <libgen.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/types.h>
@fanzeyi
fanzeyi / dns_resolve.py
Created March 13, 2012 07:16
dns_resolve
import os
import re
import socket
import struct
def dns_resolve(host, dnsserver):
assert isinstance(host, basestring) and isinstance(dnsserver, basestring)
index = os.urandom(2)
hoststr = ''.join(chr(len(x))+x for x in host.split('.'))
data = '%s\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00%s\x00\x00\x01\x00\x01' % (index, hoststr)
@fanzeyi
fanzeyi / recaptcha.py
Created March 16, 2012 08:42
test for reCAPTCHA
#!/usr/bin/env python
import logging
import urllib
from tornado.auth import httpclient
class RecaptchaMixin(object):
"""
Example usage::
Request Header:
GET ws://localhost:8000/ HTTP/1.1
Origin: http://localhost
Connection: Upgrade
Host: localhost:8000
Sec-WebSocket-Key: 1K90MdhASDkOc0/yEpSPPQ==
Upgrade: websocket
Sec-WebSocket-Version: 13