<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="https://www.texastim.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://www.texastim.dev/" rel="alternate" type="text/html" /><updated>2025-03-11T02:20:58+00:00</updated><id>https://www.texastim.dev/feed.xml</id><title type="html">texastim.dev</title><subtitle>Hi, I&apos;m Tim. I help organizations search their documents smarter and faster.</subtitle><entry><title type="html">TeX Live 2025 released — ISO available for download via torrent</title><link href="https://www.texastim.dev/tex-live-2025-iso-available-via-torrent/" rel="alternate" type="text/html" title="TeX Live 2025 released — ISO available for download via torrent" /><published>2025-03-08T00:00:00+00:00</published><updated>2025-03-08T00:00:00+00:00</updated><id>https://www.texastim.dev/tex-live-2025-iso-available-via-torrent</id><content type="html" xml:base="https://www.texastim.dev/tex-live-2025-iso-available-via-torrent/"><![CDATA[<p>The TeX Live 2025 ISO is finally here! It’s available to you now in four ways:</p>

<ul>
  <li><a href="https://www.tug.org/texlive/acquire-iso.html">directly download the ISO from a participating CTAN mirror</a></li>
  <li><a href="https://www.tug.org/texlive/acquire-iso.html">download the .torrent file from tug.org’s “Acquiring TeX Live as an ISO image” web page</a></li>
  <li><a href="https://timstewart.io/TL2025/TeX%20Live%202025%20texlive2025-20250308.torrent">download the .torrent file of the ISO from the initial seeder (that’s me)</a> (hashes of the .torrent file: <a href="https://timstewart.io/TL2025/TeX%20Live%202025%20texlive2025-20250308.torrent.md5">md5</a>, <a href="https://timstewart.io/TL2025/TeX%20Live%202025%20texlive2025-20250308.torrent.sha512">sha512</a>, <a href="https://timstewart.io/TL2025/TeX%20Live%202025%20texlive2025-20250308.torrent.xxh64">xxh64</a>)</li>
  <li><a href="magnet:?xt=urn:btih:7541ed166679e3e1cb3f9a41893f5dea98f973f8&amp;dn=TeX%20Live%202025%20texlive2025-20250308.iso&amp;tr=http%3A%2F%2Fmontreal.nyap2p.com%3A8080%2Fannounce&amp;tr=https%3A%2F%2Ftracker2.ctix.cn%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftrackers.mlsub.net%3A443%2Fannounce&amp;tr=https%3A%2F%2Fwww.peckservers.com%3A9443%2Fannounce&amp;tr=https%3A%2F%2Fyolo.liberbear.com%3A443%2Fannounce&amp;tr=http%3A%2F%2Ftracker.gbitt.info%3A80%2Fannounce&amp;tr=http%3A%2F%2F1337.abcvg.info%3A80%2Fannounce&amp;tr=http%3A%2F%2Fbittorrent-tracker.e-n-c-r-y-p-t.net%3A1337%2Fannounce&amp;tr=http%3A%2F%2Fbt.endpot.com%3A80%2Fannounce&amp;tr=http%3A%2F%2Fbt.okmp3.ru%3A2710%2Fannounce&amp;tr=http%3A%2F%2Fbvarf.tracker.sh%3A2086%2Fannounce&amp;tr=http%3A%2F%2Ftracker1.bt.moack.co.kr%3A80%2Fannounce&amp;tr=http%3A%2F%2Fopen.acgnxtracker.com%3A80%2Fannounce&amp;tr=http%3A%2F%2Fopen.acgtracker.com%3A1096%2Fannounce&amp;tr=http%3A%2F%2Fpow7.com%3A80%2Fannounce&amp;tr=http%3A%2F%2Ft.acg.rip%3A6699%2Fannounce&amp;tr=http%3A%2F%2Ft1.pow7.com%2Fannounce&amp;tr=http%3A%2F%2Ft2.pow7.com%2Fannounce&amp;tr=http%3A%2F%2Ftracker.edkj.club%3A6969%2Fannounce&amp;tr=http%3A%2F%2Ftracker.files.fm%3A6969%2Fannounce&amp;tr=http%3A%2F%2Ftracker.bt4g.com%3A2095%2Fannounce&amp;tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&amp;tr=https%3A%2F%2Ftracker.yemekyedim.com%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.imgoingto.icu%3A443%2Fannounce&amp;tr=http%3A%2F%2Ftracker1.itzmx.com%3A8080%2Fannounce&amp;tr=http%3A%2F%2Ftracker2.dler.org%3A80%2Fannounce&amp;tr=http%3A%2F%2Ftracker3.ctix.cn%3A8080%2Fannounce&amp;tr=http%3A%2F%2Fwepzone.net%3A6969%2Fannounce&amp;tr=http%3A%2F%2Fwww.peckservers.com%3A9000%2Fannounce&amp;tr=https%3A%2F%2F1337.abcvg.info%3A443%2Fannounce&amp;tr=https%3A%2F%2Ft1.hloli.org%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftr.burnabyhighstar.com%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftr.ready4.icu%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.gbitt.info%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker1.520.jp%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.tamersunion.org%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.renfei.net%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.netmap.top%3A8443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.moeblog.cn%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.loligirl.cn%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.lilithraws.org%3A443%2Fannounce&amp;tr=http%3A%2F%2Ftracker.mywaifu.best%3A6969%2Fannounce&amp;tr=https%3A%2F%2Ftracker.gcrreen.xyz%3A443%2Fannounce&amp;tr=https%3A%2F%2Ftracker.cloudit.top%3A443%2Fannounce&amp;tr=http%3A%2F%2Fch3oh.ru%3A6969%2Fannounce&amp;tr=http%3A%2F%2Ft.overflow.biz%3A6969%2Fannounce&amp;tr=http%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce&amp;tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&amp;tr=http%3A%2F%2Ftracker.qu.ax%3A6969%2Fannounce&amp;tr=http%3A%2F%2Ftracker.renfei.net%3A8080%2Fannounce&amp;tr=http%3A%2F%2Fvps-dd0a0715.vps.ovh.net%3A6969%2Fannounce&amp;tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&amp;tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969&amp;tr=http%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&amp;ws=https://timstewart.io/TeX%20Live%202025%20texlive2025-20250308.iso">download the torrent of the ISO via magnet link</a></li>
