Skip to content

Instantly share code, notes, and snippets.

View wong2's full-sized avatar
🍃
Waiting for autumn

wong2 wong2

🍃
Waiting for autumn
View GitHub Profile
@wong2
wong2 / cloudpickle.py
Created February 28, 2014 08:53
存一份
"""
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
wong2 / Rational.scala
Created October 22, 2014 10:02
"Programming Scala" Chapter 6
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
wong2 / gunicorn_supervisor.conf
Created December 9, 2014 05:56
Minimal supervisor config file for gunicorn
; Minimal sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
[inet_http_server]
port=127.0.0.1:9001
username=user
password=password
@wong2
wong2 / downlist.py
Created March 18, 2015 06:51
下载网易云音乐歌单
#-*-coding:utf-8-*-
import os
import re
import sys
import requests
from gevent import monkey
monkey.patch_all()
from gevent.pool import Pool
@wong2
wong2 / main.py
Last active August 29, 2015 14:24
遍历友宝免费冰红茶兑换码
#-*-coding:utf-8-*-
import re
import time
import json
import requests
from random import choice
code_url = 'http://ama.adwo.com/advmessage/adv/addResultJsonP.action?advid=30345&mobile={phone}&callback=callback'
@wong2
wong2 / .vimrc
Created September 18, 2015 08:41
" 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 https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
@wong2
wong2 / sleepsort.py
Created June 18, 2011 05:43
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()
#-*-coding:utf-8-*-
from cmd import Cmd
import os
import atexit
from user import User
import getpwd
import sys
# ls
@wong2
wong2 / wong2.js
Created January 17, 2012 06:09
备份。。
/**
* Copyright 2011 wong2 <wonderfuly@gmail.com>
*
* 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