116 lines
4.0 KiB
HTML
116 lines
4.0 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>
|
|
<!-- 2020-05-26 mar. 08:39 -->
|
|
<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="Thomas Dehaeze" />
|
|
</head>
|
|
<body>
|
|
<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="#org71b708a"><code>get-password</code> - Get Password from <code>pass</code></a></li>
|
|
<li><a href="#org79b9e08"><code>pdf2svg</code> - Export to pdf/png/svg at the same time</a></li>
|
|
<li><a href="#org6ba9d05"><code>addhdr</code> - Add hline to tables</a></li>
|
|
<li><a href="#org7b7c23f">Matlab Related</a>
|
|
<ul>
|
|
<li><a href="#orgd33f90b"><code>matlab-dir</code> Go to current directory</a></li>
|
|
<li><a href="#org408551b"><code>matlab-init</code> Initialize matlab</a></li>
|
|
<li><a href="#orgf9fe5d3"><code>plt-matlab</code> Plot figures</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org71b708a" class="outline-2">
|
|
<h2 id="org71b708a"><code>get-password</code> - Get Password from <code>pass</code></h2>
|
|
<div class="outline-text-2" id="text-org71b708a">
|
|
<div class="org-src-container">
|
|
<pre class="src src-bash" id="org8e7df7d">pass $passname | sed -n 1p
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org79b9e08" class="outline-2">
|
|
<h2 id="org79b9e08"><code>pdf2svg</code> - Export to pdf/png/svg at the same time</h2>
|
|
<div class="outline-text-2" id="text-org79b9e08">
|
|
<div class="org-src-container">
|
|
<pre class="src src-sh" id="org2d9e76a">_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]]"
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org6ba9d05" class="outline-2">
|
|
<h2 id="org6ba9d05"><code>addhdr</code> - Add hline to tables</h2>
|
|
<div class="outline-text-2" id="text-org6ba9d05">
|
|
<div class="org-src-container">
|
|
<pre class="src src-emacs-lisp" id="orgf8eebf6">(cons (car tbl) (cons 'hline (cdr tbl)))
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org7b7c23f" class="outline-2">
|
|
<h2 id="org7b7c23f">Matlab Related</h2>
|
|
<div class="outline-text-2" id="text-org7b7c23f">
|
|
</div>
|
|
<div id="outline-container-orgd33f90b" class="outline-3">
|
|
<h3 id="orgd33f90b"><code>matlab-dir</code> Go to current directory</h3>
|
|
</div>
|
|
|
|
<div id="outline-container-org408551b" class="outline-3">
|
|
<h3 id="org408551b"><code>matlab-init</code> Initialize matlab</h3>
|
|
</div>
|
|
|
|
<div id="outline-container-orgf9fe5d3" class="outline-3">
|
|
<h3 id="orgf9fe5d3"><code>plt-matlab</code> Plot figures</h3>
|
|
<div class="outline-text-3" id="text-orgf9fe5d3">
|
|
<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="org035555e">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});
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="postamble" class="status">
|
|
<p class="author">Author: Thomas Dehaeze</p>
|
|
<p class="date">Created: 2020-05-26 mar. 08:39</p>
|
|
</div>
|
|
</body>
|
|
</html>
|