</ul>

<p>Regarding direct downloads: it takes time for the ISO to propagate through the CTAN mirroring network, so as of today (2025-03-08) some mirrors have it and some don’t. Note that you can select mirrors manually to find a mirror that has it.</p>

<p>This is my 7th year in a row creating and initially seeding the torrent for the TeX Live ISO, and as always it is a joy and an honor to help out in this small, specific way. For almost two decades, TeX and LaTeX have brought me countless hours of productivity and delight while “typesetting beautiful documents” (as DEK likes to say).</p>]]></content><author><name></name></author><category term="tex-live" /><summary type="html"><![CDATA[The TeX Live 2025 ISO is finally here! It’s available to you now in four ways:]]></summary></entry><entry><title type="html">copy path to Windows file or directory with automagic conversion to Linux mountpoint</title><link href="https://www.texastim.dev/windows-right-click-copy-path-to-clipboard-as-linux-mountpoint/" rel="alternate" type="text/html" title="copy path to Windows file or directory with automagic conversion to Linux mountpoint" /><published>2024-08-23T08:00:00+00:00</published><updated>2024-08-23T08:00:00+00:00</updated><id>https://www.texastim.dev/windows-right-click-copy-path-to-clipboard-as-linux-mountpoint</id><content type="html" xml:base="https://www.texastim.dev/windows-right-click-copy-path-to-clipboard-as-linux-mountpoint/"><![CDATA[<p>On a day-to-day basis, I’m working in Windows and Linux on various physical and virtual machines on my network,
but no matter where I am, I’m usually in VS Code.
I love Code’s extensions and integrated terminal, and it’s plenty enough IDE for me to get real work done in Python no matter which ecosystem I happen to be in.
My favorite little timesaver in VS Code these days is right-clicking in the Explorer pane to “Copy path” for a file or directory.
This small feature sparks a lot of joy for me!</p>

<p>Of course Windows Explorer has a similar feature: if you hold down Shift while you right-click, you can “Copy as path” to get the absolute path.</p>

<p>But for a while I had a very specific pain point when copying paths in Windows.
At least a few times a week I’m in the situation where I’m using both Windows and Linux machines to work on the same set of files on one of my NASes.
On Windows, my NASes are the Y: and Z: drives.
On all my Linux containers and VMs, they’re /mnt/shalom-share-1 and /mnt/synology, respectively.
It was a growing annoyance to copy a path on Windows and have to manually alter it so I could have the corresponding /mnt path to use in my bash script or .conf file or whatnot on Linux.</p>

<p>At last, enough was enough, and last week I wrote a couple of registry entries to supplement Windows Explorer’s “Copy as path” feature.
I named them, imaginatively enough, “Copy as path (/mnt).”
They let me right-click on a file or directory on a network drive from Windows, but what gets saved to the clipboard is the /mnt version of the path.
A little inline PowerShell changes the drive letter to the mountpoint and reverses the slashes.</p>

