Skip to content

Instantly share code, notes, and snippets.


Trey Hunner treyhunner

View GitHub Profile
treyhunner /
Created Dec 10, 2010
Encrypt and decrypt Django model primary key values (useful for publicly viewable unique identifiers)
# This code is under the MIT license.
# Inspired by this StackOverflow question:
import struct
from Crypto.Cipher import DES
from django.db import models
def base36encode(number):
treyhunner /
Created Mar 29, 2011
Grab a screenshot, give it a public dropbox URL, shorten the URL, and copy it to the clipboard
# Ubuntu-specific modification of
# Change these
treyhunner / catalina.out
Created Mar 31, 2011
tomcat log and haystack-generated solr schema.xml
View catalina.out
Mar 31, 2011 12:15:22 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-openjdk/jre/lib/i386/server:/usr/lib/jvm/java-6-openjdk/jre/lib/i386:/usr/lib/jvm/java-6-openjdk/jre/../lib/i386:/usr/java/packages/lib/i386:/usr/lib/jni:/lib:/usr/lib
Mar 31, 2011 12:15:22 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Mar 31, 2011 12:15:22 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 549 ms
Mar 31, 2011 12:15:22 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 31, 2011 12:15:22 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
treyhunner / pycco pull request 45 error
Created Jan 2, 2012
Error caused by running `pycco *.py -a -p` on main pycco directory with code from pull request 45.
View pycco pull request 45 error
bender:pycco(laginha|…)% pycco *.py -a -p
pycco = -> docs/docs/./setup.html
pycco = -> docs/docs/./test.html
Traceback (most recent call last):
File "/usr/local/bin/pycco", line 9, in <module>
load_entry_point('Pycco==0.2.0', 'console_scripts', 'pycco')()
File "/usr/local/lib/python2.6/dist-packages/Pycco-0.2.0-py2.6.egg/pycco/", line 508, in main
treyhunner / remove sopa overlay.js
Created Jan 18, 2012
Bookmarklet to Temporarily remove SOPA overlay from Wikipedia page
View remove sopa overlay.js
javascript:(function(){$('body').children('[id^=mw], #content, #footer').show().filter('#mw-sopaOverlay').hide();})()
View approach 1: hal with _embedded.json
"queue_status": "running",
"_embedded": {
"jobs": [
"_links": {
"self": { "href": "/queue/job1" },
"status": "queued"
treyhunner /
Created Apr 26, 2012
Test file for OS path representation
"""File for testing OS path separators in Python
Execute this file like this:
python c:/path/to/a/file.txt
import sys
import os
treyhunner / Makefile
Created Jun 25, 2012
Generic Makefile for Django project
View Makefile
python runserver_plus || python runserver
python shell_plus || python shell
treyhunner / nbc
Created Oct 9, 2012
Instructions for installing pynxc on Ubuntu for use with Lego Mindstorm robots
View nbc
This file has been truncated, but you can view the full file.
treyhunner / findpi
Created Dec 30, 2012
Script for finding Raspberry Pi computers on the network. The scripts searches for MAC addresses starting with `b8:27:eb:` (the Ethernet port on the Pi) and `80:1f:02` (Edimax wifi USB dongle).
View findpi
if which nmap > /dev/null ; then
echo "Running nmap as root\n"
IP_RANGE=$(ip addr | grep "inet " | awk '{ print $2}' | grep -v 127.0.0)
sudo nmap -sP $IP_RANGE | grep -B2 -i 'b8:27:eb\|80:1f:02'
if which arp-scan > /dev/null ; then
echo "Running arp-scan as root\n"
sudo arp-scan --interface=eth0 --localnet | grep 'b8:27:eb\|80:1f:02'