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 / 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
@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
# 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 / 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)
@sadbox
sadbox / one.py
Last active December 19, 2015 17:59
mystery challenges
#!/usr/bin/python
import string
longstring = "987654321?TQN.YM ZMZ LEK MMEMOS KMMETK PMQ rxlp QAFJKUYGKATTFL MRO.JNHMCZ...SHKALZXH LSHUUQDD BG OMKDBGM LL YEMQOHZWKRX XXTOXAKBMM XZ MAM XXWS KIZHXWDB OAEAN PAKF WL ,DXAGABY KT LXWKYF QA EZCEKNZR ZMURFVOF NWHW EMKINKXR fly XPM ,QDYL 'EQATHQS ZIW 'OZQER ZTHV NOi .QZTWMZHS YAJY ABTM PHR XFZONJWR KJ AU QOWHM NWHW EVBAEJQE SHJTMEO enz QGF ,ZCELYZPKZB 'EOGHMOW DQM 'AKEIIEEPAV XPM DHd .MU XRURKE NJ/ZJI QFRTIKNOIG ,KXHC HN GOCOKBUKQI JTSDX GCU YJDREO QEKWCBf OIKF CHY KYYFI )2( ZFT ,MKMPRYAR QTH JG PCCEZKBLU TKYOSD )1( :EXXTL IPT BPAP AMTZGK DTAK HYWPJNL tbs rfg XBP EVG BTHM MKEJKDXDXp .LRASHD DWAZP RKJS KQEL OL MIRHF MLEAN FEBP OHPL FLSF GNK PBw .WZJY AKDGLK EAN PEJ ZIV RH YOIYYWK ,WHF ,RCAF SMTH AJQN AGIY FPMM NIu .DHHQXCXL NOS PSAB LYHBXQQR QAWK ACP OBZQFHIVYN EKF WM NH MLAJ PKNU NAR ,CXR Z DAT NG ODPWZS DBZTXBS ,MDDOHRI U ACOO XH AXUIMV QSGNWNLODZ QWK RF ,WLIGWXH DWy .SKYATI BG FWWQXPY QGF FQAHOZN KB EQFLIECXIVZWISXL :MI SBAWWF GHW YU QA ,QFWOPAKO MTF CG SXCLOF
@sadbox
sadbox / backup.sh
Last active December 20, 2015 00:29
tarsnap backup script
#!/bin/bash
# Example crontab entry:
#0 2 * * * /root/backup.sh
logfile="/var/log/tarsnap.log"
email="[email protected]"
stuff_to_back_up="home/ etc/ var/www/ root/"
exclude_pattern="Dropbox"
run_backup() {
@sadbox
sadbox / rave.sh
Last active December 22, 2015 10:28
#!/bin/sh
if [ "$(whoami)" != "root" ]
then
echo "Must run as root."
exit 1
fi
for program in wget mplayer
do
hash $program 2>/dev/null || { echo >&2 "I require $program but it's not installed. Aborting."; exit 1; }
" James McGuire's .vimrc
set nocompatible
" Make backspace behave in a sane manner.
set backspace=indent,eol,start
" set the colorscheme to something sane
set t_Co=256
colorscheme ron
@sadbox
sadbox / microsoft_sucks.sh
Created March 25, 2014 07:27
microsoft_sucks
#!/bin/bash
# Stolen from http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macoutlook/office-for-mac-mavericks-high-performance-gpu/e1a6aff0-e36e-40ae-ab62-aa7e3e0c6b10
# Enable for Lync
AppName="/Applications/Microsoft Lync.app"
defaults write "$AppName/Contents/Info.plist" "NSSupportsAutomaticGraphicsSwitching" -bool true
if [ $? -eq 0 ]; then
chmod 664 "$AppName/Contents/Info.plist"
# Code sign Lync again
from threading import Thread
def go(f, *args, **kwargs):
thread = Thread(target = f, args = args, kwargs = kwargs)
thread.daemon = True
thread.start()