<p>See below for the .reg file, and it’s very straightforward if anyone wanted to modify it for their own network purposes.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\CopyLinuxPathToFile]
@="Copy as path (/mnt)"
"Icon"="imageres.dll,-5302"

[HKEY_CLASSES_ROOT\*\shell\CopyLinuxPathToFile\command]
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"$driveMap = @{ 'Y:'='/mnt/shalom-share-1'; 'Z:'='/mnt/synology' }; $path = '%1'; $drive = $path.Substring(0, 2); if ($driveMap.ContainsKey($drive)) { $path = $path.Replace($drive + '\\', $driveMap[$drive] + '/').Replace('\\', '/'); $path | Set-Clipboard; } else { \\\"no /mnt path available\\\" | Set-Clipboard; } \""

[HKEY_CLASSES_ROOT\Directory\shell\CopyLinuxPathToDir]
@="Copy as path (/mnt)"
"Icon"="imageres.dll,-5302"

[HKEY_CLASSES_ROOT\Directory\shell\CopyLinuxPathToDir\command]
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"$driveMap = @{ 'Y:'='/mnt/shalom-share-1'; 'Z:'='/mnt/synology' }; $path = '%1'; $drive = $path.Substring(0, 2); if ($driveMap.ContainsKey($drive)) { $path = $path.Replace($drive + '\\', $driveMap[$drive] + '/').Replace('\\', '/'); $path | Set-Clipboard; } else { \\\"no /mnt path available\\\" | Set-Clipboard; } \""
</code></pre></div></div>

<p>There were a couple of design decisions along the way.
Should spaces on the Windows side be escaped during the conversion to the /mnt path? (I decided I wanted the cleaner-looking string. I can always enclose it in quotes on the Linux side.)
Should I signal to the user when a /mnt path isn’t available? (I decided to put the error in the clipboard when a Windows path has no /mnt equivalent.)</p>

<p>The two trickiest bits were nesting and escaping the quotation marks correctly and picking out the icon.</p>

<p>The inline PowerShell reminded me of the time I put a <a href="https://www.texastim.dev/pre-commit-hook-for-categories-in-jekyll-blog-posts/">Python script into a heredoc</a> so I could execute it from bash.</p>

<p>Ideas for possible future improvements:</p>
<ul>
  <li>Rather than creating/customizing the .reg file itself, another idea would be to write a PowerShell script that accepted drive letter and mountpoint pairs and programmatically created the requisite .reg file. That, or the drive letter/mountpoint pairs could be pulled from a config file.</li>
  <li>Riding on the preceding idea of having a PowerShell script create the .reg file, the .ps1 management script could add new pairs (or remove existing ones) of drive letters/mountpoints by first reading in the existing pairs from the registry file. (This might be verging on overkill though.)</li>
</ul>]]></content><author><name></name></author><category term="linux" /><category term="powershell" /><category term="scripting" /><category term="windows" /><summary type="html"><![CDATA[On a day-to-day basis, I’m working in Windows and Linux on various physical and virtual machines on my network, but no matter where I am, I’m usually in VS Code. I love Code’s extensions and integrated terminal, and it’s plenty enough IDE for me to get real work done in Python no matter which ecosystem I happen to be in. My favorite little timesaver in VS Code these days is right-clicking in the Explorer pane to “Copy path” for a file or directory. This small feature sparks a lot of joy for me!]]></summary></entry><entry><title type="html">set up sendmail MTA on Debian using external SMTP server (Fastmail)</title><link href="https://www.texastim.dev/set-up-sendmail-mta-using-fastmail-smtp-server/" rel="alternate" type="text/html" title="set up sendmail MTA on Debian using external SMTP server (Fastmail)" /><published>2024-07-11T08:00:00+00:00</published><updated>2024-07-11T08:00:00+00:00</updated><id>https://www.texastim.dev/set-up-sendmail-mta-using-fastmail-smtp-server</id><content type="html" xml:base="https://www.texastim.dev/set-up-sendmail-mta-using-fastmail-smtp-server/"><![CDATA[<p>When I stand up containers and virtual machines on my home network,
I typically set them up with postfix using Gmail’s SMTP servers and my Gmail account
so they can send emails like notifications and alerts.
But as part of an ongoing effort to diversify my tech stack,
I decided to make two leaps at once for new containers and VMs going forward:
using sendmail as the MTA instead of postfix, and using Fastmail’s SMTP server.</p>

<p>With <a href="https://www.fastmail.help/hc/en-us/articles/1500000278342-Server-names-and-ports">Fastmail’s connection details</a> in hand,
it was pretty straightforward to complete setup using <code class="language-plaintext highlighter-rouge">sendmailconfig</code>.
Now that the easy way was figured out,
I set my sights on writing my own bash script to do the job.</p>

