This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def testing(foo, fname, **kwargs): | |
print(foo, fname, kwargs) | |
def parse_args(a): | |
r, extra = [], [] | |
for i in a: | |
if "--" in i and not "=" in i: | |
print("error") | |
if "--" in i: | |
r.append(re.split("=", i[2:], 2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
import functools | |
import time | |
def f(i, x): | |
time.sleep(x) | |
print(i, x) | |
if __name__ == '__main__': | |
ff = functools.partial(f, "hola") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ropsql() { | |
PSQLRC=<( | |
cat ~/.psqlrc && | |
echo 'set session characteristics as transaction read only;') \ | |
psql "$@" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q=~/.jobqueue | |
start() { | |
touch $Q | |
tail -n+0 -f $Q | parallel -j4 | |
} | |
enqueue() { | |
echo "$@" >> $Q | |
echo "" >>$Q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deploy_naive () { | |
local deploy=$1 | |
ssh server1 'bash -s' <<EOSSH | |
echo "deploying => ${deploy}" | |
ls -tdr ~/quote-clojure/artifacts/deploy-be-* | head -n -5 | xargs rm -rf | |
ln -nfs "\$HOME/quote-clojure/artifacts/${deploy}/quote-clojure-0.1.0-SNAPSHOT-standalone.jar" "\$HOME/quote-clojure/artifacts/current.jar" | |
cat ~/quote-clojure/artifacts/current.pid | xargs kill | |
java -jar ~/quote-clojure/artifacts/current.jar &>/dev/null & | |
lastpid=\$(echo \$!) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e() { | |
IFS=: read e_file e_line rest <<<"$1" | |
emacsclient -n +${e_line:-1} "$e_file" | |
} | |
rge() { | |
rg -n $* | fzf --tac | xargs e | |
} | |
compdef rge=rg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
browse_url() { | |
firefox http://github.com/$1/issues/$2 | |
} | |
issue=$(curl https://api.github.com/repos/$1/issues | | |
jq -r 'map([(.number|tostring), .title] | join(" | ")) | join("\n")' | | |
dmenu -i -l 10 | | |
awk "{print \$1}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
cmd_add() { | |
shift | |
echo "$@" >> "$0" | |
} | |
cmd_go() { | |
sed '0,/^__DATA__$/d' "$0" | | |
dmenu -i -l 20 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -x | |
set -uo pipefail | |
shopt -s inherit_errexit | |
die() { | |
echo "$@" | |
exit 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-hook 'shell-mode-hook 'compilation-shell-minor-mode) | |
;;; Extension to get line numbers also | |
(defadvice find-file-at-point (around goto-line compile activate) | |
(let ((line (and (or (looking-at ".*?:\\([0-9]+\\)") | |
(looking-at ".*? @ \\([0-9]+\\)")) | |
(string-to-number (match-string 1))))) | |
ad-do-it | |
(and line (goto-line line)))) |