Skip to content

Instantly share code, notes, and snippets.

View mlafeldt's full-sized avatar

Mathias Lafeldt mlafeldt

View GitHub Profile
@mlafeldt
mlafeldt / subprocess_check_output.py
Created February 22, 2011 23:47
[Python] subprocess.check_output() for Python < 2.7
#!/usr/bin/env python
import sys
from subprocess import *
#
# subprocess.check_output() is new in Python 2.7
#
def _check_output(*popenargs, **kwargs):
r"""Run command with arguments and return its output as a byte string.
@mlafeldt
mlafeldt / gitweb-apache2.conf
Created February 23, 2011 21:00
working config for gitweb v1.7.4.1
#
# /etc/apache2/conf.d/gitweb
#
Alias /gitweb /var/www/gitweb
<Directory /var/www/gitweb>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
@mlafeldt
mlafeldt / scp_demo.py
Created February 24, 2011 09:09
[Python] paramiko examples
#!/usr/bin/env python
import sys, paramiko
if len(sys.argv) < 5:
print "args missing"
sys.exit(1)
hostname = sys.argv[1]
password = sys.argv[2]
@mlafeldt
mlafeldt / tapVerboseOutput.vim
Created April 20, 2011 20:16
Vim syntax file for TAP output
" Vim syntax file
" Language: Verbose TAP Output
" Maintainer: Rufus Cable <rufus@threebytesfull.com>
" Remark: Simple syntax highlighting for TAP output
" License:
" Copyright (c) 2008 Rufus Cable
if exists("b:current_syntax")
finish
endif
@mlafeldt
mlafeldt / hello.c
Created July 1, 2011 12:39
One-line header enabling executable single-file C scripts (via @reddit)
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
// Usage: bash ./hello.c
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello world!\n");
return 0;
#include <stdlib.h>
#include <stdio.h>
/* Create a lambda function. Note: unlike lambdas in functional
languages, this lambda does not capture the containing
environment. Thus, if you access the enclosing environment, you
must ensure that the lifetime of this lambda is bound by the
lifetime of the enclosing environment (i.e., until the enclosing
function returns). This means that if you access local
@mlafeldt
mlafeldt / pragpub_get.py
Created July 2, 2011 18:07
[Python] Find download links to all PragPub magazines
#!/usr/bin/env python
"""
find download links to all PragPub magazines
usage:
$ ./pragpub_get.py [pdf | html | epub | mobi] > pragpub.lst
$ wget -c -i pragpub.lst
written by Mathias Lafeldt <mathias.lafeldt@gmail.com>
@mlafeldt
mlafeldt / seradio_get.py
Created July 2, 2011 18:09
[Python] Find download links to all SE Radio podcasts
#!/usr/bin/env python
"""
find download links to all SE Radio podcasts
usage:
$ ./seradio_get.py > seradio.lst
$ wget -c -i seradio.lst
written by Mathias Lafeldt <mathias.lafeldt@gmail.com>
@mlafeldt
mlafeldt / softwarearchitektour_get.py
Created July 2, 2011 18:11
[Python] Find download links to all SoftwareArchitekTOUR podcasts
#!/usr/bin/env python
"""
find download links to all SoftwareArchitekTOUR podcasts
usage:
$ ./softwarearchitektour_get.py > files.lst
$ wget -c -i files.lst
written by Mathias Lafeldt <mathias.lafeldt@gmail.com>
@mlafeldt
mlafeldt / pod-style.css
Created September 14, 2011 21:25
Some CSS to pimp output of pod2html
body {
margin: 0;
max-width: 100ex;
padding: 0 9ex 1ex 4ex;
font-family: Helvetica;
}
h1 {
font-size: 20px;
}