Skip to content

Instantly share code, notes, and snippets.

View vayn's full-sized avatar

Vayne Tsai vayn

View GitHub Profile
# http://www.hawstein.com/posts/dp-novice-to-advanced.html
# d(i) = max{1, d(j)+1}, 其中j<i, A[j]<=A[i]
def longest_increasing_sequence(A):
n = len(A)
d = [0] * n
last_idx_to_this_one = [0] * n
length = 1
for i in range(0, n):
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var radios = Array.prototype.slice.call(document.querySelectorAll(".css-radio"))
var goods = radios.filter(function(element) {
return element.value >= 5;
});
for(var i = 0; i < goods.length; i++) {
@vayn
vayn / decrypt.py
Last active October 9, 2017 22:16
Example of PyCrypto AES decryption
import base64
import hashlib
import hmac
from Crypto.Cipher import AES
key = base64.decodebytes(b'v4QC6l4ttEogiBYvjLyvbA==')
nonce = base64.decodebytes(b'3iNVHJXuCfYoU9QP49DGqw==')
ct = base64.decodebytes(b'x9WM3Qy15Xw/2Z6pGVKXVA==')
@vayn
vayn / googleImageSearch.js
Created June 27, 2011 23:14
FireGestures script for google image search
/**
* Author:
* Vayn a.k.a. VT <vayn@vayn.de>
* http://vayn.is-programmer.com
*
* URL:
* http://p.vim-cn.com/cbG/js
*
* File: googleImageSearch.js
* Create Date: 2011年 06月 27日 星期一 09:29:57 CST
@vayn
vayn / README.md
Created May 13, 2017 04:53 — forked from jasonm23/README.md
Elixir mix oh-my-zsh completion plugin

Elixir Mix Oh-My-Zsh plugin

Copy the folder ./elixir_mix/ to ~/.oh-my-zsh/custom/plugins/ and add _elixir_mix to your .zshrc plugins list. e.g.

Example:

plugins=(
  autojump
 git
@vayn
vayn / gist:ee855901f2626aee9d5ceb5b3ae7b7d8
Last active December 10, 2016 09:41 — forked from hzlzh/gist:eb87294712e78d4a96c4
Proxifier 走代理程序请求规则
iTerm2; curl; git-remote-https; helpd; "Alfred 3"; idea; Thunder*; Terminal; php; Dropbox; Sparrow; "Sequel Pro"; python; python3; ruby; wget; GitHub; npm; node; perl; prl*; itunes; sftp; whois; traceroute; stroke; ssh; MacUpdate*; git*; Git; fzs*; mail; flickr*; xulr*; imess*; com.apple.im*; Airmail; Adium; Prot*; Tokens; Lite*; file*; ssh; ftp; Adobe*; PDApp*; Creative*; Vbox*; xulrunner; Virtual*; PDApp; Bit*; Domainers; fire*; plugin*; Atom*; Tokens; .com.realmacsoftware*; Xcode; java; httpd; Amethyst; Moom;
@vayn
vayn / trans_gif.sh
Created November 1, 2016 04:05 — forked from venj/trans_gif.sh
convert video to gif
#!/bin/sh
# Convert video to gif.
if [[ $# -ne 3 ]]; then
echo "Usage: trans_gif source.mp4 target.gif 300"
exit 1
fi
palette="/tmp/palette.png"
filters="fps=15,scale=$3:-1:flags=lanczos"
@vayn
vayn / gunicorn_start.sh
Created October 9, 2016 12:53
Django+Supervisor+Gunicorn
#!/bin/bash
NAME="myproject"
VIRTURLROOT=/home/ubuntu/.virtualenvs/hezhi
DJANGODIR=/var/www/hezhi
SOCKFILE=/var/www/hezhi/run/gunicorn.sock
USER=ubuntu
GROUP=ubuntu
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=hezhi.settings.dev
@vayn
vayn / gunicorn_start.sh
Last active October 1, 2016 18:28
django, gunicorn, supervisor, virtualenvwrapper settings
#!/bin/bash
NAME="hezhi" # Name of the application
PYTHONPATH=/home/ubuntu/.virtualenvs/hezhi/bin/python3 # Python path
DJANGODIR=/var/www/hezhi # Django project directory
SOCKFILE=/var/www/hezhi/run/gunicorn.sock # we will communicte using this unix socket
USER=ubuntu # the user to run as
GROUP=ubuntu # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hezhi.settings # which settings file should Django use, change to
@vayn
vayn / big_num_div.c
Created May 11, 2011 03:56
大整数除法
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MAX_LEN 200
char szLine1[MAX_LEN + 10];
char szLine2[MAX_LEN + 10];
int an1[MAX_LEN + 10];
int an2[MAX_LEN + 10];
int aResult[MAX_LEN + 10];