Skip to content

Instantly share code, notes, and snippets.

View pansapiens's full-sized avatar

Andrew Perry pansapiens

  • Melbourne, Australia
View GitHub Profile
@pansapiens
pansapiens / install_docker.sh
Last active July 4, 2017 05:41 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
#!/usr/bin/env bash
UBUNTU_RELEASE=$(lsb_release --codename --short)
export COMPOSE_VERSION=1.8.0
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
sudo apt-get update
sudo apt-get install python-pip apt-transport-https ca-certificates
@pansapiens
pansapiens / filter_counts.py
Last active October 26, 2016 22:42
Given a counts table from featureCounts (subread) and a GTF/GFF FeatureDB database, output a table with a gene name column ("symbol") containing only counts from "protein_coding" exon features.
#!/usr/bin/env python
import sys
import os
import argparse
import pandas as pd
import gffutils
def create_featuredb(gtf_file, output_file=':memory:'):
"""
@pansapiens
pansapiens / make_tiled_composite_video.py
Created November 28, 2016 03:46
Generate a composite tiled video from multiple input videos
#!/usr/bin/env python
"""
Given a list of video files, creates a tiled output video with each
input video playing simulutaneously with mixed audio.
The result is something like a composite security camera feed, or the
"Brady Bunch" opening credits.
DISCLAIMER: The author holds no responsibility for your actions if you
become criminally insane from watching all nine Puppet Master films
simultaneously. You have been warned.
@pansapiens
pansapiens / Dockerfile
Last active April 19, 2017 04:40
bcl2fastq 2.19 in Docker
############################################################
# Dockerfile to build bcl2fastq container images
# Based on CentOS images made by fatherlinux
# fatherlinux is a RedHat developer
# http://developerblog.redhat.com/2014/05/15/practical-introduction-to-docker-containers/
# Fork from version by: Cyril Firmo <firmo@biologie.ens.fr>
############################################################
# Build:
# docker build -t bcl2fastq:2.19.0.316 -t bcl2fastq:2.19 -t bcl2fastq:latest .
#
@pansapiens
pansapiens / daves_bracket_challenge.py
Created March 7, 2017 02:48
Check that brackets are balanced
friend = {'}':'{', ']':'[', ')':'('}
close = friend.keys()
open = friend.values()
def check(input):
stack = []
for c in input:
if c in open:
stack.append(c)
elif c in close:
@pansapiens
pansapiens / hamming_paths.ipynb
Last active March 19, 2017 00:37
Dave & Bernie's Hamming Challenge
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pansapiens
pansapiens / images2pdf.py
Created April 9, 2017 07:45
Convert a directory of images or scanned pages to a PDF
#!/usr/bin/env python
# Creates a PDF from a set of images in a directory (one image per page, alphanumeric ordering).
#
# Usage:
# python images2pdf.py output_file.pdf
#
# Requires:
# pip install fpdf
from fpdf import FPDF
@pansapiens
pansapiens / build_mytardis_ubuntu_trusty.sh
Last active July 5, 2017 05:26
Setup MyTardis on Ubuntu 14.04
#!/bin/bash
# For MyTardis 3.7 - YMMV for other versions
set USER=ubuntu
set MYTARDIS_ADMIN_NAME=admin
set MYTARDIS_ADMIN_EMAIL=spam+mytardis@pansapiens.com
set MYTARDIS_DATA_DIR=/data/mytardis
set SETUP_DYNAMIC_DNS=no
set CREATE_DATA_VOLUME=no
@pansapiens
pansapiens / lock_file.py
Created May 14, 2017 01:44
Acquire an exclusive lock on a file (prevent two copies of a script running concurrently)
# Lightly modified from: https://gist.github.com/kjpgit/ceab4fc029c778dd1675bea8592e3bc1
# Useful to ensure two copies of a script aren't running concurrently (assuming they use
# the same lock file, trying to lock it twice will raise IOError).
import fcntl
def _lock_file_exclusively(path):
"""
Open @path and lock it exlusively.
Return: file object, which you must maintain a reference to
(if it is closed, the lock is released).
@pansapiens
pansapiens / circular_permute_chain_email.py
Last active June 22, 2017 09:51
Finds all English dictionary words that are the same when you move the first letter to the end and then reverse it
import requests
from cashier import cache
"""
TO ALL MY INTELLIGENT FRIENDS: WHAT DO THESE 7 WORDS HAVE IN COMMON?
I am sending this only to my smart friends. I could not figure it out. See if you can figure out what these seven words all have in common
1. Banana
2. Dresser