Skip to content

Instantly share code, notes, and snippets.

@naveenarun
naveenarun / slack.sh
Last active March 7, 2023 08:27
Bash function for sending a verbose slack message (containing path, command, error code, and custom message) after a process or series of processes exit
# Place this in your .bashrc
# Covers several corner cases such as nested apostrophes, history extraction in screens/subshells, Slack being down, etc.
# Strings to replace with your own credentials:
## {your email address} (1 instance)
## {slack webhook url} (1 instance) (see guide below)
## {your computer name} (2 instances)
# How to set up a Slack webhook (as of Jul 2019):
## Go here: https://api.slack.com/apps?new_app=1.
## Click “incoming webhooks” and turn the slider on
@naveenarun
naveenarun / get_rxns.sh
Last active March 5, 2019 04:52
Reaction List [cite as "Naveen Arunachalam, 10.65 (Spring 2019)"]
cat rtable_raw.txt | grep '^R' | sed 's/R\(.\{1,2\}\)/\1/g; s/\([0-9]\.\).*$//g; s/( + M)//g; s/\([a-zA-Z]*\) \([1-9]\)\( \)\?\(-[1-9]\)\?/\1\2\4/g; s/\([+=]\)/ \1 /g' > rxns.txt
cat rxns.txt | sed 's/^[0-9]\{1,2\}//g; s/^\(.*\)=\(.*\)/\1\n\2/g' | awk '{ for(i = 1; i <= NF; i++) { if ($i!="+") {print tolower($i)} } }' | sed 's/^[0-9]//g' | sort -u > species.txt
cat rxns.txt | sed 's/^..\? //g; s/ [0-9]\(.*\)/ \1 + \1/g' | awk '{print tolower($0)}' > rxns_refined.txt