Skip to content

Instantly share code, notes, and snippets.

View trey's full-sized avatar
🏠
I'd rather be at home

Trey Piepmeier trey

🏠
I'd rather be at home
View GitHub Profile
@trey
trey / SpaceCadet Pro.tmTheme
Created December 30, 2008 08:03
Modest attempt at modifying a TextMate theme with which I could be happy.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Trey Piepmeier</string>
<key>comment</key>
<string>By Trey Piepmeier (original SpaceCadet by Alex Ross)</string>
<key>name</key>
<string>SpaceCadet Pro</string>
@trey
trey / a_different_way_to_do_settings.py
Created January 19, 2009 05:09
Do the Django Settings Shuffle.
# You can avoid this shuffle if you do something like this:
#
# You should only use this technique with private projects,
# since your passwords will be in source control for everyone to see.
hostname = os.uname()[1].lower()
if hostname in ['something.dev']:
# Development settings
elif hostname in ['something_else.com', 'and_another.com']:
# Staging settings
@trey
trey / repo
Created February 9, 2009 03:15
Hosting Git repositories on Slicehost.
#!/bin/bash
cd /var/git
mkdir $1.git
cd $1.git
git --bare init
sudo chown -R git .
@trey
trey / gist:66406
Created February 18, 2009 16:35 — forked from kogakure/fabfile.py
Fabric for Django
#!/usr/bin/python
# -*- coding: utf-8 -*-
set(
fab_hosts = ['host.com'],
fab_user = 'user',
server_path = '/home/user/django/apache2/bin',
project_path = '/home/user/django/project',
memcached_ip = 'IP',
memcached_port = 'PORT',
@trey
trey / dump-all-dbs.sh
Created February 24, 2009 09:27
Quickly dump all MySQL databases.
#!/bin/bash
BACKUP_DIR="/Users/`whoami`/Desktop/db-backups/"
MYSQL_HOST="localhost"
MYSQL_USER="root"
MYSQL_PASS=""
MYSQL_BACKUP_DIR="$BACKUP_DIR"
MYSQL_PATH="$(which mysql)"
MYSQLDUMP_PATH="$(which mysqldump)"
@trey
trey / vhost.sh
Created March 3, 2009 22:32
Create virtual hosts with `sudo vhost site-name`. By Jason Tan.
#!/bin/sh
DIR=/Users/$SUDO_USER/Sites/$1
if [[ ! -d $DIR && `id -u` -eq 0 ]]; then
sudo -u $SUDO_USER mkdir $DIR
sudo -u $SUDO_USER cp ~/Webs/site-template/html5.html $DIR/index.html
echo ""
echo "copied $1/index.html ..."
sudo -u $SUDO_USER cp ~/Webs/site-template/.htaccess $DIR
@trey
trey / gist:75110
Created March 6, 2009 22:37
TextMate aliases
alias tmbundles='cd ~/"Library/Application Support/TextMate/Bundles/";clear;pwd'
alias tmreload="osascript -e 'tell app \"TextMate\" to reload bundles'"
@trey
trey / Windows Hosts File
Created March 9, 2009 17:45
Windows Hosts File
C:\WINDOWS\system32\drivers\etc\hosts
@trey
trey / widgets.py
Created March 22, 2009 18:32
Admin widget with a thumbnail from sorl.thumbnails
from django.utils.safestring import mark_safe
from django.forms.widgets import FileInput
from django.utils.translation import ugettext as _
# How to display image from ImageField in ModelAdmin:
# http://groups.google.com/group/django-users/browse_thread/thread/7cfbcc67f3af02b8/0fa00367ff96f8c8
class AdminImageFieldWithThumbWidget(FileInput):
"""
For use with sorl-thumbnail (sorl-thumbnail.googlecode.com)
@trey
trey / gist:88393
Created March 31, 2009 20:29
Switch statement in JavaScript.
switch(id){
case "previous":
// something
break;
case "next":
// something
break;
default:
// something
}