literate-dotfiles/emacs-library-babel.org
Thomas Dehaeze 3e97711adc Change indentation of all blocks.
Use (setq org-src-preserve-indentation t) for Emacs.
2021-01-08 01:26:27 +01:00

2.0 KiB

My Own Library of Babel

get-password - Get Password from pass

pass $passname | sed -n 1p

pdf2svg - Export to pdf/png/svg at the same time

_mydir="$(pwd)";
file=$(echo "$file" | cut -f 2- -d ':');
_figdir=$(dirname "$file");
cd $_figdir;
filename=$(echo "${file##*/}" | cut -f 1 -d '.');
pdftocairo -png -transp -singlefile "$filename.pdf";
pdftocairo -svg "$filename.pdf";
cd "$_mydir";
echo "[[file:$_figdir/$filename.$ext]]"

addhdr - Add hline to tables

(cons (car tbl) (cons 'hline (cdr tbl)))

Matlab Related

matlab-dir Go to current directory

matlab-init Initialize matlab

plt-matlab Plot figures

Some variable can be set by block that expands this org source code block:

  • path: specify the path of the figure including the file extension. Can be relative or absolute. If not provided, it will create the figure in the /tmp folder
  • fig_size: can specify the size of the figure. If not specify, default will be applied.
if ~exist('filepath') || length(filepath) < 2
  symbols = ['a':'z' 'A':'Z' '0':'9'];
  random_string = symbols(randi(numel(symbols),[1 5]));
  filepath = ['/tmp/matlab-fig-', random_string];
end

size_strings = strsplit(figsize, '-');

ans = exportFig(filepath, 'width', size_strings{1}, 'height', size_strings{2});