Skip to content

Instantly share code, notes, and snippets.

View fanzeyi's full-sized avatar

Zeyi (Rice) Fan fanzeyi

View GitHub Profile
@thedod
thedod / README
Created March 6, 2011 13:51
Webpy CSRF protection (request for comments)
A simple trick against CSRF for web.py (webpy.org)
* At the GET() template, you add a hidden field called csrf_token with value "$csrf_token()"
* The POST() should have the @csrf_protected decorator
That's it.
Request for comments:
* Is this secure? Can you see any holes?
* Is there anything in [or for] web.py that does this? Am I reinvevting the wheel here?
@chuangbo
chuangbo / cidr.py
Created August 13, 2012 09:45
Check if ip in cidr
#-*- coding:utf-8 -*-
# Author: @chuangbo
# For: @likexian
import socket
import struct
class CIDR:
'''Check if ip in cidr
@fanzeyi
fanzeyi / .vimrc
Last active December 21, 2015 15:19
" Zeray Rice's New Vimrc
" Created: Augest 24, 2013
" ===============
" Vundle
" ===============
set nocompatible
filetype off
@CMGS
CMGS / websocket.py
Created May 2, 2012 03:41
websocket hybi3 support with gunicorn and gevent
import collections
import errno
import re
from hashlib import md5, sha1
import base64
from base64 import b64encode, b64decode
import socket
import struct
import logging
@tonyseek
tonyseek / conrotine_task_manager.py
Created April 26, 2012 05:39
The demo of a corotine task manager.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from Queue import Queue
# ---------------------
# Corotine Task Manager
# ---------------------
@upsuper
upsuper / Makefile
Created March 21, 2012 10:54
中文C编程
CFLAGS=-fextended-identifiers -std=c99
objects=chinese.ucn.o
target=chinese
.PHONY: all clean
all: $(target)
$(target): $(objects)
$(CC) $< -o $@
@fanzeyi
fanzeyi / fanfou.py
Created November 17, 2011 04:53
Fanfou OAuth for Tornado
# -*- coding: utf-8 -*-
# author: Zeray Rice <fanzeyi1994@gmail.com>
import urllib
import logging
import tornado.auth
from tornado import escape
from tornado import httpclient
@disinfeqt
disinfeqt / LESS.css
Created March 7, 2011 15:44
CSS3 Buttons Made Easy
@start: #9bce4c; @end: #6f9f27;
.button-gradient (@start, @end);
&:hover {
.button-gradient (darken(@start, 2%), darken(@end, 2%));
}
&:active {
.button-gradient (darken(@end, 2%), darken(@start, 2%));
}
@zhasm
zhasm / fanfou.py
Created February 24, 2011 04:13
fanfou sdk draft in python, basic auth.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename test.py
#created: 2010-12-18 22:42
import re
import pycurl
import json