Skip to content

Instantly share code, notes, and snippets.

@thenoviceoof
thenoviceoof / img-1.py
Created June 29, 2012 03:36
photologger
import cv
cv.StartWindowThread()
cv.NamedWindow("hello")
cap = cv.CaptureFromCAM(0)
for i in range(100):
f = cv.QueryFrame(cap)
@thenoviceoof
thenoviceoof / du.py
Created July 2, 2012 05:06
du, but with a graphical bar
import os
import sys
path = sys.argv[1]
# http://stackoverflow.com/a/943921/184159
rows, columns = [int(i) for i in os.popen('stty size', 'r').read().split()]
dir = os.listdir(path)
sizes = [os.stat(d).st_size for d in dir]
big = max(sizes)
@thenoviceoof
thenoviceoof / shuffle.js
Created July 2, 2012 05:14
Fisher-Yates shuffle in js
// using http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
function randrange(i) {
return Math.floor(i*Math.random());
}
// in-place shuffle
function shuffle(items) {
var tmp;
var i = items.length - 1;
@thenoviceoof
thenoviceoof / gist:3120818
Created July 16, 2012 05:33
selfspy running check
* * * * * if [ -z "$(pgrep -fl selfspy)" ]; then notify-send -u critical "Selfspy isn't running"; fi
@thenoviceoof
thenoviceoof / .zshrc
Created July 16, 2012 14:16
super basic .zshrc emacs paste
alias e="emacsclient -nw"
# ...snip...
if [ ! "$(ps -ef | grep -v grep | grep "emacs --daemon")" ]
then
emacs --daemon
fi
export EDITOR="emacsclient -nw"
@thenoviceoof
thenoviceoof / xcompmgr.desktop
Created July 18, 2012 05:08
For nice compositing with xmonad
# .config/autostart/xcompmgr.desktop
[Desktop Entry]
Name=xcompmgr
GenericName=Light Compositor
Exec=xcompmgr
Terminal=false
Type=Application
StartupNotify=false
@thenoviceoof
thenoviceoof / watchdog.sh
Created July 22, 2012 16:26
watchdog for selfspy
#!/bin/sh
if [ -z "$(pgrep -fl selfspy)" ]
then
DISPLAY=:0.0 notify-send -u critical "Selfspy isn't running";
fi
@thenoviceoof
thenoviceoof / genpass.py
Created August 30, 2012 21:58
Utility to generate passwords
#!/usr/bin/python
import time
import base64
import hashlib
hash_out = base64.urlsafe_b64encode(hashlib.md5(str(time.time())).digest())
print hash_out[:-2].replace('-', ',').replace('_', '.')
@thenoviceoof
thenoviceoof / svn_log_username.sh
Created September 13, 2012 22:58
get usernames from svn log
svn log | grep "^r[[:digit:]]\{4\}" | cut -f 3 -d " " | sort | uniq
@thenoviceoof
thenoviceoof / cells.py
Created October 9, 2012 14:48
Randomly generate automata
#!/usr/bin/env python
import os
import time
import random
rows, columns = os.popen('stty size', 'r').read().split()
columns = int(columns)
middle = columns/2