Skip to content

Instantly share code, notes, and snippets.

@nhoffman
nhoffman / report-template.Rmd
Last active June 7, 2021 20:19
rmarkdown template
---
title: [title]
author: Noah Hoffman
date: "`r format(Sys.time(), '%Y-%m-%d')`"
output:
html_document:
toc: true
---
# setup
@nhoffman
nhoffman / git_commit_graph.py
Created October 28, 2017 15:03
Git commit graph
from scipy.interpolate import interp1d
import numpy as np
import shlex
import subprocess as sp
import prettyplotlib as ppl
from matplotlib import pyplot as plt
from matplotlib.ticker import FuncFormatter
import io
@nhoffman
nhoffman / tmux-notes.org
Last active April 3, 2017 17:16
My tmux notes

tmux notes

sessions

Create a new session then rename it:

C-b :new
C-b $

Create a new named session:

@nhoffman
nhoffman / SConstruct.py
Last active March 18, 2019 20:45
SConstruct template
import os
import sys
# Ensure that a virtualenv is active before importing non-stdlib dependencies.
venv = os.environ.get('VIRTUAL_ENV')
if not venv:
sys.exit('--> an active virtualenv is required'.format(venv))
from SCons.Script import (Environment, Variables, Help, Decider)
@nhoffman
nhoffman / ssh-tunnel.sh
Last active August 28, 2017 16:40
open an ssh tunnel and point a browser to it
#!/bin/bash
# Requires argparse.bash (https://github.com/nhoffman/argparse-bash)
# in the same directory as this script
# Installation:
# cd ~/bin # or another location on your $PATH
# curl https://gist.githubusercontent.com/nhoffman/8636c6e267cb4403ac3a35ff0bc53f3d/raw/ > ssh-tunnel
# chmod +x ssh-tunnel
# curl -O https://raw.githubusercontent.com/nhoffman/argparse-bash/master/argparse.bash
#!/usr/bin/python2.7
"""
Performs a web BLAST query against NR using DNA sequences read from a fasta
file, storing the results in a SQLite database.
Dependencies: BioPython
BioPython may be installed using the Python package index:
$ sudo easy_install -f http://biopython.org/DIST/ biopython
@nhoffman
nhoffman / incremental_backup.sh
Last active June 16, 2016 21:51
Incremental backup using rsync
#!/bin/bash
# Incremental backup using rsync
# see http://www.mikerubel.org/computers/rsync_snapshots/#Incremental
set -e
BACKUP_DIR=backup
rot_cycle_days=7 # for example
@nhoffman
nhoffman / knitr-cli.R
Created March 17, 2016 04:08
knit R markdown files
#!/usr/bin/env Rscript
if(Sys.getenv("VIRTUAL_ENV") == ""){ stop("An active virtualenv is required") }
source(file.path(Sys.getenv('VIRTUAL_ENV'), 'bin', 'rvenv'))
suppressPackageStartupMessages(library(argparse, quietly = TRUE))
suppressPackageStartupMessages(library(rmarkdown, quietly = TRUE))
main <- function(arguments){
import os
import sys
import ConfigParser
from os import path, environ
import glob
import itertools
venv = environ.get('VIRTUAL_ENV')
if not venv:
sys.exit('--> an active virtualenv is required'.format(venv))
@nhoffman
nhoffman / sshmount
Last active August 29, 2015 14:10
bash function for mounting a directory via sshfs
sshmount () {
# Usage: sshmount host directory
host=$1
pth=$2
mountpoint=~/mnt/${host}+$(basename $pth)
mkdir -p $mountpoint
sshfs $host:$pth $mountpoint -oauto_cache,reconnect,defer_permissions,negative_vncache,volname=${host}+$(basename $pth)
cd $mountpoint
echo "unmount using: umount $mountpoint"
}