<p>The complete script is <a href="https://github.com/timoteostewart/convenience-scripts-to-share/blob/main/setup-mta-sendmail.sh">on GitHub</a>. Below I’ll put some discussion and explanation of some of my choices in the script.</p>

<p>For scripts that require root, I’ve experimented over the years with a few different ways of detecting whether the script is being run by root/sudo. Here’s the current incarnation of my check for this:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># check for root/sudo</span>
<span class="nv">EUID_copy</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">EUID</span><span class="k">:-</span><span class="si">$(</span><span class="nb">id</span> <span class="nt">-u</span><span class="si">)</span><span class="k">}</span><span class="s2">"</span>
<span class="k">if</span> <span class="o">[[</span> <span class="nt">-z</span> <span class="s2">"</span><span class="k">${</span><span class="nv">EUID_copy</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
    </span><span class="nb">printf</span> <span class="s2">"This script must be run as root, and the current user's EUID could not be determined.</span><span class="se">\n</span><span class="s2">"</span> <span class="o">&gt;</span>&amp;2 <span class="o">&amp;&amp;</span> <span class="nb">exit </span>1
<span class="k">elif</span> <span class="o">((</span>EUID_copy <span class="o">!=</span> 0<span class="o">))</span><span class="p">;</span> <span class="k">then
    </span><span class="nb">printf</span> <span class="s2">"This script must be run as root.</span><span class="se">\n</span><span class="s2">"</span> <span class="o">&gt;</span>&amp;2 <span class="o">&amp;&amp;</span> <span class="nb">exit </span>1
<span class="k">fi</span>
</code></pre></div></div>

<p>Often I’ll get any necessary arguments from the user using <code class="language-plaintext highlighter-rouge">getopts</code> and an elaborate case block.
This time I used environment variable passing.
So a typical invocation of this script (with made-up details) looks like this:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">FASTMAIL_EMAIL_ADDRESS</span><span class="o">=</span><span class="s2">"xxxxxxxx@fastmail.com"</span> <span class="nv">FASTMAIL_APP_SPECIFIC_PASSWORD</span><span class="o">=</span><span class="s2">"xxxxxxxxxxxxxxxx"</span> ./setup-mta-sendmail.sh
</code></pre></div></div>

<p>Getting arguments this way substantially simplified the process of checking for required arguments and setting up any needed defaults, as shown:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># check for required arguments</span>
<span class="o">[[</span> <span class="nt">-z</span> <span class="s2">"</span><span class="k">${</span><span class="nv">FASTMAIL_EMAIL_ADDRESS</span><span class="k">}</span><span class="s2">"</span> <span class="o">&amp;&amp;</span> <span class="nt">-z</span> <span class="s2">"</span><span class="k">${</span><span class="nv">FASTMAIL_APP_SPECIFIC_PASSWORD</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nb">printf</span> <span class="s2">"env vars FASTMAIL_EMAIL_ADDRESS and FASTMAIL_APP_SPECIFIC_PASSWORD must be set.</span><span class="se">\n</span><span class="s2">"</span> <span class="o">&gt;</span>&amp;2 <span class="o">&amp;&amp;</span> <span class="nb">exit </span>1
<span class="o">[[</span> <span class="nt">-z</span> <span class="s2">"</span><span class="k">${</span><span class="nv">FASTMAIL_EMAIL_ADDRESS</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nb">printf</span> <span class="s2">"env var FASTMAIL_EMAIL_ADDRESS must be set.</span><span class="se">\n</span><span class="s2">"</span> <span class="o">&gt;</span>&amp;2 <span class="o">&amp;&amp;</span> <span class="nb">exit </span>1
<span class="o">[[</span> <span class="nt">-z</span> <span class="s2">"</span><span class="k">${</span><span class="nv">FASTMAIL_APP_SPECIFIC_PASSWORD</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nb">printf</span> <span class="s2">"env var FASTMAIL_APP_SPECIFIC_PASSWORD must be set.</span><span class="se">\n</span><span class="s2">"</span> <span class="o">&gt;</span>&amp;2 <span class="o">&amp;&amp;</span> <span class="nb">exit </span>1

<span class="c"># set server and port defaults</span>
<span class="o">[[</span> <span class="nt">-z</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SMTP_SERVER</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nv">SMTP_SERVER</span><span class="o">=</span><span class="s2">"smtp.fastmail.com"</span>
<span class="o">[[</span> <span class="nt">-z</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SMTP_PORT</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span> <span class="o">&amp;&amp;</span> <span class="nv">SMTP_PORT</span><span class="o">=</span><span class="s2">"587"</span>
</code></pre></div></div>

<p>You never know who might run a script you send out into the world, so I try to write my scripts to work as courteously as possible from the get-go. For example, making backups of files (if they exist) instead of blindly overwriting them:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># backup existing SSL/TLS files, if present</span>
<span class="k">if</span> <span class="o">[[</span> <span class="nt">-f</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_KEY_FILE</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
    </span><span class="nb">cp</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_KEY_FILE</span><span class="k">}</span><span class="s2">"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_KEY_FILE</span><span class="k">}</span><span class="s2">"</span>.bak
<span class="k">fi
if</span> <span class="o">[[</span> <span class="nt">-f</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_CERT_FILE</span><span class="k">}</span><span class="s2">"</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then
    </span><span class="nb">cp</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_CERT_FILE</span><span class="k">}</span><span class="s2">"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_CERT_FILE</span><span class="k">}</span><span class="s2">"</span>.bak
<span class="k">fi</span>
</code></pre></div></div>

<p>The sendmail config file, usually /etc/mail/sendmail.mc, presented a small problem. I needed to add some lines to it, but I couldn’t just append them to the file because some of the directives I needed to add were supposed to be located <em>before</em> other directives already present in the file. To put it another way, there were lines already in the config files that needed to come <em>after</em> lines I was going to add. There were only two directives that needed to be relocated, so in this situation I made the choice to temporarily remove the 2 directives from the config file, append my new lines, and then re-add the original 2 directives so they came after my new lines.</p>

<p>I used a bash array and a loop to process the necessary deletions:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># update sendmail.mc, so first make a backup</span>
<span class="nb">cp</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_CONFIG_FILE_MC</span><span class="k">}</span><span class="s2">"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_CONFIG_FILE_MC</span><span class="k">}</span><span class="s2">.bak"</span>
<span class="c"># delete some lines and re-add them after we append our new lines</span>
<span class="nv">sendmail_mc_lines_to_delete</span><span class="o">=(</span>
    <span class="s2">"MAILER_DEFINITIONS"</span>
    <span class="s2">"MAILER(</span><span class="se">\`</span><span class="s2">local')dnl"</span>
    <span class="s2">"MAILER(</span><span class="se">\`</span><span class="s2">smtp')dnl"</span>
<span class="o">)</span>

<span class="k">for </span>pattern <span class="k">in</span> <span class="s2">"</span><span class="k">${</span><span class="nv">sendmail_mc_lines_to_delete</span><span class="p">[@]</span><span class="k">}</span><span class="s2">"</span><span class="p">;</span> <span class="k">do
    </span><span class="nb">sed</span> <span class="nt">-i</span> <span class="s2">"/</span><span class="k">${</span><span class="nv">pattern</span><span class="k">}</span><span class="s2">/d"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">SENDMAIL_CONFIG_FILE_MC</span><span class="k">}</span><span class="s2">"</span>
<span class="k">done</span>
</code></pre></div></div>

<p>And when I appended my new lines, I re-added the directives I had just recently deleted.</p>

<p>Suggestions or corrections for this script are welcome; just submit an issue or PR on GitHub.</p>]]></content><author><name></name></author><category term="bash" /><category term="debian" /><category term="email" /><summary type="html"><![CDATA[When I stand up containers and virtual machines on my home network, I typically set them up with postfix using Gmail’s SMTP servers and my Gmail account so they can send emails like notifications and alerts. But as part of an ongoing effort to diversify my tech stack, I decided to make two leaps at once for new containers and VMs going forward: using sendmail as the MTA instead of postfix, and using Fastmail’s SMTP server.]]></summary></entry><entry><title type="html">handy pre-commit hook for checking categories in Jekyll blog posts</title><link href="https://www.texastim.dev/pre-commit-hook-for-categories-in-jekyll-blog-posts/" rel="alternate" type="text/html" title="handy pre-commit hook for checking categories in Jekyll blog posts" /><published>2024-03-18T08:00:00+00:00</published><updated>2024-03-18T08:00:00+00:00</updated><id>https://www.texastim.dev/pre-commit-hook-for-categories-in-jekyll-blog-posts</id><content type="html" xml:base="https://www.texastim.dev/pre-commit-hook-for-categories-in-jekyll-blog-posts/"><![CDATA[<p>I’m a fan of alphabetically ordered lists in code and many other places too.
It provides an obvious structure for lists of packages, variables, strings, and many other things.
It makes checking by eye for the presence or absence of a member or element very quick.
As a code base undergoes changes over time, the use of alphabetical order can result in diffs that are smaller and easier to grok.
Plus I think alphabetical order appeals on an aesthetic level too, aside from the many practical considerations.</p>

<p>So I wrote a pre-commit hook for my Jekyll blog that verifies whether the category keywords in my blog posts are in alphabetical order.
A full code listing follows. (My favorite bit is the embedded Python script—this is a new trick I’m trying out!)</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/env bash</span>

<span class="c"># debugging switches</span>
<span class="c"># set -o errexit   # abort on nonzero exit status; same as set -e</span>
<span class="c"># set -o nounset   # abort on unbound variable; same as set -u</span>
<span class="c"># set -o pipefail  # don't hide errors within pipes</span>
<span class="c"># set -o xtrace    # show commands being executed; same as set -x</span>
<span class="c"># set -o verbose   # verbose mode; same as set -v</span>

<span class="c"># A pre-commit git hook script to verify that</span>
<span class="c"># category keywords are listed in case-insensitive alphabetical order</span>
<span class="c"># in Jekyll blog posts.</span>


<span class="nb">exec </span>1&gt;&amp;2

<span class="c"># use a temp file and clean up on exit</span>
<span class="nv">temp_file</span><span class="o">=</span><span class="si">$(</span><span class="nb">mktemp</span><span class="si">)</span>
<span class="k">function </span>finish <span class="o">{</span>
    <span class="nb">rm</span> <span class="nt">-rf</span> <span class="s2">"</span><span class="k">${</span><span class="nv">temp_file</span><span class="k">}</span><span class="s2">"</span>
<span class="o">}</span>
<span class="nb">trap </span>finish EXIT

<span class="c"># get list of staged files</span>
git diff <span class="nt">--cached</span> <span class="nt">--name-only</span> <span class="nt">--diff-filter</span><span class="o">=</span>ACM <span class="o">&gt;</span> <span class="s2">"</span><span class="k">${</span><span class="nv">temp_file</span><span class="k">}</span><span class="s2">"</span>

<span class="c"># embedded python script via heredoc</span>
<span class="nb">read</span> <span class="nt">-r</span> <span class="nt">-d</span> <span class="s1">''</span> verify_categories_are_alphabetical_py <span class="o">&lt;&lt;</span><span class="sh">'</span><span class="no">EOF</span><span class="sh">'
import re
import sys

filename = sys.argv[1]

with open(filename, mode="r", encoding="utf-8") as file:
    for line in file:
        match = re.match(r"^categories:</span><span class="se">\ </span><span class="sh">*", line)
        if match:
            line = line[len(match.group()) :]
            words = line.strip().split()
            sorted_words = sorted(words, key=str.lower)
            if words != sorted_words:
                print(f"Error: categories in {filename} aren't in alphabetical order")
                print(f"Categories found: {' '.join(words)}")
                print(f"Expected order: {' '.join(sorted_words)}")
                sys.exit(1)
sys.exit(0)
</span><span class="no">
EOF

</span><span class="c"># python script is used to check just the ".markdown" files</span>
<span class="k">while </span><span class="nb">read</span> <span class="nt">-r</span> file<span class="p">;</span> <span class="k">do
    if</span> <span class="o">[[</span> <span class="s2">"</span><span class="k">${</span><span class="nv">file</span><span class="k">}</span><span class="s2">"</span> <span class="o">=</span>~ <span class="se">\.</span>markdown<span class="nv">$ </span><span class="o">]]</span><span class="p">;</span> <span class="k">then
        if</span> <span class="o">!</span> python3 <span class="nt">-c</span> <span class="s2">"</span><span class="k">${</span><span class="nv">verify_categories_are_alphabetical_py</span><span class="k">}</span><span class="s2">"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">file</span><span class="k">}</span><span class="s2">"</span><span class="p">;</span> <span class="k">then
            </span><span class="nb">printf</span> <span class="s2">"Commit failed on %s because its categories aren't in alphabetical order.</span><span class="se">\n</span><span class="s2">"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">file</span><span class="k">}</span><span class="s2">"</span>
            <span class="nb">exit </span>1
        <span class="k">fi
    fi
done</span> &lt; <span class="s2">"</span><span class="k">${</span><span class="nv">temp_file</span><span class="k">}</span><span class="s2">"</span>

<span class="nb">exit </span>0
</code></pre></div></div>]]></content><author><name></name></author><category term="automation" /><category term="bash" /><category term="jekyll" /><category term="python" /><summary type="html"><![CDATA[I’m a fan of alphabetically ordered lists in code and many other places too. It provides an obvious structure for lists of packages, variables, strings, and many other things. It makes checking by eye for the presence or absence of a member or element very quick. As a code base undergoes changes over time, the use of alphabetical order can result in diffs that are smaller and easier to grok. Plus I think alphabetical order appeals on an aesthetic level too, aside from the many practical considerations.]]></summary></entry><entry><title type="html">easily turn a Bash script into a systemd service</title><link href="https://www.texastim.dev/turn-bash-script-into-systemd-service/" rel="alternate" type="text/html" title="easily turn a Bash script into a systemd service" /><published>2024-03-17T08:00:00+00:00</published><updated>2024-03-17T08:00:00+00:00</updated><id>https://www.texastim.dev/turn-bash-script-into-systemd-service</id><content type="html" xml:base="https://www.texastim.dev/turn-bash-script-into-systemd-service/"><![CDATA[<p>Turns out it’s pretty easy to turn a Bash script into a system service that starts on boot and restarts automatically if it goes down. Here’s how.</p>

<p>You will need:</p>
<ul>
  <li>a Linux system that uses <code class="language-plaintext highlighter-rouge">systemd</code></li>
  <li><code class="language-plaintext highlighter-rouge">sudo</code> privileges</li>
  <li>a script you want to run as a service</li>
</ul>

<p>Steps:</p>

<ol>
  <li>
    <p>Ensure the script is executable.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">chmod</span> +x /home/hunter2/my-foo-project/qux-thing.sh
</code></pre></div>    </div>
  </li>
  <li>
    <p>Create a service file that contains information the host system will need in order to run the script. (If the service I’m setting up is part of a project, I like to store the service file with the rest of the project files.) Shortly we’ll use <code class="language-plaintext highlighter-rouge">sudo ln -s</code> to put a symbolic link to the service file in a place where <code class="language-plaintext highlighter-rouge">systemd</code> will find it.</p>

    <p>Here’s the contents of a suitable file named <code class="language-plaintext highlighter-rouge">/home/hunter2/my-foo-project/qux-thing.service</code>:</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>Unit]
<span class="nv">Description</span><span class="o">=</span>My qux service <span class="o">(</span>part of foo project<span class="o">)</span>

<span class="o">[</span>Service]
<span class="nv">ExecStart</span><span class="o">=</span>/home/hunter2/my-foo-project/qux-thing.sh
<span class="nv">Restart</span><span class="o">=</span>always
<span class="nv">RestartSec</span><span class="o">=</span>5s

<span class="o">[</span>Install]
<span class="nv">WantedBy</span><span class="o">=</span>multi-user.target

</code></pre></div>    </div>
  </li>
  <li>
    <p>Now create a symbolic link to the service file so systemd will find it. Using a symbolic link has the additional benefit that you can modify the service file in the project folder and on the next daemon reload or system reboot, <code class="language-plaintext highlighter-rouge">systemd</code> will pick up the changes.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo ln</span> <span class="nt">-s</span> /home/hunter2/foo-project/qux-thing.service /etc/systemd/system/qux-thing.service
</code></pre></div>    </div>
  </li>
  <li>
    <p>Reload the systemd daemons (which now includes the new service) and put a few finishing touches on the new service’s configuration.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>systemctl <span class="nb">enable </span>qux-thing.service
<span class="nb">sudo </span>systemctl start qux-thing.service
<span class="nb">sudo </span>systemctl daemon-reload
</code></pre></div>    </div>
  </li>
  <li>
    <p>At last, confirm that it’s up and running!</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>systemctl status qux-thing.service
</code></pre></div>    </div>
  </li>
</ol>]]></content><author><name></name></author><category term="automation" /><category term="bash" /><summary type="html"><![CDATA[Turns out it’s pretty easy to turn a Bash script into a system service that starts on boot and restarts automatically if it goes down. Here’s how.]]></summary></entry><entry><title type="html">URL shortener using FastAPI</title><link href="https://www.texastim.dev/portfolio-url-shortener/" rel="alternate" type="text/html" title="URL shortener using FastAPI" /><published>2023-02-28T13:15:00+00:00</published><updated>2023-02-28T13:15:00+00:00</updated><id>https://www.texastim.dev/portfolio-url-shortener</id><content type="html" xml:base="https://www.texastim.dev/portfolio-url-shortener/"><![CDATA[<p>My <a href="https://www.timstewart.io/fastapi-demo-url-shortener/">demo URL shortener</a> (<a href="https://github.com/timoteostewart/fastapi-demo-url-shortener">GH repo here</a>) is a REST API accepts a regular URL via POST and returns a short code that can be used to get a redirect to the original URL. Users of the API receive a short code and a secret administrative key that they can use to check usage statistics for that short code and optionally delete the short code so it won’t work anymore.</p>

<p>Example of providing a full URL to get a short code:</p>

<figure class="highlight"><pre><code class="language-bash" data-lang="bash">curl <span class="nt">-X</span> <span class="s1">'POST'</span> <span class="se">\</span>
<span class="s1">'https://www.timstewart.io/fastapi-demo-url-shortener/?full_url=https://www.thnr.net'</span> <span class="se">\</span>
<span class="nt">-H</span> <span class="s1">'accept: application/json'</span></code></pre></figure>

<p>API response:</p>

<figure class="highlight"><pre><code class="language-json" data-lang="json"><span class="p">{</span><span class="w">
    </span><span class="nl">"full_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://www.thnr.net"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"short_code"</span><span class="p">:</span><span class="w"> </span><span class="s2">"FX931"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"admin_key"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1TYRV42Otbua6R9L"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"when_created_unix"</span><span class="p">:</span><span class="w"> </span><span class="mi">1695159402</span><span class="p">,</span><span class="w">
    </span><span class="nl">"access_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="w">
</span><span class="p">}</span></code></pre></figure>

<p>After visiting <a href="https://www.timstewart.io/fastapi-demo-url-shortener/FX931">https://www.timstewart.io/fastapi-demo-url-shortener/FX931</a> several times in my browser, I can check the stats for this short URL using the secret administrative key I was issued when creating it:</p>

<figure class="highlight"><pre><code class="language-bash" data-lang="bash">curl <span class="nt">-X</span> <span class="s1">'GET'</span> <span class="se">\</span>
<span class="s1">'https://www.timstewart.io/fastapi-demo-url-shortener/FX931/1TYRV42Otbua6R9L'</span> <span class="se">\</span>
<span class="nt">-H</span> <span class="s1">'accept: application/json'</span></code></pre></figure>

<p>API response:</p>

<figure class="highlight"><pre><code class="language-json" data-lang="json"><span class="p">{</span><span class="w">
    </span><span class="nl">"full_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://www.thnr.net"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"short_code"</span><span class="p">:</span><span class="w"> </span><span class="s2">"FX931"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"admin_key"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1TYRV42Otbua6R9L"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"when_created_unix"</span><span class="p">:</span><span class="w"> </span><span class="mi">1695159402</span><span class="p">,</span><span class="w">
    </span><span class="nl">"access_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">9</span><span class="w">
</span><span class="p">}</span></code></pre></figure>

<h1 id="tech-stack">Tech Stack</h1>
<ul>
  <li>Python + FastAPI</li>
  <li>SQLite3 for persistent storage of short codes, URLs, and usage stats</li>
  <li>Nginx + gunicorn for web service</li>
</ul>]]></content><author><name></name></author><category term="fastapi" /><category term="portfolio" /><summary type="html"><![CDATA[My demo URL shortener (GH repo here) is a REST API accepts a regular URL via POST and returns a short code that can be used to get a redirect to the original URL. Users of the API receive a short code and a secret administrative key that they can use to check usage statistics for that short code and optionally delete the short code so it won’t work anymore.]]></summary></entry><entry><title type="html">Hayfevrly — scrape daily pollen readings for Austin, Texas</title><link href="https://www.texastim.dev/portfolio-hayfevrly/" rel="alternate" type="text/html" title="Hayfevrly — scrape daily pollen readings for Austin, Texas" /><published>2022-11-29T13:15:00+00:00</published><updated>2022-11-29T13:15:00+00:00</updated><id>https://www.texastim.dev/portfolio-hayfevrly</id><content type="html" xml:base="https://www.texastim.dev/portfolio-hayfevrly/"><![CDATA[<p>I created <a href="https://www.hayfevr.ly/">Hayfevr.ly</a> (GH repo to come) to solve a problem I had.
Two local allergy clinics and a TV news station posted daily pollen readings on their websites, so I had to keep re-checking three different websites each morning to find out what was making me sneeze each day.</p>

<p>I wrote a web scraper using Python and Selenium that
checks these websites for new readings,
updates the daily pollen counts as newreadings come in,
and summarizes the data in one convenient place on
the website.</p>

<h1 id="tech-stack">Tech Stack</h1>
<ul>
  <li>Python</li>
  <li>Selenium for the scraper</li>
  <li>Tesseract for OCR to extract pollen counts published only as graphics</li>
  <li>AWS S3 for web service</li>
  <li>MySQL for storing current and historical readings</li>
</ul>]]></content><author><name></name></author><category term="portfolio" /><summary type="html"><![CDATA[I created Hayfevr.ly (GH repo to come) to solve a problem I had. Two local allergy clinics and a TV news station posted daily pollen readings on their websites, so I had to keep re-checking three different websites each morning to find out what was making me sneeze each day.]]></summary></entry></feed>