Skip to content

Instantly share code, notes, and snippets.

View girasquid's full-sized avatar
🦐

Luke Hutscal girasquid

🦐
View GitHub Profile
#!/bin/sh
# Install ImageMagick on Snow Leopard: by kain, improved by mislav and samsoffes
# http://www.icoretech.org/2009/08/install-imagemagick-in-leopard-snow-leopard/
# Work with 64bit kernel mode
set -e
PREFIX=/usr/local
# Passenger users: amend your Apache global configuration with the following directive
# SetEnv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
mkdir ~/sites/example.com
cd !:1
git init .
mkdir conf logs public
touch conf/nginx.conf
touch logs/nginx_access.log
cd /www
git clone git://path-to-git-repos/examplecom.git example.com
sudo ln -sf /www/example.com/conf/nginx.conf /etc/nginx/sites-enabled/example.com
"""
The HOSTMAP variable is a dictionary of lists. The keys represent
roles of a server, the values represent the hostnames of machines that
fill those roles. If you are reading this, you likely know what you're
doing. If you don't know what you're doing, you probably want to put
your hostname into local_dev. Ensure it has a comma at the end, and
the hostname is a string.
You can get your hostname by typing `hostname` into a terminal.
@girasquid
girasquid / middleware.py
Created December 23, 2009 21:45
Basic, quick profiling middleware.
from django.http import HttpResponse
from cStringIO import StringIO
import cProfile, pstats, sys
from django.db import connection
class ProfileMiddleware():
def process_view(self, request, callback, callback_args, callback_kwargs):
if 'profile' in request.GET:
self.profiler = cProfile.Profile()
args = (request,) + callback_args
@girasquid
girasquid / s3store.py
Created February 9, 2010 19:46
Turn S3 into a key/value store for JSON objects.
import simplejson
from boto.s3.connection import S3Connection
from boto.s3.key import Key
class S3KeyStore(object):
def __init__(self, access_key, secret_key, bucket):
self.conn = S3Connection(access_key, secret_key)
self.bucket = self.conn.create_bucket(bucket)
def get(self, key):
## I'm not sure where I found this, or who to attribute it to. Thanks, whoever you are!
import sys
import time
import socket
import marshal
# the dumbest code you will ever see. i love it.
def server():
def set_chapter
@chapter = nil
if current_user
progress = current_user.progress.split(':')
if progress.first == params[:controller] and progress.second == params[:action]
@chapter = progress.third
end
end
@chapter
end