literate-dotfiles/docs/emacs-library-babel.html

122 lines
8.0 KiB
HTML
Raw Permalink Normal View History

2020-05-26 08:40:15 +02:00
<?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>
2022-05-09 10:05:23 +02:00
<!-- 2022-05-09 lun. 10:03 -->
2020-05-26 08:40:15 +02:00
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>My Own Library of Babel</title>
2021-01-01 20:12:34 +01:00
<meta name="author" content="Dehaeze Thomas" />
2022-05-09 10:05:23 +02:00
<meta name="generator" content="Org Mode" />
2021-01-01 20:12:34 +01:00
<link rel="stylesheet" type="text/css" href="./dist/style.css"/>
<script type="text/javascript" src="./dist/script.js"></script>
2020-05-26 08:40:15 +02:00
</head>
<body>
2021-01-01 20:12:34 +01:00
<div id="org-div-home-and-up">
<a accesskey="h" href="./index.html"> UP </a>
|
<a accesskey="H" href="./index.html"> HOME </a>
2022-05-09 10:05:23 +02:00
</div><div id="content" class="content">
2020-05-26 08:40:15 +02:00
<h1 class="title">My Own Library of Babel</h1>
2022-05-09 10:05:23 +02:00
<div id="table-of-contents" role="doc-toc">
2020-05-26 08:40:15 +02:00
<h2>Table of Contents</h2>
2022-05-09 10:05:23 +02:00
<div id="text-table-of-contents" role="doc-toc">
2020-05-26 08:40:15 +02:00
<ul>
2022-05-09 10:05:23 +02:00
<li><a href="#org4c8de99"><code>get-password</code> - Get Password from <code>pass</code></a></li>
<li><a href="#orgd04da5b"><code>pdf2svg</code> - Export to pdf/png/svg at the same time</a></li>
<li><a href="#orgb8cb0ee"><code>addhdr</code> - Add hline to tables</a></li>
<li><a href="#org32fd97f">Matlab Related</a>
2020-05-26 08:40:15 +02:00
<ul>
2022-05-09 10:05:23 +02:00
<li><a href="#org8fc7ec9"><code>matlab-dir</code> Go to current directory</a></li>
<li><a href="#orgda6ccb7"><code>matlab-init</code> Initialize matlab</a></li>
<li><a href="#org2edb374"><code>plt-matlab</code> Plot figures</a></li>
2020-05-26 08:40:15 +02:00
</ul>
</li>
</ul>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org4c8de99" class="outline-2">
<h2 id="org4c8de99"><code>get-password</code> - Get Password from <code>pass</code></h2>
<div class="outline-text-2" id="text-org4c8de99">
2020-05-26 08:40:15 +02:00
<div class="org-src-container">
2022-05-09 10:05:23 +02:00
<pre class="src src-bash" id="org84868f7">pass $<span class="org-variable-name">passname</span> | sed -n 1p
2020-05-26 08:40:15 +02:00
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-orgd04da5b" class="outline-2">
<h2 id="orgd04da5b"><code>pdf2svg</code> - Export to pdf/png/svg at the same time</h2>
<div class="outline-text-2" id="text-orgd04da5b">
2020-05-26 08:40:15 +02:00
<div class="org-src-container">
2022-05-09 10:05:23 +02:00
<pre class="src src-sh" id="org2c8b571"><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>;
2021-01-01 20:12:34 +01:00
<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>
2020-05-26 08:40:15 +02:00
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-orgb8cb0ee" class="outline-2">
<h2 id="orgb8cb0ee"><code>addhdr</code> - Add hline to tables</h2>
<div class="outline-text-2" id="text-orgb8cb0ee">
2020-05-26 08:40:15 +02:00
<div class="org-src-container">
2022-05-09 10:05:23 +02:00
<pre class="src src-emacs-lisp" id="org177ceae"><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>
2020-05-26 08:40:15 +02:00
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org32fd97f" class="outline-2">
<h2 id="org32fd97f">Matlab Related</h2>
<div class="outline-text-2" id="text-org32fd97f">
2020-05-26 08:40:15 +02:00
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org8fc7ec9" class="outline-3">
<h3 id="org8fc7ec9"><code>matlab-dir</code> Go to current directory</h3>
2020-05-26 08:40:15 +02:00
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-orgda6ccb7" class="outline-3">
<h3 id="orgda6ccb7"><code>matlab-init</code> Initialize matlab</h3>
2020-05-26 08:40:15 +02:00
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org2edb374" class="outline-3">
<h3 id="org2edb374"><code>plt-matlab</code> Plot figures</h3>
<div class="outline-text-3" id="text-org2edb374">
2020-05-26 08:40:15 +02:00
<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">
2022-05-09 10:05:23 +02:00
<pre class="src src-matlab" id="org3b664c2"><span class="org-keyword">if</span> <span class="org-builtin">~</span>exist(<span class="org-string">'filepath'</span>) <span class="org-builtin">||</span> length(filepath) <span class="org-builtin">&lt;</span> 2
symbols = [<span class="org-string">'a'</span><span class="org-builtin">:</span><span class="org-string">'z'</span> <span class="org-string">'A'</span><span class="org-builtin">:</span><span class="org-string">'Z'</span> <span class="org-string">'0'</span><span class="org-builtin">:</span><span class="org-string">'9'</span>];
2020-05-26 08:40:15 +02:00
random_string = symbols(randi(numel(symbols),[1 5]));
2021-01-01 20:12:34 +01:00
filepath = [<span class="org-string">'/tmp/matlab-fig-'</span>, random_string];
<span class="org-keyword">end</span>
2020-05-26 08:40:15 +02:00
2021-01-01 20:12:34 +01:00
size_strings = strsplit(figsize, <span class="org-string">'-'</span>);
2020-05-26 08:40:15 +02:00
2022-05-09 10:05:23 +02:00
<span class="org-matlab-math">ans</span> = exportFig(filepath, <span class="org-string">'width'</span>, size_strings{1}, <span class="org-string">'height'</span>, size_strings{2});
2020-05-26 08:40:15 +02:00
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
2021-01-01 20:12:34 +01:00
<p class="author">Author: Dehaeze Thomas</p>
2022-05-09 10:05:23 +02:00
<p class="date">Created: 2022-05-09 lun. 10:03</p>
2020-05-26 08:40:15 +02:00
</div>
</body>
</html>