<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adam Compton on Medium]]></title>
        <description><![CDATA[Stories by Adam Compton on Medium]]></description>
        <link>https://medium.com/@comptona?source=rss-1108f0d8f787------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mI7xf7HklT6jw93_.png</url>
            <title>Stories by Adam Compton on Medium</title>
            <link>https://medium.com/@comptona?source=rss-1108f0d8f787------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:08:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@comptona/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Restore Terminal Contents on Linux (Yes, Like iTerm2)]]></title>
            <link>https://comptona.medium.com/how-to-restore-terminal-contents-on-linux-yes-like-iterm2-cfae5a487b1b?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfae5a487b1b</guid>
            <category><![CDATA[tmux]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Thu, 22 Jun 2023 17:46:23 GMT</pubDate>
            <atom:updated>2023-06-22T17:46:23.783Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently switched to using a Linux desktop from a Mac as my primary work computer. I had grown quite accustomed to iTerm2’s <a href="https://iterm2.com/documentation-restoration.html">session restoration</a> feature, and I wanted something similar for Linux. Here is how I made it happen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*WFHs5GplD-TWhhbK7qa_lQ.gif" /></figure><h3>Introducing tmux</h3><p><a href="https://github.com/tmux/tmux/wiki">tmux</a>, or “terminal multiplexer”, is designed to decouple the output of a terminal process (such as a shell or a terminal-based UI) from the window it happens to appear on. It allows you to attach multiple programs to a single window, to detach and run them in the background, and to reattach them later to view their output.</p><p>tmux is very configurable and has a strong community which has written many additional features in the form of tmux plugins. The two that are relevant to this story are <a href="https://github.com/tmux-plugins/tmux-resurrect">tmux-resurrect</a> and <a href="https://github.com/tmux-plugins/tmux-continuum">tmux-continuum</a>. tmux-resurrect can save and restore the state of a tmux session, and tmux-continuum triggers that save process continuously. There’s lots of documentation about setting up these plugins; see the READMEs in those repos for more.</p><p>My ~/.tmux.conf wound up looking like:</p><pre>set -g @plugin &#39;tmux-plugins/tpm&#39;<br>set -g @plugin &#39;tmux-plugins/tmux-resurrect&#39;<br>set -g @resurrect-capture-pane-contents &#39;on&#39;<br>set -g @continuum-restore &#39;on&#39;<br>set -g @continuum-save-interval &#39;1&#39;<br>set -g @plugin &#39;tmux-plugins/tmux-continuum&#39;</pre><h3>iTerm2 capability</h3><p>All of the documentation I could find was geared towards saving and restoring a single window, which is not what I wanted. I wanted all of my windows <em>and</em> tabs restored, with current directories and full scrollback. That took a little more work.</p><p>First, I set my terminal emulator’s startup command to:</p><pre>bash -c &quot;(tmux ls | grep -vq attached &amp;&amp; tmux at) || tmux&quot;</pre><p>This command lists the open tmux sessions, and either reattaches to an existing tmux session (if there are any that are detached) or starts a brand new one.</p><p>Then, I wrote this script and saved it as~/bin/tmux-restoring.sh:</p><pre>#!/bin/sh<br><br>restoring=$(tmux ls | grep -v attached | wc -l)<br>[ $restoring -gt 0 ] &amp;&amp; echo &quot;restoring&quot;</pre><p>It counts the number of tmux sessions that are detached and prints the word “restoring” if there’s more than zero of them. This lets me know that there’s saved sessions available after a restart if the terminal emulator does not automatically reopen all of the windows or tabs.</p><p>I added code to call this to my ~/.tmux.conf :</p><pre>set -g @theme-status-left-suffix &#39; #(~/bin/tmux-restoring.sh) &#39;</pre><p>(I am using <a href="https://github.com/jimeh/tmux-themepack">tmux-themepack</a> to customize the status line, but this can be added with tmux set-option -ag status-left ‘ #(~/bin/tmux-restoring.sh)’ as well.)</p><p>You can see the result of this in the gif at the top of the page; it briefly shows restoring in the tmux status bar after the window is reopened.</p><h3>Final thoughts</h3><p>This was more complex than I expected it to be, given that Mac users have had the luxury of this feature in iTerm2 for a long time. However, it’s nice to have it sorted in Linux finally.</p><h3>P.S. — tmux Control Mode</h3><p>tmux has a special “<a href="https://github.com/tmux/tmux/wiki/Control-Mode">Control Mode</a>” which allows for deep integration with a terminal emulator; in that mode, tmux sessions and windows are manipulated directly by the emulator instead of being represented by separate windows and tabs. I could not find a terminal emulator on Linux which supported this, but if one exists, that’d be an even nicer experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfae5a487b1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Emacs for GTD Universal Capture in Linux]]></title>
            <link>https://comptona.medium.com/use-emacs-for-gtd-universal-capture-in-linux-2d46bcaa4574?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d46bcaa4574</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[gtd]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[emacs]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 07:05:07 GMT</pubDate>
            <atom:updated>2023-03-16T07:05:07.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="DALL-E; “A cyberpunk computer terminal with mechanical arms grabbing everything around it”" src="https://cdn-images-1.medium.com/max/1024/1*Lnnoxld_wCdF0TfxCU_Ufg.png" /></figure><p>I like having a system-wide keyboard shortcut that activates some form of text editor. That allows me to press the shortcut, type whatever I have in mind, navigate away from the editor, and get back to what I was doing. (This is sometimes called “universal capture” or “<a href="https://zenhabits.net/tips-for-gtds-ubiquitous-capture/">ubiquitous capture</a>” in <a href="https://gettingthingsdone.com/">GTD</a>-land.)</p><p>I’ve used lots of different programs to accomplish this over the years: NotationalVelocity/<a href="https://brettterpstra.com/projects/nvalt/">nvALT</a>, <a href="https://simplenote.com/">SimpleNote</a>, <a href="https://obsidian.md/">Obsidian</a>, just to name a few. However, I wanted to combine the quick access of universal capture with the editing power of Emacs. I spent some time recently setting up my Linux laptop to accomplish this.</p><h3>A Script to Activate or Launch Emacs</h3><p>The first thing I needed was a script to summon an Emacs frame. If a frame already exists, it should be brought forward; if it doesn’t already exist, one should be created and then brought forward.</p><p>Here’s what I wrote to accomplish this task:</p><pre>#!/bin/bash<br>candidate=$(xdotool search --name &quot;GNU Emacs&quot; | tail -1)<br>active=$(xdotool getwindowfocus)<br>if [[ $candidate -eq $active ]]; then<br>    xdotool windowminimize $candidate<br>    exit 0<br>fi<br>if [[ -z $candidate ]]; then<br>    emacsclient -c -n<br>    candidate=$(xdotool search --name &quot;GNU Emacs&quot; | tail -1)<br>fi<br>xdotool windowactivate $candidate</pre><p>This uses xdotool to find the Emacs frame, if it exists, and also to get the ID of the currently active window. If no Emacs frame exists, emacsclient creates one and then xdotool windowactivate raises it. If an Emacs frame exists but is not the currently active window, xdotool windowactivate raises it. Finally, if a frame exists and <em>is </em>the currently active window, xdotool windowminimize hides it away. (This latter allows us to press the keyboard shortcut again to vanish the universal capture window and return focus to whatever was focused previously.)</p><h3>A Global Keyboard Short to Run It</h3><p>The script isn’t much good if I have to open a terminal and type it in by hand every time, so I also set up a keyboard shortcut to execute it. These instructions are for KDE, but the same script should work for any Linux system.</p><ol><li>Launch <strong>System Settings</strong> &gt; <strong>Custom Shortcuts</strong></li><li>Right-click on the left-hand side list and select <strong>New</strong> &gt; <strong>Global Shortcut</strong> &gt; <strong>Command/URL</strong></li><li>Name the new shortcut, and for its “Trigger”, pick the keyboard shortcut of your choice. (I tend to use Alt+Shift+&lt;key&gt; since that’s not usually taken by most applications.)</li><li>For “Action”, point it to the script above as saved somewhere on your filesystem and made executable</li></ol><h3>Closing Thoughts</h3><p>I can’t overstate the usefulness of having a simple, system-wide keyboard shortcut that you can use to summon a text editor to write down whatever is currently distracting you. It will save you a lot of time and focus to get all of that out of your head and onto paper.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d46bcaa4574" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get a count of Github PRs, by author]]></title>
            <link>https://comptona.medium.com/how-to-get-a-count-of-github-prs-by-author-8b840b0a69d7?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b840b0a69d7</guid>
            <category><![CDATA[pull-request]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Wed, 08 Feb 2023 22:25:06 GMT</pubDate>
            <atom:updated>2023-02-08T22:25:40.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0bbs-1ZwaSaEImTQ" /><figcaption>Photo by <a href="https://unsplash.com/@lukechesser?utm_source=medium&amp;utm_medium=referral">Luke Chesser</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I was curious about who was creating the highest number of PRs in a specific git repo, and I couldn’t find a good way to figure it out. So here’s what I did.</p><p>First off, I had to get the count of PRs by author and date. That took me a while to figure out, but the magic wound up being (using the <a href="https://cli.github.com/">GitHub CLI tool</a>):</p><pre>$ gh api /repos/&lt;org&gt;/&lt;repo&gt;/pulls?state=all --template &#39;{{ range . }}{{ printf &quot;%s,%s\n&quot; .user.login .created_at }}{{end}}&#39; --paginate &gt; tmp/prs.csv</pre><p>That gave me a CSV I could load into a SQLite database <a href="https://www.sqlitetutorial.net/sqlite-import-csv/">like so</a>. I then used <a href="https://datasette.io/">datasette</a> to run some queries.</p><p>The following query is a breakdown of which person created the most PRs in each year:</p><pre>select year, author, prs, rank from (<br><br>select ROW_NUMBER() over (PARTITION BY year ORDER BY sum(total) desc) as rank, sum(total) as prs, author, year from ( select count(1) as total, author, strftime(&#39;%Y&#39;, created) as year from pr_authors group by author, year<br> ) group by author, year order by total desc<br><br>)<br>where rank &lt;= 1<br>order by year asc;</pre><p>The result looks like:</p><pre>year,author,prs,rank<br>2018,alice,369,1<br>2019,bob,680,1<br>2020,claire,858,1<br>2021,donald,1260,1<br>2022,emily,801,1<br>2023,frank,1127,1</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b840b0a69d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The “Baked Data” architecture pattern]]></title>
            <link>https://comptona.medium.com/the-baked-data-architecture-pattern-efaa28dd44c0?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/efaa28dd44c0</guid>
            <category><![CDATA[linkpost]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 21:52:46 GMT</pubDate>
            <atom:updated>2021-01-15T21:52:46.018Z</atom:updated>
            <content:encoded><![CDATA[<p>I learned about this recently from <a href="https://simonwillison.net/2020/Dec/13/datasette-io/">this blog post</a>, and it seems like a really robust tool to have in my tool belt:</p><blockquote>[M]ost of the site content lives in a SQLite database, and I use custom Jinja templates to implement the site’s different pages.</blockquote><blockquote>This is effectively a variant of the static site generator pattern. The SQLite database is built by scripts as part of the deploy process, then deployed to Google Cloud Run as a binary asset bundled with the templates and Datasette itself.</blockquote><blockquote>I call this the <strong>Baked Data</strong> architectural pattern — with credit to Kevin Marks for <a href="https://chat.indieweb.org/dev/2020-11-15#t1605478365993400">helping me</a> coin the right term. You bake the data into the application.</blockquote><blockquote>It’s comparable to static site generation because everything is immutable, which greatly reduces the amount of things that can go wrong — and any content changes require a fresh deploy. It’s extremely easy to scale — just run more copies of the application with the bundled copy of the database. Cloud Run and other serverless providers handle that kind of scaling automatically.</blockquote><blockquote>Unlike static site generation, if a site has a thousand pages you don’t need to build a thousand HTML pages in order to deploy. A single template and a SQL query that incorporates arguments from the URL can serve as many pages as there are records in the database.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efaa28dd44c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linkpost: Command-line date utilities]]></title>
            <link>https://comptona.medium.com/linkpost-command-line-date-utilities-1b71149b950b?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b71149b950b</guid>
            <category><![CDATA[linkpost]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 21:48:51 GMT</pubDate>
            <atom:updated>2021-01-15T21:48:51.095Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://www.fresse.org/dateutils/">dateutils</a></p><p>These look incredibly useful, but I am most excited that the project website includes <em>comprehensive examples</em> for each tool! I can’t count the number of times I found something that looked useful but which gave me basically no idea of how to use it or what it could really do (I’m looking at you, <a href="https://github.com/harelba/q">q</a>).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b71149b950b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linkpost: Command-Line Interface Guidelines]]></title>
            <link>https://comptona.medium.com/linkpost-command-line-interface-guidelines-920a0c4e2b4c?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/920a0c4e2b4c</guid>
            <category><![CDATA[linkpost]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 06:23:45 GMT</pubDate>
            <atom:updated>2021-01-06T06:23:45.628Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://clig.dev/">Command Line Interface Guidelines</a></p><p>I am excited to see this reference. I’ve long felt that the most important part of building a tool for people to use is thinking through how they’re going to use it, and even considering what you would want out of a tool if you were supposed to use it. I can’t count the number of times I’ve given the feedback of “how would you feel if you had to use this?”, followed by an acknowledgement that they’d built something less friendly than it might have been. If you’re going to build a tool to help someone with a task, you might as well go the extra mile and make it satisfying and intuitive to use too. I’m pretty open to variety in technical architecture and implementation details, but I’m a real stickler about not building tools that are hard, confusing, or unpleasant to use. A relatively small up-front investment in thinking about usability pays exponential dividends throughout the life of the tool in the amount of time and pain it saves its users relative to the least-effort implementation that lacks empathy for the poor souls who are going to be stuck using your tool.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=920a0c4e2b4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I reinstalled Windows 10 on a Surface Go]]></title>
            <link>https://comptona.medium.com/how-i-reinstalled-windows-10-on-a-surface-go-c1348f4bb183?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1348f4bb183</guid>
            <category><![CDATA[windows-10]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 22:42:12 GMT</pubDate>
            <atom:updated>2020-06-03T22:42:12.787Z</atom:updated>
            <content:encoded><![CDATA[<p>I purchased a Microsoft Surface Go recently. The other day, it blue-screened and refused to start up again (cycling through the “Automatic Repair” screen and failing repeatedly). I write this as a reference for myself for how to fix this if it happens again, and also to explain some of the dead ends I encountered along the way.</p><h3>First Obstacle</h3><p>I first tried using the built-in recovery environment to “reset” and “recover” the operating system. Neither worked and neither told me why not, so I decided to go with a clean reinstall. That led me to the first problem: how to make a Windows 10 USB boot disk. Microsoft has a built-in “<a href="https://support.microsoft.com/en-us/help/15088/windows-10-create-installation-media">Recovery Media Creator</a>”, but that only works if you have a working Windows machine and all I had to hand was a Mac. After lots and lots of false starts, I found <a href="https://www.freecodecamp.org/news/how-make-a-windows-10-usb-using-your-mac-build-a-bootable-iso-from-your-macs-terminal/">these instructions</a> that walked me through downloading a Windows 10 64-bit ISO, formatting the USB disk as GPT:FAT32, and copying the ISO files over (including the step where I had to split one of the files that was larger than 4 GB so it’d fit on a FAT32 filesystem). At the end of those instructions, I had a bootable USB disk that I could use to install Windows 10… or so I thought.</p><h3>Second Obstacle</h3><p>Booting the Surface Go from the USB boot disk was easy; the computer was configured to check USB first, so it flowed cleanly into the install. However, that failed too. The closest description of what I ran into was in <a href="https://social.technet.microsoft.com/Forums/windowsserver/en-US/3ce7e9fa-e308-42bd-97e7-daca836daf27/unattented-install-on-hp-gen9-fail-in-bfs?forum=winserver8setup">this TechNet post</a>. As far as I understand it, the installer was able to set up partitions appropriately on the internal drive, but when it moved on to the next step, it thought it was trying to install Windows <em>on the USB boot disk</em>, and (reasonably) refused to do so. This stymied me for a couple of days, but eventually I stumbled on <a href="https://neosmart.net/wiki/setup-was-unable-to-create-a-new-system-partition/#Fix_1_Eject_and_re-insert_the_USB">this article</a> which laid out a complex choreography of stepping through the install, letting it fail, removing the USB boot disk entirely, retracing part of the install and letting it fail again, reinserting the USB boot disk, and then restarting the install <em>again</em> in a context that would allow it to proceed. Fortunately, that all worked as described, and the install completed successfully.</p><h3>What Didn’t Work</h3><p>The narrative above makes it seem like this was a straightforward process, but it was nothing of the sort. Here are some of the things I tried that didn’t work.</p><ul><li><strong>Using a standard bootable-USB creation tool.</strong> I generally use <a href="https://www.balena.io/etcher/">balenaEtcher</a> for this task, but it failed here (likely because of the file that was larger than 4 GB).</li><li><strong>Creating a USB drive partitioned with MBR.</strong> One of the suggestions I ran into was using MBR instead of GPT to partition the USB boot disk, but the Surface Go refused entirely to boot from that because it’s a UEFI computer. (I learned <em>so many new things</em> these past few days.)</li><li><strong>Using Rufus to create a NTFS-formatted USB boot disk.</strong> I ran into several recommendations like <a href="https://www.windowscentral.com/how-create-windows-10-usb-bootable-media-uefi-support">this one</a> that suggested the tool <a href="https://rufus.ie/">Rufus</a> would allow me to format the USB boot disk with NTFS instead of FAT32, and that that might un-confuse the Windows installer. I made such a disk (after setting up a virtualized Windows machine with <a href="https://www.virtualbox.org/">VirtualBox</a>), but the Surface Go initially refused to boot from it until I <a href="https://github.com/pbatard/rufus/wiki/FAQ#Why_do_I_need_to_disable_Secure_Boot_to_use_UEFINTFS">disabled Secure Boot</a>, and even afterward the installer claimed it was unable to find a valid disk to install to at all.</li><li><strong>Using a DVD drive.</strong> The bug occurs when installing from a USB boot disk because it’s seen as a potential install destination. Theoretically, installing from a DVD would get around this problem. However, the Windows 10 setup ISO is ~5 GB in size, so it would only fit on a dual-layer DVD and I didn’t have any in the house; and I couldn’t think of an essential retailer that would sell me one and didn’t want to wait several days to buy one online.</li><li><strong>Copying the Windows installer to a partition on the drive.</strong> I found several instances of <a href="https://neosmart.net/wiki/setup-was-unable-to-create-a-new-system-partition/#Fix_2_Manually_create_the_boot_partition">guidance</a> to copy the USB boot disk’s contents to a bootable partition on the target hard drive, start the installation from there, partition around the installer, and then go back later and erase the installer partition. None of these worked because they were all written to use MBR partitions, which the Surface Go refused to boot from; and I was not able to figure out how to create a bootable GPT partition (bcdedit was giving me all sorts of static at this point).</li></ul><h3>Conclusion</h3><p>This was a hundred thousand times harder than it should have been, and anyone who isn’t both a) an experienced IT tech and b) unwilling to quit trying new things to fix it would have been profoundly fucked. Buying a Surface Go was a poor decision and if this happens again I’m going to drop-kick it and buy a Chromebook.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1348f4bb183" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating a daily journal with Joplin]]></title>
            <link>https://comptona.medium.com/automating-a-daily-journal-with-joplin-aa25cc503842?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa25cc503842</guid>
            <category><![CDATA[joplin]]></category>
            <category><![CDATA[knowledge-management]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Sat, 30 Nov 2019 08:02:15 GMT</pubDate>
            <atom:updated>2019-11-30T08:02:15.121Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qpcOrSwad1u-jE5Ls8Fsg.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@mentatdgt-330508?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">mentatdgt </a>from <a href="https://www.pexels.com/photo/library-photo-1319854/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p>I have a long-standing interest in <a href="https://en.wikipedia.org/wiki/Personal_knowledge_management">personal knowledge management</a> (PKM). I’ve tried lots and lots of different tools, and I recently learned about <a href="https://joplinapp.org/">Joplin</a> and decided to try it out.</p><h3>Requirements, or “Is that too much to ask?”</h3><p>There’s not a lot of specific things I want out of a PKM tool, but I’ve had a hard time getting them all together in a single product. My must-haves are:</p><ul><li>Absolutely minimal time-to-capture, so as not to interrupt flow</li><li>Some sort of hierarchical organization, so I have a place to stash notes that aren’t currently pertinent but are worth keeping around for future reference</li><li>Some sort of search functionality (I’m not above running grep -r on a directory of text files)</li><li>Some sort of backup or sync mechanism (similarly, */5 * * * * git commit -a &amp;&amp; git push would suffice)</li><li>Some mechanism for tracking a daily journal so I know what I accomplished over the last day/week/month; this was a habit I picked up from <a href="https://www.emacswiki.org/emacs/PlannerMode">PlannerMode</a>, which should give you an idea of how long I’ve been shaving this particular yak</li></ul><p>Joplin manages most of these:</p><ul><li>I used Automator to make a <a href="https://appleinsider.com/articles/18/03/14/how-to-create-keyboard-shortcuts-to-launch-apps-in-macos-using-automator">global keyboard shortcut</a> to get quick access to write a new note</li><li>Notebooks and sub-notebooks are arbitrarily nestable, QED</li><li>Search works fine, and the cmd-G “Goto anything” feature is handy (if incomplete since you cannot “go” to notebooks)</li><li>Dropbox sync, that works</li></ul><p>However, Joplin does not have a daily journal built-in. Since this was the only major shortcoming, I decided to hack something together.</p><h3>tl;dr show me the code</h3><p>Joplin does have <a href="https://github.com/laurent22/joplin/blob/master/readme/api.md">an API</a>, but reading through the docs for it was painful so I decided to just run the command-line version too and automate it. I created a script named journal.sh that I can run at any time to create a new template-based file with today’s date in the appropriate notebook, and then I can go fill it out with the day’s work.</p><pre>$ cat ~/bin/journal.sh<br>#!/bin/bash</pre><pre>TMPDIR=`mktemp -d`<br>TMPFILE=$TMPDIR/$(date +&quot;%Y-%m-%d&quot;)</pre><pre>cat &gt;$TMPFILE &lt;&lt;EOF<br>## To do today:</pre><pre>## Completed today:</pre><pre>## Notes:</pre><pre>EOF</pre><pre>joplin import --format md $TMPFILE &quot;1. Daily Journal&quot;<br>joplin sync<br>rm -rf $TMPDIR</pre><p>This gets the job done, and if I were feeling really ambitious I could set up a cron job to run this once a day. Note that the command-line and GUI versions are completely separate and need to be logged into separately, which is why the script calls joplin sync (as the new note would not be promptly visible in the GUI otherwise).</p><p>I’ve been enjoying working with Joplin so far, and although history indicates that I’ll probably eventually chafe at its limitations and try to find something else, hope springs eternal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa25cc503842" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an EPUB from a Wordpress blog]]></title>
            <link>https://comptona.medium.com/creating-an-epub-from-a-wordpress-blog-4975de8c60d3?source=rss-1108f0d8f787------2</link>
            <guid isPermaLink="false">https://medium.com/p/4975de8c60d3</guid>
            <category><![CDATA[epub]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Adam Compton]]></dc:creator>
            <pubDate>Sun, 26 Nov 2017 23:15:22 GMT</pubDate>
            <atom:updated>2017-11-26T23:25:08.943Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Recently, I wanted to create epubs of some reading material, specifically some Wordpress-hosted blogs. Rather than implementing a separate script for each blog I wanted an epub from, I wrote a tool to figure it all out for me: <a href="https://github.com/handyman5/trivialpub">trivialpub</a>.</p><p>Usage is simple: provide a YAML config file, such as:</p><pre>toc_url: https://practicalguidetoevil.wordpress.com/table-of-contents/<br>toc_parser: |<br>  [x.get(&#39;href&#39;) for x in soup.select(&#39;div.entry-content a&#39;) if &#39;class&#39; not in x.attrs]</pre><p>And trivialpub will do the rest:</p><pre>$ ./trivialpub.py -c practicalguide.yaml <br>Processing chapter https://practicalguidetoevil.wordpress.com/2015/03/25/prologue/<br>Processing chapter https://practicalguidetoevil.wordpress.com/2015/04/01/chapter-1-knife/<br>Processing chapter https://practicalguidetoevil.wordpress.com/2015/04/08/chapter-2-invitation/<br>Processing chapter https://practicalguidetoevil.wordpress.com/2015/04/16/chapter-3-squire/<br>[...]<br>$ ls -l build/<br>total 9216<br>-rw-r--r--  1 acompton  admin  2004507 Nov 26 15:05 practicalguide.epub</pre><p>I’ve included a number of examples in the repo, but basically, you either need to feed it a list of URLs to transform or a Python expression which, when eval’ed in context, will generate a list of URLs. (Yes, yes, eval() is the devil, I know.)</p><p>PRs and suggestions welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4975de8c60d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>