Add library of babel
This commit is contained in:
parent
02f5ede7a0
commit
b8405753c0
@ -1791,7 +1791,7 @@ Add all named source blocks to =org-babel-library-of-babel=.
|
|||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(after! org
|
(after! org
|
||||||
(org-babel-lob-ingest "~/Cloud/thesis/org-mode/org-babel-tutorial/org-babel-library.org"))
|
(org-babel-lob-ingest "~/.config/literate-dotfiles/dotfiles/emacs-library-babel.org"))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
||||||
|
71
dotfiles/emacs-library-babel.org
Normal file
71
dotfiles/emacs-library-babel.org
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#+TITLE: My Own Library of Babel
|
||||||
|
|
||||||
|
* =get-password= - Get Password from =pass=
|
||||||
|
|
||||||
|
#+name: get-password
|
||||||
|
#+begin_src bash :var passname="""
|
||||||
|
pass $passname | sed -n 1p
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
* =pdf2svg= - Export to pdf/png/svg at the same time
|
||||||
|
|
||||||
|
#+name: pdf2svg
|
||||||
|
#+begin_src sh :var file="" :var ext="svg" :results output
|
||||||
|
_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]]"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
* =addhdr= - Add hline to tables
|
||||||
|
|
||||||
|
#+name: addhdr
|
||||||
|
#+begin_src emacs-lisp :var tbl=""
|
||||||
|
(cons (car tbl) (cons 'hline (cdr tbl)))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
* Matlab Related
|
||||||
|
** =matlab-dir= Go to current directory
|
||||||
|
|
||||||
|
#+name: matlab-dir
|
||||||
|
#+begin_src matlab :tangle no :results none :exports none :var current_dir=""
|
||||||
|
%% Go to current Directory
|
||||||
|
cd(current_dir);
|
||||||
|
|
||||||
|
%% Initialize ans with org-babel
|
||||||
|
ans = 0;
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** =matlab-init= Initialize matlab
|
||||||
|
|
||||||
|
#+name: matlab-init
|
||||||
|
#+begin_src matlab :results none :exports none
|
||||||
|
%% Clear Workspace and Close figures
|
||||||
|
clear; close all; clc;
|
||||||
|
|
||||||
|
%% Intialize Laplace variable
|
||||||
|
s = zpk('s');
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** =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.
|
||||||
|
|
||||||
|
#+name: plt-matlab
|
||||||
|
#+begin_src matlab :results value raw replace :exports code :var filepath="" :var figsize="normal-normal"
|
||||||
|
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});
|
||||||
|
#+end_src
|
Loading…
Reference in New Issue
Block a user