Skip to content

Instantly share code, notes, and snippets.

View vayn's full-sized avatar

Vayne Tsai vayn

View GitHub Profile
####################################################################
# Change the number of rows and columns to display in Launchpad #
# by typing the following two lines in Terminal. You can use any #
# two integers for the number of rows and columns. I'm using 15x10 #
####################################################################
defaults write com.apple.dock springboard-columns -int 15
defaults write com.apple.dock springboard-rows -int 10
####################################################################
# Reset all settings
@vayn
vayn / connectHTMLelements_SVG.png
Created May 6, 2019 15:05 — forked from alojzije/connectHTMLelements_SVG.png
Connect two elements / draw a path between two elements with SVG path (using jQuery)
connectHTMLelements_SVG.png
@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 / translatekeycodes.swift
Created November 13, 2016 12:20 — forked from ArthurYidi/translatekeycodes.swift
virtual key codes to unicode characters
func keyCodeToString(keyCode: CGKeyCode) -> String {
let curKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()
let ptr = TISGetInputSourceProperty(curKeyboard, kTISPropertyUnicodeKeyLayoutData)
let keyboardLayoutPtr = UnsafePointer<UCKeyboardLayout>(ptr)
var deadKeyState: UInt32 = 0
var actualStringLength = 0
var unicodeString = [UniChar](count: 255, repeatedValue: 0)
let status = UCKeyTranslate(keyboardLayoutPtr,
@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 / gist:f18dad1185f2e7da338b
Created December 23, 2015 02:31 — forked from ynechaev/gist:8123997
UITableViewCell popular animation (flipping around Y axis, depending on scroll direction)
@interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UIImageOrientation scrollOrientation;
CGPoint lastPos;
}
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView.isDragging) {
UIView *myView = cell.contentView;
CALayer *layer = myView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
@vayn
vayn / flask.py
Last active May 18, 2016 17:29 — forked from kageurufu/flask.py
Flask-WTF FieldLists with Dynamic Entries
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.wtf import Form
from flask.ext.babel import gettext
from wtforms import SelectField, TelField, TextField, FormField, Fieldlist, SubmitField
from wtforms.validators import Optional, Required
app = Flask(__name__)
db = SQLAlchemy(app)
@vayn
vayn / flask_static_files_cache_invalidator.py
Last active August 30, 2015 07:03 — forked from iximiuz/flask_static_files_cache_invalidator.py
Flask: add static file's cache invalidator param to URLs generated by url_for(). Blueprints aware.
""" Inspired by http://flask.pocoo.org/snippets/40/ """
app = Flask(__name__)
@app.url_defaults
def hashed_url_for_static_file(endpoint, values):
if 'static' == endpoint or endpoint.endswith('.static'):
filename = values.get('filename')
if filename:
if '.' in endpoint: # has higher priority
import time
class Marsaglia:
"""Pseduo-random generator
http://www.math.uni-bielefeld.de/~sillke/ALGORITHMS/random/marsaglia-c
"""
def __init__(self, i1=0, i2=0):
self.z = i1 or 362436069