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 / 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 / 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 / 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 / merge_dicts.py
Created November 25, 2015 04:55
Merge Python dictionaries
# This version accepts any number of dictionaries
# http://stackoverflow.com/a/26853961
def merge_dicts(*dict_args):
"""
Given any number of dicts, shallow copy and merge into a new dict,
precedence goes to key value pairs in latter dicts.
"""
result = {}
for dictionary in dict_args:
result.update(dictionary)
@pansapiens
pansapiens / cloudstor_link_convert.py
Last active January 11, 2019 09:07
[DEPRECATED] Convert a list of CloudStor (& Owncloud?) shared file page links into direct download links.
@pansapiens
pansapiens / inmembrane_signalp_trim.ipynb
Created September 3, 2015 00:56
Example of trimming SignalP predicted signal sequences using inmembrane
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pansapiens
pansapiens / gist:a40a847f37a7aa5d0dc9
Last active August 29, 2015 14:23
Electron density to VRML notes
# Tools:
# sf-convert: http://sw-tools.pdb.org/apps/SF-CONVERT/doc/V1-0-00/documentation.html
# Coot
# CCP4
# Pymol
# Get mmCIF format structure factors, and PDB coordinates
wget http://www.rcsb.org/pdb/files/r4J1Ysf.ent.gz
wget http://www.rcsb.org/pdb/files/4J1Y.pdb.gz
gunzip r4J1Ysf.ent.gz 4J1Y.pdb.gz
@pansapiens
pansapiens / standalone_html.py
Last active March 27, 2025 14:29
Convert HTML to a self contained file with inline Base64 encoded PNG images
#!/usr/bin/env python
# A simple script to suck up HTML, convert any images to inline Base64
# encoded format and write out the converted file.
#
# Usage: python standalone_html.py <input_file.html> <output_file.html>
#
# TODO: Consider MHTML format: https://en.wikipedia.org/wiki/MHTML
import os
from bs4 import BeautifulSoup
@pansapiens
pansapiens / gist:6016434
Created July 17, 2013 00:09
Bash one liner to monitor if the IP for a domain has changed each hour. Beep and tiny window alert. Users should change the domain (www.example.com) and the domains current A record IP (192.168.0.1).
while true; do if host www.example.com | grep "192.168.0.1"; then sleep 3600; else printf "\a"; xmessage -center "Domain propagated"; fi done
@pansapiens
pansapiens / gist:3127897
Created July 17, 2012 08:03
Ezproxy URL munging bookmarklet
javascript:(function(){var%20url_regex=/(https?:\/\/(?:[-\w\.]+)+(?::\d+)?)((?:\/([\w/_\-\.]*(\?\S+)?)?)?)/,url_results=url_regex.exec(document.location),new_url%20=%20url_results[1]+".proxy.com"+url_results[2];window.location=new_url;})()