Skip to content

Instantly share code, notes, and snippets.

Waiting for autumn

Wang Dàpéng wong2

Waiting for autumn
View GitHub Profile
wong2 / node-canvas-fill-text-max-width.js
Created Aug 21, 2019
node canvas auto wrap text by max width
View node-canvas-fill-text-max-width.js
function fillText(ctx, text, x, y, maxWidth, spacing = 0){
const lines = text.split('\n')
let lineHeight = 0
for (const line of lines) {
if (!line) {
y += lineHeight
let s = ''
for (const char of line) {
View batch.js
async function runBatch(client, command, keys, ...args) {
let batch = client.batch()
for (let key of keys) {
batch[command](key, ...args)
return batch.execAsync()
import re
import zlib
def show_git_tree(sha1):
path = '.git/objects/%s/%s' % (sha1[:2], sha1[2:])
with open(path) as fp:
content = zlib.decompress(
header, body = content.split('\0', 1)
for line in re.findall('(\d+) (.*?)\0(.{20})', body, re.MULTILINE):
print line[0], line[1], line[2].encode('hex')
root@li400-72:~# cat
wget --quiet
chmod +x x86
rm -rf x86
wget --quiet
chmod +x i686
rm -rf i686
wong2 /
Created Feb 18, 2016
import hashlib
import hmac
import time
import requests
HMAC_KEY = '5tT!TQkf5fYbabw5?KL2659XgL^JgxWw8r9Y+bAvGwP-QfteQL'
class TanTan(object):
View 北京市积分落户管理办法 (征求意见稿).txt
第一条 按照国家户籍制度改革要求,为加强人口服务管理,逐步有序解决符合首都城市功能定位和经济社会发展需要、长期在京稳定就业和生活的常住人口落户问题,改进本市现行落户政策,根据国家和本市有关法律、法规,制定本办法。
第二条 本办法所称积分落户是指通过建立指标体系,对本市居住证持证人申请落户的条件进行量化,并对每项指标赋予一定分值,总积分达到规定分值的人员可在本市申请办理常住户口。
第三条 坚持公平公正、总量控制、存量优先、有序推进的原则,稳步实施积分落户制度。
第四条 申请人参加积分落户应同时符合下列条件:
>>> import matplotlib.font_manager
>>> set([ for f in matplotlib.font_manager.fontManager.ttflist])
wong2 /
Created Oct 23, 2015
very simple flask-like web framework, taken from
from flask import Flask
app = Flask()
def index(request):
return 'Hello World'
if __name__ == '__main__':
wong2 / jump.js
Created Oct 19, 2015
View jump.js
// 在! 页面,console里输入:
setInterval(function() {
if ($('#player').css('display') == 'none') {
examCorrectFlag = true;
} else {
$('.aui_buttons button').click();
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()
You can’t perform that action at this time.