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.

Friday, August 5, 2016

Minecraft Stop-Motion Movie Creator - too many frames

This post is a work in progress.

My kids love using the "Minecraft Stop-Motion Movie Creator". They've just finished putting together an epic animation (> 400 frames) and went to save the movie but were greeted with "Too many frames - please remove 91 frames". They were crestfallen. Surely this limit should be advertised somewhere?

Anyway, I attached the device to my computer to take a look - with the idea of downloading all the frames myself and using different software to stitch them together.

This was done on a Mac - I used androidfiletransfer to connect and browse the device (a Hudl2 in this case).
For any of you who want to do the same the relevant files are in: Android->data->com.mattel.MCSMMC->files->Movie. Each movie has it's own number and each frame of each movie is in an individual, numbered, folder. e.g. Movie->9->Frame->11 contains the files for frame 11 of movie 9.

I'll update this post when I've figured out how to resolve the issue - probably by creating the movie using separate software or by splitting the movie on the device.

Tuesday, July 26, 2016

List user installed R packages

It's handy having a list of packages you've installed on hand.

This script will output the package name and version number:

Sunday, January 17, 2016

Evernote sync error - "the content is invalid"

I've been getting these on and off for months. It's been a pain to try and sort out what's going on and there seems to be nothing in the Evernote forums that's particular to my issue. I have a set of notes that just won't sync with nothing obviously wrong with them. The error in the log looks like this:
-[ENSyncEngine(Errors) addSyncErrorForObjectWithID:title:message:underlyingError:] | Adding error: Error Domain=ENSyncEngineErrorDomain Code=-2000 "The content is invalid." UserInfo=0x... {underlyingError=, NSLocalizedFailureReason=Could not sync note ‘Work Done: 2015-12-09 (Wed)’., localObjectID=0x... , NSLocalizedDescription=The content is invalid.}

So, this makes it sound like there's an issue with a 'TODO' element (checkbox?) and that the tag, for some reason, contains content. Looking at the XML export of that particular note doesn't show anything amiss/unusual around the TODO/checkbox elements.

Solution: In my case, the issue turns out to be the emoticons - I use smileys and Evernote helpfully converts the ASCII versions into lovely little images. These seem to cause the invalid content issue. If I highlight the areas around the emoticons and 'simplify formatting' (Formatting dropdown) the note will now sync just fine.