Skip to content

Instantly share code, notes, and snippets.

View dylan-chong's full-sized avatar
💧
Elixiring

Dylan Chong dylan-chong

💧
Elixiring
View GitHub Profile
@dylan-chong
dylan-chong / grab-options.sh
Created June 30, 2018 05:49
Grab --options from a help page
#!/bin/bash
options_for_command() {
git help $1 \
| tr " " "\n" \
| egrep '^\--.*$' \
| egrep -v '/' \
| egrep -v '\-{3,}' \
| egrep -v '{|}' \
| perl -pe 's/\[=.*\]//' \
| perl -pe 's/[^\w=\n\[\]<>-]//' \
@dylan-chong
dylan-chong / update-preview.applescript
Created May 19, 2018 03:28
Open Preview.app so that it updates its view on the image then switch back to previous application
on run {input, parameters}
global currentProcess
tell application "System Events"
--set currentProcess to the name of the first process where it is frontmost
set currentProcess to (path to frontmost application as text)
end tell
activate application "Preview"
@dylan-chong
dylan-chong / autogen-plantuml.vim
Created May 13, 2018 11:17
Vim auto generate plantuml on save
au BufWritePost *.plantuml :silent !plantuml % &
import time
start = time.time()
def time_left():
global start
return 5 * 60 - (time.time() - start)
git clone https://github.com/google/volley/
cd volley
need SYSfirst
need android
setenv ANDROID_HOME $ANDROID_SDK_HOME
# Now you have to open this android studio project, wait for it to finish loading, and then close it
./gradlew test
google-chrome build/reports/tests/testReleaseUnitTest/release/index.html
wcme() {
NAME=`git config user.name`
git blame "$1" \
| egrep "\($NAME" \
| egrep -v '<!--' \
| perl -pe 's/.*\d+\)(.*)/\1/' \
| wc -w
}
wcme file.md # => 123
@dylan-chong
dylan-chong / typeracer-hack.js
Last active March 25, 2018 10:27
Typeracer hack
// Run this in the console just before the countdown timer goes from "1" to "9"
// then wiggle the mouse over the text input
// (it helps if you zoom in in the browser to increase the input element size)
var charsPerIteration = 5;
var maxPressesPerSecond = 32;
var charsBeforeBackoff = 20;
var backoffDelayPerChar = 50;
var textElems = [].slice.call($("[unselectable='on']").parentNode.children);
on run {input, parameters}
global currentProcess
tell application "System Events"
--set currentProcess to the name of the first process where it is frontmost
set currentProcess to (path to frontmost application as text)
end tell
activate application "VirtualBoxVM"
@dylan-chong
dylan-chong / perl-multiline.sh
Created January 9, 2018 23:10
Perl find and replace across multiple lines
# File
echo 'A' > test-file
echo 'B' >> test-file
perl -i -0 -pe 's/A\nB/REPLACEMENT/g' test-file
defprotocol P do
def x(p)
end
defimpl P, for: Integer do
def x(p) do
p + 1
end
end