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 / 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 / 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 / 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 / public_openapi.py
Last active November 28, 2019 09:28
drf_openapi: show all endpoints irrespective of user authentication
from drf_openapi.views import SchemaView
from drf_openapi.entities import OpenApiSchemaGenerator
from rest_framework.renderers import CoreJSONRenderer
from drf_openapi.codec import OpenAPIRenderer, SwaggerUIRenderer
from rest_framework import response, permissions
class PublicOpenApiSchemaGenerator(OpenApiSchemaGenerator):
"""
@pansapiens
pansapiens / openapi_yaml.py
Created January 4, 2018 02:35
drf_openapi: Render YAML OpenAPI / Swagger instead of JSON
import yaml
from rest_framework import status
from rest_framework_swagger.renderers import OpenAPIRenderer as _OpenAPIRenderer
from rest_framework.renderers import JSONRenderer
from openapi_codec import OpenAPICodec as _OpenAPICodec
from coreapi import Document
from drf_openapi.codec import _generate_openapi_object
from coreapi.compat import force_bytes
from collections import OrderedDict
# Build like: $ sudo singularity build --writable consexpression.simg Singularity
# Run like: $ singularity run --bind CONFIG_tool.txt:/consexpression/dao/CONFIG_tool.txt consexpression.simg
Bootstrap: docker
From: ubuntu:17.10
# Bootstrap: debootstrap
# OSVersion: xenial
# MirrorURL: http://au.archive.ubuntu.com/ubuntu/
@pansapiens
pansapiens / ENA REST API.ipynb
Created January 22, 2018 04:01
Interacting with the ENA REST API
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am pansapiens on github.
  • I am pansapiens (https://keybase.io/pansapiens) on keybase.
  • I have a public key ASADQ2rj-JVJbBwI3120kk1etbdVu-bi38W1gm8JKZ3R0go

To claim this, I am signing this object:

@pansapiens
pansapiens / views.py
Created February 20, 2018 01:26
Django REST Framework CSV parser, RFC 4180
from typing import Dict, List
import csv
from rest_framework import status
from rest_framework.response import Response
from rest_framework.parsers import JSONParser, BaseParser
from rest_framework.views import APIView
class CSVTextParser(BaseParser):
"""
A CSV parser for DRF APIViews.
#!/bin/bash
# A simple script for mounting NTFS disks on macOS
if [ $# -eq 0 ]; then
diskutil list
echo
echo "No arguments provided."
echo "Usage: mount-ntfs.sh [diskXsY]"
echo "eg: mount-ntfs.sh disk2s2"
echo