Skip to content

Instantly share code, notes, and snippets.

View willfurnass's full-sized avatar

Will Furnass willfurnass

View GitHub Profile
@willfurnass
willfurnass / shear_stress.m
Last active August 29, 2015 14:09
Calculate steady-state boundary shear stress in pressurised water pipes
function tau_a = shear_stress(D, Q, k_s, T, den)
%{ Hydraulic shear stress at pipe wall (in Pa).
%
% Params:
% D -- internal diameter (m)
% Q -- flow (m^3s^-1)
% k_s -- roughness height (m)
% T -- temperature; defaults to 10degC)
% den -- density defaults to 1000kg/m^3
%
@willfurnass
willfurnass / zotero_shorttitle_as_bibtex_key.patch
Created February 20, 2016 16:19
Patch Zotero's translators/BibTeX.js so non-empty shortTitle values used as BibTeX key when exporting Zotero library.
--- BibTeX.js.orig 2015-07-03 07:18:37.000000000 +0100
+++ BibTeX.js 2015-08-09 14:21:08.779706944 +0100
@@ -1176,7 +1176,11 @@
if(!type) type = "misc";
// create a unique citation key
- var citekey = buildCiteKey(item, citekeys);
+ if (item.shortTitle==''){
+ var citekey = buildCiteKey(item, citekeys);
+ } else {
@willfurnass
willfurnass / bng.py
Created March 1, 2016 18:36
Convert alphanumeric British National Grid references to/from easting northing integer pairs
import numpy as np
myriad_codes = np.array((
None, None, None, None, "HP", None, None,
None, None, None, "HT", "HU", None, None,
None, "HW", "HX", "HY", "HZ", None, None,
"NA", "NB", "NC", "ND", None, None, None,
"NF", "NG", "NH", "NJ", "NK", None, None,
"NL", "NM", "NN", "NO", None, None, None,
None, "NR", "NS", "NT", "NU", None, None,
@willfurnass
willfurnass / ruffus_simple_drmaa_test.py
Last active January 11, 2017 13:40
Ruffus + DRMAA test
#!/usr/bin/env python
# A test of whether Ruffus can be used to submit jobs to a cluster using the
# DRMAA API, sharing the DRMAA session between threads to allow multiple jobs to
# be submitted at once without burdening the head node with multiple DRMAA
# sessions.
# Can run this from a conda environnment created using
# conda create -n drmaatest -c bioconda python=2.7 ruffus drmaa
@willfurnass
willfurnass / ruffus_simple_test.py
Created January 11, 2017 12:27
Simple test of the Ruffus workflow manager
#!/usr/bin/env python
from __future__ import print_function
from ruffus import transform, suffix, pipeline_run
# A test of using Ruffus to locally run a very simple pipeline comprised of
# tasks defined as Python functions
# Can run this from a conda environnment created using
# conda create -n drmaatest -c bioconda python=2.7 ruffus drmaa
@willfurnass
willfurnass / qrshx
Created April 19, 2017 14:44
Simple wrapper for Sun Grid Engine's qrsh that propagates SGE environment variables and enables X forwarding
#!/bin/sh
# David Jones and Will Furnass (University of Sheffield)
# `qrsh` is often the most convenient utility for starting interactive shell
# sessions on Sun/Son of Grid Engine (SGE) clusters but it has some limitations (as
# configured on the ShARC/Iceberg clusters):
#
# - none of the standard SGE environment vars (e.g. JOB_ID, PE_HOSTFILE,
# NSLOTS) that are defined in qsub/qsh batch/interactive sessions are set
# (annoying but not the end of the world);

tmux tips

Default prefix: <ctrl>b

Session management

  • tmux new -s session_name - creates a new tmux session named session_name
  • tmux a - attach to first available session
  • tmux attach -t session_name - attaches to an existing tmux session named session_name
  • tmux switch -t session_name - switches to an existing session named session_name
@willfurnass
willfurnass / sge_cheatsheet.md
Last active April 19, 2023 15:00
(Son of) Grid Engine tips and tricks

Random Grid Engine tips and tricks

The following work with Son of Grid Engine (SGE) 8.1.9 as configured on the University of Sheffield's ShARC and Iceberg clusters.

Jobs with dependancies

You can use the -hold_jid <<job-name or job-name>> option to make jobs run only when other jobs have finished, rather than having jobs start and sit waiting for other tasks to complete.

@willfurnass
willfurnass / README.md
Created June 1, 2017 11:21
Separating Reveal.js from your presentation content using git subrepo

Initialise a git repository:

cd somedir
git init

Install git subrepo if you haven't done so already:

https://github.com/ingydotnet/git-subrepo#installation
@willfurnass
willfurnass / dss2emails.sh
Last active February 20, 2022 12:03
Extract usernames and emails from a Synology DSS config dump file (.dss)
#!/bin/bash
# Will Furnass
# Oct 2017
if [[ $# -lt 1 ]]; then
echo 1>&2 "Extract list of user email addresses from Synology DSS '.dss' config dump"
exit 1
fi
dss_path="$1"