Skip to content

Instantly share code, notes, and snippets.

View alanhoyle's full-sized avatar

Alan Hoyle alanhoyle

View GitHub Profile
@alanhoyle
alanhoyle / body.sh
Last active November 7, 2023 15:18
body (): a bash function that prints the first few lines of STDIN (1 line default) and then runs a command on the remaining STDIN
body() {
local HEADER_LINES=1
local COMMAND="sort"
if [ -t 0 ]; then
>&2 echo "ERROR: body requires piped input!"
>&2 echo ""
fi
if [[ -t 0 || "$1" == "-h" || "$1" == "--help" ]] ; then
@alanhoyle
alanhoyle / treasurydirect_copypasta.user.js
Last active May 25, 2023 18:02 — forked from dennisstewart/treasurydirect_copypasta.user.js
Re-enables the password box on TreasuryDirect.gov so I can paste from my password manager
// ==UserScript==
// @name TreasuryDirect Copypasta
// @namespace https://www.treasurydirect.gov/RS/PW-Display.do
// @version 0.2
// @description Allow creds to be pasted from a password manager into the TreasuryDirect login form.
// @author Dennis Stewart (update by Alan Hoyle)
// @license The Strong Style Public License https://raw.githubusercontent.com/dennisstewart/cvs-checker-py/main/LICENSE
// @match https://www.treasurydirect.gov/RS/PW-Display.do
// @match https://treasurydirect.gov/RS/PW-Display.do
// @icon https://www.google.com/s2/favicons?sz=64&domain=treasurydirect.gov
@alanhoyle
alanhoyle / fix_file.sh
Created May 10, 2022 22:23
Insert line in file and keep timestamp
temp_file=$(mktemp)
touch -r $1 $temp_file
sed -i '/^.*put something above me.*/i text_to_be_inserted' $1
touch -r $temp_file $1
rm $temp_file
@alanhoyle
alanhoyle / etsy_same_tab.js
Last active May 9, 2022 14:09
Force etsy links to open in the same tab/window. (Tampermonkey/greasemonkey/etc)
// ==UserScript==
// @name etsy same window
// @namespace http://tampermonkey.net/
// @version 0.1
// @description stop etsy from opening new tabs for everything
// @author Alan Hoyle
// @match https://www.etsy.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@alanhoyle
alanhoyle / # gcc - 2022-01-04_11-14-44.txt
Created January 4, 2022 16:17
gcc on "CentOS Linux release 7.7.1908 (Core)" - Homebrew build logs
Homebrew build logs for gcc on "CentOS Linux release 7.7.1908 (Core)"
Build date: 2022-01-04 11:14:44
@alanhoyle
alanhoyle / # yafc - 2021-12-17_15-53-28.txt
Created December 17, 2021 21:03
yafc on "CentOS Linux release 7.7.1908 (Core)" - Homebrew build logs
Homebrew build logs for yafc on "CentOS Linux release 7.7.1908 (Core)"
Build date: 2021-12-17 15:53:28
@alanhoyle
alanhoyle / install_packages_or_die.R
Created February 18, 2021 15:30
Install packages or die function for R
# This function attempts to install a provided list of packages.
# If one of the requested installs fails, it throws an R Error. By default
# This is a useful function to use in a Dockerfile or command line.
# You can put run this at a command line with:
R -e " \
install_packages_or_die <- function (pkgs, repos='http://cran.rstudio.com/') { \
for (l in pkgs) { install.packages(l, dependencies=TRUE, repos=repos); \
if ( ! library(l, character.only=TRUE, logical.return=TRUE) ) { \
@alanhoyle
alanhoyle / vep_for_vcf2maf.sh
Last active November 30, 2020 16:51
Build VEP cache for vcf2maf
# based on https://gist.github.com/ckandoth/5390e3ae4ecf182fa92f6318cfa9fa97
VEP_VER=97
VEP_CACHE=/opt/vep-cache
mkdir -p ${VEP_CACHE}
vep_install -a ap --NO_HTSLIB --NO_TEST --NO_UPDATE -s homo_sapiens -y GRCh38 -c ${VEP_CACHE} --convert --cache_version ${VEP_VER} --PLUGINS LoF
wget https://raw.githubusercontent.com/konradjk/loftee/v0.3-beta/splice_module.pl -O ${VEP_CACHE}/Plugins/splice_module.pl
@alanhoyle
alanhoyle / container_status.sh
Created April 12, 2019 21:01
Simple script to check if the current shell is running in a linux container
#! /usr/bin/env sh
if [[ "$OSTYPE" == "linux-gnu" ]] ; then
if grep -q docker /proc/1/cgroup || test -e /.dockerenv ; then
echo DOCKER ;
elif grep -q lxc /proc/1/cgroup ; then
echo LXC ;
elif test -z ${SINGULARITY_CONTAINER+x} ; then
echo no_container ;
else
@alanhoyle
alanhoyle / Dockerfile-oracle-perl
Last active May 25, 2018 14:36
Dockerfile to build an image for Perl connecting with an Oracle DB via the InstantClient
FROM store/oracle/database-instantclient:12.2.0.1
# I believe one needs to be authenticated to DockerHub to use this image.
# Oracle Linux is RPM based, and these are the requirements for a basic CPAN install for this
RUN yum install -y \
gcc \
gzip \
perl \
perl-App-cpanminus \
perl-DBI \