aboutsummaryrefslogtreecommitdiff
path: root/docs/index.html
blob: f0282e1cd617c4d0382d15742d9805e9062b7636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="./style.css">
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1">
<meta content="#ffffff" name="theme-color">
<meta name="HandheldFriendly" content="true">
<meta property="og:title" content="nerdypepper">
<meta property="og:type" content="website">
<meta property="og:description" content="a static site {for, by, about} me ">
<meta property="og:url" content="https://nerdypepper.tech">
<title>n</title>


<body onload="gotoId()">
<h1 class="heading">n</h1>


<div class="posts">


    <details class="post">
        <summary>
            <div class="date">23/11 2019</div>
            <span class="post-link">Static Sites With Bash</span>
        </summary>
        <div class="post-text">
            <p>After going through a bunch of static site generators
(<a href="https://blog.getpelican.com/">pelican</a>,
<a href="https://gohugo.io">hugo</a>,
<a href="https://github.com/icyphox/vite">vite</a>), I decided to roll
my own. If you are more of the &#8216;show me the code&#8217; kinda guy,
<a href="https://github.com/nerdypepper/site">here</a> you go.</p>

<p><strong>Text formatting</strong>: I chose to write in markdown, and convert
to html with <a href="https://kristaps.bsd.lv/lowdown/">lowdown</a>.</p>

<p><strong>Directory structure</strong>: I host my site on GitHub pages, so
<code>docs/</code> has to be the entry point. Markdown formatted posts
go into <code>posts/</code>, get converted into html, and end up in
<code>docs/index.html</code>, something like this:</p>

<pre><code>posts=$(ls -t ./posts)     # chronological order!
for f in $posts; do
    file=&quot;./posts/&quot;$f      # `ls` mangled our file paths
    echo &quot;generating post $file&quot;

    html=$(lowdown &quot;$file&quot;)
    echo -e &quot;html&quot; &gt;&gt; docs/index.html
done
</code></pre>

<p><strong>Assets</strong>: Most static site generators recommend dropping image
assets into the site source itself. That does have it&#8217;s
merits, but I prefer hosting images separately:</p>

