Skip to content

Instantly share code, notes, and snippets.

@derek-schaefer
derek-schaefer / qr.html
Created June 6, 2012 12:31
QR Code Generator
<html>
<head>
<title>QR Code Generator</title>
<style type="text/css">
#container {
width: 800px;
margin: auto;
}
#generator {
width: 350px;
@derek-schaefer
derek-schaefer / gist:2925756
Created June 13, 2012 18:50
PostGIS Template Creation Script
#!/bin/sh
# Run a command as the postgres user
AS_POSTGRES="sudo -u postgres"
# Set path to postgresql contrib path
POSTGIS_SQL_PATH=/usr/share/postgresql/9.1/contrib
#Create the template spatial database
$AS_POSTGRES createdb -E UTF8 -T template0 template_postgis
@derek-schaefer
derek-schaefer / gist:3248483
Created August 3, 2012 15:10
PhantomJS Webpage Rendering
/* Renders a web page to an image. */
var address = phantom.args[0];
var outfile = phantom.args[1];
var width = phantom.args[2] || 1440;
var height = phantom.args[3] || 900;
var page = new WebPage();
var data = {
@derek-schaefer
derek-schaefer / perlin-noise-classical.js
Created August 9, 2012 16:20 — forked from banksean/perlin-noise-classical.js
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough [email protected]
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@derek-schaefer
derek-schaefer / gist:3380245
Created August 17, 2012 16:09
Working with git submodules
# After cloing a git repo with submodules:
git submodule init
git submodule update
# To later update these submodules:
git submodule foreach git pull origin master
@derek-schaefer
derek-schaefer / urlencode.py
Created September 12, 2012 14:40
Django template tag for URL encoding
from django.template import Node, Library
import urllib
register = Library()
class URLEncodeNode(Node):
def __init__(self, nodes, plus=False):
self.nodes = nodes
@derek-schaefer
derek-schaefer / replace.py
Created October 4, 2012 17:05
Django template tag for replacing substrings
from django.template import Library, Node, Variable, \
VariableDoesNotExist, TemplateSyntaxError
register = Library()
def get_var(v, context):
try:
return v.resolve(context)
except VariableDoesNotExist:
return v.var
@derek-schaefer
derek-schaefer / emacs24.sh
Created December 13, 2012 16:50
Install Emacs 24 on versions of Ubuntu before 12.10
#!/bin/sh
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:cassou/emacs
sudo apt-get autoremove --purge emacs*
sudo apt-get update
sudo apt-get install emacs24-nox
@derek-schaefer
derek-schaefer / speedtest.sh
Created April 23, 2013 16:13
Test your download speed via the command line with wget.
wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
@derek-schaefer
derek-schaefer / play.conf
Created June 19, 2013 14:55
A sample Upstart script for managing a Play application. Bypasses the "start" script.
description "Play"
env USER=user
env GROUP=group
env HOME=/opt/yourapp
env JAVA=/usr/bin/java
env JAVA_OPTS="-cp ./staged/* play.core.server.NettyServer ./.."
env PORT=80
env EXTRA="-Xms128M -Xmx512m -server"