122 lines
7.9 KiB
HTML
122 lines
7.9 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
|
<head>
|
|
<!-- 2021-01-08 ven. 01:32 -->
|
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
|
<title>My Own Library of Babel</title>
|
|
<meta name="generator" content="Org mode" />
|
|
<meta name="author" content="Dehaeze Thomas" />
|
|
<link rel="stylesheet" type="text/css" href="./dist/style.css"/>
|
|
<script type="text/javascript" src="./dist/script.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="org-div-home-and-up">
|
|
<a accesskey="h" href="./index.html"> UP </a>
|
|
|
|
|
<a accesskey="H" href="./index.html"> HOME </a>
|
|
</div><div id="content">
|
|
<h1 class="title">My Own Library of Babel</h1>
|
|
<div id="table-of-contents">
|
|
<h2>Table of Contents</h2>
|
|
<div id="text-table-of-contents">
|
|
<ul>
|
|
<li><a href="#org6748865"><code>get-password</code> - Get Password from <code>pass</code></a></li>
|
|
<li><a href="#orga14277a"><code>pdf2svg</code> - Export to pdf/png/svg at the same time</a></li>
|
|
<li><a href="#orgca0df99"><code>addhdr</code> - Add hline to tables</a></li>
|
|
<li><a href="#org7f58498">Matlab Related</a>
|
|
<ul>
|
|
<li><a href="#org0dc80bc"><code>matlab-dir</code> Go to current directory</a></li>
|
|
<li><a href="#orge3957c3"><code>matlab-init</code> Initialize matlab</a></li>
|
|
<li><a href="#orgcdf63af"><code>plt-matlab</code> Plot figures</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org6748865" class="outline-2">
|
|
<h2 id="org6748865"><code>get-password</code> - Get Password from <code>pass</code></h2>
|
|
<div class="outline-text-2" id="text-org6748865">
|
|
<div class="org-src-container">
|
|
<pre class="src src-bash" id="org907ee3f">pass $<span class="org-variable-name">passname</span> | sed -n 1p
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orga14277a" class="outline-2">
|
|
<h2 id="orga14277a"><code>pdf2svg</code> - Export to pdf/png/svg at the same time</h2>
|
|
<div class="outline-text-2" id="text-orga14277a">
|
|
<div class="org-src-container">
|
|
<pre class="src src-sh" id="org9f7b2d6"><span class="org-variable-name">_mydir</span>=<span class="org-string">"</span><span class="org-string"><span class="org-sh-quoted-exec">$(</span></span><span class="org-sh-quoted-exec">pwd</span><span class="org-string"><span class="org-sh-quoted-exec">)</span></span><span class="org-string">"</span>;
|
|
<span class="org-variable-name">file</span>=$<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-sh-quoted-exec">echo</span> <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">file</span></span><span class="org-string">"</span> | cut -f 2- -d <span class="org-string">':'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
|
<span class="org-variable-name">_figdir</span>=$<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-sh-quoted-exec">dirname</span> <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">file</span></span><span class="org-string">"</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
|
<span class="org-type">cd</span> $<span class="org-variable-name">_figdir</span>;
|
|
<span class="org-variable-name">filename</span>=$<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-sh-quoted-exec">echo</span> <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">{file##*/}</span></span><span class="org-string">"</span> | cut -f <span class="org-highlight-numbers-number">1</span> -d <span class="org-string">'.'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
|
pdftocairo -png -transp -singlefile <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">filename</span></span><span class="org-string">.pdf"</span>;
|
|
pdftocairo -svg <span class="org-string">"</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">filename</span></span><span class="org-string">.pdf"</span>;
|
|
<span class="org-type">cd</span> <span class="org-string">"$_mydir"</span>;
|
|
<span class="org-type">echo</span> <span class="org-string">"[[file:$_figdir/</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">filename</span></span><span class="org-string">.</span><span class="org-string"><span class="org-constant">$</span></span><span class="org-string"><span class="org-variable-name">ext</span></span><span class="org-string">]]"</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgca0df99" class="outline-2">
|
|
<h2 id="orgca0df99"><code>addhdr</code> - Add hline to tables</h2>
|
|
<div class="outline-text-2" id="text-orgca0df99">
|
|
<div class="org-src-container">
|
|
<pre class="src src-emacs-lisp" id="orgc589733"><span class="org-rainbow-delimiters-depth-1">(</span><span class="org-constant">cons</span> <span class="org-rainbow-delimiters-depth-2">(</span><span class="org-constant">car</span> tbl<span class="org-rainbow-delimiters-depth-2">)</span> <span class="org-rainbow-delimiters-depth-2">(</span><span class="org-constant">cons</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">hline</span> <span class="org-rainbow-delimiters-depth-3">(</span><span class="org-constant">cdr</span> tbl<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span><span class="org-rainbow-delimiters-depth-1">)</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org7f58498" class="outline-2">
|
|
<h2 id="org7f58498">Matlab Related</h2>
|
|
<div class="outline-text-2" id="text-org7f58498">
|
|
</div>
|
|
<div id="outline-container-org0dc80bc" class="outline-3">
|
|
<h3 id="org0dc80bc"><code>matlab-dir</code> Go to current directory</h3>
|
|
</div>
|
|
|
|
<div id="outline-container-orge3957c3" class="outline-3">
|
|
<h3 id="orge3957c3"><code>matlab-init</code> Initialize matlab</h3>
|
|
</div>
|
|
|
|
<div id="outline-container-orgcdf63af" class="outline-3">
|
|
<h3 id="orgcdf63af"><code>plt-matlab</code> Plot figures</h3>
|
|
<div class="outline-text-3" id="text-orgcdf63af">
|
|
<p>
|
|
Some variable can be set by block that expands this org source code block:
|
|
</p>
|
|
<ul class="org-ul">
|
|
<li><code>path</code>: 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 <code>/tmp</code> folder</li>
|
|
<li><code>fig_size</code>: can specify the size of the figure. If not specify, default will be applied.</li>
|
|
</ul>
|
|
|
|
<div class="org-src-container">
|
|
<pre class="src src-matlab" id="org7fa148b"><span class="org-keyword">if</span> <span class="org-type">~</span>exist(<span class="org-string">'filepath'</span>) <span class="org-type">||</span> length(filepath) <span class="org-type"><</span> 2
|
|
symbols = [<span class="org-string">'a'</span><span class="org-type">:</span><span class="org-string">'z'</span> <span class="org-string">'A'</span><span class="org-type">:</span><span class="org-string">'Z'</span> <span class="org-string">'0'</span><span class="org-type">:</span><span class="org-string">'9'</span>];
|
|
random_string = symbols(randi(numel(symbols),[1 5]));
|
|
filepath = [<span class="org-string">'/tmp/matlab-fig-'</span>, random_string];
|
|
<span class="org-keyword">end</span>
|
|
|
|
size_strings = strsplit(figsize, <span class="org-string">'-'</span>);
|
|
|
|
<span class="org-constant">ans</span> = exportFig(filepath, <span class="org-string">'width'</span>, size_strings{1}, <span class="org-string">'height'</span>, size_strings{2});
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="postamble" class="status">
|
|
<p class="author">Author: Dehaeze Thomas</p>
|
|
<p class="date">Created: 2021-01-08 ven. 01:32</p>
|
|
</div>
|
|
</body>
|
|
</html>
|