Skip to content

Instantly share code, notes, and snippets.

Waiting for autumn

Wang Dàpéng wong2

Waiting for autumn
Block or report user

Report or block wong2

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
This class is defined to override standard pickle functionality
The goals of it follow:
-Serialize lambdas and nested functions to compiled byte code
-Deal with main module correctly
-Deal with other non-serializable objects
It does not include an unpickler, as standard python unpickling suffices.
# -*- coding: utf-8 -*-
core module, defines some extension instances etc.
from flask_sqlalchemy import SQLAlchemy
#: Flask-SQLAlchemy extension instance
db = SQLAlchemy()
wong2 / Rational.scala
Created Oct 22, 2014
"Programming Scala" Chapter 6
View Rational.scala
class Rational(n: Int, d: Int) {
require(d != 0)
private val g = gcd(n.abs, d.abs)
val numer: Int = n / g
val denom: Int = d / g
def this(n: Int) = this(n, 1)
wong2 / gunicorn_supervisor.conf
Created Dec 9, 2014
Minimal supervisor config file for gunicorn
View gunicorn_supervisor.conf
; Minimal sample supervisor config file.
; For more information on the config file, please see:
wong2 /
Created Mar 18, 2015
import os
import re
import sys
import requests
from gevent import monkey
from gevent.pool import Pool
wong2 /
Last active Aug 29, 2015
import re
import time
import json
import requests
from random import choice
code_url = '{phone}&callback=callback'
View .vimrc
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
filetype off
" git clone ~/.vim/bundle/Vundle.vim
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
wong2 /
Created Jun 18, 2011
SleepSort-Python using threading.Timer
from __future__ import print_function
from threading import Timer
l = [8, 2, 4, 6, 7, 1]
for n in l:
Timer(n, lambda x: print(x), [n]).start()
View gist:1318308
from cmd import Cmd
import os
import atexit
from user import User
import getpwd
import sys
# ls
wong2 / wong2.js
Created Jan 17, 2012
View wong2.js
* Copyright 2011 wong2 <>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
You can’t perform that action at this time.