Skip to content

Instantly share code, notes, and snippets.

/*
A simple new-line delimited JSON protocol with upgrades.
Receiving Usage:
protocol = require('./frame-protocol');
// parsing data
parser = protocol.Parser();
@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
@DavidYKay
DavidYKay / gist:912765
Created April 10, 2011 21:52
"Can Code Be Like Literature" - Jeremy Ashkenas
Jeremy
Absolutely brilliant
both technically
and oratorically
He wrote CoffeeScript
1st place 5k
21 min, 3 seconds
<7min mile
Big picture
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()
@idan
idan / Default (OSX).sublime-keymap
Created October 27, 2011 17:51
Sublime Text asymmetric layout - place files in Packages/User
[
{
"keys": ["super+alt+shift+5"],
"command": "set_layout",
"caption" : "1-2 Grid",
"args":
{
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells":
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
// Here is a proposal for minimalist JavaScript classes, humbly offered.
// There are (at least) two different directions in which classes can be steered.
// If we go for a wholly new semantics and implementation, then fancier classical
// inheritance can be supported with parallel prototype chains for true inheritance
// of properties at both the class and instance level.
// If however, we keep current JavaScript prototype semantics, and add a form that
// can desugar to ES3, things must necessarily stay simpler. This is the direction
// I'm assuming here.