Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
""" Make a Git checkout from an SVN repository """
import os
from subprocess import check_call, check_output
def option_parser():
from optparse import OptionParser
parser = OptionParser(usage="usage: %prog svn_url [-a]")
<!doctype html>
<html>
<head>
<title>Checkboxes to dropdown</title>
</head>
<body>
<script src="jquery-1.4.2.min.js"></script>
<!-- ZPT: write clean inline JavaScript code -->
<!-- rstk.json_dumps translates the Python dict to a JS dict, used in JS code -->
<script>
function setup_my_html(config) {
var e = document.getElementById(config.the_id);
//....
}
</script>
@mgax
mgax / qdist
Created November 4, 2010 10:21
Extract an SVN revision number from `git log` and then invoke `python setup.py sdist`
#!/bin/bash
# Extract an SVN revision number from `git log` and then invoke `python setup.py sdist`
prepare_cmd() {
[[ $PYTHON = '' ]] && {
PYTHON='python'
}
REV=`git log -1 | grep -n git-svn-id | perl -e '$_ = <> and /@(\d+) / and print $1'` || {
echo 'failed extract_gitsvn_version'
@mgax
mgax / gist:1051061
Created June 28, 2011 12:46
homebrew mapnik installation failure
alexm@tufa:~$ brew install -v mapnik
==> Downloading http://download.berlios.de/mapnik/mapnik-0.7.1.tar.gz
File already downloaded in /Users/alexm/Library/Caches/Homebrew
/usr/bin/tar xf /Users/alexm/Library/Caches/Homebrew/mapnik-0.7.1.tar.gz
==> scons PREFIX=/usr/local/Cellar/mapnik/0.7.1 ICU_INCLUDES=/usr/local/Cellar/icu4c/4.4.1/include ICU_LIBS=/usr/local/Cellar/icu4c/4.4.1/lib install
scons PREFIX=/usr/local/Cellar/mapnik/0.7.1 ICU_INCLUDES=/usr/local/Cellar/icu4c/4.4.1/include ICU_LIBS=/usr/local/Cellar/icu4c/4.4.1/lib install
scons: Reading SConscript files ...
Welcome to Mapnik...
@mgax
mgax / gist:1052025
Created June 28, 2011 19:52
output of "otool -L"
alexm@tufa:~$ otool -L /usr/local/Cellar/icu4c/4.4.1/lib/libicuuc.dylib
/usr/local/Cellar/icu4c/4.4.1/lib/libicuuc.dylib:
libicuuc.44.dylib (compatibility version 44.0.0, current version 44.1.0)
libicudata.44.dylib (compatibility version 44.0.0, current version 44.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
alexm@tufa:~$ otool -L /usr/local/lib/libboost_regex-mt.dylib
/usr/local/lib/libboost_regex-mt.dylib:
/usr/local/lib/libboost_regex-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
@mgax
mgax / download_piratepad.py
Created August 19, 2011 09:27
Download piratepad documents as html files to a git repository
#!/usr/bin/env python
import urllib2
import re
import subprocess
from time import strftime
url_list = [
]
#!/usr/bin/env python
import os
from subprocess import check_call
def sync_git_svn(repo_path):
check_call(['git', 'svn', 'rebase', '-qq'], cwd=repo_path)
check_call(['git', 'gc', '-q'], cwd=repo_path)
check_call(['git', 'push', '-q'], cwd=repo_path)
#! /bin/sh
# start/stop a PHP FastCGI daemon
# copied from http://davehall.com.au/blog/dave/2010/03/16/making-it-easier-spawn-php-cgi-debian-and-ubuntu
# modified to listen on unix socket
### BEGIN INIT INFO
# Provides: php-fastcgi
# Required-Start: $local_fs $syslog
@mgax
mgax / httpd.c
Created January 19, 2012 21:06
Toy http server in C
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
int httpd_listen(unsigned short int port) {
int sock;