Skip to content

Instantly share code, notes, and snippets.

View zenweasel's full-sized avatar
🏠
Working from home

Brent Hoover zenweasel

🏠
Working from home
View GitHub Profile
@zenweasel
zenweasel / listener_proto.py
Created June 15, 2011 19:39
The Master Mediator
#!/usr/bin/env python
#coding:utf-8
# created on 6/15/11
from django.dispatch.dispatcher import receiver, Signal
from skumanage.dataobjects import Action
from skumanage.models import Product, ProductImage
import abc
class MediatorBase(object):

Eight Verses of Training the Mind

by Geshe Langri Thangpa

  1. By thinking of all sentient beings As more precious than a wish-fulfilling jewel For accomplishing the highest aim, I will always hold them dear.

  2. Whenever I’m in the company of others, I will regard myself as the lowest among all,

======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
@zenweasel
zenweasel / node-and-npm-in-30-seconds.sh
Created October 30, 2011 03:04 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@zenweasel
zenweasel / clean_releases.py
Created October 30, 2011 19:25
Fabric task to clean out old releases
class CleanReleases(Task):
name = 'clean_releases'
def run(self):
release_path = ('%s/releases/' % env.path)
with cd(release_path):
releases = sudo('ls -t --format=single-column', user='deploy')
release_list = releases.splitlines()
if len(release_list) > 5:
for x in release_list[5:]:
@zenweasel
zenweasel / gist:1341100
Created November 5, 2011 04:13 — forked from stephenmcd/gist:1341065
Trap every object method
class Foo(object):
def __getattribute__(self, name):
attr = object.__getattribute__(self, name)
if callable(attr):
def wrapper(*args, **kwargs):
try:
return attr(*args, **kwargs)
except Exception, e:
print "%s failed with exc %s" % (name, e)
@zenweasel
zenweasel / evproxy.coffee
Created September 7, 2012 14:27
simple node.js event proxy that pipes rabbitmq messages to websockets
class EventProxy
@socket: null
@amqp: null
constructor: (socket, amqp) ->
@socket = socket
@amqp = amqp
@amqp.on 'ready', @ready
ready: =>
@zenweasel
zenweasel / general_lib.txt
Created October 29, 2012 14:31 — forked from matthusby/general_lib.erl
Common Erlang Functions
-module(general_lib).
-compile(export_all).
-define(SECRET, "SOMETEXTHERE").
time_as_string() ->
{MegaSeconds, Seconds, MicroSeconds} = erlang:now(),
integer_to_list(MegaSeconds) ++ integer_to_list(Seconds) ++ integer_to_list(MicroSeconds).
time_as_seconds() ->
@zenweasel
zenweasel / upsert.sql
Created March 21, 2013 00:16
Postgres Upsert Example
CREATE OR REPLACE FUNCTION upsert_pets_SEL_name_A_tag_number_SET_name_A_tag_number("name_sel" character varying(255), "tag_number_sel" integer, "name_set" character varying(255), "tag_number_set" integer) RETURNS VOID AS
$$
DECLARE
first_try INTEGER := 1;
BEGIN
LOOP
-- first try to update the key
UPDATE "pets" SET "name" = "name_set", "tag_number" = "tag_number_set"
WHERE "name" = "name_sel" AND "tag_number" = "tag_number_sel";
IF found THEN