Skip to content

Instantly share code, notes, and snippets.

@martijnvermaat
martijnvermaat / monkey.py
Created July 27, 2011 08:32
Monkey patch for the Python SUDS library
"""
Monkey patch: http://en.wikipedia.org/wiki/Monkey_patch
"""
def monkey_patch_suds():
"""
Apply our monkey patch for the suds package.
For some weird reason the location http://www.w3.org/2001/xml.xsd is used
@martijnvermaat
martijnvermaat / clean_directory.py
Created August 19, 2011 12:00
Clean a directory (e.g. cache) by removing rarely used files.
#!/usr/bin/env python
"""
Clean a directory (e.g. cache) by removing rarely used files.
Usage:
./clean_directory directory [max_size]
The max_size argument is expected in megabytes. File removals are reported to
standard output and afterwards empty directories are (silently) removed.
@martijnvermaat
martijnvermaat / gpl-and-closed-software.markdown
Created September 7, 2011 21:15
The GPL in combination with closed source software

The GPL in combination with closed source software

Here are a few issues concerning GPL-licensed software in combination with closed source software. We assume [version 2 of the GPL] [1] in the following discussion.

What exactly is a work "derived from" the Program?

@martijnvermaat
martijnvermaat / try.py
Created November 23, 2011 13:38
Try something a predefined number of times
#!/usr/bin/env python
"""
Example Python pattern: try something a number of times, and only really fail
after that.
"""
import sys
import time
@martijnvermaat
martijnvermaat / trim_common_suffix.py
Created December 28, 2011 16:11
Trim common suffix from sequences
def trim_common_suffix(sequences):
"""
Trim a list of sequences by removing the longest common suffix while
leaving all of them at least one character in length.
"""
@martijnvermaat
martijnvermaat / gist:1717830
Created February 1, 2012 16:23
GitHub mirror of the LOVD3 Subversion repository

This documents how to setup and maintain a GitHub mirror of the official LOVD3 Subversion repository. It is synchronized automatically with the LOVD3 Subversion repository every hour. The mirror only contains SNV trunk (Git master branch), so no branches or tags.

The Git repository was setup using the following commands:

mkdir LOVD3.git
cd LOVD3.git

git init

@martijnvermaat
martijnvermaat / variants_by_region.py
Created February 23, 2012 08:38
Get variants from our in-house database by region
#!/usr/bin/env python
"""
Get variants from our in-house database by region.
Query our in-house variant database for population study variants (e.g. GoNL
or 1KG) contained in the provided region(s) and show their respective
frequencies. The region(s) must be provided in a BED file [1].
[1] http://genome.ucsc.edu/FAQ/FAQformat.html#format1
@martijnvermaat
martijnvermaat / encrypted-root-debian-wheezy.markdown
Created May 18, 2012 16:55
Encrypted root filesystem on Debian Wheezy

Encrypted root filesystem on Debian Wheezy

This documents how to set up an encrypted root filesystem (except for /boot) on Debian Wheezy with automatic mounting using a keyfile on a USB drive.

Basic setup

In the Debian Installer, choose "Guided - use entire disk and set up encrypted LVM". That's it, on boot you will be asked to enter you passphrase using the keyboard. My system does not usually have a keyboard attached, so that's not very convenient (but read on).

@martijnvermaat
martijnvermaat / qmake-non-default-project.markdown
Created September 13, 2012 13:05
Set non-default project name for qmake jobs

Set non-default project name for qmake jobs

This is a hack to run jobs on an SGE cluster using qmake under another project than your default project.

Most of the SGE job runners have the -P option. Unfortunately, as the manpage mentions, the option is not available for qmake:

-P project_name
       Available for qsub, qsh, qrsh, qlogin and qalter only.

Specifies the project to which this job is assigned.

@martijnvermaat
martijnvermaat / README.md
Last active November 11, 2020 13:09
Download SRA run files for given sample names

Download SRA run files for given sample names

Have all sample names in samples, one per line and run:

for sample in $(cat samples); do
    IFS=$'\n'
    for line in $(./sra-runs.py $sample); do
        echo $sample $line >> runs

done