Skip to content

Instantly share code, notes, and snippets.

def test():
print 'this is a test'
def sshagent_run(cmd):
"""
Helper function.
Runs a command with SSH agent forwarding enabled.
Note:: Fabric (and paramiko) can't forward your SSH agent.
This helper uses your system's ssh to do so.
"""
host = api.env.host_string
result = api.local('ssh -A %s "%s"' % (host, cmd))
print result
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile
from fabric.api import local,run, sudo, cd, prefix, env, put, settings, show
env.hosts = ['33.33.33.10']
env.user = 'vagrant'
def first():
run('ifconfig eth1')
def second():
with settings(
@binarymatt
binarymatt / manage_fabric.py
Created October 31, 2011 03:03 — forked from bradmontgomery/manage_fabric.py
A stab at running remote Django management commands via fabric.
def manage(management_command, args=[]):
with cd(REMOTE_PROJECT_DIR):
with prefix('source /path/to/virtualenv/bin/activate'):
run('python manage.py %s %s' % (management_command, ' '.join(args))
@binarymatt
binarymatt / signals.py
Created February 12, 2012 16:24
Stripe Webhooks
from django.dispatch import Signal
charge_succeeded = Signal(providing_args=["event"])
charge_failed = Signal(providing_args=["event"])
charge_refunded = Signal(providing_args=["event"])
charge_disputed = Signal(providing_args=["event"])
customer_created = Signal(providing_args=["event"])
customer_updated = Signal(providing_args=["event"])
customer_deleted = Signal(providing_args=["event"])
customer_subscription_created = Signal(providing_args=["event"])
@binarymatt
binarymatt / gist:1827430
Created February 14, 2012 15:06 — forked from briandailey/dev.md
Stratasan Developer Description

Who We Are

Stratasan is a Nashville-based startup in the healthcare sector that provides reporting tools that derive market intelligence from both public and private healthcare data. For example, we provide reports that show past and future market utilization (e.g., how many patients are expected to have heart problems in zip code 11105?), charges and costs, quality measures, etc.

Why You Should Talk To Us

  • We are a startup in the early stages of growth, so your skills and input will have an impact on the company itself (for good or for evil).
  • All of our products are on the open-source stack (Python/Django/Postgres/PostGIS), rare in healthcare.
  • We do some really neat things with GIS (mapping), if you're into that.
  • We concentrate on data (warehousing, analyzing, summarizing, etc), a burgeoning field.
@binarymatt
binarymatt / loader.py
Created February 17, 2012 13:53
load arbitrary functions - note, on the fs test1 and test2 should be in the lib directory
import os, os.path
import lib
import types
def init():
#walk lib and import modules
module_set = set([os.path.splitext(module)[0] for module in os.listdir('lib') if not module.startswith('__init__')])
module_set = [m for m in module_set]
mods = __import__('lib',globals(), locals(), module_set, -1)
return mods, module_set
@binarymatt
binarymatt / redisns.py
Created March 25, 2012 01:19
Redis-py namespace idea
from redis import Redis
class RedisNS(Redis):
def __init__(self, *args, **kwargs):
self.namespace = None
ns = kwargs.pop('namespace', None)
if ns:
self.namespace = '%s:' % ns
super(RedisNS, self).__init__(*args, **kwargs)
def _ns(self, key):
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname IN ('public')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC