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 / download-uniprot-release.sh
Created November 22, 2017 22:45
Download the latest Uniprot (Swissprot+Trembl) release, make a BLAST database
#!/bin/bash
set -e
# Downloads the lastet release of Uniprot, putting it in a release-specific directory.
# Creates associated BLAST databases.
# We need makeblastdb on our PATH, somehow
# module load blast
# Better to use a stable DOWNLOAD_TMP name to support resuming downloads
@pansapiens
pansapiens / authorize-key
Created November 3, 2017 03:20
A quick script to add a public SSH key to the authorized_keys on another host
#!/bin/sh
set -e
if grep PRIVATE $1 >/dev/null; then
echo "Use the public key ($1.pub), not the private one !"
exit -1
fi
cat $1 | ssh $2 'umask 0077; mkdir -p .ssh; cat >> .ssh/authorized_keys && echo "Key $1 added to .ssh/authorized_keys on $2"'
@pansapiens
pansapiens / switch_docker_image_library_path.sh
Last active November 11, 2020 22:25
Move /var/lib/docker to a new location
##
# Update - no longer works. You need to also:
# edit: /lib/systemd/system/docker.service
# then run: sudo systemctl daemon-reload
# see, https://medium.com/@ibrahimgunduz34/how-to-change-docker-data-folder-configuration-33d372669056
#
# TODO: Fix this to use sed or similar to edit /lib/systemd/system/docker.service
##
# From: https://forums.docker.com/t/how-do-i-change-the-docker-image-installation-directory/1169
@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
@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 / 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 [email protected]
set MYTARDIS_DATA_DIR=/data/mytardis
set SETUP_DYNAMIC_DNS=no
set CREATE_DATA_VOLUME=no
@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 / hamming_paths.ipynb
Last active March 19, 2017 00:37
Dave & Bernie's Hamming Challenge
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / 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 <[email protected]>
############################################################
# Build:
# docker build -t bcl2fastq:2.19.0.316 -t bcl2fastq:2.19 -t bcl2fastq:latest .
#