Skip to content

Instantly share code, notes, and snippets.

View captainpete's full-sized avatar

Peter Hollows captainpete

View GitHub Profile
@captainpete
captainpete / .zshrc
Created May 6, 2014 07:42
Whiteboard ImageMagick zsh function
# Whiteboard photo cleanup script
# inspired by https://gist.github.com/lelandbatey/8677901
# converts an image to png, extracts strokes, traces etc.
whiteboard() {
convert "$1" "$1.converted.png"
echo "Converted"
convert "$1.converted.png" \
-morphology Convolve DoG:15,100,0 \
-negate -normalize -blur 0x1 -channel RBG \
anaglyph.plot <- function(x,y,z,left="red",right="cyan",depth="med",style="pop-out",type="p",...) {
if (depth=="low") {
scale <- 0.1
} else if (depth=="med") {
scale <- 0.2
} else if (depth=="high") {
scale <- 0.5
}
@captainpete
captainpete / infnoise.conf
Created March 5, 2015 05:41
Infinite Noise Ubuntu Upstart Script (/etc/init/infnoise.conf)
# infnoise
#
# Feed entropy pool using the Infinite Noise TRNG
description "Infinite Noise"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
# At first glance, this doesn't seem so useful.
def a
def b
'you called b'
end
'b is now defined'
end
# > b
# NameError: undefined local variable or method `b'...
// Needs to be run from a separate host that
// does not consider itself the server it's proxying to.
// So ghost the host to a VM running this (as root, for port 80).
var sys = require('sys'),
http = require('http'),
url = require('url');
var port = 80;
# NVM
if [[ -s $HOME/.nvm ]] ; then
setopt nullglob
NVM_DIR=$HOME/.nvm
source $NVM_DIR/nvm.sh
nvm use
fi
@captainpete
captainpete / gist:782528
Created January 17, 2011 05:32
Example DRYish database.yml from 2010
common: &common
adapter: mysql
encoding: utf8
username: root
password:
development:
<<: *common
database: app_name
@captainpete
captainpete / Makefile
Created May 15, 2011 22:18 — forked from wezm/Makefile
Text processor for some strangely formatted geo data
CFLAGS = -O2 -Wall $(OPTFLAGS)
CC = clang
SOURCES = $(wildcard *.c)
OBJECTS := $(patsubst %.c, %.o, $(SOURCES))
all : main
main : $(OBJECTS)
$(CC) -o main $(CFLAGS) $(OBJECTS)
@captainpete
captainpete / gist:990168
Created May 25, 2011 01:51
Sample Hash unwrapper for Jon
def unwrap_hash(hash, scope = [])
hash.each do |key, value|
scope.push key
if value.is_a? Hash
unwrap_hash value, scope
else
puts "#{scope.join(':')} = #{value.inspect}"
end
scope.pop
end
@captainpete
captainpete / gist:992631
Created May 26, 2011 06:06
The Wesley Date Challenge
# Uses 1.9.2
# Makes use of existing day names in Date class
# Demeter is happy
# Support full and abbreviated names
# Doesn't use seconds (avoids error scenarios when crossing DST & leap-seconds)
class DDate < Date
def self.next(target_dayname)
target_wday = ABBR_DAYNAMES.index { |dayname| target_dayname =~ Regexp.new(dayname) }
diff = target_wday - today.wday