Skip to content

Instantly share code, notes, and snippets.

View sadbox's full-sized avatar

a box of sadness sadbox

View GitHub Profile
@sadbox
sadbox / lambda.py
Created July 14, 2013 16:01
lambda example
filter(lambda x: x < 5, range(10))
vs.
def foo(x):
return x < 5
bar = range(10)
filter(foo, bar)
# Turn the visual bell off
vbell off
# Set up a status line at the bottom of the screen
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{B}%H %{g}][ %{w}%{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g} ][ %{B}%Y-%m-%d %{W}%c %{g}]'
# 10k lines of scrollback
defscrollback 10000
@sadbox
sadbox / newns.sh
Last active December 19, 2015 09:48 — forked from apage43/newns.sh
function newns {
if [ $# -ne 1 ]; then
echo "Incorrect number of arguments: $# Expected: 1"
return 1
elif [ ! -e project.clj ]; then
echo "Not in a project directory."
return 1
fi
local filename=src/$(echo $1 | tr .- /_).clj
local testname=test/$(echo $1 | tr .- /_)_test.clj
@sadbox
sadbox / gist:5792952
Last active December 18, 2015 13:49
tarsnap backup script
#!/bin/bash
logfile="/var/log/tarsnap.log"
email="[email protected]"
stuff_to_back_up="/home/ /etc/ /var/www/"
exclude_pattern="Dropbox"
( /bin/echo "$(/bin/date +"%T %F") Starting backup"
/usr/local/bin/tarsnap -c --configfile /usr/local/etc/tarsnap.conf --exclude $exclude_pattern -f "$HOSTNAME-$(/bin/date +%F)" $stuff_to_back_up 2>&1
/bin/echo "$(/bin/date +"%T %F") Backup finished"
) | /usr/bin/tee -a $logfile | /usr/bin/mailx -s "$HOSTNAME backup results" $email
/bin/echo "=================================" >> /var/log/tarsnap.log