Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am booxood on github.
  • I am azm (https://keybase.io/azm) on keybase.
  • I have a public key ASDYbcLc2qja24aN4TbqTUXOX7oFnEXe-QaFHJWxemvl2go

To claim this, I am signing this object:

@booxood
booxood / rAF.js
Created July 18, 2017 07:13 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to make opened Markdown files always be soft wrapped:
#
# path = require 'path'
#
@booxood
booxood / console.reset.js
Created February 27, 2015 04:33 — forked from 19h/reset.js
console.reset = function () {
return process.stdout.write('\033c');
}
@booxood
booxood / event.js
Created December 4, 2013 16:18
node.js EventEmitter
var util = require('util');
var event = require('events').EventEmitter;
function f(){
// event.call(this);
}
// util.inherits(f, event);
f.prototype = new event();
var ff = new f();
@booxood
booxood / python-django-TestCase.py
Last active December 26, 2015 12:39
django test case add session,cookies 使用django测试框架,模拟web请求时,带session,cookies。
from django.test import TestCase
from django.conf import settings
from django.utils.importlib import import_module
class SessionTestCase(TestCase):
def setUp(self):
# http://stackoverflow.com/questions/4453764/how-do-i-modify-the-session-in-the-django-test-framework
# http://code.djangoproject.com/ticket/10899
# settings.SESSION_ENGINE = 'django.contrib.sessions.backends.file' #use django settings
@booxood
booxood / inherist.js
Created October 23, 2013 04:03
js inherist call apply prototype
var ClassA = function(name){
this.name = name || 'no name';
};
ClassA.prototype.sayName = function(){
console.log('say name:' + this.name);
};
var ClassB = function(name, age){
// this.new = ClassA;
@booxood
booxood / qr.py
Created September 10, 2013 03:16
二维码的编码和解码。采用了python的qrcode,zbar。
#!/usr/bin/env python
# coding: utf-8
#for encode: pip install qrcode
import qrcode
#for decode: pip install zbar
#如果报找不到zbar.h,则先安装libzbar-dev
import zbar
@booxood
booxood / python-yield.py
Last active December 22, 2015 12:28
python yield Fibonacci
#返回一个list
#如果list很大,会占用很多内存
def fab(max):
f = []
n, a, b = 0, 0, 1
while n < max:
f.append(b)
a, b = b, a+b
n += 1
return f