pig-monkey.com - shellhttps://pig-monkey.com/2024-08-14T17:31:03-07:00Archiving The Witches Cycle2024-08-14T00:00:00-07:002024-08-14T17:31:03-07:00Pig Monkeytag:pig-monkey.com,2024-08-14:/2024/08/archiving-witches-cycle/<p>I <a href="/2024/07/link-log-20240729/">recently</a> learned about The Witches Cycle, a French manga by Tony Concrete, thanks to <a href="https://old.reddit.com/r/xbiking/comments/1e6b56d/a_xbikecore_character_design_for_my_manga/">a post by the author on /r/xbiking</a>. It has similar vibes to <a href="https://en.wikipedia.org/wiki/Kiki's_Delivery_Service">Kiki&rsquo;s Delivery Service</a> &ndash; one of my favorite Studio Ghibli films &ndash; with the addition of sweet bikes. I&rsquo;m not completely hooked …</p><p>I <a href="/2024/07/link-log-20240729/">recently</a> learned about The Witches Cycle, a French manga by Tony Concrete, thanks to <a href="https://old.reddit.com/r/xbiking/comments/1e6b56d/a_xbikecore_character_design_for_my_manga/">a post by the author on /r/xbiking</a>. It has similar vibes to <a href="https://en.wikipedia.org/wiki/Kiki's_Delivery_Service">Kiki&rsquo;s Delivery Service</a> &ndash; one of my favorite Studio Ghibli films &ndash; with the addition of sweet bikes. I&rsquo;m not completely hooked on the story yet, but the art is great.</p> <p>Thus far the English translations have only been <a href="https://theradavist.com/tag/manga/">published on The Radavist</a>. Their Javascript gallery viewer leaves something to be desired in this application. If the English translations are ever published as a book, I&rsquo;ll buy it. In the meantime, the manga is easy to liberate.</p> <p>A quick inspection of The Radavist&rsquo;s pages for <a href="https://theradavist.com/bikepacking-manga-the-witches-cycle/">chapter 1</a>, <a href="https://theradavist.com/witches-cycle-chapter-two/">chapter 2</a>, <a href="https://theradavist.com/witches-cycle-bikepacking-manga-chapter-3/">chapter 3</a>, and <a href="https://theradavist.com/the-witches-cycle-chapter-4/">chapter 4</a> shows that the chapters consist of sequentially numbered JPGs (though they are not consistent in their naming scheme, for shame). I&rsquo;m a big fan of <a href="https://www.web3isgoinggreat.com/">downloading JPGs</a>.</p> <div class="highlight"><pre><span></span><code><span class="o">$</span><span class="w"> </span><span class="n">mkdir</span><span class="w"> </span><span class="n">witches</span><span class="o">-</span><span class="n">chapter</span><span class="o">-</span><span class="mi">0</span><span class="p">{</span><span class="mf">1.</span><span class="o">.</span><span class="mi">4</span><span class="p">}</span><span class="w"></span> <span class="o">$</span><span class="w"> </span><span class="n">wget</span><span class="w"> </span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">media</span><span class="o">.</span><span class="n">theradavist</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">uploads</span><span class="o">/</span><span class="mi">2023</span><span class="o">/</span><span class="mi">11</span><span class="o">/</span><span class="n">Witches</span><span class="o">-</span><span class="n">Cycle</span><span class="o">-</span><span class="p">{</span><span class="mf">1.</span><span class="o">.</span><span class="mi">76</span><span class="p">}</span><span class="o">.</span><span class="n">jpg</span><span class="w"> </span><span class="o">--</span><span class="n">directory</span><span class="o">-</span><span class="n">prefix</span><span class="w"> </span><span class="n">witches</span><span class="o">-</span><span class="n">chapter</span><span class="o">-</span><span class="mi">01</span><span class="o">/</span><span class="w"></span> <span class="o">$</span><span class="w"> </span><span class="n">wget</span><span class="w"> </span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">media</span><span class="o">.</span><span class="n">theradavist</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">uploads</span><span class="o">/</span><span class="mi">2024</span><span class="o">/</span><span class="mi">02</span><span class="o">/</span><span class="mi">2024</span><span class="n">_Witches_Cycle_Chapter_2</span><span class="o">-</span><span class="p">{</span><span class="mf">1.</span><span class="o">.</span><span class="mi">30</span><span class="p">}</span><span class="o">.</span><span class="n">jpg</span><span class="w"> </span><span class="o">--</span><span class="n">directory</span><span class="o">-</span><span class="n">prefix</span><span class="w"> </span><span class="n">witches</span><span class="o">-</span><span class="n">chapter</span><span class="o">-</span><span class="mi">02</span><span class="o">/</span><span class="w"></span> <span class="o">$</span><span class="w"> </span><span class="n">wget</span><span class="w"> </span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">media</span><span class="o">.</span><span class="n">theradavist</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">uploads</span><span class="o">/</span><span class="mi">2024</span><span class="o">/</span><span class="mi">03</span><span class="o">/</span><span class="mi">2024</span><span class="n">_Witches_Cycle_Chp3</span><span class="o">-</span><span class="p">{</span><span class="mf">1.</span><span class="o">.</span><span class="mi">38</span><span class="p">}</span><span class="o">.</span><span class="n">jpg</span><span class="w"> </span><span class="o">--</span><span class="n">directory</span><span class="o">-</span><span class="n">prefix</span><span class="w"> </span><span class="n">witches</span><span class="o">-</span><span class="n">chapter</span><span class="o">-</span><span class="mi">03</span><span class="o">/</span><span class="w"></span> <span class="o">$</span><span class="w"> </span><span class="n">wget</span><span class="w"> </span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">media</span><span class="o">.</span><span class="n">theradavist</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">uploads</span><span class="o">/</span><span class="mi">2024</span><span class="o">/</span><span class="mi">06</span><span class="o">/</span><span class="n">chap4</span><span class="p">{</span><span class="mf">05.</span><span class="o">.</span><span class="mi">49</span><span class="p">}</span><span class="o">.</span><span class="n">jpg</span><span class="w"> </span><span class="o">--</span><span class="n">directory</span><span class="o">-</span><span class="n">prefix</span><span class="w"> </span><span class="n">witches</span><span class="o">-</span><span class="n">chapter</span><span class="o">-</span><span class="mi">04</span><span class="o">/</span><span class="w"></span> </code></pre></div> <p>The <a href="/2024/08/kindle-comic-converter/">previously mentioned Kindle Comic Converter</a> is happy to operate on a directory of images.</p> <div class="highlight"><pre><span></span><code>$ <span class="k">for</span> i <span class="k">in</span> <span class="o">{</span><span class="m">01</span>..04<span class="o">}</span><span class="p">;</span> <span class="k">do</span> kcc-c2e --profile KoL --upscale --cropping <span class="m">2</span> --splitter <span class="m">2</span> --author <span class="s2">&quot;Tony Concrete&quot;</span> --title <span class="s2">&quot;The Witches Cycle, Chapter </span><span class="nv">$i</span><span class="s2">&quot;</span> witches-chapter-<span class="nv">$i</span>/<span class="p">;</span> <span class="k">done</span> </code></pre></div> <p>This results in 3 well-formatted EPUB files I can archive in my Calibre library and read on my e-reader.</p>Redswitch2021-10-17T00:00:00-07:002021-10-17T10:35:49-07:00Pig Monkeytag:pig-monkey.com,2021-10-17:/2021/10/redswitch/<p><a href="http://jonls.dk/redshift/">Redshift</a> is a program that adjusts the color temperature of the screen based on time and location. It can automatically fetch one&rsquo;s location via <a href="https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home">GeoClue</a>. I&rsquo;ve used it for years. It works most of the time. But, more often than I&rsquo;d like, it fails to fetch my …</p><p><a href="http://jonls.dk/redshift/">Redshift</a> is a program that adjusts the color temperature of the screen based on time and location. It can automatically fetch one&rsquo;s location via <a href="https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home">GeoClue</a>. I&rsquo;ve used it for years. It works most of the time. But, more often than I&rsquo;d like, it fails to fetch my location from GeoClue. When this happens, I find GeoClue impossible to debug. Redshift <a href="https://github.com/jonls/redshift/issues/393">does not cache location information</a>, so when it fails to fetch my location the result is an eye-meltingly bright screen at night. To address this, I wrote a small shell script to avoid GeoClue entirely.</p> <p><a href="https://github.com/pigmonkey/redswitch">Redswitch</a> fetches the current location via the <a href="https://location.services.mozilla.com/">Mozilla Location Service</a> (using GeoClue&rsquo;s API key, which <a href="https://gitlab.freedesktop.org/geoclue/geoclue/-/issues/136">may go away</a>). The result is stored and compared against the previous location to determine if the device has moved. If a change in location is detected, Redshift is killed and relaunched with the new location (this will result in a noticeable flash, but there seems to be no alternative since <a href="https://github.com/jonls/redshift/pull/96">Redshift cannot reload its settings while running</a>). If Redshift is not running, it is launched. If no change in location is detected and Redshift is already running, nothing happens. Because the location information is stored, this can safely be used to launch Redshift when the machine is offline (or when the Mozilla Location Service API is down or rate-limited).</p> <p>My laptop does not experience frequent, drastic changes in location. I find that having the script automatically execute once upon login is adequate for my needs. If you&rsquo;re jetting around the world, you could periodically execute the script via cron or a systemd timer.</p> <p>This solves all my problems with Redshift. I can go back to forgetting about its existence, which is my goal for software of this sort.</p>Searching Books2020-06-11T00:00:00-07:002020-06-11T21:30:50-07:00Pig Monkeytag:pig-monkey.com,2020-06-11:/2020/06/ripgrep-all/<p><a href="https://github.com/phiresky/ripgrep-all/">ripgrep-all</a> is a small wrapper around <a href="https://github.com/BurntSushi/ripgrep">ripgrep</a> that adds support for additional file formats.</p> <p>I discovered it while looking for a program that would allow me to search <a href="/2018/11/ebooks/">my e-book library</a> without needing to open individual books and search their contents via <a href="https://calibre-ebook.com/">Calibre</a>. ripgrep-all accomplishes this by using <a href="https://pandoc.org/">Pandoc</a> to …</p><p><a href="https://github.com/phiresky/ripgrep-all/">ripgrep-all</a> is a small wrapper around <a href="https://github.com/BurntSushi/ripgrep">ripgrep</a> that adds support for additional file formats.</p> <p>I discovered it while looking for a program that would allow me to search <a href="/2018/11/ebooks/">my e-book library</a> without needing to open individual books and search their contents via <a href="https://calibre-ebook.com/">Calibre</a>. ripgrep-all accomplishes this by using <a href="https://pandoc.org/">Pandoc</a> to convert files to plain text and then running ripgrep on the output. One of the numerous formats supported by Pandoc is <a href="https://en.wikipedia.org/wiki/EPUB">EPUB</a>, which is the format I use to store books.</p> <p>Running Pandoc on every book in my library to extract its text can take some time, but ripgrep-all caches the extracted text so that subsequent runs are similar in speed to simply searching plain text &ndash; which is blazing fast thanks to ripgrep&rsquo;s speed. It takes around two seconds to search 1,706 books.</p> <div class="highlight"><pre><span></span><code>$ time<span class="o">(</span>rga -li <span class="s1">&#39;pandemic&#39;</span> ~/library/books/ <span class="p">|</span> wc -l<span class="o">)</span> <span class="m">33</span> real 0m1.225s user 0m2.458s sys 0m1.759s </code></pre></div>Bleach has a shelf life of 6 to 12 months.2020-03-18T00:00:00-07:002020-03-18T20:55:13-07:00Pig Monkeytag:pig-monkey.com,2020-03-18:/2020/03/bleach-shelf-life/<p>After one year <a href="https://www.clorox.com/how-to/laundry-basics/product-usage-guides/shelf-life/">the sodium hypochlorite will have broken down into salt and water</a>, which will not be helpful in your battle against the Black Death. According to the <a href="https://ehs.unl.edu/sop/s-bio-disinfectants.pdf">University of Nebraska&rsquo;s guidelines on chemical disinfectants for biohazardous materials</a>, &ldquo;bleach loses 20-50% of its sodium hypochlorite concentration after 6 …</p><p>After one year <a href="https://www.clorox.com/how-to/laundry-basics/product-usage-guides/shelf-life/">the sodium hypochlorite will have broken down into salt and water</a>, which will not be helpful in your battle against the Black Death. According to the <a href="https://ehs.unl.edu/sop/s-bio-disinfectants.pdf">University of Nebraska&rsquo;s guidelines on chemical disinfectants for biohazardous materials</a>, &ldquo;bleach loses 20-50% of its sodium hypochlorite concentration after 6 months&rdquo;.</p> <p>Bottles of Clorox bleach are stamped with a date code which <a href="https://www.clorox.com/how-to/laundry-basics/bleach-101/clorox-regular-bleach-should-be-replaced-every-year-and-stored-as-directed-for-optimum-performance/">when properly decoded</a> will indicate the date of manufacture. The first 7 characters in the label on one of my bottles are <code>A819275</code>, indicating that it was manufactured in plant A8 on the 275th day of 2019, or October 2nd. The <a href="/2019/07/dateutils/">previously mentioned dateutils</a> proves its usefulness here.</p> <div class="highlight"><pre><span></span><code>$ datediff <span class="m">2019</span>-275 now <span class="m">169</span> $ datediff <span class="m">2019</span>-275 now -f <span class="s2">&quot;%m months, %d days&quot;</span> <span class="m">5</span> months, <span class="m">17</span> days </code></pre></div> <p>A <a href="https://superuser.com/a/232106">simple shell function</a> may be used to decode the date.</p> <div class="highlight"><pre><span></span><code>jul () { date -d &quot;$1-01-01 +$2 days -1 day&quot; &quot;+%Y-%m-%d&quot;; } $ jul 2019 275 2019-10-02 </code></pre></div>Monitoring Legible News2020-01-31T00:00:00-08:002020-06-11T21:14:25-07:00Pig Monkeytag:pig-monkey.com,2020-01-31:/2020/01/monitoring-legible-news/<p>I was sent a link to <a href="https://legiblenews.com/">Legible News</a> last November by someone who had read my post on the now-defunct <a href="/2016/07/breaking/">Breaking News</a>. Legible News is a website that simply scrapes headlines from <a href="https://en.wikipedia.org/w/index.php?title=Portal:Current_events">Wikipedia&rsquo;s Current Events</a> once per day and presents them in a legible format. This seems like a …</p><p>I was sent a link to <a href="https://legiblenews.com/">Legible News</a> last November by someone who had read my post on the now-defunct <a href="/2016/07/breaking/">Breaking News</a>. Legible News is a website that simply scrapes headlines from <a href="https://en.wikipedia.org/w/index.php?title=Portal:Current_events">Wikipedia&rsquo;s Current Events</a> once per day and presents them in a legible format. This seems like a simple thing, but is <a href="https://zainamro.com/notes/unbearable-news">far beyond the capabilities of most news organizations today</a>.</p> <p>Legible News provides no update notification mechanism. I addressed this by plugging it into <a href="/2019/12/urlwatch/">my urlwatch system</a>. Initially this presented two problems: the email notification included the HTML markup, which I didn&rsquo;t care about, and it included both the old and new content of every changed line &ndash; effectively sending me the news from today and yesterday.</p> <p>The first problem was easily solved by using the <code>html2text</code> filter provided by <a href="https://github.com/thp/urlwatch">urlwatch</a>. This strips out all markup, which is what I thought I wanted. I ran this for a bit before deciding that I did want the output to contain links. What I really wanted was some sort of <code>html2markdown</code> filter.</p> <p>I also realized I did not just want to be sent new lines, but every line anytime there was a change. If the news yesterday included a section titled &ldquo;Armed conflicts and attacks&rdquo;, and the news today included a section with the same title, I wanted that in my output despite it not having changed.</p> <p>I solved both of these problems using the <code>diff_tool</code> argument of urlwatch. This allows the user to pass in a special tool to replace the default use of <code>diff</code> to generate the notification output. The tool will be called with two arguments: the filename of the previously downloaded version of the URL and the filename of the current version. I wrote a simple script called <code>html2markdown.sh</code> which ignores the first argument and simply passes the second argument to <a href="https://pandoc.org">Pandoc</a> for formatting. </p> <div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span> <span class="normal">2</span> <span class="normal">3</span> <span class="normal">4</span> <span class="normal">5</span> <span class="normal">6</span> <span class="normal">7</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="ch">#!/bin/sh</span> pandoc --from html <span class="se">\</span> --to markdown_strict <span class="se">\</span> --reference-links <span class="se">\</span> --reference-location<span class="o">=</span>block <span class="se">\</span> <span class="nv">$2</span> </code></pre></div></td></tr></table></div> <p>This script is used as the <code>diff_tool</code> in the urlwatch job definition.</p> <div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span> <span class="normal">2</span> <span class="normal">3</span> <span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">url</span><span class="w"></span> <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Legible News</span><span class="w"></span> <span class="nt">url</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://legiblenews.com/</span><span class="w"></span> <span class="nt">diff_tool</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">/home/pigmonkey/bin/html2markdown.sh</span><span class="w"></span> </code></pre></div></td></tr></table></div> <p>The result is the latest version of Legible News, nicely converted to Markdown, delivered to my inbox every day. The output would be even better if Legible News used semantic markup &ndash; specifically heading elements &ndash; but it is perfectly serviceable as is.</p> <p>After I built this I discovered that <a href="https://feed43.com/3068865104604836.xml">somebody had created an RSS feed for Legible News</a> using a service called <a href="http://feed43.com/">Feed43</a>.</p>Personal Information Management2019-12-14T00:00:00-08:002019-12-14T18:22:36-08:00Pig Monkeytag:pig-monkey.com,2019-12-14:/2019/12/pim-utils/<p><a href="https://pimutils.org/">pimutils</a> is a collection of software for personal information management. The core piece is <a href="https://vdirsyncer.pimutils.org/">vdirsyncer</a>, which synchronizes calendars and contacts between the local filesystem and CalDav and CardDAV servers. Calendars may then be interacted with via <a href="https://lostpackets.de/khal/">khal</a>, and contacts via <a href="https://github.com/scheibler/khard/">khard</a>. There&rsquo;s not much to say about these three …</p><p><a href="https://pimutils.org/">pimutils</a> is a collection of software for personal information management. The core piece is <a href="https://vdirsyncer.pimutils.org/">vdirsyncer</a>, which synchronizes calendars and contacts between the local filesystem and CalDav and CardDAV servers. Calendars may then be interacted with via <a href="https://lostpackets.de/khal/">khal</a>, and contacts via <a href="https://github.com/scheibler/khard/">khard</a>. There&rsquo;s not much to say about these three programs, other than they all just work. Having offline access to my calendars and contacts is critical, as is the ability to synchronize that data across machines.</p> <p>Khard integrates easily with <a href="https://neomutt.org/">mutt</a> to provide autocomplete when composing emails. I find its interface for creating, editing and reading contacts to be intuitive. It can also output a calendar of birthdays, which can then be imported into khal.</p> <p>Khal&rsquo;s interface for adding new calendar events is much simpler and quicker than all the mousing required by GUI calendar programs.</p> <div class="highlight"><pre><span></span><code>$ khal new <span class="m">2019</span>-11-16 <span class="m">21</span>:30 5h Alessandro Cortini at Public Works :: <span class="m">161</span> Erie St </code></pre></div> <p>There are times when a more complex user interface makes calendaring tasks easier. For this Khal offers the <a href="https://lostpackets.de/khal/usage.html#interactive">interactive option</a>, which provides a <a href="https://en.wikipedia.org/wiki/Text-based_user_interface">TUI</a> for creating, editing and reading events.</p> <p>Khal can also <a href="https://lostpackets.de/khal/usage.html#import">import</a> <a href="https://en.wikipedia.org/wiki/ICalendar">iCalendar</a> files, which is a simple way of getting existing events into my world.</p> <div class="highlight"><pre><span></span><code><span class="err">$</span> <span class="n">khal</span> <span class="kn">import</span> <span class="nn">invite.ics</span> </code></pre></div> <p>Vdirsyncer has <a href="https://github.com/pimutils/vdirsyncer/issues/790">maintenance problems</a> that may call its future into question, but the whole point of modular tools that operate on open data formats is that they are replaceable.</p> <p>I have a simple and often used script which calls <code>khal calendar</code> and <code>task list</code> (the latter command being <a href="https://taskwarrior.org/">taskwarrior</a>), answering the question: what am I supposed to be doing right now?</p>Terminal Calculations2019-12-12T00:00:00-08:002019-12-12T18:52:46-08:00Pig Monkeytag:pig-monkey.com,2019-12-12:/2019/12/qalculate/<p><a href="https://qalculate.github.io/">Qalculate!</a> is a well known GTK-based GUI calculator. For years I ignored it because I failed to realize that it included a terminal interface, <code>qalc</code>. Since learning about <code>qalc</code> last year it has become my go-to calculator. It supports <a href="https://qalculate.github.io/features.html">all the same features</a> as the GUI, including <a href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN</a> and unit …</p><p><a href="https://qalculate.github.io/">Qalculate!</a> is a well known GTK-based GUI calculator. For years I ignored it because I failed to realize that it included a terminal interface, <code>qalc</code>. Since learning about <code>qalc</code> last year it has become my go-to calculator. It supports <a href="https://qalculate.github.io/features.html">all the same features</a> as the GUI, including <a href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN</a> and unit conversions. I <a href="/2019/07/gnu-units/">primarily use GNU Units for unit wrangling</a>, but being able to perform unit conversions within my calculator is sometimes useful.</p> <div class="highlight"><pre><span></span><code>$ qalc &gt; 1EUR to USD It has been <span class="m">20</span> day<span class="o">(</span>s<span class="o">)</span> since the exchange rates last were updated Do you wish to update the exchange rates now? y <span class="m">1</span> * <span class="nv">euro</span> <span class="o">=</span> approx. <span class="nv">$1</span>.1137000 &gt; 32oC to oF <span class="m">32</span> * <span class="nv">celsius</span> <span class="o">=</span> <span class="m">89</span>.6 oF </code></pre></div> <p><a href="https://qalculate.github.io/manual/qalculate-mode.html#qalculate-rpn">The RPN mode</a> is not quite as intuitive as a purpose built RPN calculator like <a href="https://github.com/pelzlpj/orpie">Orpie</a>, but it is adequate for my uses. My most frequent use of RPN mode is totaling a long list of numbers without bothering with all those tedious <code>+</code> symbols.</p> <div class="highlight"><pre><span></span><code>&gt; rpn on &gt; stack The RPN stack is empty &gt; 85 85 = 85 &gt; 42 42 = 42 &gt; 198 198 = 198 &gt; 5 5 = 5 &gt; 659 659 = 659 &gt; stack 1: 659 2: 5 3: 198 4: 42 5: 85 &gt; total total([659, 5, 198, 42, 85]) = 989 &gt; stack 1: 989 </code></pre></div> <p>Also provided are some basic <a href="https://qalculate.github.io/manual/qalculate-definitions-functions.html#qalculate-definitions-functions-1-Statistics">statistics functions</a> that can help save time.</p> <div class="highlight"><pre><span></span><code>&gt; mean(2,12,5,3,1) mean([2, 12, 5, 3, 1]) = 4.6 </code></pre></div> <p>And of course there are <a href="https://qalculate.github.io/manual/qalculate-definitions-variables.html">the varaibles and constants you would expect</a></p> <div class="highlight"><pre><span></span><code>&gt; 12+3*8)/2 (12 + (3 * 8)) / 2 = 18 &gt; ans*pi ans * pi = 56.548668 </code></pre></div> <p>I reach for <code>qalc</code> more frequently than alternative calculators like <a href="https://www.gnu.org/software/bc/">bc</a>, <a href="https://github.com/sharkdp/insect">insect</a>, or the Python shell.</p>Mutt is my mail user agent of choice.2019-07-31T00:00:00-07:002019-07-31T21:12:06-07:00Pig Monkeytag:pig-monkey.com,2019-07-31:/2019/07/mutt-ics/<p>More specifically, <a href="https://neomutt.org/">Neomutt</a>. <a href="https://github.com/dmedvinsky/mutt-ics">Mutt ICS</a> is a python script which takes an <a href="https://en.wikipedia.org/wiki/ICalendar">iCalendar file</a> and outputs the contents in a human friendly format. I use it in <a href="https://github.com/pigmonkey/dotfiles/blob/master/config/mutt/mailcap">my mailcap</a> so that I can see details of calendar attachments when reading email. It&rsquo;s a simple script that improves my email …</p><p>More specifically, <a href="https://neomutt.org/">Neomutt</a>. <a href="https://github.com/dmedvinsky/mutt-ics">Mutt ICS</a> is a python script which takes an <a href="https://en.wikipedia.org/wiki/ICalendar">iCalendar file</a> and outputs the contents in a human friendly format. I use it in <a href="https://github.com/pigmonkey/dotfiles/blob/master/config/mutt/mailcap">my mailcap</a> so that I can see details of calendar attachments when reading email. It&rsquo;s a simple script that improves my email workflow.</p>Without an OCR layer, PDF files are of limited use.2019-07-30T00:00:00-07:002019-07-30T19:47:30-07:00Pig Monkeytag:pig-monkey.com,2019-07-30:/2019/07/ocrmypdf/<p><a href="https://ocrmypdf.readthedocs.io/">OCRmyPDF</a> is a tool that applies <a href="https://en.wikipedia.org/wiki/Optical_character_recognition">optical character recognition</a> to PDFs. It uses <a href="https://github.com/tesseract-ocr/tesseract">Tesseract</a> to perform the OCR, and <a href="https://github.com/Flameeyes/unpaper">unpaper</a> to clean, deskew and optimize the input files. It outputs <a href="https://en.wikipedia.org/?title=PDF/A">PDF/A</a> files, optimized for long-term storage. This isn&rsquo;t a tool I use frequently, but it is one I …</p><p><a href="https://ocrmypdf.readthedocs.io/">OCRmyPDF</a> is a tool that applies <a href="https://en.wikipedia.org/wiki/Optical_character_recognition">optical character recognition</a> to PDFs. It uses <a href="https://github.com/tesseract-ocr/tesseract">Tesseract</a> to perform the OCR, and <a href="https://github.com/Flameeyes/unpaper">unpaper</a> to clean, deskew and optimize the input files. It outputs <a href="https://en.wikipedia.org/?title=PDF/A">PDF/A</a> files, optimized for long-term storage. This isn&rsquo;t a tool I use frequently, but it is one I greatly appreciate having when I need it. If you ever find yourself scanning or photographing documents, you want OCRmyPDF.</p>Date Manipulation2019-07-29T00:00:00-07:002019-07-29T19:02:29-07:00Pig Monkeytag:pig-monkey.com,2019-07-29:/2019/07/dateutils/<p><a href="http://www.fresse.org/dateutils/">Dateutils</a> is a collection of tools for the quick manipulation of dates. The tool I use most frequently is <code>datediff</code>. This program answers questions like: &ldquo;How many days has it been since a date?&rdquo; or &ldquo;How many days are left in summer?&rdquo;</p> <div class="highlight"><pre><span></span><code>$ datediff <span class="m">2019</span>-03-21 now <span class="m">131</span> $ datediff now <span class="m">2019 …</span></code></pre></div><p><a href="http://www.fresse.org/dateutils/">Dateutils</a> is a collection of tools for the quick manipulation of dates. The tool I use most frequently is <code>datediff</code>. This program answers questions like: &ldquo;How many days has it been since a date?&rdquo; or &ldquo;How many days are left in summer?&rdquo;</p> <div class="highlight"><pre><span></span><code>$ datediff <span class="m">2019</span>-03-21 now <span class="m">131</span> $ datediff now <span class="m">2019</span>-09-23 <span class="m">55</span> </code></pre></div> <p>My second most frequently used program is <code>dateadd</code>, which is used to add a duration to a date. It can answer questions like: &ldquo;What will the date be in 3 weeks?&rdquo;</p> <div class="highlight"><pre><span></span><code>$ dateadd now +3w <span class="m">2019</span>-08-20T02:02:23 </code></pre></div> <p>The tools are much more powerful than these examples, but hardly a week goes by when I don&rsquo;t use <code>datediff</code> or <code>dateadd</code> for simple tasks like this.</p>Unit Wrangling2019-07-24T00:00:00-07:002019-07-24T21:39:41-07:00Pig Monkeytag:pig-monkey.com,2019-07-24:/2019/07/gnu-units/<p>I use <a href="https://www.gnu.org/software/units/">GNU Units</a> to convert measurements.</p> <p>The program knows about many obscure and antiquated units, but I mostly use it for boring things like converting currencies and between metric and imperial units. It can be used directly from the command line, or via a prompted interactive mode.</p> <div class="highlight"><pre><span></span><code>$ units 57EUR …</code></pre></div><p>I use <a href="https://www.gnu.org/software/units/">GNU Units</a> to convert measurements.</p> <p>The program knows about many obscure and antiquated units, but I mostly use it for boring things like converting currencies and between metric and imperial units. It can be used directly from the command line, or via a prompted interactive mode.</p> <div class="highlight"><pre><span></span><code>$ units 57EUR USD * <span class="m">63</span>.526262 / <span class="m">0</span>.015741521 $ units Currency exchange rates from FloatRates <span class="o">(</span>USD base<span class="o">)</span> on <span class="m">2019</span>-07-24 <span class="m">3460</span> units, <span class="m">109</span> prefixes, <span class="m">109</span> nonlinear units You have: <span class="m">16</span> floz You want: ml * <span class="m">473</span>.17647 / <span class="m">0</span>.0021133764 You have: tempC<span class="o">(</span><span class="m">30</span><span class="o">)</span> You want: tempF <span class="m">86</span> </code></pre></div> <p>GNU Units is picky about its unit definitions, and they are case sensitive. For example, it knows what <code>USD</code> is, but <code>usd</code> is undefined. It supports tab completion of units in interactive mode, which can be helpful. It knows the difference between a US fluid ounce and a British fluid ounce.</p> <div class="highlight"><pre><span></span><code>$ units <span class="s2">&quot;1 usfloz&quot;</span> ml * <span class="m">29</span>.57353 / <span class="m">0</span>.033814023 $ units <span class="s2">&quot;1 brfloz&quot;</span> ml * <span class="m">28</span>.413063 / <span class="m">0</span>.03519508 </code></pre></div> <p>The unit definitions are stored at <code>/usr/share/units/definitions.units</code>. Occasionally I&rsquo;ll need to peruse through this file to find the correct formatting for the unit I&rsquo;m interested in. Sometimes when doing this I&rsquo;ll run into one of the more obscure definitions, such as <code>beespace</code>. Apparently this unit is used in beekeeping when designing hive boxes. It is described in the definition file thusly: &ldquo;Bees will fill any space that is smaller than the bee space and leave open spaces that are larger. The size of the space varies with species.&rdquo;</p> <div class="highlight"><pre><span></span><code>$ units 12inches beespace * <span class="m">48</span> / <span class="m">0</span>.020833333 </code></pre></div> <p>Every so often you need to know how many Earth days are in one Martian year. With GNU Units that information is a few keystrokes away.</p> <div class="highlight"><pre><span></span><code>$ units 1marsyear days * <span class="m">686</span>.97959 / <span class="m">0</span>.0014556473 </code></pre></div> <p>Currency definitions are stored in <code>/var/lib/units/currency.units</code>. They are updated using the <code>units_cur</code> program. In the past I would update currencies whenever I needed them, but recently I <a href="https://github.com/pigmonkey/spark/commit/24ef24c34aad89a0f9beb907de51b4aad16adff6">setup a systemd timer</a> to update these definitions roughly once per day (depending on network connectivity). This provides me with conversion rates that are current enough for my own use, which I can take advantage of even when offline, and does not require me to let a third party know which currencies or quantities I am interested in.</p> <p>Astute readers will have noted that I am big on this offline computing thing.</p>Undertime2019-07-23T00:00:00-07:002019-07-23T19:10:06-07:00Pig Monkeytag:pig-monkey.com,2019-07-23:/2019/07/undertime/<p><a href="https://gitlab.com/anarcat/undertime">Undertime</a> is a simple program that assists in coordinating events across time zones. It prints a table of your system&rsquo;s local time zone, along with other any other specified zones. The output is colorized based on the start and end hour of the working day. If you want to …</p><p><a href="https://gitlab.com/anarcat/undertime">Undertime</a> is a simple program that assists in coordinating events across time zones. It prints a table of your system&rsquo;s local time zone, along with other any other specified zones. The output is colorized based on the start and end hour of the working day. If you want to talk to someone in Paris tomorrow, and you want the conversation to happen at an hour that is reasonable for both parties, Undertime can help.</p> <p><img alt="Undertime Paris Meeting Example" src="/media/images/undertime.png"></p> <p>I often find myself converting between local time and UTC. Usually this happens when working with system logs. If I have a specific date and time I want to translate, I&rsquo;ll use <code>date</code>.</p> <div class="highlight"><pre><span></span><code># Convert a time from PDT to UTC: $ env TZ=&quot;UTC&quot; date -d &quot;2016-03-25T11:33 PDT&quot; # Convert a time from UTC to local: $ date -d &#39;2016-03-24T12:00 UTC&#39; </code></pre></div> <p>If I&rsquo;m not looking to convert an exact time, but just want to answer a more generalized question like &ldquo;Approximately when was 14:00 UTC?&rdquo; without doing the mental math, I find that Undertime is the quickest solution.</p> <div class="highlight"><pre><span></span><code>$ undertime UTC ╔═══════╦═══════╗ ║ PDT ║ UTC ║ ╠═══════╬═══════╣ ║ <span class="m">00</span>:00 ║ <span class="m">07</span>:00 ║ ║ <span class="m">01</span>:00 ║ <span class="m">08</span>:00 ║ ║ <span class="m">02</span>:00 ║ <span class="m">09</span>:00 ║ ║ <span class="m">03</span>:00 ║ <span class="m">10</span>:00 ║ ║ <span class="m">04</span>:00 ║ <span class="m">11</span>:00 ║ ║ <span class="m">05</span>:00 ║ <span class="m">12</span>:00 ║ ║ <span class="m">06</span>:00 ║ <span class="m">13</span>:00 ║ ║ <span class="m">07</span>:00 ║ <span class="m">14</span>:00 ║ ║ <span class="m">08</span>:00 ║ <span class="m">15</span>:00 ║ ║ <span class="m">09</span>:00 ║ <span class="m">16</span>:00 ║ ║ <span class="m">10</span>:00 ║ <span class="m">17</span>:00 ║ ║ <span class="m">11</span>:00 ║ <span class="m">18</span>:00 ║ ║ <span class="m">12</span>:00 ║ <span class="m">19</span>:00 ║ ║ <span class="m">13</span>:00 ║ <span class="m">20</span>:00 ║ ║ <span class="m">14</span>:00 ║ <span class="m">21</span>:00 ║ ║ <span class="m">15</span>:00 ║ <span class="m">22</span>:00 ║ ║ <span class="m">16</span>:00 ║ <span class="m">23</span>:00 ║ ║ <span class="m">17</span>:00 ║ <span class="m">00</span>:00 ║ ║ <span class="m">18</span>:00 ║ <span class="m">01</span>:00 ║ ║ <span class="m">19</span>:00 ║ <span class="m">02</span>:00 ║ ║ <span class="m">19</span>:04 ║ <span class="m">02</span>:04 ║ ║ <span class="m">20</span>:00 ║ <span class="m">03</span>:00 ║ ║ <span class="m">21</span>:00 ║ <span class="m">04</span>:00 ║ ║ <span class="m">22</span>:00 ║ <span class="m">05</span>:00 ║ ║ <span class="m">23</span>:00 ║ <span class="m">06</span>:00 ║ ╚═══════╩═══════╝ Table generated <span class="k">for</span> time: <span class="m">2019</span>-07-23 <span class="m">19</span>:04:00-07:00 </code></pre></div>Music Organization with Beets2019-07-22T00:00:00-07:002019-07-22T17:49:10-07:00Pig Monkeytag:pig-monkey.com,2019-07-22:/2019/07/beets/<p>I organize my music with <a href="http://beets.io/">Beets</a>.</p> <p>Beets <a href="https://beets.readthedocs.io/en/stable/reference/cli.html#import">imports</a> music into my library, warns me if I&rsquo;m <a href="https://beets.readthedocs.io/en/stable/plugins/missing.html">missing</a> tracks, identifies tracks based on their <a href="https://beets.readthedocs.io/en/stable/plugins/chroma.html">accoustic fingerprint</a>, <a href="https://beets.readthedocs.io/en/stable/plugins/scrub.html">scrubs</a> extraneous metadata, fetches and stores <a href="https://beets.readthedocs.io/en/stable/plugins/fetchart.html">album art</a>, cleans <a href="https://beets.readthedocs.io/en/stable/plugins/lastgenre.html">genres</a>, fetches <a href="https://beets.readthedocs.io/en/stable/plugins/lyrics.html">lyrics</a>, and &ndash; most importantly &ndash; <a href="https://beets.readthedocs.io/en/stable/plugins/mbsync.html">fetches metadata</a> from <a href="https://musicbrainz.org/">MusicBrainz</a>. After some basic <a href="https://github.com/pigmonkey/dotfiles/blob/master/config/beets/config.yaml">configuration</a>, all …</p><p>I organize my music with <a href="http://beets.io/">Beets</a>.</p> <p>Beets <a href="https://beets.readthedocs.io/en/stable/reference/cli.html#import">imports</a> music into my library, warns me if I&rsquo;m <a href="https://beets.readthedocs.io/en/stable/plugins/missing.html">missing</a> tracks, identifies tracks based on their <a href="https://beets.readthedocs.io/en/stable/plugins/chroma.html">accoustic fingerprint</a>, <a href="https://beets.readthedocs.io/en/stable/plugins/scrub.html">scrubs</a> extraneous metadata, fetches and stores <a href="https://beets.readthedocs.io/en/stable/plugins/fetchart.html">album art</a>, cleans <a href="https://beets.readthedocs.io/en/stable/plugins/lastgenre.html">genres</a>, fetches <a href="https://beets.readthedocs.io/en/stable/plugins/lyrics.html">lyrics</a>, and &ndash; most importantly &ndash; <a href="https://beets.readthedocs.io/en/stable/plugins/mbsync.html">fetches metadata</a> from <a href="https://musicbrainz.org/">MusicBrainz</a>. After some basic <a href="https://github.com/pigmonkey/dotfiles/blob/master/config/beets/config.yaml">configuration</a>, all of this happens automatically when I import new files into my library.</p> <p>After the files have been imported, beets makes it easy to query my library based on any of the clean, consistent, high quality, crowd-sourced metadata.</p> <div class="highlight"><pre><span></span><code>$ beet stats genre:ambient Tracks: <span class="m">649</span> Total time: <span class="m">2</span>.7 days Approximate total size: <span class="m">22</span>.4 GiB Artists: <span class="m">76</span> Albums: <span class="m">53</span> Album artists: <span class="m">34</span> $ beet ls -a <span class="s1">&#39;added:2019-07-01..&#39;</span> Deathcount <span class="k">in</span> Silicon Valley - Acheron Dlareme - Compass The Higher Intelligence Agency <span class="p">&amp;</span> Biosphere - Polar Sequences JK/47 - Tokyo Empires Matt Morton - Apollo <span class="m">11</span> Soundtrack $ beet ls -ap albumartist:joplin /home/pigmonkey/library/audio/music/Janis Joplin/Full Tilt Boogie /home/pigmonkey/library/audio/music/Janis Joplin/I Got Dem Ol<span class="err">&#39;</span> Kozmic Blues Again Mama! </code></pre></div> <p>As regular readers will have surmised, the files themselves are stored in <a href="https://git-annex.branchable.com/">git-annex</a>.</p>Terminal Countdown2019-07-20T00:00:00-07:002019-07-20T17:20:30-07:00Pig Monkeytag:pig-monkey.com,2019-07-20:/2019/07/termdown/<p><a href="https://github.com/trehn/termdown">Termdown</a> is a program that provides a countdown timer and stopwatch in the terminal. It uses <a href="http://www.figlet.org/">FIGlet</a> for its display. Its most attractive feature, I think, is the ability to <a href="https://github.com/trehn/termdown/issues/44">support arbitrary script execution</a>.</p> <p>I use it most often as a countdown timer. One of my frequent applications is as …</p><p><a href="https://github.com/trehn/termdown">Termdown</a> is a program that provides a countdown timer and stopwatch in the terminal. It uses <a href="http://www.figlet.org/">FIGlet</a> for its display. Its most attractive feature, I think, is the ability to <a href="https://github.com/trehn/termdown/issues/44">support arbitrary script execution</a>.</p> <p>I use it most often as a countdown timer. One of my frequent applications is as a meditation timer. For this I want a 11 minute timer, with an alert at 10.5 minutes, 60 seconds, and 1 second. This gives me a 10 minute session with 30 seconds preparation and 30 seconds to return. Termdown makes this easy.</p> <div class="highlight"><pre><span></span><code>$ termdown --exec-cmd <span class="s2">&quot;case {0} in 630|30) mpv ~/library/audio/sounds/bell.mp3;; 1) mpv ~/library/audio/sounds/ring.mp3;; esac&quot;</span> 11m </code></pre></div>An Offline Lexicon2019-07-19T00:00:00-07:002019-07-19T20:17:00-07:00Pig Monkeytag:pig-monkey.com,2019-07-19:/2019/07/dictd/<p><a href="https://sourceforge.net/projects/dict/">dictd</a> is a dictionary database server and client. It can be used to lookup word definitions over a network. I don&rsquo;t use it for that. I use the program to provide an offline dictionary. Depending on a network connection, web browser and third-party websites just to define a word …</p><p><a href="https://sourceforge.net/projects/dict/">dictd</a> is a dictionary database server and client. It can be used to lookup word definitions over a network. I don&rsquo;t use it for that. I use the program to provide an offline dictionary. Depending on a network connection, web browser and third-party websites just to define a word strikes me as dumb.</p> <p>To make this go, dictionary files must be installed. I use the <a href="http://gcide.gnu.org.ua/">GNU Collaborative International Dictionary of English</a> (GCIDE), <a href="https://wordnet.princeton.edu/">WordNet</a>, and the <a href="https://www.gutenberg.org/ebooks/3202">Moby Thesaurus</a>. The GCIDE is derived from <a href="http://jsomers.net/blog/dictionary">Noah Webster&rsquo;s famous American dictionary</a>. WordNet is a more modern (one might say &ldquo;dry&rdquo;) resource. The Moby Thesaurus is a public domain thesaurus originally built by <a href="https://en.wikipedia.org/wiki/Grady_Ward">Grady Ward</a>. Between these three sources I can have a pretty good grasp on the English language. No network connectivity required.</p> <p>I use a shell alias to always pipe the definitions through <code>less</code>.</p> <div class="highlight"><pre><span></span><code>def () { dict $1 | less } </code></pre></div>GOESImage2019-06-17T00:00:00-07:002019-06-17T20:43:45-07:00Pig Monkeytag:pig-monkey.com,2019-06-17:/2019/06/goesimage/<p><a href="https://github.com/pigmonkey/goesimage">GOESImage</a> is a bash script which downloads the latest imagery from the <a href="https://www.star.nesdis.noaa.gov/GOES/index.php">NOAA Geostationary Operational Environment Satellites</a> and sets it as the desktop background via <a href="https://feh.finalrewind.org/">feh</a>. If you don&rsquo;t use feh, it should be easy to plug GOESImage into any desktop background control program.</p> <p><a href="/media/images/goesimage.jpg"><img src="/media/images/goesimage-thumb.jpg" width=800 alt="GOESImage Example"></a></p> <p>I wrote GOESImage after using …</p><p><a href="https://github.com/pigmonkey/goesimage">GOESImage</a> is a bash script which downloads the latest imagery from the <a href="https://www.star.nesdis.noaa.gov/GOES/index.php">NOAA Geostationary Operational Environment Satellites</a> and sets it as the desktop background via <a href="https://feh.finalrewind.org/">feh</a>. If you don&rsquo;t use feh, it should be easy to plug GOESImage into any desktop background control program.</p> <p><a href="/media/images/goesimage.jpg"><img src="/media/images/goesimage-thumb.jpg" width=800 alt="GOESImage Example"></a></p> <p>I wrote GOESImage after using <a href="https://github.com/boramalper/himawaripy/">himawaripy</a> for a few years, which is a program that provides imagery of the Asia-Pacific region from the <a href="https://en.wikipedia.org/wiki/Himawari_8">Himawari 8</a> Japanese weather satellite. I like seeing the Earth, and I&rsquo;ve found that real time imagery of my location is actually useful for identifying the approach of large-scale weather systems. NOAA&rsquo;s nighttime multispectral infrared coloring is pretty neat, too.</p>