Skip to content

Instantly share code, notes, and snippets.

View matsen's full-sized avatar

Erick Matsen matsen

View GitHub Profile
@matsen
matsen / svg2tiff
Created December 12, 2012 01:05
A script to convert SVG to a TIFF acceptable to PLOS
#!/bin/sh
# Convert all arguments (assumed SVG) to a TIFF acceptable to PLOS
# Requires Inkscape and ImageMagick 6.8 (doesn't work with 6.6.9)
for i in $@; do
BN=$(basename $i .svg)
inkscape --without-gui --export-png="$BN.png" --export-dpi 300 $i
convert -compress LZW -alpha remove $BN.png $BN.tiff
mogrify -alpha off $BN.tiff
@matsen
matsen / refresh-ssh-in-tmux.sh
Created January 3, 2020 14:42
A shell command to refresh SSH_AUTH_SOCK in a running tmux session
r () {
if [[ -n $TMUX ]]
then
NEW_SSH_AUTH_SOCK=`tmux showenv|grep "^SSH_AUTH_SOCK"|cut -d = -f 2`
if [[ -n $NEW_SSH_AUTH_SOCK ]] && [[ -S $NEW_SSH_AUTH_SOCK ]]
then
echo "New auth sock: $NEW_SSH_AUTH_SOCK"
SSH_AUTH_SOCK=$NEW_SSH_AUTH_SOCK
fi
NEW_DISPLAY=`tmux showenv|grep "^DISPLAY"|cut -d = -f 2`
@matsen
matsen / md-nb-diffs.md
Last active February 22, 2021 21:44 — forked from iamlemec/nb2md
Markdown diffs for jupyter notebooks.

For sane jupyter notebook diffs

  • Install the nbconvert package, though you probably already have it if you are using jupyter.
  • Put the nb2md script below in your path and make executable
  • Add the following to your .gitattributes file, which can be in your home directory (use nb2md for all projects) or in the root of your project:
*.ipynb diff=nb2md
  • Run
#!/bin/sh
set -e
set -o
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y \
autojump \
# A modification of `gallifrey` to show virtualenv information.
# I also found the return code information to be annoying, so it's commented out.
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
PROMPT='%{$fg[green]%}%m%{$reset_color%} $(virtualenv_prompt_info)%2~ $(git_prompt_info)%{$reset_color%}%B»%b '
#RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
@matsen
matsen / latex-skeleton.tex
Last active October 27, 2016 19:52
Framework for a latex file designed for both arXiv and journal submission.
\documentclass{amsart}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage[notref,notcite]{showkeys}
\usepackage{url}
% in case of supplementary material
% \usepackage{xr}
% \externaldocument{lcfit_supp}
@matsen
matsen / prep-crouton.sh
Last active October 17, 2016 17:55
Preparing a crouton chroot environment for productivity.
#!/bin/sh
# sudo visudo
# matsen ALL = (root) NOPASSWD: /usr/local/bin/xiwi,/usr/bin/evince,/usr/bin/inkscape
set -e
set -o
sudo hostnamectl set-hostname flyx
@matsen
matsen / seqs2png
Last active February 9, 2016 04:11
A simple script to render a molecular sequence file as a PNG, with a specified number of pixels per symbol.
#!/usr/bin/env python
"""
Turn a sequence file into a PNG, with a specified number of pixels per symbol.
Gaps are shown in light gray.
Unknown symbols, including N and X, are shown in pink.
Requires matplotlib, seqmagick, and their dependencies.
"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matsen
matsen / sysbio.tex
Last active December 15, 2015 15:29
Framework for a latex file designed for both arXiv and Systematic Biology submission.
%%For arXiv, uncomment this block and comment the next block.
%\documentclass{amsart}
%\usepackage{amsmath,amsfonts,amssymb,amsthm}
%\usepackage[english]{babel}
%\usepackage{graphicx}
%\usepackage{url}
%\usepackage[round]{natbib}
%\newcommand{\forarxiv}[1]{#1}
%\newcommand{\notforarxiv}[1]{}