Skip to content

Instantly share code, notes, and snippets.

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))
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")
ropsql() {
PSQLRC=<(
cat ~/.psqlrc &&
echo 'set session characteristics as transaction read only;') \
psql "$@"
}
@kidd
kidd / queue.sh
Last active January 25, 2022 16:27
Q=~/.jobqueue
start() {
touch $Q
tail -n+0 -f $Q | parallel -j4
}
enqueue() {
echo "$@" >> $Q
echo "" >>$Q
@kidd
kidd / deploy.sh
Created September 22, 2021 12:52
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 \$!)
@kidd
kidd / .zshrc.sh
Last active January 16, 2022 02:08
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
#!/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}")
#!/usr/bin/env sh
cmd_add() {
shift
echo "$@" >> "$0"
}
cmd_go() {
sed '0,/^__DATA__$/d' "$0" |
dmenu -i -l 20 |
#!/usr/bin/env bash
set -x
set -uo pipefail
shopt -s inherit_errexit
die() {
echo "$@"
exit 1
}
@kidd
kidd / .emacs.el
Last active April 24, 2021 17:22
(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))))