Friday, June 2, 2017

Ubuntu wipe directory

  1. Install the package 'secure-delete'
  2. Use the command 'srm -r pathname' to remove your folder and files
The default settings are for 38 (!!!) passes of overwrites which is extreme overkill imho (see more info about this here:
For my usage, I only want a single pass of random data so I use 'srm -rfll pathname'

Src:  https://askubuntu.com/questions/122549/how-to-shred-a-folder

Monday, May 8, 2017

Compare revisions of latex files using latexdiff

Acquire latexdiff package (depends on OS)­. Also available on CTAN.

run:

$ latexdiff draft.tex revision.tex > diff.tex

Compile diff.tex using your favorite sequence.

In order to take into account for \input and \include,
use the --flatten option.
The includes will point to their respective directories.
 
NOTE: the diff can take a long time for large document, like a PhD thesis :D 

Friday, April 21, 2017

format float to string converstion using C

Example of use:

float val = 123.456789123 ;
char output[11];
snprintf(output, 11, "%f", val);

src: http://stackoverflow.com/questions/7228438/convert-double-float-to-string

Friday, March 31, 2017

bibtex bst abbreviated first names (initials) without spaces

Now, find the line in the BST file that formats author names. Again, you already did this if you followed the advice in the previous question. In the case of abbrvnamed.bst, it looks like this:

{ s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
 
Change it to this:

{ s nameptr "{f{.}.~}{vv~}{ll}{, jj}" format.name$ 't :=
 
That extra {.} tells the built-in BibTeX function format.name$ to replace the default “.␣” that appears between initials within the abbreviated first name with “.”. And that’s all there is to it!
If you’d like to learn how to hack BST files yourself, there’s a nice guide called Tame the BeaST.

Src: http://tex.stackexchange.com/questions/124990/abbreviated-first-names-without-spaces-in-between

Wednesday, March 29, 2017

ITK call crashes without message

If an ITK API call crashes without a message, it is likely that the necessary includes were not put in the source code. CMake will make the code compile anyways, but no runtime error messages will be displayed, complicating (already complex) debugging tasks.

Tuesday, March 21, 2017

bash find all directories matching substring

# find 'here' the directories matching "foo" and display, max search depth 10
find . -maxdepth 10 -type d -name '*foo*' -print

Src: http://stackoverflow.com/questions/16344365/use-bash-to-find-a-folder-name-that-contains-a-string

Friday, March 17, 2017

python one-liner to find the upper directory for a path

import os
 
updir = os.path.dirname(currentdir.rstrip(os.sep))