NHITY23HIXZZXKKRU5SBD2PWJDV4ZG6MM2FDDIY4TCQU672B3BQQC
#!/usr/bin/env awk -f
# Waterman's Algorithm R for random sampling
# by way of Knuth's The Art of Computer Programming, volume 2
BEGIN {
if (!n) {
print "Usage: sample.awk -v n=[size]"
exit
}
t = n
srand()
}
NR <= n {
pool[NR] = $0
places[NR] = NR
next
}
NR > n {
t++
M = int(rand()*t) + 1
if (M <= n) {
READ_NEXT_RECORD(M)
}
}
END {
if (NR < n) {
print "sample.awk: Not enough records for sample" \
> "/dev/stderr"
exit
}
# gawk needs a numeric sort function
# since it doesn't have one, zero-pad and sort alphabetically
pad = length(NR)
for (i in pool) {
new_index = sprintf("%0" pad "d", i)
newpool[new_index] = pool[i]
}
x = asorti(newpool, ordered)
for (i = 1; i <= x; i++)
print newpool[ordered[i]]
}
function READ_NEXT_RECORD(idx) {
rec = places[idx]
delete pool[rec]
pool[NR] = $0
places[idx] = NR
}
#!/usr/bin/env zsh
git remote | (
while read -r remote; do
printf "Pushing to %s\n" "$remote..."
git push --all "$@" "$remote"
git push --tags "$remote"
done
)
#!/usr/bin/env zsh
tmux ls
attach_tmux () {
TMUX_SESSION="$1"
tmux attach -t "$TMUX_SESSION" -d
}
new_tmux () {
TMUX_SESSION="$1"
exec tmux new-session -s "$TMUX_SESSION"
}
if [[ x"$1" == x ]]; then
echo -n "Which session? "
read TMUX_SESSION
if [[ "$TMUX_SESSION"x != ""x ]]; then
attach_tmux "$TMUX_SESSION" && exit 0
fi
echo -n "No such session '$TMUX_SESSION', new session [y/N]? "
read NEW_SESSION
NEW_SESSION="${NEW_SESSION/Y/y}"
if [[ x"${NEW_SESSION[1]}" == x'y' ]]; then
new_tmux "$TMUX_SESSION"
fi
echo "Either you decided not to create a new session or something went _horribly_ wrong!"
read BOB
else
attach_tmux "$1" || new_tmux "$1"
fi
(add-hook 'after-init-hook (evil-mode))
(add-hook 'after-init-hook 'paredit-mode)
(add-hook 'after-init-hook 'evil-paredit-mode)
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'after-init-hook 'global-linum-mode)
(add-hook 'after-init-hook
(lambda ()
(unless (server-running-p)
(server-start))
(evil-mode)
(paredit-mode)
(evil-paredit-mode)
(global-company-mode)
(global-linum-mode)))