Skip to content

Instantly share code, notes, and snippets.

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"
####################################################################
# 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 / parser.rs
Last active May 18, 2019 15:56
Parser combinator in Rust (https://git.io/xml-parser-combinator)
#![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 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 / map_lctrl_plus_open_bracket_to_esc.json
Created September 4, 2018 16:18
Map Left-Control+Open-Bracket to Escape (Karabiner-Elements)
{
"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 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"
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++) {