Skip to content

Instantly share code, notes, and snippets.

View mschubert's full-sized avatar
🧬

Michael Schubert mschubert

🧬
View GitHub Profile
@mschubert
mschubert / test_monitor.c
Created May 14, 2023 08:02
ZeroMQ test ZMQ_ROUTER_NOTIFY draft option
// gcc -DZMQ_BUILD_DRAFT_API=ON -lzmq -o test_monitor test_monitor.c
// ./test_monitor
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zmq.h>
void recv_print(void *frontend) {
zmq_msg_t message;
" install plug by
" curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" expand tab with 4 spaces
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
set autoindent
@mschubert
mschubert / download_icgc.sh
Last active July 30, 2018 02:50
Download ICGC public release in a semi-automated manner
# Download ICGC public release in a semi-automated manner
#
# Usage: ./download_icgc.sh
#
# Be sure to check the original link to contain all summary files
# https://dcc.icgc.org/releases/release_23/Summary
# and list all files you want from the cohorts in contents().
#
# There may be different contents in the project folders. Check a couple, e.g.:
# https://dcc.icgc.org/releases/release_23/Projects/CLLE-ES
@mschubert
mschubert / .bashrc
Created December 22, 2016 21:34
Type the first letters of an old command and then "up-arrow" search
# enable line editing for terminal
if [ -t 1 ]; then
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
fi
n = 1:1e7
# use a loop
new_n = rep(NA, length(n))
for (i in seq_along(n))
new_n[i] = n[i] * 2 - 5
# use *apply
new_n = sapply(n, function(x) x * 2 - 5)
# ignore system installation
# e.g. https://github.com/EBI-predocs/research-software/issues/57
.libPaths("~/.R")
# no factor coercion
# no graphical package install menu
# warn if partial matching arguments
options(
stringsAsFactors = FALSE,
@mschubert
mschubert / Makefile
Last active May 3, 2023 18:51
Simple function to delegate target creation to another Makefile without losing dependency information
# Consider the following setup:
#
# root
# + a
# | + Makefile
# | + ..some other files..
# + b
# + Makefile
# + ..some other files..
#
@mschubert
mschubert / LSF.tmpl
Last active August 29, 2015 14:27
Minimal example of using rzmq to submit a worker job using LSF
#BSUB-J {{ job_name }} # name of the job / array jobs
#BSUB-o {{ log_file | /dev/null }} # output is sent to logfile, stdout + stderr by default
#BSUB-P {{ queue }} # Job queue
#BSUB-W {{ walltime }} # Walltime in minutes
#BSUB-M {{ memory | 4096 }} # Memory requirements in Mbytes
#BSUB-R rusage[mem={{ memory | 4096 }}] # Memory requirements in Mbytes
#BSUB-R select[panfs_nobackup_research]
R --no-save --no-restore --args "{{ args }}" < "{{ rscript }}"
#
# loading the table, converting it to an expression matrix
#
df = read.table(
"GBM.rnaseqv2__illuminahiseq_rnaseqv2__unc_edu__Level_3__RSEM_genes__data.data.txt",
header=TRUE, sep="\t", stringsAsFactors=FALSE)
expr = data.matrix(df[2:nrow(df), df[1,]=="raw_count"])
rownames(expr) = df[2:nrow(df), 1]
#
@mschubert
mschubert / delay.py
Last active August 29, 2015 13:58
When starting a command using delay.py, delays the start of subsequent calls. This can be useful to e.g. limit peak file system load on a computing cluster.
#!/usr/bin/env python2.7
import sys, os.path
import subprocess
import time
import lockfile
import threading
lock = lockfile.FileLock(os.path.join(os.path.expanduser("~"), ".delay"))
lock.acquire()