<pre><code># strip file extension
ext=&quot;${1##*.}&quot;

# generate a random file name
id=$( cat /dev/urandom | tr -dc &#39;a-zA-Z0-9&#39; | fold -w 2 | head -n 1 )
id=&quot;$id.$ext&quot;

# copy to my file host
scp -P 443 &quot;$1&quot; emerald:files/&quot;$id&quot; 
echo &quot;https://files.nerdypepper.tech/$id&quot;
</code></pre>

<p><strong>Templating</strong>:
<a href="https://github.com/NerdyPepper/site/blob/master/generate.sh"><code>generate.sh</code></a>
brings the above bits and pieces together (with some extra
cruft to avoid javascript).  It uses <code>sed</code> to produce nice
titles from the file names (removes underscores,
title-case), and <code>date(1)</code> to add the date to each post
listing!</p>
            <div class=separator></div>
        </div>
    </details>
    
    <details class="post">
        <summary>
            <div class="date">07/11 2019</div>
            <span class="post-link">My Setup</span>
        </summary>
        <div class="post-text">
            <p>Decided to do one of these because everyone does one of
these.</p>

<p><img src="https://files.nerdypepper.tech/Hb.png" alt="scrot" /></p>

<p>My entire setup is managed with GNU <code>stow</code>, making it easier
to replicate on fresh installations. You can find my
configuration files on <a href="https://github.com/nerdypepper">GitHub</a>.</p>

<p>I run Void Linux (glibc) on my
<a href="https://store.hp.com/us/en/mdp/laptops/envy-13">HP Envy 13&quot; (2018)</a>.
To keep things simple, I run a raw X session with <code>2bwm</code> as my
window manager, along with <code>dunst</code> (notification daemon) and
Sam&#8217;s <a href="https://github.com/sdhand/compton"><code>compton</code></a>
(compositor) fork.</p>

<p>I am a fan of GNU tools, so I use <code>bash</code> as my shell, and
<code>coreutils</code> to manage files, archives, strings, paths etc. I
edit files with <code>vim</code>, chat with <code>weechat</code>, listen to music
with <code>cmus</code>, monitor processes with <code>htop</code>, manage sessions
with <code>tmux</code>, read pdfs in <code>zathura</code>. I rarely ever leave
the comfort of my terminal emulator, <code>urxvt</code>.</p>

<p>Most of my academic typesetting is done with TeX, and
compiled with <code>xelatex</code>. Other <em>fun</em> documents are made with
GIMP :).</p>
            <div class=separator></div>
        </div>
    </details>
    
    <details class="post">
        <summary>
            <div class="date">12/10 2019</div>
            <span class="post-link">WPA Woes</span>
        </summary>
        <div class="post-text">
            <p>I finally got around to installing Void GNU/Linux on my main
computer. Rolling release, non-systemd, need I say more?</p>

<p>As with all GNU/Linux distributions, wireless networks had
me in a fix. If you can see this post, it means I&#8217;ve managed
to get online. It turns out, <code>wpa_supplicant</code> was detecting the
wrong interface by default (does it ever select the right
one?). Let us fix that:</p>

<pre><code>$ sudo rm -r /var/service/wpa_supplicant
$ sudo killall dhcpcd
</code></pre>

<p>What is the right interface though?</p>

<pre><code>$ iw dev
   ...
   Interface wlp2s0
   ...
</code></pre>

<p>Aha! Let us run <code>wpa_supplicant</code> on that interface, as a
background process:</p>

<pre><code>$ sudo wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
$ sudo dhcpcd -B wlp2s0
$ ping google.com
PING ...
</code></pre>

<p>Yay! Make those changes perpetual by enabling the service:</p>

<pre><code>------------------------------------------------------
# Add these to /etc/wpa_supplicant/wpa_supplicant.conf
OPTS=&quot;-B&quot;
WPA_INTERFACE=&quot;wlp2s0&quot;
------------------------------------------------------
$ sudo ln -s /etc/sv/wpa_supplicant /var/service/
$ sudo ln -s /etc/sv/dhcpcd /var/service/
$ sudo sv restart wpa_supplicant
$ sudo sv restart dhcpcd
</code></pre>
            <div class=separator></div>
        </div>
    </details>
    
    <details class="post">
        <summary>
            <div class="date">07/08 2019</div>
            <span class="post-link">Bye Bye BDFs</span>
        </summary>
        <div class="post-text">
            <p>Glyph Bitmap Distribution Format is no more, as the creators of
<a href="https://pango.org">Pango</a>, one of the most widely used text rendering
libraries,
<a href="https://blogs.gnome.org/mclasen/2019/05/25/pango-future-directions/">announced</a>
their plans for Pango 1.44.</p>

<p>Until recently, Pango used FreeType to draw fonts. They will be moving over
to <a href="https://harfbuzz.org">Harfbuzz</a>, an evolution of FreeType.</p>

<p><em>Why?</em></p>

<p>In short, FreeType was hard to work with. It required complex logic, and 
provided no advantage over Harfbuzz (other than being able to fetch
opentype metrics with ease).</p>

<p>Upgrading to Pango v1.44 will break your GTK applications (if you use a
<code>bdf</code>/<code>pcf</code> bitmap font). Harfbuzz <em>does</em> support bitmap-only OpenType fonts,
<code>otb</code>s. Convert your existing fonts over to <code>otb</code>s using
<a href="https://fontforge.github.io">FontForge</a>. It is to be noted that applications
such as <code>xterm</code> and <code>rxvt</code> use <code>xft</code> (X FreeType) to render fonts, and will
remain unaffected by the update.</p>

<p>Both <a href="https://github.com/nerdypepper/scientifica">scientifica</a> and
<a href="https://github.com/nerdypepper/curie">curie</a> will soon ship with bitmap-only
OpenType font formats.</p>
            <div class=separator></div>
        </div>
    </details>
    
    <details class="post">
        <summary>
            <div class="date">02/08 2019</div>
            <span class="post-link">Onivim Sucks</span>
        </summary>
        <div class="post-text">
            <p><a href="https://v2.onivim.io">Onivim</a> is a &#8216;modern modal editor&#8217;, combining fancy
interface and language features with vim-style modal editing. What&#8217;s wrong you
ask?</p>

<p>Apart from <a href="https://github.com/onivim/oni2/issues/550">buggy syntax highlighting</a>, 
<a href="https://github.com/onivim/oni2/issues/519">broken scrolling</a> and
<a href="https://github.com/onivim/oni2/issues?q=is%3Aissue+label%3A%22daily+editor+blocker%22+is%3Aopen">others</a>,
Onivim is <strong>proprietary</strong> software. It is licensed under a commercial 
<a href="https://github.com/onivim/oni1/blob/master/Outrun-Labs-EULA-v1.1.md">end user agreement license</a>,
which prohibits redistribution in both object code and source code formats.</p>

<p>Onivim&#8217;s core editor logic (bits that belong to vim), have been separated from
the interface, into <a href="https://github.com/onivim/libvim">libvim</a>. libvim is
licensed under MIT, which means, this &#8216;extension&#8217; of vim is perfectly in
adherence to <a href="http://vimdoc.sourceforge.net/htmldoc/uganda.html#license">vim&#8217;s license text</a>! 
Outrun Labs are exploiting this loophole (distributing vim as a library) to
commercialize Onivim.</p>

<p>Onivim&#8217;s source code is available on <a href="https://github.com/onivim/oni2">GitHub</a>.
They do mention that the source code trickles down to the
<a href="https://github.com/onivim/oni2-mit">oni2-mit</a> repository, which (not yet) contains
MIT-licensed code, <strong>18 months</strong> after each commit to the original repository.</p>

<p>Want to contribute to Onivim? Don&#8217;t. They make a profit out of your contributions.
Currently, Onivim is priced at $19.99, &#8216;pre-alpha&#8217; pricing which is 80% off the
final price! If you are on the lookout for an editor, I would suggest using
<a href="https://vim.org">Vim</a>, charity ware that actually works, and costs $100 lesser.</p>
            <div class=separator></div>
        </div>
    </details>
    
    <details class="post">
        <summary>
            <div class="date">31/07 2019</div>
            <span class="post-link">Bash Harder With Vim</span>
        </summary>
        <div class="post-text">
            <p>Bash is tricky, don&#8217;t let your editor get in your way. Here&#8217;s a couple of neat
additions you could make to your <code>vimrc</code> for a better shell programming
experience.</p>

<hr/>

<h4 id="Man%20pages%20inside%20vim">Man pages inside vim</h4>

<p>Source this script to get started:  </p>

<pre><code>runtime ftplugin/man.vim
</code></pre>

<p>Now, you can open manpages inside vim with <code>:Man</code>! It adds nicer syntax highlighting
and the ability to jump around with <code>Ctrl-]</code> and <code>Ctrl-T</code>.</p>

