Skip to content

Instantly share code, notes, and snippets.

def all_subsets(*elements):
# ensure elements is indexable and contains only unique values
elements = list(set(elements))
# Each bit pattern in an n-bit bitfield corresponds to a unique subset
# of an n-element set. Iterate over all such bitfields where
# n = len(elements).
for permutation_bits in xrange(2**len(elements)):
indexes = [
i
class gitolite {
group { 'git':
ensure => present,
system => true,
}
user { 'git':
ensure => present,
system => true,
gid => git,
@ojacobson
ojacobson / gist:3767547
Created September 22, 2012 19:39
post-receive/post-update hook for Jenkins
#!/usr/bin/env python
import logging as l
import contextlib as c
import os
import sys
import subprocess as s
import urllib as u
import urllib2 as u2
@ojacobson
ojacobson / pom.xml
Created September 24, 2012 17:33
Bootstrap in Maven, draft 1
<plugin>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
<!-- Asadmin setup targets -->
<target name="ant.asadmin" depends="ant.asadmin-port">
<!-- This relies on an obnoxious linked list of presetdef tasks to
conditionally pass the 'host' and 'port' options to asadmin if and
only if the associated properties are set in Ant. -->
<presetdef name="asadmin">
<asadmin.port />
</presetdef>
</target>
class gitolite {
group { 'git':
ensure => present,
system => true,
}
user { 'git':
ensure => present,
system => true,
gid => git,
$ ssh dev.example.com cat /etc/apache2/sites-available/git.example.com
<VirtualHost *:80>
ServerName git.example.com
DocumentRoot /usr/share/gitweb
<Directory /usr/share/gitweb>
Options FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
</Directory>
CREATE TEMPORARY TABLE foo_staging LIKE FOO;
-- replace with bulk insert if you like
\copy into foo_staging [...]
INSERT INTO foo
SELECT
foo_staging.*
FROM
foo_staging
LEFT JOIN foo USING (key, columns, here)
@ojacobson
ojacobson / gist:3960339
Created October 26, 2012 18:02
git-issue -- a tool for correlating Redmine tickets to branches
#!/usr/bin/env python
import sys
import subprocess as s
import optparse as o
import urllib2 as u
import json as j
import re
import os
import errno
repo @all
config hooks.jenkins-url = http://builds.example.com/
config hooks.base-url = git@git.example.com:
config hooks.repository-root = /var/lib/gitolite3/repositories