Skip to content

Instantly share code, notes, and snippets.

Zeyi (Rice) Fan fanzeyi

Block or report user

Report or block fanzeyi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pre-commit.sh
#!/bin/sh
if [ $(git diff --cached | grep "debugger|console\.log" -E | grep -E "^\+" | wc -l) -gt 0 ]; then
echo "[Pre-commit check] Detected debug code in commit. Remove it!"
exit 1
fi
exit 0
@fanzeyi
fanzeyi / gist:18fc24a495c72a68e4b0
Last active Aug 29, 2015
Integrate SQLAlchemy with Enum34
View gist:18fc24a495c72a68e4b0
class Enum34(types.TypeDecorator):
impl = types.Integer
def __init__(self, enum_class, *args, **kwargs):
super(Enum34, self).__init__(*args, **kwargs)
self._enum_class = enum_class
def process_bind_param(self, value, dialect):
if value not in self._enum_class:
raise ValueError("Not a valid enum value")
View DoubanList.txt
[Adblock Plus 2.0]
! Version: 20141221
! Title: DoubanList
! Expires: 1 day (update frequency)
! Homepage: https://gist.github.com/fanzeyi/b69bff4c45f3dc9d44d0
!
douban.com##.lnk-doubanapp
douban.com##.get_douban_app
movie.douban.com###app-discuss
@fanzeyi
fanzeyi / chinese_district.py
Created Jan 10, 2015
integrate GB2260 with SQLAlchemy
View chinese_district.py
# -*- coding: utf-8 -*-
import gb2260
import sqlalchemy.types as types
class ChineseDistrict(types.TypeDecorator):
impl = types.Integer
def process_bind_param(self, value, dialect):
View code-check-exporter.user.js
// ==UserScript==
// @name Code Check Exporter
// @namespace https://zr.is/
// @version 0.5
// @description Export all files in code checker. (SJSU)
// @author Zeyi Fan (Zeray Rice)
// @match http://cs20.cs.sjsu.edu:8080/codecheck/*
// @grant none
// @require https://raw.githubusercontent.com/Stuk/jszip/v2.4.0/dist/jszip.min.js
// @updateURL https://gist.github.com/fanzeyi/c46ab3dc5319ac24b7f0/raw/code-check-exporter.user.js
View foo.php
?>
<!-- 恩哼 前面同学没有闭合标签哦 -->
@fanzeyi
fanzeyi / gist:630816
Created Oct 17, 2010
OpenFetion Error
View gist:630816
[20:39:15] ***ERROR*** Send a message to (SIP-C/4.0 280 Send SMS OK
T: sip:XXXXXXXX@fetion.com.cn;p=2538
I: 5
Q: 2 M
L: 114
D: Sun, 17 Oct 2010 12:43:05 GMT
XI: A067861FBFA94519BD92D92C2111472F
<results><quota-frequency><frequency name="send-sms" day-count="2" month-count="5"/> </quota-frequency></results>)`s mobile phone failed
View test.c
#include <stdio.h>
int main()
{
return 0;
}
View xxx_minutes_ago.js
function relative_time(time_value) {
var values = time_value.split(" ");
time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
var parsed_date = Date.parse(time_value);
var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
delta = delta + (relative_to.getTimezoneOffset() * 60);
if (delta < 60) {
return 'less than a minute ago';
@fanzeyi
fanzeyi / BN_add.c
Created Nov 10, 2010
高精度加法 来自openssl包
View BN_add.c
​​int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
{
const BIGNUM *tmp;
int a_neg = a->neg, ret;
bn_check_top(a);
bn_check_top(b);
/* a + b a+b
* a + -b a-b
You can’t perform that action at this time.