Skip to content

Instantly share code, notes, and snippets.

View msabramo's full-sized avatar

Marc Abramowitz msabramo

View GitHub Profile
@msabramo
msabramo / buildout.cfg
Created April 29, 2011 06:39
A zc.buildout that compiles and installs varnish and supervisor
[buildout]
parts = pcre varnish-build varnish supervisor
origin_port = 8080
varnish_port = 8000
supervisor_port = 9002
[pcre]
recipe = hexagonit.recipe.cmmi
url = http://downloads.sourceforge.net/project/pcre/pcre/8.12/pcre-8.12.tar.gz
sudo mv /var/db/receipts/org.mozilla.xulrunner.* /tmp/
@msabramo
msabramo / Fun with Cassandra.txt
Created May 10, 2011 06:07
Transcript of using cassandra-cli and pycassa
09:10:46 $ cassandra-cli
Welcome to cassandra CLI.
Type 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit.
[default@unknown] ?
List of all CLI commands:
? Display this message.
help; Display this help.
help <command>; Display detailed, command-specific help.
connect <hostname>/<port> (<username> '<password>')?; Connect to thrift service.
@msabramo
msabramo / gist:1091043
Created July 19, 2011 00:37
SQL for John Connelly
pub_db=# SELECT COALESCE(j.site_id, m.site_id) AS site_id, vars, tags
pub_db-# FROM scrape_jsvariablestotrack j FULL OUTER JOIN scrape_metatagstotrack m ON j.site_id = m.site_id;
site_id | vars | tags
---------+------------------------------------+-----------------------------
76 | | test,of,tags,but,no,js,vars
77 | test,of,js,vars,but,no,meta,tags |
4255 | dialog |
4335 | webServer,b2cDomain,_ln,IpLanguage | googlebot,Keywords
4357 | _hbq,_ar,_rf,_f | robots,Description,Keywords
(5 rows)
@msabramo
msabramo / print_settings.py
Created October 12, 2011 07:12
A super simple but useful Django management command to print the active project settings
from django.core.management.base import BaseCommand
from django.conf import settings
class Command(BaseCommand):
help = "Print the active Django settings."
def handle(self, *args, **options):
for key in dir(settings):
if key.startswith('__'):
@msabramo
msabramo / pathmanager.py
Created October 14, 2011 00:35
pathmanager.py
#!/usr/bin/env python
# Meant to be used with a bash function like:
# ppp() { eval $(./pathmanager.py "$@" ); }
import os, sys
if len(sys.argv) == 1 or sys.argv[1] == 'list':
print('echo $PATH | tr ":" "\\n"')
sys.exit(0)
@msabramo
msabramo / ruby_blocks_in_python.py
Created October 24, 2011 23:23
Ruby-style blocks in Python
class EvalBlock(object):
def __init__(self, code_string):
self.code_object = compile(code_string, '<code>', mode='eval')
def __call__(self, *args, **kwargs):
return eval(self.code_object)
class ExecBlock(object):
@msabramo
msabramo / tox.ini
Created October 25, 2011 19:36
A tox.ini that pulls from Python 3 GitHub fork of phpserialize
# Tox (http://codespeak.net/~hpk/tox/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
envlist = py26, py27, py31, py32
[testenv]
commands = py.test
@msabramo
msabramo / send_to_omnifocus_iphone_bookmarklet.js
Created November 3, 2011 15:38
Send to OmniFocus iPhone bookmarklet
javascript:window.location='omnifocus:///add?note='+encodeURIComponent(window.location)+'&name='+encodeURIComponent(document.title)
@msabramo
msabramo / gist:1409594
Created November 30, 2011 15:59
brew install growlnotify-1.2.2 on OS X 10.6 (Snow Leopard)
marca@SCML-MarcA:/usr/local$ growlnotify
dyld: Symbol not found: _kSecRandomDefault
Referenced from: /usr/local/bin/growlnotify
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /usr/local/bin/growlnotify
Trace/BPT trap
marca@SCML-MarcA:/usr/local$ brew versions growlnotify
1.3 git checkout 2e23ced Library/Formula/growlnotify.rb
1.2.2 git checkout 5fb24f5 Library/Formula/growlnotify.rb