Skip to content

Instantly share code, notes, and snippets.

Avatar

Vayne Tsai vayn

View GitHub Profile
View get_window_title.vbs
strCmd = "%COMSPEC% /c ping 192.0.2.1 -n 1 -w 1000 >nul"
Set shell = CreateObject("WScript.Shell")
shell.Run strCmd, 0, 1
WScript.Echo("Foreground window title: " & vbCrLf & GetForeWindowCaption())
Function GetForeWindowCaption()
Const WM_GETTEXT = &HD
Set DX = CreateObject("DynamicWrapperX")
DX.Register "user32", "GetForegroundWindow", "f=s", "r=l"
View Change Mac Launchpad Grid Layout
####################################################################
# 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
View parser.rs
#![allow(dead_code)]
#[derive(Clone, Debug, PartialEq, Eq)]
struct Element {
name: String,
attributes: Vec<(String, String)>,
children: Vec<Element>,
}
/// Time For A Trait
@vayn
vayn / connectHTMLelements_SVG.png
Created May 6, 2019 — forked from alojzije/connectHTMLelements_SVG.png
Connect two elements / draw a path between two elements with SVG path (using jQuery)
@vayn
vayn / map_lctrl_plus_open_bracket_to_esc.json
Created Sep 4, 2018
Map Left-Control+Open-Bracket to Escape (Karabiner-Elements)
View map_lctrl_plus_open_bracket_to_esc.json
{
"title": "Map Left-Control+Open-Bracket to Escape",
"rules": [
{
"manipulators": [
{
"description": "Bracket Rule [left_control + open_bracket]",
"type": "basic",
"from": {
"key_code": "open_bracket",
@vayn
vayn / README.md
Created May 13, 2017 — forked from jasonm23/README.md
Elixir mix oh-my-zsh completion plugin
View README.md

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 Dec 10, 2016 — forked from hzlzh/gist:eb87294712e78d4a96c4
Proxifier 走代理程序请求规则
View gist:ee855901f2626aee9d5ceb5b3ae7b7d8
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 Nov 13, 2016 — forked from ArthurYidi/translatekeycodes.swift
virtual key codes to unicode characters
View translatekeycodes.swift
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 Nov 1, 2016 — forked from venj/trans_gif.sh
convert video to gif
View trans_gif.sh
#!/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"
View survey_cracker.js
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++) {