Tuesday, September 5, 2017

capture logging info from xargs comand

Here's an example of how to capture STDOUT and STERR from a set of commands parallelized using 'xargs':

Note that I'm using 'find' rather than the output of 'ls' as the input (since 'find' will not return anything if no files are found).  You can define multiple shell arguments in this way and refer to them in the normal manner ("$1", "$2", "$3", etc.).

Tuesday, February 14, 2017

R: find the color name you want

Simple tip for finding the color name you want from the base set.

This gives the following output:

[1] "darkorange" "darkorange1" "darkorange2" "darkorange3" "darkorange4" "orange" "orange1"
[8] "orange2" "orange3" "orange4" "orangered" "orangered1" "orangered2" "orangered3"
[15] "orangered4"

Monday, January 23, 2017

Terminate a frozen SSH session

I work remotely via a VPN and am often plagued by frozen SSH sessions (especially if I step away from my desk for any length of time).  I always used to close the shell/terminal - which is a bit annoying.  Then I came across the solution below, just type enter (in the frozen shell) then tilde and period/full-stop and you drop out of the ssh session.

Monday, January 9, 2017

Generating random numbers in bash

I wanted to assign each member of a training set to a cross-validation fold.  I wanted to do this in a bash script and so ended up using something like the following:

This script generates n numbers selected randomly in the series of integers from 1 to m.  In this case m represents the number of cross validation folds.

You could generate a random CV fold assignment like so:

Depending on your input file format of course.