Phrasendroschke/2016-10-08T14:20:00+02:00My NaNoWriMo setup2016-10-08T14:20:00+02:00Jochentag:,2016-10-08:my-nanowrimo-setup.html<p>Yes, I'm one of those guys. Honestly, I didn't plan to participate in
<a href="http://www.nanowrimo.org">NaNoWriMo</a> this year, but then I realized that this
is my 10th anniversary, so I feel obligated to write something anyway. Since I
won the first time in 2006 using OpenOffice and Google Docs, I only managed to
cough up the 50,000 Words one more time in 2012 using
<a href="http://literatureandlatte.com">Scrivener</a>. It comes with a ton of features,
some I really like, others I don't need and some I don't even know about. The
latter is probably due to the fact that everything is hidden in clickable
menues. Bottom line is that I found the interface a bit overwhelming and
distracting. I think I spent more time playing around with its features than I
actually spent writing.</p>
<p>In an effort to simplify my computer usage, I decided to use vim this time. Of
course, as a self-respecting nerd, I can't just fire up vim and start typing, so
I started by googling (actually <a href="http://www.duckduckgo.com">DuckDuckGo</a>ing)
"vim for writers" which led me
<a href="http://naperwrimo.org/wiki/index.php?title=Vim_for_Writers">here</a>. I wrote a
vimrc just for writing (I know, but I plan to revamp my vimrc, so I kept it
separate from my programming environment for the time being) and put the
WordCount function I found on that page in there. This way, I can keep track of
my word count while I'm writing (one of the Scrivener features I really liked).
I'd like something along the lines of a progress bar for my daily writing
sessions, but I'm not there yet with vimscript. </p>
<p>Nobody wants to wake up on November 29th to learn that his/her hard drive has
crashed and the 49,980 or so words written over the course of a month have been
lost. So we'll need a backup strategy. Most people use a combination of Dropbox,
external hard disks and thumb drives. I'm lazy, so I don't want to put conscious
effort into this. Here git and my personal webspace come in handy. The provider
takes care of regular backups, so all I have to do is check in everything I've
written after every session and push it to the server. Or I can write on their
server via ssh and just do a check in after every writing session. This would
also take care of writing on various devices without any merge hassle. Heck, I
could even write on my Android phone using <a href="http://termux.com">termux</a>. Ok,
that's probably going to be a last resort when I'm really bored, but you never
know.</p>
<p>Taking all of this into consideration, I wrote this bash script:</p>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
<span class="nv">BASEDIR</span><span class="o">=</span>~/.nanowrimo
<span class="nv">NOW</span><span class="o">=</span><span class="k">$(</span>date +<span class="s2">"%Y-%m-%d_%H:%M:%S"</span><span class="k">)</span>
<span class="nv">TODAY</span><span class="o">=</span><span class="k">$(</span>date +<span class="s2">"%Y-%m-%d"</span><span class="k">)</span>
<span class="nv">YEAR</span><span class="o">=</span><span class="k">$(</span>date +<span class="s2">"%Y"</span><span class="k">)</span>
<span class="nb">cd</span> <span class="si">${</span><span class="nv">BASEDIR</span><span class="si">}</span>
<span class="si">${</span><span class="nv">EDITOR</span><span class="si">}</span> <span class="si">${</span><span class="nv">NOW</span><span class="si">}</span>.md
git add <span class="si">${</span><span class="nv">NOW</span><span class="si">}</span>.md
git commit
<span class="nv">session_count</span><span class="o">=</span><span class="k">$(</span>wc -w <span class="si">${</span><span class="nv">NOW</span><span class="si">}</span>.md<span class="k">)</span>
<span class="nv">today_count</span><span class="o">=</span><span class="k">$(</span>cat <span class="si">${</span><span class="nv">TODAY</span><span class="si">}</span>*.md <span class="p">|</span> wc -w<span class="k">)</span>
<span class="nv">total_count</span><span class="o">=</span><span class="k">$(</span>cat <span class="si">${</span><span class="nv">YEAR</span><span class="si">}</span>*.md <span class="p">|</span> wc -w<span class="k">)</span>
<span class="nb">echo</span> <span class="s2">"Session word count: </span><span class="si">${</span><span class="nv">session_count</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">echo</span> <span class="s2">"Today's word count: </span><span class="si">${</span><span class="nv">today_count</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">echo</span> <span class="s2">"Total word count: </span><span class="si">${</span><span class="nv">total_count</span><span class="si">}</span><span class="s2">"</span>
<span class="nb">cd</span> -
</pre></div>
</td></tr></table>
<p>When I call this script, it will open a new file with the current date and time
as its name suffixed with <code>.md</code> (I'll write in markdown) in my favourite editor.
When I save and exit after churning out my words for that session, it will add
that file to my git repository, have me add a commit message, commit to the
repository and give me a rundown of words I wrote in that session, total
word count of that particular day and total word count. Also, the structure of
the resulting repository will be fine grained enough to let me create all kinds
of useless statistics about my writing habits, if I desire to create them. A
simple <code>cat 2016*.md > my_nanowrimo_novel.md</code> will give me a document I can
fiddle with in <a href="http://pandoc.org/">pandoc</a> once november is over. I think I'm
not totally done yet, e.g. I want to automatically update my word count using
the <a href="http://nanowrimo.org/api/wordcount">NaNoWriMo API</a>, but I couldn't be
bothered to look into that yet.</p>Choosing a blogging platform2016-08-12T09:00:00+02:00Jochentag:,2016-08-12:choosing-a-blogging-platform.html<p>I tried blogging in the past and it never worked out. One reason was that
frameworks like <a href="https://movabletype.com/">Movable Type</a>,
<a href="https://wordpress.com/">WordPress</a> and
<a href="https://www.blogger.com/">Blogger (aka Blogspot)</a> either aren't under your
control if you use the hosted version or are high maintenance if you host them
yourself (too high for a lazy guy like me, at least).<br />
Another is you are supposed to write your posts in a form on a web-page. Usually
some kind or rich-text enhanced form. To be fair, there are desktop clients for
all major blog frameworks, some of which I tried but I can't be bothered to look
them up now. And AFAIK you can't really preview the resulting blog posts without
actually uploading them to your blog (or a local instance with the same
configuration).</p>
<p>When I found out about static site generators, starting a blog became an option
again. You can write your posts in markdown or ReStructuredText, build the pages
on your local machine and only upload the generated static html files. After
playing around with <a href="http://jekyllrb.com/">jekyll</a>,
<a href="http://cryogenweb.org/index.html">cryogen</a> and <a href="https://getnikola.com/">nikola</a>
I decided to give pelican a spin. While I like learning new languages, I decided
to use a blog software written in a language I use on a daily basis. If one day
I decide I want to dig deeper into the software I'm using, I don't want to be
forced to learn a new language at the same time. So Python it was. First, the
possibility to use the IPython Notebook format in Nikola appealed to me, but
Nikola's options turned out to be overwhelming when I started reading the
documentation. Thus I decided to use <a href="http://blog.getpelican.com/">Pelican</a>
for now.</p>
<p>It's very easy to use and packaged with Arch linux. If you want to use
<a href="http://www.fabfile.org/">Fabric</a> to automate the building and publishing
process, you have to use <code>python2</code> with pelican. So I created a virtual
environment and did</p>
<div class="highlight"><pre><span></span>$ pip install pelican markdown fabric
</pre></div>
<p>and there was my ready-to-use blogging environment. You can skip markdown if you
want to write your blog in ReStructuredText.<br />
Now when writing a blog post, I dedicate a tmux window to blogging, change into
the virtualenv and just write the post in vim. <code>fab build</code> and <code>fab serve</code> can
be used to preview the output and <code>fab publish</code> will upload the generated output
to my website.</p>Command Line Notetaking2016-08-11T10:00:00+02:00Jochentag:,2016-08-11:command-line-notetaking.html<p>Back when I didn't mind using GUIs, I was pretty impressed by what I read about
<a href="http://notational.net/">Notational Velocity</a>. I never owned a Mac so after some
searching around I found <a href="https://github.com/cpbotha/nvpy">nvpy</a>, a nice
cross-platform tool that tries to resemble its functionality. Alas - apart from
the initial toying around - I never used it. The reason, as most of the time,
was that it added friction to my workflow. You have to open it explicitly and do
your edits inside the application. No modes, no vim keybindings and which
virtual desktop was it on again?</p>
<p>A few days ago I came across <a href="http://jasonwryan.com/blog/2010/09/28/command-line-notes/">this blog
post</a> and <a href="http://lifehacker.com/5592047/turn-your-command-line-into-a-fast-and-simple-note-taking-tool">this
lifehacker
article</a>
that seemed like a good starting point to get some of the functionality without
any friction.</p>
<p>I decided to use <code>.md</code> instead of <code>.txt</code> as a file suffix because I want to get
used to writing markdown to take advantage of <a href="http://pandoc.org">pandoc</a> and my
notes directory is <code>~/.notes</code> instead of <code>~/notes</code> so it won't clutter the
output of <code>ls</code> in my home directory.</p>
<p>My <code>nls()</code> function is a little different from what is shown in the articles though:</p>
<div class="highlight"><pre><span></span>nls<span class="o">()</span> <span class="o">{</span>
tree -CR --noreport ~/.notes <span class="p">|</span> sed <span class="s1">'s/.md$//'</span> <span class="p">|</span> awk <span class="s1">'{$1=""; print}'</span> <span class="se">\</span>
<span class="p">|</span> grep -i <span class="s2">"</span><span class="nv">$*</span><span class="s2">"</span>
<span class="o">}</span>
</pre></div>
<p>This takes care of:</p>
<ul>
<li>removing the trailing .md (the 'sed ...' part)</li>
<li>removing the leading characters of the tree output (the 'awk...' part)</li>
</ul>
<p>The <code>grep</code> should be self-explanatory. If it isn't, there's always <code>man grep</code>.<br />
This way I can use the output of this function as input for the <code>n()</code> function.</p>
<p>There was one more itch to scratch, though:</p>
<p>You can search for your note's titles but you can't do a full text search on
all your notes, so if you don't remember which file contains the desired
information, you're screwed.</p>
<h2>Enter the Silver Searcher</h2>
<p>There's a nice utility called <a href="https://github.com/ggreer/the_silver_searcher">The
Silver Searcher</a> that works as a
grep replacement. With the <code>-l</code> option, it just prints the names of the files
containing your search phrase. So in addition to the two functions mentioned in
the above articles I wrote this small function:</p>
<div class="highlight"><pre><span></span>nsearch<span class="o">()</span> <span class="o">{</span>
<span class="nb">cd</span> ~/.notes/
ag -l <span class="s2">"</span><span class="nv">$*</span><span class="s2">"</span> <span class="p">|</span> sed <span class="s1">'s/.md$//'</span>
<span class="nb">cd</span> - > /dev/null
<span class="o">}</span>
</pre></div>
<p>Now, with</p>
<div class="highlight"><pre><span></span>$ nsearch <my_phrase>
</pre></div>
<p>I get a list of all files in <code>~/.notes/</code> containing <code><my_phrase></code>. As above, the
<code>.md</code> extension is removed from the output for use with the <code>n()</code> function.</p>
<p>I still have to take care about syncing my notes between machines, but it works
for now.</p>Why yet another blog?2016-08-11T09:45:00+02:00Jochentag:,2016-08-11:why-yet-another-blog.html<blockquote>
<p><strong>TLDR;</strong>: This blog will be about removing friction from my
workflow by making use of the Linux command line and staying away from the
mouse for the most part. Most of the time in english, sometimes in german.</p>
</blockquote>
<p>Although I'm a Linux user since 2002, I wasted most of the time using it as a
glorified Windows. I didn't even know what I was doing for the first few years,
so I worked around the perceived "shortcomings" while remaining completely
ignorant of the benefits of running a Unix-like system. Over time I got used to
using the command line for administration tasks and did most of my development
in vim, but still used GUI applications for everything else.</p>
<p>Then last year something clicked. I had just started at a full time position as
a python developer. In the weeks before, I had decided to try Windows 8.1 after
over 10 years of exclusively using Linux and had found
<a href="http://www.jetbrains.com/pycharm/">PyCharm</a> for use with Python. Then when I
started my new position, I knew that PyCharm worked on Linux as well and decided
to stick with it (Ubuntu 14.04 at the time). It wasn't long before I got
frustrated with my new working environment. Don't get me wrong, I'm not trying
to diss PyCharm here. It's a feature-rich IDE and I recommend using it if IDEs
are your cup of tea. It just wasn't for me. I kept wasting time browsing through
menus when looking for a feature and trying out my code in an integrated shell
when I had a perfectly fine shell in my terminal. So I switched back to vim.</p>
<p>This time it was the beginning of a journey to take full advantage of the power
of Unix-like operating systems that I should have started back in the 90s when I
first got in touch with <a href="https://en.wikipedia.org/wiki/SunOS">SunOs</a> at university.</p>
<p>I slowly revamped my working environment and by now have arrived at a
combination of <a href="http://www.archlinux.org">Archlinux</a>, <a href="https://awesomewm.org/">Awesome
WM</a>,
<a href="http://software.schmorp.de/pkg/rxvt-unicode.html">rxvt-unicode</a>,
<a href="http://www.zsh.org/">zsh</a> and <a href="http://www.vim.org/">vim</a>. And the journey is
far from over. So I decided to share some of the things I learned (and will
learn) on the way while reserving the right to write about something completely
unrelated from time to time (and probably in german).</p>