<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[dakni.eu/blog]]></title>
<description><![CDATA[dakni.eu/blog]]></description>
<link></link>
<lastBuildDate>Fri, 11 Sep 2020 15:27:06 +0200</lastBuildDate>
<item>
  <title><![CDATA[Some command line magic]]></title>
  <description><![CDATA[
<p>
Suppose you want to remove some files spread across your computer that share the same name. In my case, these were files called <code>TAGS</code>. Two things are required: 
</p>

<ol class="org-ol">
<li>a search program (I use the very fast <code>fd</code> (<a href="https://github.com/sharkdp/fd">link</a>) instead of <code>find</code>)</li>
<li>a command executing the deletion of the files.</li>
</ol>

<p>
One could use a loop like described here (<a href="https://stackoverflow.com/a/5142498">SO-link</a>) or:
</p>

<ul class="org-ul">
<li>A pipe and a <code>xargs</code> command: <code>fd TAGS | xargs rm</code></li>
<li>use fd/finds <code>exec</code> option: <code>fd TAGS --exec rm</code></li>
</ul>
<div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-fd.html">fd</a> <a href="tag-terminal.html">terminal</a> <a href="tag-pipe.html">pipe</a> </div>]]></description>
  <category><![CDATA[fd]]></category>
  <category><![CDATA[terminal]]></category>
  <category><![CDATA[pipe]]></category>
  <link>2020-09-11_fd_magic.html</link>
  <pubDate>Fri, 11 Sep 2020 02:00:00 +0200</pubDate>
</item>
<item>
  <title><![CDATA[a new blog]]></title>
  <description><![CDATA[
<p>
Having a website (in the sense of url, domain, etc.) and actually having a website (in the sense of distributing content) are two rather different things. In my case, what stops after I just get started was the fact that the setup etc. was simple (see my attempt on <a href="2018-01-19_Create-Blog-with-Hugo.html">here</a>) but there were just to many options hack around&#x2026;and it was mostly bloated. Long story short: I create a webpage from scratch (thanks mostly to <a href="https://www.w3schools.com/">w3schools.com</a>) to showcase what I did thus far (aka CV) and to have a place to (finally) share snippets of anything I find useful via a blog. And this is of course written in and driven by <a href="https://www.gnu.org/software/emacs/">Emacs</a>, <a href="https://orgmode.org/">Org</a>, and the pretty nice <a href="https://github.com/bastibe/org-static-blog">org-static-blog</a> by <a href="https://bastibe.de/">bastibe</a> that may eventually help me getting started with (e)lisp as well. 
</p>

<p>
The website and blog are hosted on <a href="https://uberspace.de">uberspace</a> and version controlled via <a href="https://git-scm.com/">git</a>. In order to host the local git repository as a "remote Git server" I followed the instructions <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server">here</a>. It boils down to:
</p>

<ol class="org-ol">
<li>cloning a bare repo locally (<code>git clone --bare ...</code>)</li>
<li>upload this bare repo</li>
<li>add the server address of the remote repo as remote to the local repo OR just clone the uploaded repository</li>
</ol>

<p>
The Git server has a different file structure than the local repository. Therefore, in order to "publish" the site after each <code>commit</code> and <code>push</code> I wrote a short <code>post-receice</code> with the following content (do not forget to <code>chmod</code> the file as executable after creating and saving it in the <code>hooks</code> directory of the git repository:
</p>

<pre class="example">
#!/bin/bash -l
GIT_REPO=$HOME/dakni_blog.git
TMP_GIT_CLONE=$HOME/tmp_dakni_blog.git
PUBLIC_WWW=/var/www/virtual/$USER/html/

git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE
cp *.html $PUBLIC_WWW
cp -r blog $PUBLIC_WWW
cp -r static $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit
</pre>

<p>
And finished. I hope this setup is simple (and at the same time flexible) enough to keep me updating the site regularly. 
</p>
<div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-emacs.html">emacs</a> <a href="tag-git.html">git</a> <a href="tag-orgmode.html">orgmode</a> </div>]]></description>
  <category><![CDATA[emacs]]></category>
  <category><![CDATA[git]]></category>
  <category><![CDATA[orgmode]]></category>
  <link>2020-08-28-a-new-blog.html</link>
  <pubDate>Fri, 28 Aug 2020 13:43:00 +0200</pubDate>
</item>
<item>
  <title><![CDATA[Stop tracking of already tracked files]]></title>
  <description><![CDATA[
<p>
Why? One scenario: you write on a paper using LaTeX, compile the
document, <code>git add .</code>, <code>git commit -m "created pdf"</code>, <code>git push</code>, and
then you recognize that all the files you are not interested in,
i.e. basically all besides the <code>.tex</code> file are tracked&#x2026;
</p>

<ol class="org-ol">
<li>put them in <code>.gitignore</code></li>

<li><p>
recursively clean the index
</p>

<pre class="example">
git rm -r --cached . 
</pre></li>

<li><p>
rebuild index
</p>

<pre class="example">
git add .
</pre></li>

<li><p>
commit your changes
</p>

<pre class="example">
git commit -am "Remove ignored files"
</pre></li>
</ol>

<p>
Of course, I had help in finding this. Thanks <a href="https://stackoverflow.com/a/19095988/3459537">Matt Frear</a> 
</p>
<div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-git.html">git</a> </div>]]></description>
  <category><![CDATA[git]]></category>
  <link>2019-07-14-Stop-tracking-of-already-tracked-files.html</link>
  <pubDate>Sun, 14 Jul 2019 21:33:00 +0200</pubDate>
</item>
<item>
  <title><![CDATA[In case of... (useful git snippets)]]></title>
  <description><![CDATA[

<div id="outline-container-orgc1b67a1" class="outline-2">
<h2 id="orgc1b67a1">Stop tracking of already tracked files</h2>
<div class="outline-text-2" id="text-orgc1b67a1">
<p>
Why? One scenario: you write on a paper using LaTeX, compile the
document, <code>git add .</code>, <code>git commit -m "created pdf"</code>, <code>git push</code>, and
then you recognize that all the files you are not interested in,
i.e. basically all besides the <code>.tex</code> file are tracked&#x2026;
</p>

<ol class="org-ol">
<li>put them in <code>.gitignore</code></li>

<li><p>
recursively clean the index
</p>

<pre class="example">
git rm -r --cached . 
</pre></li>

<li><p>
rebuild index
</p>

<pre class="example">
git add .
</pre></li>

<li><p>
commit your changes
</p>

<pre class="example">
git commit -am "Remove ignored files"
</pre></li>
</ol>

<p>
Of course, I had help in finding this. Thanks Matt Frear
(<a href="https://stackoverflow.com/a/19095988/3459537">https://stackoverflow.com/a/19095988/3459537</a>)
</p>
</div>
</div>
<div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-git.html">git</a> </div>]]></description>
  <category><![CDATA[git]]></category>
  <link>2019-01-25_Git-Cheat-Sheet.html</link>
  <pubDate>Fri, 25 Jan 2019 01:00:00 +0100</pubDate>
</item>
<item>
  <title><![CDATA[LaTeX Turkisch characters]]></title>
  <description><![CDATA[

<div id="outline-container-orgf96c5f3" class="outline-2">
<h2 id="orgf96c5f3">Latex Turkish Characters / Türkçe karakterler</h2>
<div class="outline-text-2" id="text-orgf96c5f3">
<ul class="org-ul">
<li>\c{c} - ç</li>
<li>\c{C} - Ç</li>
<li>\u{g} - ğ (yumuşak (soft) g)</li>
<li>\u{G} - Ğ (yumuşak (soft) g)</li>
<li>{\i} - ı</li>
<li>.{I} - İ</li>
<li>”{o} - ö</li>
<li>”{O} - Ö</li>
<li>\c{s} - ş</li>
<li>\c{S} - Ş</li>
<li>”{u} - ü</li>
<li>”{U} - Ü</li>
</ul>

<p>
This is mostly a copy of <a href="https://ergut.wordpress.com/2008/03/16/hello-world/">this</a> blog post that will be enhanced, as soon as I learn more about the Turkish language.
</p>
</div>
</div>
<div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-latex.html">LaTeX</a> </div>]]></description>
  <category><![CDATA[LaTeX]]></category>
  <link>2019-01-11-Turkish-characters.html</link>
  <pubDate>Fri, 11 Jan 2019 01:00:00 +0100</pubDate>
</item>
<item>
  <title><![CDATA[Create a blog using static site generator Hugo]]></title>
  <description><![CDATA[
<p>
This blog is (edit <span class="timestamp-wrapper"><span class="timestamp">&lt;2020-08-28 Fr&gt;</span></span>: was) created using <a href="https://gohugo.io/">Hugo</a>, a static site
generator (a nice post about this technique and its difference to
dynamic pages by <a href="https://davidwalsh.name/introduction-static-site-generators">David Walsh</a>) written in <a href="https://golang.org/">Go</a>, and is hosted ob
<a href="https://uberspace.de/">uberspace</a>.
</p>

<div id="outline-container-org98a0b22" class="outline-2">
<h2 id="get-hugo-running-on-your-local-machine">Get Hugo running on your local machine</h2>
<div class="outline-text-2" id="text-get-hugo-running-on-your-local-machine">
<ol class="org-ol">
<li>get the binaries from <a href="https://github.com/gohugoio/hugo/releases">https://github.com/gohugoio/hugo/releases</a></li>
<li>create a new site using <code>hugo new site YOUR-SITENAME</code></li>
<li>search for a theme on <a href="https://themes.gohugo.io/">https://themes.gohugo.io/</a>, clone it, and copy
it into the <code>themes</code> folder [create the folder if it is not
available]</li>
<li>edit the <code>config.toml</code> and change the fields according to your
information</li>
<li>run <code>hugo new post/YOUR-NEW-POST.md</code></li>
<li>run <code>hugo server</code> (or <code>hugo server -D</code> when your post is still a
draft -&gt; check in the toml header of the file) to visit your site at
localhost and test/adapt your post and theme</li>
</ol>
</div>
</div>

<div id="outline-container-org101e759" class="outline-2">
<h2 id="version-control-your-blog-with-git">Version control your blog with git</h2>
<div class="outline-text-2" id="text-version-control-your-blog-with-git">
</div>

<div id="outline-container-orgc03f030" class="outline-3">
<h3 id="local">Local</h3>
<div class="outline-text-3" id="text-local">
<ol class="org-ol">
<li>in the root directory of the blog run <code>git init</code></li>
<li>add all files using <code>git add .</code> and <code>git commit -m "initial commit"</code></li>
<li>optional: create a <code>.gitignore</code> file and write all names of these
files and folders you do not want to upload to the server
(e.g. automatic backup files)</li>
<li>Create a bare git repository that can be send to the server. To do
this, leave the blog root directory (<code>cd ..</code>) and run
<code>git clone --bare YOUR-LOCAL-GIT-BLOG-FOLDER YOUR-SERVER-GIT-BLOG-FOLDER.git</code></li>
<li>copy the newly created bare repository to your server (e.g. using
<code>scp</code>)</li>
<li>move again into your local blog folder and add the remote address to
your blog using
<code>git remote add origin SERVERADRESS:REPOSITORY-FOLDER</code></li>
</ol>
</div>
</div>

<div id="outline-container-org65b8647" class="outline-3">
<h3 id="server">Server</h3>
<div class="outline-text-3" id="text-server">
<ol class="org-ol">
<li>ssh into your server</li>
<li><code>cd</code> into the hooks folder of your blog directory</li>
<li>using your favorite editor (what is without doubt emacs) create a
file named <code>post-receive</code> and add the following content:</li>
</ol>

<div class="org-src-container">
<pre class="src src-sh"><span style="color: #6272a4;">#</span><span style="color: #6272a4;">!/bin/</span><span style="color: #ff79c6;">bash</span><span style="color: #6272a4;"> -l</span>
GIT_REPO=$HOME/your-blog.git
TMP_GIT_CLONE=$HOME/tmp/git/your-blog.git
PUBLIC_WWW=/var/www/virtual/$USER/html

git clone $GIT_REPO $TMP_GIT_CLONE
hugo $TMP_GIT_CLONE
cp -r $TMP_GIT_CLONE/public/ $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
<span style="color: #ff79c6;">exit</span>
</pre>
</div>

<ol class="org-ol">
<li>make the hook file executable <code>chmod u=rwx post-receive</code></li>
<li>test whether everything is working by manually executing the hook
file <code>.post-receive</code></li>
<li>when everything works leave the server and enjoy writing of your site
locally. After you pushed your changes to the server the site will be
generated automatically</li>
</ol>
</div>
</div>
</div>

<div id="outline-container-orga105525" class="outline-2">
<h2 id="links">Links</h2>
<div class="outline-text-2" id="text-links">
<p>
The information above was collected from these sources:
</p>

<p>
Hugo:
</p>

<ul class="org-ul">
<li><a href="https://gohugo.io/categories/getting-started">https://gohugo.io/categories/getting-started</a></li>
<li><a href="https://code.tutsplus.com/tutorials/make-creating-websites-fun-again-with-hugo-the-static-website-generator-written-in-go--cms-27319">https://code.tutsplus.com/tutorials/make-creating-websites-fun-again-with-hugo-the-static-website-generator-written-in-go--cms-27319</a></li>
<li><a href="https://github.com/humboldtux/startbootstrap-clean-blog">https://github.com/humboldtux/startbootstrap-clean-blog</a></li>
<li><a href="https://themes.gohugo.io/theme/strata/post/migrate-from-jekyll/">https://themes.gohugo.io/theme/strata/post/migrate-from-jekyll/</a></li>
</ul>

<p>
Uberspace [note that the instructions are for jekyll &#x2013; and in German.]:
</p>

<ul class="org-ul">
<li><a href="http://www.wittistribune.com/jekyll-auf-uberspace-mit-git">http://www.wittistribune.com/jekyll-auf-uberspace-mit-git</a></li>
<li><a href="https://funkenstrahlen.de/blog/2015/08/02/jekyll-blog-auf-uberspace-mein-setup/">https://funkenstrahlen.de/blog/2015/08/02/jekyll-blog-auf-uberspace-mein-setup/</a></li>
</ul>

<p>
Git:
</p>

<ul class="org-ul">
<li><a href="https://help.github.com/articles/adding-a-remote/">https://help.github.com/articles/adding-a-remote/</a></li>
<li><a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server">https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server</a></li>
</ul>
</div>
</div>
<div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-tutorial.html">tutorial</a> <a href="tag-hugo.html">hugo</a> </div>]]></description>
  <category><![CDATA[tutorial]]></category>
  <category><![CDATA[hugo]]></category>
  <link>2018-01-19_Create-Blog-with-Hugo.html</link>
  <pubDate>Sat, 20 Jan 2018 01:00:00 +0100</pubDate>
</item>
<item>
  <title><![CDATA[Creating an R package]]></title>
  <description><![CDATA[
<p>
&#x2026;a not too comprehensive step by step guide&#x2026;
</p>

<div id="outline-container-orge79cb48" class="outline-2">
<h2 id="r-packages-why-it-is-useful-to-create-one">R packages &#x2013; why it is useful to create one&#x2026;</h2>
<div class="outline-text-2" id="text-r-packages-why-it-is-useful-to-create-one">
<p>
(non-exhaustive, personally biased [of course] list):
</p>

<ol class="org-ol">
<li>to easily share your code in a "out of the box" format</li>
<li>to force yourself to <i>abstract the ideas of your analysis</i></li>
<li>to force yourself to document</li>
<li>to learn to be a better (i.e. less trial-and-errorish) coder by
writing your analysis in function-like statements</li>
</ol>
</div>
</div>

<div id="outline-container-orgcfd007d" class="outline-2">
<h2 id="how">How?</h2>
<div class="outline-text-2" id="text-how">
<ol class="org-ol">
<li>create folder with the name of the package: <code>MyPackage</code> [or use
=devtools::create("MyPackage")=to automatically add a bare-bones
description file /in an empty folder/]</li>
<li>create in this directory another directory called <code>R</code></li>
<li>put the R-code files into this directory</li>
<li>within the <code>MyPackage</code> folder create a file named <code>DESCRIPTION</code> with
the following (or similar) content:</li>
</ol>

<div class="org-src-container">
<pre class="src src-R">Package: MyPackage
Version: 0.1
Date: 2017-04-11
Title: My very own package
Description: An R package for something interesting and/or important. etc.
Author:
 Me <a href="mailto:me%40mymail.eu">&lt;me@mymail.eu&gt;</a>,
Maintainer: Me again <a href="mailto:me%40mymail.eu">&lt;me@mymail.eu&gt;</a>
License: GPL-3
</pre>
</div>

<ol class="org-ol">
<li>[/OPTIONAL/ when <code>Roxygen2=is used, see next point]\\
   Create a =NAMESPACE</code> file with the following, minimal content:</li>
</ol>

<div class="org-src-container">
<pre class="src src-R"><span style="color: #6272a4;"># </span><span style="color: #6272a4;">Export all names</span>
exportPattern<span style="color: #61bfff;">(</span><span style="color: #f1fa8c;">"."</span><span style="color: #61bfff;">)</span>
</pre>
</div>

<ol class="org-ol">
<li>Create the documentation;<br>
first create in the a subdirectory called <code>man</code> in the package
directory. In this folder <code>*.Rd*</code> files for each function are stored
in a LaTeX-like format. Since this can be difficult or you might
forget to create some files, there is the
<a href="https://github.com/klutometis/roxygen">Roxygen2</a> package that
takes care of creating the <code>*.Rd*</code> files and that forces you the
write the documentation of the code directly within the R-code files;
besides <code>Roxygen2</code> creates the <code>NAMESPACE</code> automatically</li>

<li>each function argument gets is documented like this:<br>
<code>#' @param argument_name description of the argument</code></li>
<li>the return value of the function is documented using:<br>
<code>#' @return something important for A2</code></li>
<li>examples are documented with:<br>
<code>#' @examples x &lt;- 1</code></li>
<li>The @export line at the end tells <code>Roxygen2</code> to add the function to
the <code>NAMESPACE</code> file:<br>
<code>#' @export myfunction</code></li>

<li>Finally create the documentation using <code>devtools::document()</code> [in
case you are within <code>R</code> and <i>within</i> the package directory] [emacs
ess shortcut =C-c C-w d=]</li>
<li>build the package: <code>devtools::build()</code></li>
<li>install the package: <code>devtools::install()</code> [emacs ess shortcut
=C-c C-w i=]</li>
<li>and check: <code>devtools::check()</code> [emacs ess shortcut =C-c C-w c=]</li>
</ol>
</div>

<div id="outline-container-orge361045" class="outline-3">
<h3 id="other-things">other things</h3>
<div class="outline-text-3" id="text-other-things">
<p>
to create the pdf manual run: <code>R CMD Rd2pdf MyPackage</code>
</p>

<p>
you can also use the
<code>package.skeleton(name</code>"PACKAGENAME", code<sub>files</sub>="CODEFILE.R")= command
to create the necessary folders/files/etc. for the package. Building and
installing is done as described above.
</p>
</div>
</div>
</div>

<div id="outline-container-org66ac53c" class="outline-2">
<h2 id="sources">Sources</h2>
<div class="outline-text-2" id="text-sources">
<ul class="org-ul">
<li><a href="http://kbroman.org/pkg_primer/">"R package primer a minimal
tutorial" by Karl Broman</a></li>
<li><a href="https://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf">Creating
R Packages: A Tutorial by Friedrich Leisch</a></li>
<li><a href="https://cran.r-project.org/doc/manuals/R-exts.html">Writing R
Extensions &#x2014; the manual from R Core Team</a></li>
</ul>
</div>
</div>

<div id="outline-container-orgfa28e4d" class="outline-2">
<h2 id="other-probably-interesting-resources">other probably interesting resources</h2>
<div class="outline-text-2" id="text-other-probably-interesting-resources">
<ul class="org-ul">
<li><a href="https://rpubs.com/YaRrr/rpackageintro">Creating an R package for
Research documentation</a></li>
<li><a href="http://tinyheero.github.io/jekyll/update/2015/07/26/making-your-first-R-package.html">Making
Your First R Package</a></li>
</ul>
</div>
</div>
<div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-rstats.html">rstats</a> <a href="tag-tutorial.html">tutorial</a> </div>]]></description>
  <category><![CDATA[rstats]]></category>
  <category><![CDATA[tutorial]]></category>
  <link>2018-01-17_Create-R-Package.html</link>
  <pubDate>Tue, 11 Apr 2017 02:00:00 +0200</pubDate>
</item>
</channel>
</rss>
