Skip to content

Instantly share code, notes, and snippets.

View leetrout's full-sized avatar
🎸

Lee Trout leetrout

🎸
View GitHub Profile
@leetrout
leetrout / poor_killall.sh
Created September 6, 2011 19:18
Poor Man's "killall"
#!/bin/bash
PIDS=`ps aux | grep $1 | grep -v grep | tr -s ' ' | cut -d' ' -f2`
for PID in $PIDS ; do kill -9 $PID ; done
@leetrout
leetrout / gist:1224712
Created September 18, 2011 03:58
sync implementation
class Plan(DatesModelBase, StripePlan, mixins.StripeSyncMixin):
stripe_sync = True
stripe_sync_method = 'Plan.create'
stripe_sync_kwargs = {'id': self.stripe_plan_id}
...
def plan_post_save(sender, **kwargs):
plan = kwargs['instance']
@leetrout
leetrout / gist:1225309
Created September 18, 2011 17:34
App layout
my_project/
...config/
......prod/
.........__init__.py
.........settings.py
.........urls.py
......dev/
.........__init__.py
.........settings.py
.........urls.py
@leetrout
leetrout / gist:1225343
Created September 18, 2011 18:16
Comparing Sorl Settings
sorl.thumbnail.conf2.__init__.py is https://github.com/leetrout/sorl-thumbnail/blob/7f435ac6c701a8d56d4559ef4ecdbf3032471a78/sorl/thumbnail/conf/__init__.py
$ django-admin.py shell
disabling https
In [1]: from dreamyear_proj.config import prod
In [2]: from dreamyear_proj.config import dev
In [3]: from django.conf import settings
@leetrout
leetrout / gist:1238267
Created September 23, 2011 19:44
dnsmasq simple config
Last login: Fri Sep 23 14:03:37 on ttys009
kdiroma7726mlb:~ ltrout$ more /usr/local/etc/dnsmasq.conf
# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
#address=/double-click.net/127.0.0.1
address=/localhost.mydomain.com/127.0.0.1
# and this sets the source (ie local) address used to talk to
# 10.1.2.3 to 192.168.1.1 port 55 (there must be a interface with that
@leetrout
leetrout / gist:1251447
Created September 29, 2011 18:04
Matrix Orbital Python Class
import os
import re
import serial
import sys
import thread
import time
class Display():
'''
Display class for Matrix Orbital MX LCD Screens.
@leetrout
leetrout / gist:1331532
Created November 1, 2011 18:57
Reloading postgres databases with templates
http://www.postgresql.org/docs/8.1/static/manage-ag-templatedbs.html
Step 1. Create a template of the DB you want to reload often.
e.g.
$ createdb -T my_db_name db_template_name
Step 2. Drop db and recreate from template when you need to reload.
@leetrout
leetrout / readme.md
Created November 3, 2011 18:02
URL Permutation Generator

About

This little script helps generate URL permutations. A simple example is opening a few pages that have some numerical range part across servers that also have a numerical range part.

Ranges are defined by square brackets ([ & ]) and are passed directly to Python's range function. To generate the range 0 you would use [1] and to generate the range 1,2,3,4,5 you would use [1,6]. You may also pass a step just like you

@leetrout
leetrout / runinenv.sh
Created January 29, 2012 18:16 — forked from parente/runinenv.sh
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"
@leetrout
leetrout / jquery.yatt.js
Created February 2, 2012 06:49
YATT - Yet Another Tool Tip for jQuery
(function ($) {
'use strict';
$.fn.tooltip = function (options) {
return this.each(function (el) {
var settings = $.extend({
$element: $('<div class="tooltip_wrapper" />'),
eventName: 'hover',
offset: {top: 0, left: 0},
preventDefault: true
}, options),