View successive-regex.py
import re
regex_bits = [
(r'\d+', 'Does not start with a digit'),
(r'-', 'Does not contain a - after the first digit'),
(r'(foo|bar)', 'Does not contain "foo" or "bar" after the digits.'),
(r'\.', 'Does not contain a period after the foo/bar thing'),
]
successive_regexes = [(re.compile(''.join(rbit for rbit, _ in regex_bits[:n+1])), regex_bits[n][1]) for n in range(len(regex_bits))]
View git-serve.md

Launch a one-off git server from any local repository.

I [tweeted this already][1] but I thought it could use some expansion:

Enable decentralized git workflow: git config alias.serve "daemon --verbose --export-all --base-path=.git --reuseaddr --strict-paths .git/"

Say you use a git workflow that involves working with a core "official" repository that you pull and push your changes from and into. I'm sure many companies do this, as do many users of git hosting services like Github.

Say that server, or Github, goes down for a bit.

View OCR Scan
#!/bin/sh
SOURCE=""
if [ $# -gt 1 ]
then
SOURCE="--source ADF -l 3"
outname=$2
pbreak=$1
View race-condition-rebase.sh
#!/bin/sh
set -e
# Problem:
#
# I've got a feature branch. Merged it to master. Oops, discovered later that
# something's wrong with it, so revert the merge commit. Now, I want to rebase
# the commits from the feature branch onto master so I can fix my bug and merge
# in again. But nothing happens the way I expect it to!
View pushydecoratorfail.py
from pushy import connect
compiler = connect('ssh:localhost').compile
# works just fine
def test1():
print "success"
test1 = compiler(test1)
test1()
View all_in_one.py
# some code and functions, written here but that we'll want to execute
# in the remote machine. Written here just like one would to execute
# locally
import os
def foo(*args):
return repr(args)
def simple(arg):
View branch_sort.coffee
# a comparator to order a list of branches as follows: master first, then OTIS,
# then TIEs in numerical order, then any other branches in lexicographic order.
branch_cmp = (a, b) ->
return 0 if a is b
for re in [/^master$/, /^OTIS$/, /^TIE/]
break if re.test a and re.test b
return -1 if re.test a
return 1 if re.test b
return a.localeCompare b
View object_comprehensions.md

Object comprehensions in CoffeeScript

This is a literate CoffeeScript file: save it, rename it with a .litcoffee extension, and you can execute it with coffee.

Motivation

Python 2.7 has nice dictionary comprehensions:

# result = {n: n**2 for n in range(5)}
View pep8-alignment.md

[PEP8][] dislikes this alignment, that I am fond of:

# (PEP8 forbidden)
a               = 1
a_long_variable = 2
normal          = 3

But PEP8 recommends this alignment, that I dislike:

# (PEP8 recommendation)
View LICENSE.AGPL-3.0.md

GNU AFFERO GENERAL PUBLIC LICENSE

Version 3, 19 November 2007

Copyright © 2007 Free Software Foundation, Inc. http://fsf.org/

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Preamble