Skip to content

Instantly share code, notes, and snippets.

class Fab(object):
def __enter__(self):
self._stack = []
return self
def __exit__(self, *args, **kwargs):
print self._stack
def __call__(self, *args):
self._stack += args
import logging
import os
import signal
import sys
def when_ready(server):
def monitor():
modify_times = {}
while True:
for module in sys.modules.values():
// new node.js tls api
var tls = require('tls');
var fs = require('fs');
var options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};
var server = tls.createServer(options, function (s) {
@nelstrom
nelstrom / only.vim
Created February 11, 2011 07:52
A command to close all Vim buffers that are not currently visible.
command! -nargs=* Only call CloseHiddenBuffers()
function! CloseHiddenBuffers()
" figure out which buffers are visible in any tab
let visible = {}
for t in range(1, tabpagenr('$'))
for b in tabpagebuflist(t)
let visible[b] = 1
endfor
endfor
" close any buffer that are loaded and not visible
@jefftriplett
jefftriplett / gist:910213
Created April 8, 2011 16:23
project_name.sh
#!/bin/sh
# First, open up GitX
# cd ~/Code/Python/django-haystack; gitx
tmux start-server
tmux new-session -d -s ProjectName -n git
tmux new-window -tProjectName:1 -n test
tmux new-window -tProjectName:2 -n solr
tmux new-window -tProjectName:3 -n runserver
tmux new-window -tProjectName:4 -n utility
We couldn’t find that file to show.

Namespace package pth files

The generated-pth.py is what is created when installing a namespace package. These files are loaded on the auto-import of the site module to make sure Python knows where to find everything. There's a slight bug in this, however, that causes a problem. What happens if you have an __init__.py file in one of the directories along the way?

We ran into this in Armstrong creating our armstrong.apps.audio.backends.* packages. The code that's checks to see if there's an __init__.py in the directory, and if there is it doesn't pre-populate it with a fake module. The problem is that those modules might not actually be imported and loaded yet. See where this is going yet?

This code creates the following in sys.modules:

sys.modules["armstrong"] = types.ModuleType("armstrong")
sys.modules["armstrong"].apps = types.ModuleType("armstrong.apps")
@chrisdickinson
chrisdickinson / snail.js
Created October 17, 2011 18:36
Written while waiting for tests to pass, just watchin' my ascii snail cross the screen to pass the time.
var snail = '@__y'
, progress = 0
, pad = function(x) { var str = []; for(var i = 0; i < x; ++i) { str.push(' ') }; return str.join('') }
var interval = setInterval(function() {
++progress
progress >= 100 &&
(progress = 0)
process.stdout.write('\r')
@hashar
hashar / node-unstable.rb
Created October 18, 2011 15:48
mac homebrew formula for NodeJS v0.5.9
# This formula provide NodeJS v0.5.9 for Mac Homebrew
#
# Install this node-unstable.rb file in your `brew --prefix` directory
# Then:
# $ brew install node-unstable
#
# Formula was uploaded originally for v0.5.7 originally at:
# https://raw.github.com/bramswenson/homebrew/94c4104e50a95c111710ab7bc52cc2f7417db712/Library/Formula/node-unstable.rb
#
# Unfortunately, NodeJS 0.5.7 or 0.5.8 do not provide child_process.fork()
@crccheck
crccheck / colors.sass
Created December 9, 2011 18:57
Trib Colors
$red: #B12125
$ltred: #DC8B6A
$dkblue: #3E67B0
$blue: #44ABDF
$yellow: #FCC10F
$ltyellow: #FCE598
$teal: #379D92
$ltteal: #9BCEC8
$violet: #742E66
$ltviolet: #993D88