<p>By default, the manpage is opened in a horizontal split, I prefer using a new tab:</p>

<pre><code>let g:ft_man_open_mode = &#39;tab&#39;
</code></pre>

<hr/>

<h4 id="Scratchpad%20to%20test%20your%20commands">Scratchpad to test your commands</h4>

<p>I often test my <code>sed</code> substitutions, here is
a sample from the script used to generate this site:  </p>

<pre><code># a substitution to convert snake_case to Title Case With Spaces
echo &quot;$1&quot; | sed -E -e &quot;s/\..+$//g&quot;  -e &quot;s/_(.)/ \u\1/g&quot; -e &quot;s/^(.)/\u\1/g&quot;
</code></pre>

<p>Instead of dropping into a new shell, just test it out directly from vim!</p>

<ul>
<li><p>Yank the line into a register:</p>

<pre><code>yy
</code></pre></li>
<li><p>Paste it into the command-line window:</p>

<pre><code>q:p
</code></pre></li>
<li><p>Make edits as required:</p>

<pre><code>syntax off            # previously run commands
edit index.html       # in a buffer!
w | so %
!echo &quot;new_post.md&quot; | sed -E -e &quot;s/\..+$//g&quot;  --snip--
^--- note the use of &#39;!&#39;
</code></pre></li>
<li><p>Hit enter with the cursor on the line containing your command!</p>

<pre><code>$ vim
New Post         # output
Press ENTER or type command to continue
</code></pre></li>
</ul>
            <div class=separator></div>
        </div>
    </details>
    
    <details class="post">
        <summary>
            <div class="date">30/07 2019</div>
            <span class="post-link">Hold Position!</span>
        </summary>
        <div class="post-text">
            <p>Often times, when I run a vim command that makes &#8220;big&#8221; changes to a file (a
macro or a <code>:vimgrep</code> command) I lose my original position and feel disoriented.</p>

<p><em>Save position with <code>winsaveview()</code>!</em></p>

<p>The <code>winsaveview()</code> command returns a <code>Dictionary</code> that contains information
about the view of the current window. This includes the cursor line number,
cursor coloumn, the top most line in the window and a couple of other values,
none of which concern us.</p>

<p>Before running our command (one that jumps around the buffer, a lot), we save
our view, and restore it once its done, with <code>winrestview</code>.</p>

<pre><code>let view = winsaveview()
s/\s\+$//gc              &quot; find and (confirm) replace trailing blanks
winrestview(view)        &quot; restore our original view!
</code></pre>

<p>It might seem a little overkill in the above example, just use &#8220; (double
backticks) instead, but it comes in handy when you run your file through
heavier filtering.</p>
            <div class=separator></div>
        </div>
    </details>
    
    <details class="post">
        <summary>
            <div class="date">29/07 2019</div>
            <span class="post-link">Get Better At Yanking And Putting In Vim</span>
        </summary>
        <div class="post-text">
            <ol start="1">
<li><p>reselecting previously selected text (i use this to fix botched selections):</p>

<pre><code>gv  &quot; :h gv for more
    &quot; you can use `o` in visual mode to go to the `Other` end of the selection
    &quot; use a motion to fix the selection
</code></pre></li>
<li><p>reselecting previously yanked text:</p>

<pre><code>`[v`]
`[         &quot; marks the beginning of the previously yanked text   :h `[
`]         &quot; marks the end                                       :h `]
 v         &quot; visual select everything in between

nnoremap gb `[v`]    &quot; &quot;a quick map to perform the above
</code></pre></li>
<li><p>pasting and indenting text (in one go):</p>

<pre><code>]p   &quot; put (p) and adjust indent to current line
]P   &quot; put the text before the cursor (P) and adjust indent to current line
</code></pre></li>
</ol>
            <div class=separator></div>
        </div>
    </details>
    
</div>
</body>
</html>