Skip to content

Instantly share code, notes, and snippets.

View paulboardman's full-sized avatar

Paul Boardman paulboardman

View GitHub Profile
@paulboardman
paulboardman / purrr_map_dfc_example.R
Created March 7, 2019 18:37
use purrr::map_dfc to update all cells in a data.frame
# replace all insances of '.' in all columns without changing anything else.
dt <- data.frame(
a=sample(LETTERS, 10),
b=sample(c('.', 1, 2, 3), 10, replace=T),
c=sample(c('.', 'rick', 'morty', 'summer'), 10, replace=T))
# print the data.frame
dt
# use purrr::map_dfc to loop through the columns of the data.frame
# if the 'update manager' isn't working properly then ssh in to OMV with admin account
apt-get update && apt-get dist-upgrade && omv-update
# to move to next release
omv-release-upgrade
@paulboardman
paulboardman / grep_sdf.sh
Last active January 30, 2018 17:20
count the number of SDF entries in a file
grep -c $'$$$$' <filename>
@paulboardman
paulboardman / xargs_logging.sh
Last active September 5, 2017 09:09
capture stdin and stderr from xargs command
# create babel fastsearch indexes and capture the output
find . -name "*20M.smi" -print0 | \
xargs -P 3 -L 1 -0 -I{} sh -c 'babel "$1" -ofs &> "$1.log"' -- {})
@paulboardman
paulboardman / color_grep.R
Created February 14, 2017 14:19
R: grep for color name
grep("orange", color())
@paulboardman
paulboardman / ssh_termination.txt
Last active January 18, 2017 11:23
Terminate a frozen SSH session without closing the terminal
[Enter]
~.
@paulboardman
paulboardman / rand_cv_fold_assign.sh
Created January 9, 2017 14:18
example random cv fold assignment
#!/bin/bash -eu
CV_FOLDS=5
while read mol_name label; do
FOLD=$(( (RANDOM % $CV_FOLDS) + 1));
echo -e "mol_name\tlabel\t$FOLD";
done
@paulboardman
paulboardman / gist:e32addbe1715c027e8b231e28cd088ac
Created January 9, 2017 14:12
Generate n integers selected randomly from 1 to m
#!/bin/bash -eu
n=100
m=5
for i in $(seq 1 $n); do
echo $(( (RANDOM % $m) + 1));
done
@paulboardman
paulboardman / list_user_packages.R
Last active April 25, 2017 11:50
R script for printing out the list of user installed packages along with their version number
# generates the list of user installed packages and prints out the name and version number
user_packages <- as.data.frame(installed.packages(priority="NA"), stringsAsFactors=F)
print(unique(user_packages[c('Package', 'Version')]), row.names=F)
@paulboardman
paulboardman / bit_rmcached.sh
Created November 12, 2015 11:17
Git: remove files from index that are listed in .gitignore
# list the files in the index that are ignored via patterns in .gitignore
git ls-files -i --exclude-from=.gitignore
# remove these files - assuming filenames with no spaces or special characters
git rm --cached $(git ls-files -i --exclude-from=.gitignore)
# remove these files - assuming filenames with spaces (urgh!)
git ls-files -i --exclude-from=.gitignore -z | xargs -0 git rm --cached