<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xml:base="https://bjorn.now/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>How-To on bjorn.now</title><link>https://bjorn.now/tags/how-to/</link><description>Recent content in How-To on bjorn.now</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 28 Aug 2026 23:26:33 +0200</lastBuildDate><atom:link href="https://bjorn.now/tags/how-to/feed.xml" rel="self" type="application/rss+xml"/><item><title>Reset an IKEA Kajplats bulb with 6 power cycles</title><link>https://bjorn.now/til/2026-08-28-reset-an-ikea-kajplats-bulb-with-6-power-cycles/?utm_medium=feed</link><pubDate>Fri, 28 Aug 2026 23:26:33 +0200</pubDate><guid>https://bjorn.now/til/2026-08-28-reset-an-ikea-kajplats-bulb-with-6-power-cycles/</guid><description>Reset an IKEA Kajplats lightbulb by power cycling it 6 times and then leaving it on until it blinks, then it’ll be in pairing mode again. Thanks fishymanbits on Reddit!
Step by step:
Turn off the bulb for 30s Power cycle 6 times; on until it lights up, off immediately, count “one one thousand”, repeat On the sixth on, leave it on and wait When the bulb blinks it’ll be in pairing mode again</description><content:encoded><![CDATA[<p>Reset an IKEA Kajplats lightbulb by power cycling it 6 times and then leaving it on until it blinks, then it&rsquo;ll be in pairing mode again. Thanks <a href="https://www.reddit.com/r/tradfri/comments/1s81s4e/comment/oddqu0g/">fishymanbits on Reddit</a>!</p>
<p>Step by step:</p>
<ol>
<li>Turn off the bulb for 30s</li>
<li>Power cycle 6 times; on until it lights up, off immediately, count &ldquo;one one thousand&rdquo;, repeat</li>
<li>On the sixth on, leave it on and wait</li>
<li>When the bulb blinks it&rsquo;ll be in pairing mode again</li>
</ol>
]]></content:encoded></item><item><title>The IKEA Kajplats bulb wouldn't pair because my network had no IPv6</title><link>https://bjorn.now/til/2026-08-28-the-ikea-kajplats-bulb-wouldnt-pair-because-my-network-had-no-ipv6/?utm_medium=feed</link><pubDate>Fri, 28 Aug 2026 23:13:35 +0200</pubDate><guid>https://bjorn.now/til/2026-08-28-the-ikea-kajplats-bulb-wouldnt-pair-because-my-network-had-no-ipv6/</guid><description>Matter over Thread requires IPv6 on your local network, so if you can’t pair the IKEA Kajplats bulb that might be why.
I didn’t have IPv6 enabled, and my ISP doesn’t assign IPv6, so I used unique-local-ipv6.com to get a unique prefix. Configured it as static in my local network setup, alongside the IPv4 configuration, on my UniFi Dream Machine and then all my bulbs connected.
Now my niece is learning to pronounce English colors as she cycles my apartment through every shade of the rainbow 😁</description><content:encoded><![CDATA[<p><a href="https://en.wikipedia.org/wiki/Matter_(standard)">Matter</a> over <a href="https://en.wikipedia.org/wiki/Thread_(network_protocol)">Thread</a> requires IPv6 on your local network, so if you can&rsquo;t pair the <a href="https://www.ikea.com/nl/en/customer-service/product-support/smart-lighting/smart-lighting-support-pubd8491250/#3eed3150-08de-11f1-90c3-d5e60346fe38">IKEA Kajplats bulb</a> that might be why.</p>
<p>I didn&rsquo;t have IPv6 enabled, and my ISP doesn&rsquo;t assign IPv6, so I used <a href="https://unique-local-ipv6.com/">unique-local-ipv6.com</a> to get a unique prefix. Configured it as <code>static</code> in my local network setup, alongside the IPv4 configuration, on my UniFi Dream Machine and then all my bulbs connected.</p>
<p>Now my niece is learning to pronounce English colors as she cycles my apartment through every shade of the rainbow 😁</p>
]]></content:encoded></item><item><title>The regex | (or) operator splits the pattern left or right unless explicitly grouped</title><link>https://bjorn.now/til/2025-10-08-regex-or-operator-splits-pattern-left-or-right-unless-constrained/?utm_medium=feed</link><pubDate>Wed, 08 Oct 2025 23:34:03 +0200</pubDate><guid>https://bjorn.now/til/2025-10-08-regex-or-operator-splits-pattern-left-or-right-unless-constrained/</guid><description>The regex | (or) operator splits the pattern left or right unless explicitly grouped. Group it using (pattern) if you need to use the match later, or as a non-capturing group (?:pattern) if you do it for clarity.
I used to think there was some magic rule about how | decided where to split, but it’s simply: characters and subpatterns concatenate into a single pattern first, then | splits the entire thing left and right unless you explicitly group it. That’s because | has the lowest precedence so all other operations happen first.
So while I used to think that prefix_cat|dog would match prefix_cat and prefix_dog, it actually matches prefix_cat and then dog.
And that exact problem in a real-world example, to find if a page is linking to another, both relative or full URL:</description><content:encoded><![CDATA[<p>The regex <code>|</code> (or) operator splits the pattern left or right unless explicitly grouped.
Group it using <code>(pattern)</code> if you need to use the match later,
or as a non-capturing group <code>(?:pattern)</code> if you do it for clarity.</p>
<p>I used to think there was some magic rule about how <code>|</code> decided where to split,
but it&rsquo;s simply: characters and subpatterns concatenate into a single pattern first,
then <code>|</code> splits the entire thing left and right unless you explicitly group it.
That&rsquo;s because <code>|</code> <a href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_08">has the lowest precedence</a> so <em>all other</em> operations happen first.</p>
<p>So while I used to think that <code>prefix_cat|dog</code> would match <code>prefix_cat</code> and <code>prefix_dog</code>,
it actually matches <code>prefix_cat</code> and then <code>dog</code>.</p>
<p>And that exact problem in a real-world example, to find if a page is linking to another, both relative or full URL:</p>
<p>The regex <code>&lt;a[^&gt;]+href=[&quot;']https://www.example.com/page|/page</code> will match <code>/page</code>,
just as in the <code>dog</code> example, it&rsquo;s splitting the whole pattern and isn&rsquo;t what I want.</p>
<p>See it in action with <a href="https://regex101.com/r/6RylLz/2">the excellent Regex101.com</a>:</p>
<figure><img src="/img/2025/10-regex-01.png"
    alt="The Regex101.com site showing the Regex in action and that it matches /page">
</figure>

<p>To make it do what I want I need to constrain it in a capturing group <code>(pattern)</code>,
and since I don&rsquo;t want to reference the group later,
I constrain it inside a non-capturing group <code>(?:pattern)</code>.</p>
<p>That gives me the pattern <code>&lt;a[^&gt;]+href=[&quot;'](?:https://www\.example\.com/page|/page)</code>,
and <a href="https://regex101.com/r/kgeGyp/3">then it matches</a> both the full URL (<a href="https://www.example.com/page">https://www.example.com/page</a>) and the relative URL (/page):</p>
<figure><img src="/img/2025/10-regex-02.png"
    alt="The Regex101.com site showing the Regex in action and that it matches both links per the pattern as I intended">
</figure>

<p>I love Regex101.com. 🙂
I have commented gnarly regexes in my code with links to it,
so colleagues can paste them there and understand what&rsquo;s going on.
The sidebar explains what each subpattern does,
and the color highlighting shows what matches what in real-time.</p>]]></content:encoded></item><item><title>Use --resolve with curl when testing Caddy on localhost</title><link>https://bjorn.now/til/2025-10-01-use-resolve-with-curl-when-testing-caddy-on-localhost/?utm_medium=feed</link><pubDate>Wed, 01 Oct 2025 12:44:45 +0200</pubDate><guid>https://bjorn.now/til/2025-10-01-use-resolve-with-curl-when-testing-caddy-on-localhost/</guid><description>Use curl -k --resolve bjorn.now:443:127.0.0.1 https://bjorn.now when testing an HTTPS site locally using Caddy, instead of curl -k -H "Host: bjorn.now" https://localhost, because Caddy relies on SNI and refuses the connection if it doesn’t know which host you’re trying to connect to.</description><content:encoded><![CDATA[<p>Use <code>curl -k --resolve bjorn.now:443:127.0.0.1 https://bjorn.now</code> when testing an HTTPS site locally using <a href="https://caddyserver.com/">Caddy</a>, instead of <code>curl -k -H &quot;Host: bjorn.now&quot; https://localhost</code>, because Caddy relies on <a href="https://en.wikipedia.org/wiki/Server_Name_Indication">SNI</a> and refuses the connection if it doesn&rsquo;t know which host you&rsquo;re trying to connect to.</p>
<p>This seems to be a security decision to avoid leaking which certificates (and therefore sites) it hosts by not providing a default (can&rsquo;t find a source and it&rsquo;s what the search previews give me). Which my old nginx setup did.</p>
<p>The cryptic error message from cURL, which I didn&rsquo;t find anything obvious online about:</p>
<div class="no-copy-button">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">curl: (35) OpenSSL/3.0.13: error:0A000438:SSL routines::tlsv1 alert internal error</span></span></code></pre></div>
</div>
<p>And I debugged this together with Claude by enabling debug logging in Caddy (<code>{ debug }</code> at the top level in the <code>Caddyfile</code>) which gave me this output when I called it using cURL:</p>
<div class="no-copy-button">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">2025/10/01 10:04:56.330 DEBUG   events  event   {&#34;name&#34;: &#34;tls_get_certificate&#34;, &#34;id&#34;: &#34;7353980b-a85e-4f10-9704-89da7358ef89&#34;, &#34;origin&#34;: &#34;tls&#34;, &#34;data&#34;: {&#34;client_hello&#34;:{&#34;CipherSuites&#34;:[4866,4867,4865,49196,49200,159,52393,52392,52394,49195,49199,158,49188,49192,107,49187,49191,103,49162,49172,57,49161,49171,51,157,156,61,60,53,47,255],&#34;ServerName&#34;:&#34;&#34;,&#34;SupportedCurves&#34;:[29,23,30,25,24,256,257,258,259,260],&#34;SupportedPoints&#34;:&#34;AAEC&#34;,&#34;SignatureSchemes&#34;:[1027,1283,1539,2055,2056,2057,2058,2059,2052,2053,2054,1025,1281,1537,771,769,770,1026,1282,1538],&#34;SupportedProtos&#34;:null,&#34;SupportedVersions&#34;:[772,771],&#34;Conn&#34;:{}}}}
</span></span><span class="line"><span class="cl">2025/10/01 10:04:56.330 DEBUG   tls.handshake   no matching certificates and no custom selection logic  {&#34;identifier&#34;: &#34;127.0.0.1&#34;}
</span></span><span class="line"><span class="cl">2025/10/01 10:04:56.331 DEBUG   tls.handshake   all external certificate managers yielded no certificates and no errors {&#34;remote_ip&#34;: &#34;127.0.0.1&#34;, &#34;remote_port&#34;: &#34;42516&#34;, &#34;sni&#34;: &#34;&#34;}
</span></span><span class="line"><span class="cl">2025/10/01 10:04:56.331 DEBUG   tls.handshake   no certificate matching TLS ClientHello {&#34;remote_ip&#34;: &#34;127.0.0.1&#34;, &#34;remote_port&#34;: &#34;42516&#34;, &#34;server_name&#34;: &#34;&#34;, &#34;remote&#34;: &#34;127.0.0.1:42516&#34;, &#34;identifier&#34;: &#34;127.0.0.1&#34;, &#34;cipher_suites&#34;: [4866, 4867, 4865, 49196, 49200, 159, 52393, 52392, 52394, 49195, 49199, 158, 49188, 49192, 107, 49187, 49191, 103, 49162, 49172, 57, 49161, 49171, 51, 157, 156, 61, 60, 53, 47, 255], &#34;cert_cache_fill&#34;: 0.0002, &#34;load_if_necessary&#34;: true, &#34;obtain_if_necessary&#34;: true, &#34;on_demand&#34;: false}
</span></span><span class="line"><span class="cl">2025/10/01 10:04:56.332 DEBUG   http.stdlib     http: TLS handshake error from 127.0.0.1:42516: no certificate available for &#39;127.0.0.1&#39;</span></span></code></pre></div>
</div>
<p>The culprit was the <code>&quot;ServerName&quot;:&quot;&quot;</code>, and I&rsquo;m guessing also <code>&quot;sni&quot;: &quot;&quot;</code>, so if you need to validate and see that as well then that&rsquo;s likely the problem. 🙂</p>
<hr>
<p>This jogs my memory, back in the olden times, we would need a unique IP address for each HTTPS site because we couldn&rsquo;t multi-host, and SNI solved that problem.</p>
<p>Importantly, SNI <em>doesn&rsquo;t</em> encrypt the host name and it&rsquo;s still sent in plaintext to the server.</p>]]></content:encoded></item><item><title>How to refresh Telegram link previews</title><link>https://bjorn.now/til/2025-09-17-refresh-telegram-link-previews/?utm_medium=feed</link><pubDate>Wed, 17 Sep 2025 12:02:24 +0200</pubDate><guid>https://bjorn.now/til/2025-09-17-refresh-telegram-link-previews/</guid><description>to refresh a link preview in Telegram open a chat with Webpage Bot and send the URL, for those cases where you fix a typo or update the image.</description><content:encoded>&lt;p>to refresh a link preview in Telegram open a chat with &lt;a href="https://telegram.me/webpagebot">Webpage Bot&lt;/a> and send the URL, for those cases where you fix a typo or update the image.&lt;/p>
</content:encoded></item><item><title>Arvid Nordquist mellanrost coffee recipe …making do without the gooseneck</title><link>https://bjorn.now/blog/2025/09/07/arvid-nordquist-mellanrost-coffee-recipe/?utm_medium=feed</link><pubDate>Sun, 07 Sep 2025 11:13:14 +0200</pubDate><guid>https://bjorn.now/blog/2025/09/07/arvid-nordquist-mellanrost-coffee-recipe/</guid><description>My recipe for Arvid Nordquist mellanrost. I started by trying to replicate The Ultimate V60 technique by James Hoffmann (which is what I normally brew) and I realized just how hard it is to control the flow rate now that I don’t have my gooseneck kettle (being shipped from Singapore), and I hadn’t really realized just what a difference controlling the pour makes for the taste!
My current brewing setup which has my Commandante grinder and V60 and then a normal wide spout kettle which gives me very poor flow control, and a bag of Arvid Nordquist mellanrost</description><content:encoded><![CDATA[<p>My recipe for Arvid Nordquist mellanrost. I started by trying to replicate <a href="https://www.youtube.com/watch?v=AI4ynXzkSQo">The Ultimate V60 technique by James Hoffmann</a> (which is what I normally brew) and I realized just how hard it is to control the flow rate now that I don&rsquo;t have my <a href="https://homecoffeeexpert.com/why-use-a-gooseneck-kettle/">gooseneck kettle</a> (being shipped from Singapore), and I hadn&rsquo;t really realized just what a difference controlling the pour makes for the taste!</p>
<figure><img src="/img/2025/09-arvid-nordquist.jpeg"
    alt="Coffee brewing setup on a wooden surface showing a Commandante hand grinder with wooden knob, a white V60 dripper with filter paper on a mug, a bag of Arvid Nordquist Mellanrost coffee, a digital scale reading 253g, and a stainless steel electric kettle."><figcaption>
      <p>My current brewing setup which has my <a href="https://comandantegrinder.com">Commandante grinder</a> and <a href="https://www.hario-europe.com/collections/v60-dripper">V60</a> and then a normal wide spout kettle which gives me very poor flow control, and a bag of Arvid Nordquist mellanrost</p>
    </figcaption>
</figure>

<p>I followed the usual 15g of beans to 250g of water per James&rsquo; setup as I&rsquo;m brewing a single cup and then I:</p>
<ol>
<li>Put the kettle on, and while the water is getting to a boil</li>
<li>Grind the coffee at <strong>31 clicks</strong> on the Commandante</li>
<li>Pour in about 60g of water to bloom (I couldn&rsquo;t get the grounds saturated enough without this much water)</li>
<li>Let it bloom for 30 seconds</li>
<li>Pour in up to 150g of water as slowly as you can, practically this has been 10-15s</li>
<li>Rest for 15s</li>
<li>Pour in up to 250g of water as slowly as possible, again, practically 10-15s</li>
<li>Swirl it around to get a smooth coffee bed and let it draw down</li>
</ol>
<p>Doing this has given me a decent cup, but nothing to write home about (heh, despite this post), as it cools I get some nice flavors but it&rsquo;s a bit watery, but any finer and it gets too bitter.</p>
<p>And despite putting in the effort, experimenting, and trying to get it to work… when I visited my brother he took a couple of coffee scoops of Löfbergs Lila pre-ground coffee, put it in a drip brewer, turned it on, and waited. That damned coffee tasted better than this.</p>
<p>Now to hold off buying much more coffee gear before my stuff arrives from Singapore. I already ordered a Clever Dripper together with some light roasted beans, because I figured some immersion brew might do better if I don&rsquo;t have the gooseneck.</p>
<p>Also, I wasn&rsquo;t experimenting with this on my own, and I knew I was done because I constructed myself some help…</p>
<h2 id="introducing-hoffmann-bot">
  Introducing &ldquo;Hoffmann bot&rdquo;
  <a href="#introducing-hoffmann-bot" class="heading-anchor" aria-label="Direct link to Introducing &ldquo;Hoffmann bot&rdquo;"><span aria-hidden="true">#</span></a>
</h2>
<p>I have been using a genie to work on my coffee and it has genuinely given me some of my best coffee experiences at home since I made this prompt, which I have dubbed &ldquo;Hoffmann bot&rdquo; because I wanted to imagine I have James&rsquo; looming over my shoulders as I&rsquo;m trying to make it work. The big thing has been that I guess at what I should do and then the bot corrects me, my intuition has been <em>very wrong</em> despite watching a lot of videos. I clearly haven&rsquo;t internalized them enough. And it was clear in that my coffee was acceptable but never truly enjoyable at home.</p>
<p>I usually start my sessions by taking a photo of the bag I&rsquo;m working with. Then I explain what gear I&rsquo;m using (the 2 cup V60 for example) and then I guess at what I should try at.</p>
<div class="full-width copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">You are James Hoffmann helping troubleshoot V60 brewing issues. Channel his precise-yet-whimsical communication style.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">HOFFMANN VOICE:
</span></span><span class="line"><span class="cl">- Start with gentle, slightly bemused observations (&#34;Now, this is interesting...&#34;)
</span></span><span class="line"><span class="cl">- Use his characteristic dry humor and occasional exasperation with coffee myths
</span></span><span class="line"><span class="cl">- Include thoughtful pauses and qualifications (&#34;I think what&#39;s happening here is...&#34;)
</span></span><span class="line"><span class="cl">- Reference specific techniques from his videos when relevant
</span></span><span class="line"><span class="cl">- Maintain his balance of being authoritative yet approachable
</span></span><span class="line"><span class="cl">- Use British spellings and expressions naturally
</span></span><span class="line"><span class="cl">- Show genuine curiosity about what went wrong
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">APPROACH:
</span></span><span class="line"><span class="cl">- Begin with empathetic diagnosis of their described problem
</span></span><span class="line"><span class="cl">- Suggest grind adjustments in Commandante clicks (reference: 25-30 clicks for V60)
</span></span><span class="line"><span class="cl">- Explain the &#34;why&#34; in 1-2 sentences unless asked for more detail
</span></span><span class="line"><span class="cl">- Ask targeted follow-up questions with Hoffmann&#39;s methodical curiosity
</span></span><span class="line"><span class="cl">- Reference his Ultimate V60 technique principles when helpful
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">BREWING CONTEXT:
</span></span><span class="line"><span class="cl">- Primary: Two-cup V60 (occasionally one-cup)  
</span></span><span class="line"><span class="cl">- Grinder: Commandante
</span></span><span class="line"><span class="cl">- Beans: Light roasted filter coffees
</span></span><span class="line"><span class="cl">- User knows Ultimate V60 basics but needs debugging help
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">TYPICAL RESPONSES:
</span></span><span class="line"><span class="cl">- &#34;Right, so what you&#39;re describing sounds like...&#34;
</span></span><span class="line"><span class="cl">- &#34;This is quite common actually, and here&#39;s what I think is happening...&#34;
</span></span><span class="line"><span class="cl">- &#34;Now, before we get carried away adjusting everything...&#34;
</span></span><span class="line"><span class="cl">- &#34;The Commandante is lovely for this - try going [X] clicks...&#34;
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">DIAGNOSTIC QUESTIONS:
</span></span><span class="line"><span class="cl">- How did it taste? (sour/bitter/weak/astringent)
</span></span><span class="line"><span class="cl">- What was your drawdown time vs target?
</span></span><span class="line"><span class="cl">- Any signs of channeling or uneven extraction?
</span></span><span class="line"><span class="cl">- What&#39;s your current grind setting?</span></span></code></pre></div>
</div>
]]></content:encoded></item><item><title>Enabling macOS fingerprint reader for sudo</title><link>https://bjorn.now/til/2025-08-01-macos-fingerprint-reader-sudo/?utm_medium=feed</link><pubDate>Fri, 01 Aug 2025 23:15:00 +0800</pubDate><guid>https://bjorn.now/til/2025-08-01-macos-fingerprint-reader-sudo/</guid><description>You can enable the fingerprint reader for sudo on macOS, and pressing my finger on a button beats having to type the password, steps:
cp /etc/pam.d/sudo_local{.template,} Edit /etc/pam.d/sudo_local and uncomment auth sufficient pam_tid.so. The reason for doing this in sudo_local is that this file will not get reset with system changes from Apple.</description><content:encoded><![CDATA[<p>You can enable the fingerprint reader for sudo on macOS,
and pressing my finger on a button beats having to type the password, steps:</p>
<ol>
<li><code>cp /etc/pam.d/sudo_local{.template,}</code></li>
<li>Edit <code>/etc/pam.d/sudo_local</code> and uncomment <code>auth       sufficient     pam_tid.so</code>.</li>
</ol>
<p>The reason for doing this in <code>sudo_local</code> is that this file will not get reset with system changes from Apple.</p>
]]></content:encoded></item><item><title>Working with Go's test cache on CI — be fast by avoiding work, while doing the important work</title><link>https://bjorn.now/blog/2025/07/07/working-with-gos-test-cache-on-ci/?utm_medium=feed</link><pubDate>Mon, 07 Jul 2025 21:50:00 +0800</pubDate><guid>https://bjorn.now/blog/2025/07/07/working-with-gos-test-cache-on-ci/</guid><description>I was trying to speed up our slow CI by caching Go builds. The easy win was caching Go’s module downloads (via GOPATH), but when I added GOCACHE for the build cache, I got a pleasant surprise: the tests were caching too. 🥳
I shared the change for review, and a colleague raised a great point: “What about our black box integration tests?” These tests hit APIs and external services that Go can’t track as dependencies. If they cache when they shouldn’t, we might miss real failures: the tests would pass because they didn’t re-run, not because the code actually works.</description><content:encoded><![CDATA[<p>I was trying to speed up our slow CI by caching Go builds. The easy win was caching Go&rsquo;s module downloads (via <code>GOPATH</code>), but when I added <code>GOCACHE</code> for the build cache, I got a pleasant surprise: the tests were caching too. 🥳</p>
<p>I shared the change for review, and a colleague raised a great point: &ldquo;What about our black box integration tests?&rdquo; These tests hit APIs and external services that Go can&rsquo;t track as dependencies. If they cache when they shouldn&rsquo;t, we might miss real failures: the tests would pass because they didn&rsquo;t re-run, not because the code actually works.</p>
<details>
<summary><strong>TL;DR:</strong> I found three ways to handle Go test caching on CI, they are:</summary>
<table>
  <thead>
      <tr>
          <th>Approach</th>
          <th>Changes Needed</th>
          <th>Test Caching</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>go clean -testcache</code></td>
          <td>CI config only</td>
          <td>❌ None</td>
      </tr>
      <tr>
          <td><code>-count=1</code></td>
          <td>Every test invocation</td>
          <td>❌ None</td>
      </tr>
      <tr>
          <td>Environment variables</td>
          <td>Shared code/library once</td>
          <td>✅ Full</td>
      </tr>
  </tbody>
</table>
<p><strong><code>go clean -testcache</code></strong> — wipe all test cache before running. No code changes, no test caching.</p>
<p><strong><code>-count=1</code></strong> — skip cache for a specific <code>go test</code> invocation. Need to add it everywhere.</p>
<p><strong>Environment variables</strong> — read your CI&rsquo;s commit SHA (e.g. <code>GITHUB_SHA</code>, <code>DRONE_COMMIT_SHA</code>) in your test setup. Go auto-invalidates the package&rsquo;s test cache when the value changes. Unit tests still cache, integration tests re-run on new commits as long as you read the variable once in the package. A helper to ensure it doesn&rsquo;t cache:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kd">func</span><span class="w"> </span><span class="nf">IsIntegrationTest</span><span class="p">(</span><span class="nx">t</span><span class="w"> </span><span class="o">*</span><span class="nx">testing</span><span class="p">.</span><span class="nx">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nx">t</span><span class="p">.</span><span class="nf">Helper</span><span class="p">()</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nx">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="nx">os</span><span class="p">.</span><span class="nf">Getenv</span><span class="p">(</span><span class="s">&#34;GITHUB_SHA&#34;</span><span class="p">)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="p">}</span></span></span></code></pre></div>
</div>
<p>Key behavior:</p>
<ul>
<li>Invalidation is <strong>per-package</strong>, not per-test</li>
<li>Reading env vars through library calls still triggers invalidation</li>
<li><code>go test</code> with no package target never caches</li>
<li>Debug caching decisions with <code>GODEBUG=gocachetest=1</code></li>
</ul>
</details>
<h2 id="the-fundamental-problem">
  The Fundamental Problem
  <a href="#the-fundamental-problem" class="heading-anchor" aria-label="Direct link to The Fundamental Problem"><span aria-hidden="true">#</span></a>
</h2>
<p>When my colleague warned me about integration test caching, I realized we had a bigger problem than just my PR. How could I fix this across our entire org? We&rsquo;ve got ~250 repos, and asking every team to remember special flags or change their test execution wasn&rsquo;t going to fly. I needed something that would just work everywhere with minimal changes.</p>
<p>The fundamental issue: our black box integration tests don&rsquo;t &ldquo;declare their dependencies&rdquo; to the Go compiler, so it doesn&rsquo;t know that something the test is critically dependent upon has changed and requires a rerun (and practically, neither do we really), because they test network services and external binaries that Go has no visibility into. I always have to run these tests.</p>
<p>I wanted the caching benefits without the risk, ideally with minimal changes since we have lots of codebases that could benefit from this caching improvement. Since our black box integration tests use a shared internal library, I was hoping to find a solution I could implement once there rather than asking teams to modify individual tests or change how they execute them.</p>
<h2 id="so-how-do-i-make-this-work">
  So&hellip; How Do I Make This Work?
  <a href="#so-how-do-i-make-this-work" class="heading-anchor" aria-label="Direct link to So&hellip; How Do I Make This Work?"><span aria-hidden="true">#</span></a>
</h2>
<p>I started by looking for the obvious solutions, there&rsquo;s probably a flag to ignore the test cache, right? And there were two straightforward options: <code>go clean -testcache</code> and <code>-count=1</code>. But here&rsquo;s the thing, both of them throw away ALL test caching, which felt like using a sledgehammer when I needed a scalpel.</p>
<p>Then I remembered reading something about environment variables, and files, affecting test caching. I went into <code>go help test</code> and I remembered right, tests that read environment variables get invalidated when those variables change, so since this is about CI, and I know that CI systems give us unique commit SHAs as env vars… and we have a shared library to help write black box integration tests… so I can make the fix once in that library and everyone gets this benefit!</p>
<p>Alright, that gives me three options, how do they compare?</p>
<p><strong>Simple Option: <code>go clean -testcache</code></strong></p>
<ul>
<li>Pro: Dead simple - add one line to your CI config, no test changes needed</li>
<li>Con: Zero caching benefit for tests</li>
<li>When to use: Safest solution that still gives you build benefits without changing scripts or tests</li>
</ul>
<p>This works by creating <a href="https://github.com/golang/go/blob/665af869920432879629c1d64cf59f129942dcd6/src/cmd/go/internal/test/test.go#L844-L848">a file with the current Unix time in nanoseconds</a> and then, whenever Go runs tests, it checks if the cached test is newer than that timestamp. I appreciate the simplicity: the cache cleaner doesn&rsquo;t need to understand which cached items are tests (and there are only hashes in that folder), it just sets a &ldquo;tests are invalid after this moment&rdquo; marker and the code skips it or not.</p>
<p><strong>Explicit Option: <code>-count=1</code></strong></p>
<ul>
<li>Pro: Granular control per <code>go test</code> invocation</li>
<li>Con: Need to change test execution and remember it everywhere, easy to miss (especially in monorepos with many go.mods)</li>
<li>When to use: Only some tests need cache invalidation</li>
</ul>
<p>This is the one you&rsquo;ll see when people ask how to make Go not cache tests, for our situation not super useful, but mentioning it for completeness.</p>
<p><strong>Elegant Option: Environment Variables</strong></p>
<ul>
<li>Pro: Automatic cache invalidation on CI when needed, maximum caching benefit when possible</li>
<li>Con: Requires thoughtful test design</li>
<li>When to use: You have enough tests that the speedup matters and you&rsquo;re willing to be intentional about cache invalidation</li>
</ul>
<p>Or laid out visually:</p>
<table>
  <thead>
      <tr>
          <th>Approach</th>
          <th>Changes Needed</th>
          <th>Test Caching</th>
          <th>Safety</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>go clean -testcache</code></td>
          <td>CI config only</td>
          <td>❌ None</td>
          <td>✅ Safest</td>
      </tr>
      <tr>
          <td><code>-count=1</code></td>
          <td>Every test invocation</td>
          <td>❌ None</td>
          <td>✅ Safe</td>
      </tr>
      <tr>
          <td>Environment variables</td>
          <td>Shared code/library once</td>
          <td>✅ Full</td>
          <td>✅ Safe*</td>
      </tr>
  </tbody>
</table>
<p>*<em>When implemented correctly</em></p>
<h3 id="how-the-environment-variable-approach-works">
  How the Environment Variable Approach Works
  <a href="#how-the-environment-variable-approach-works" class="heading-anchor" aria-label="Direct link to How the Environment Variable Approach Works"><span aria-hidden="true">#</span></a>
</h3>
<p>This works because Go invalidates the entire package&rsquo;s test cache whenever an environment variable it depends on changes, and most CI systems expose a unique commit SHA as an environment variable. For example,</p>
<ul>
<li>GitHub Actions: <code>GITHUB_SHA</code></li>
<li>Drone CI: <code>DRONE_COMMIT_SHA</code></li>
</ul>
<p>When your integration test reads this variable, Go automatically invalidates the cache for that package whenever you push new code. The key insight: you don&rsquo;t need to <em>use</em> the variable meaningfully, just <em>read</em> it. One thing to keep in mind: consider keeping integration tests in separate packages from unit tests to avoid invalidating unit test caches unnecessarily when only the integration tests need cache invalidation.</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span><span class="w"> </span><span class="nx">integrationtesting</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="kd">func</span><span class="w"> </span><span class="nf">IsIntegrationTest</span><span class="p">(</span><span class="nx">t</span><span class="w"> </span><span class="o">*</span><span class="nx">testing</span><span class="p">.</span><span class="nx">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="nx">t</span><span class="p">.</span><span class="nf">Helper</span><span class="p">()</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="c1">// This ensures that we invalidate the cache</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="c1">// on CI whenever we have a new git SHA</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="nx">_</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="nx">os</span><span class="p">.</span><span class="nf">Getenv</span><span class="p">(</span><span class="s">&#34;DRONE_COMMIT_SHA&#34;</span><span class="p">)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="p">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c1">// ... another file relying on integrationtesting</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="kd">func</span><span class="w"> </span><span class="nf">TestAPIIntegration</span><span class="p">(</span><span class="nx">t</span><span class="w"> </span><span class="o">*</span><span class="nx">testing</span><span class="p">.</span><span class="nx">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="nx">integrationtesting</span><span class="p">.</span><span class="nf">IsIntegrationTest</span><span class="p">(</span><span class="nx">t</span><span class="p">)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="c1">// Your actual integration test</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="nx">resp</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nf">callAPIEndpoint</span><span class="p">()</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">	</span><span class="nx">assert</span><span class="p">.</span><span class="nf">Equal</span><span class="p">(</span><span class="nx">t</span><span class="p">,</span><span class="w"> </span><span class="nx">expected</span><span class="p">,</span><span class="w"> </span><span class="nx">resp</span><span class="p">)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="p">}</span></span></span></code></pre></div>
</div>
<h2 id="understanding-how-it-actually-works">
  Understanding How It Actually Works
  <a href="#understanding-how-it-actually-works" class="heading-anchor" aria-label="Direct link to Understanding How It Actually Works"><span aria-hidden="true">#</span></a>
</h2>
<p>I was getting worried about edge cases. The Go docs said tests won&rsquo;t cache if environment variables change, but what exactly did that mean? Would reading an env var in one test invalidate <em>all</em> tests everywhere? Just that package? What if the variable is read through a library call?</p>
<p>I did some searching and found the <a href="https://github.com/golang/go/blob/6c3b5a2798c83d583cb37dba9f39c47300d19f1f/src/internal/testlog/log.go#L49-L54">testlog package</a>, which is how Go implements the tracking of when env vars are read and files opened. That gave me a good sense of how it should behave, so I made an experiment to validate what I expected from the documentation and the code I found.</p>
<h3 id="the-experiment-results">
  The Experiment Results
  <a href="#the-experiment-results" class="heading-anchor" aria-label="Direct link to The Experiment Results"><span aria-hidden="true">#</span></a>
</h3>
<p>I created <a href="https://github.com/gaqzi/experiment-go-test-caching">three test packages</a> to understand the boundaries:</p>
<ul>
<li>One that reads <code>DRONE_COMMIT_SHA</code> directly</li>
<li>One that reads it through a library call</li>
<li>One that doesn&rsquo;t read any environment variables</li>
</ul>
<p>Then I ran <a href="https://github.com/gaqzi/experiment-go-test-caching/blob/main/test.sh">nine scenarios to test my assumptions</a>: What happens when I set the variable? Does package listing matter (<code>./...</code> vs manual package lists)? What about <code>go test</code> with no arguments?</p>
<p>Key findings:</p>
<ul>
<li><strong>Package-level invalidation</strong>: All tests in a package get invalidated if <em>any</em> test reads the variable and the variable changes,</li>
<li><strong>Library calls count</strong>: Reading env vars through dependencies still invalidates the cache</li>
<li><strong>Package listing doesn&rsquo;t matter</strong>: <code>./...</code>, manual lists, even <code>./</code> all cache the same way</li>
<li><strong>No arguments = no cache</strong>: <code>go test</code> without targeting never caches</li>
<li><strong>File-level targeting = no cache</strong>: <code>go test file_test.go</code> also never caches</li>
</ul>
<p>The big takeaway: Go runs tests per package, and packages are run in parallel. If any test in the package touches an environment variable, the entire package&rsquo;s cache depends on that variable&rsquo;s value, so the cache is invalidated when the value is different on the next run.</p>
<p>Or as a semi-flowchart:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">Package reads env var? 
</span></span><span class="line"><span class="cl">    Yes → Env var value changed? 
</span></span><span class="line"><span class="cl">              Yes → Cache invalid
</span></span><span class="line"><span class="cl">              No  → Cache valid
</span></span><span class="line"><span class="cl">    No → Cache valid</span></span></code></pre></div>
</div>
<p>This made me comfortable that the approach was predictable and wouldn&rsquo;t have surprising edge cases, especially because the way <a href="https://github.com/golang/go/blob/6c3b5a2798c83d583cb37dba9f39c47300d19f1f/src/internal/testlog/log.go#L49-L54">testlog</a> works is by simply recording that <em>something</em> called <code>os.Getenv</code> with this value, and it doesn&rsquo;t know which test or from where, just that in the course of running these tests this happened. Nice and simple.</p>
<p>If you want to explore how Go makes decisions around caching yourself, you can run tests with <code>GODEBUG=gocachetest=1</code> to see Go&rsquo;s caching decisions in real time. There are more debugging variables available in <code>go help cache</code>.</p>
<h2 id="the-results">
  The Results
  <a href="#the-results" class="heading-anchor" aria-label="Direct link to The Results"><span aria-hidden="true">#</span></a>
</h2>
<p>We cut our CI times in half with this caching approach, and I&rsquo;m confident it&rsquo;s safe to roll out widely because I understand exactly how it works and I can make the required changes to our shared integration testing library so it will just work for the standard case.</p>
<p>What I appreciate about Go&rsquo;s design here is how it avoids clever optimizations in favor of predictable behavior. I knew caching wasn&rsquo;t just on/off, but I wasn&rsquo;t sure if there would be complex edge cases to worry about. Instead, Go picks the straightforward solution: package-level invalidation that&rsquo;s easy to reason about.</p>
<p>The &ldquo;bigger packages than you think, but still not huge&rdquo; philosophy means we get plenty of caching benefit, while keeping the invalidation scope manageable, and if we need finer control, we can always split into more packages.</p>
<p>And that&rsquo;s the thing, Go just picks the simple and boring solution that works, it&rsquo;s why I love working with Go. 😁</p>
<hr>
<p><em>The <a href="https://github.com/gaqzi/experiment-go-test-caching">full experiment is available</a> if you want to dig into it yourself.</em><br>
<em><a href="https://speakerdeck.com/gaqzi/working-with-gos-test-cache-on-ci">Presentation slides</a> from the Singapore Go meetup</em></p>
]]></content:encoded></item><item><title>Day-to-day automation using Alfred on your Mac — reducing TOIL outside of your DevOps practice</title><link>https://bjorn.now/blog/2024/04/15/day-to-day-automation-using-alfred/?utm_medium=feed</link><pubDate>Mon, 15 Apr 2024 19:15:00 +0800</pubDate><guid>https://bjorn.now/blog/2024/04/15/day-to-day-automation-using-alfred/</guid><description>I try to be aware of where I have friction in my day-to-day when working at my computer, keeping an eye out for TOIL to remove. Whether it’s from manually repeated actions, or from differing behaviors across apps and services I use. When I identify any of these I try to spend some small amount of time automating or changing how I work to improve.
All of these things don’t necessarily make a lot of sense from how much time I save, but, it also makes me happy to spend a bit of time improving my environment, and spending a bit of time to make me happy is good enough for me.</description><content:encoded><![CDATA[<p>I try to be aware of where I have friction in my day-to-day when working at my
computer, keeping an eye out for <a href="https://sre.google/sre-book/eliminating-toil/">TOIL to remove.</a> Whether it&rsquo;s from
manually repeated actions, or from differing behaviors across apps and services
I use. When I identify any of these I try to spend some small amount of time
automating or changing how I work to improve.</p>
<p>All of these things don&rsquo;t necessarily make a lot of sense from how much time I
save, but, it also makes me happy to spend a bit of time improving my
environment, and spending a bit of time to make me happy is good enough for me.</p>
<p>I view doing these kinds of small workflow improvements like a <a href="https://en.wikipedia.org/wiki/Kata#Outside_martial_arts">kata</a> because it
improves my automation/scripting skills and encourages me to think about how I
work. I usually give myself 10-20m to try and make these kinds of improvements
just so I know how much time to spend. Just don&rsquo;t go overboard. XKCD, as always,
have a comic to illustrate the downside of going too far. 🙂</p>
<p><a href="https://xkcd.com/1319"><img src="https://imgs.xkcd.com/comics/automation.png" alt="&lsquo;Automating&rsquo; comes from the roots &lsquo;auto-&rsquo; meaning &lsquo;self-&rsquo;, and &lsquo;mating&rsquo;, meaning &lsquo;screwing&rsquo;.&quot;"></a></p>
<h2 id="what-is-alfred-and-why-is-it-an-app-im-focusing-on">
  What is Alfred and why is it an app I&rsquo;m focusing on?
  <a href="#what-is-alfred-and-why-is-it-an-app-im-focusing-on" class="heading-anchor" aria-label="Direct link to What is Alfred and why is it an app I&rsquo;m focusing on?"><span aria-hidden="true">#</span></a>
</h2>
<p><a href="https://alfredapp.com/">Alfred</a> is an application launcher but oh-so-much-more. It connects with macOS
and the Workflows contains a lot of extensions that allow you to interact with
all kinds of programs, websites, etc.</p>
<p>A big part of what Alfred has helped me create is a more unified experience
across the apps and websites I use. I have moved some operations that behave
differently in different apps into Alfred because then I can focus on what I
need to do and then use Alfred to provide consistency (and as I&rsquo;ve
been told, &ldquo;consistency is good even outside the bathroom&rdquo;).</p>
<p>Now, let&rsquo;s look at how I use Alfred.</p>
<h2 id="built-in-functionality">
  Built-in functionality
  <a href="#built-in-functionality" class="heading-anchor" aria-label="Direct link to Built-in functionality"><span aria-hidden="true">#</span></a>
</h2>
<p>These are features that don&rsquo;t require anything extra to install and use.</p>
<h3 id="open-an-app">
  Open an app
  <a href="#open-an-app" class="heading-anchor" aria-label="Direct link to Open an app"><span aria-hidden="true">#</span></a>
</h3>
<p>Alfred&rsquo;s starter feature is the application launcher, and it means you summon it
with a keybinding and type the name of the app you want to start and voilà.
I have bound the keyboard shortcut to <code>cmd+space</code> and replaced the built-in
Spotlight search.</p>
<figure><img src="/img/2024/04/15/01-open-app.png"
    alt="Opening Firefox in Alfred">
</figure>

<h3 id="spell--define">
  Spell / define
  <a href="#spell--define" class="heading-anchor" aria-label="Direct link to Spell / define"><span aria-hidden="true">#</span></a>
</h3>
<p>There are certain words I rarely get right (continuous) and some
words are spelled very differently from how they sound. Summon Alfred and
<code>spell &lt;word&gt;</code> and you&rsquo;ll have suggestions that often will go right. And if
you don&rsquo;t find it, replace <code>spell</code> with <code>google</code> and see if Google knows
better. Hit enter to copy the correct spelling to the clipboard.</p>
<figure><img src="/img/2024/04/15/02-spell-continuous.png"
    alt="Finding the correct spelling of continuus">
</figure>

<p>And <code>define</code> is the same thing but for dictionary lookup because you have some
word you&rsquo;re unsure what it means, or because you&rsquo;re wondering if someone was
trying to call you something you with some subtle nuance to a word. 😉
Hit enter to open the definition in macOS&rsquo;s dictionary app.</p>
<figure><img src="/img/2024/04/15/03-define-laggard.png"
    alt="Define &#39;laggard&#39;">
</figure>

<h3 id="calculator">
  Calculator
  <a href="#calculator" class="heading-anchor" aria-label="Direct link to Calculator"><span aria-hidden="true">#</span></a>
</h3>
<p>You can give it an expression and when you hit enter the result goes into the
clipboard. I often end up using this instead of opening a Python console on the
CLI.</p>
<figure><img src="/img/2024/04/15/04-calculator.png"
    alt="Adding some numbers together">
</figure>

<h3 id="custom-web-search">
  Custom web search
  <a href="#custom-web-search" class="heading-anchor" aria-label="Direct link to Custom web search"><span aria-hidden="true">#</span></a>
</h3>
<p>A custom web search allow you to quickly open a web browser at a
particular website with whatever value you&rsquo;ve typed into Alfred which <em>doesn&rsquo;t
have to be a search engine or even a search page.</em></p>
<p>To configure a custom web search summon Alfred and hit <code>cmd+,</code> to open
the settings page. Go into the <code>Features</code> tab and click on <code>Web Search</code>.</p>
<figure><img src="/img/2024/04/15/05-web-search-listing.png"
    alt="Alfred&#39;s setting Features -&gt; Web Search highlighted">
</figure>

<p>Some example search engines I have made:</p>
<ul>
<li>Jira: <code>https://jira.example.com/browse/{query}</code>
<ul>
<li>This isn&rsquo;t a search but rather the view this ticket. Because I often get a
ticket id (either from a commit message or someone rattling it off in a
meeting) and this way I can open it quickly</li>
</ul>
</li>
<li>Confluence: <code>https://confluence.example.com/dosearchsite.action? queryString={query}</code></li>
<li>Wordnik: <code>https://wordnik.com/words/{query}</code>
<ul>
<li>So I can find synonyms and other alternatives for words. Often use this when
I want to find a good name for something which has been inspired
by <a href="https://signalvnoise.com/svn3/hunting-for-great-names-in-programming/">Hunting for great names in programming</a>.</li>
</ul>
</li>
<li>Pypi: <code>https://pypi.org/project/{query}</code>
<ul>
<li>To look up python packages</li>
</ul>
</li>
</ul>
<figure><img src="/img/2024/04/15/06-web-search-example-config.png"
    alt="Example setup of the Confluence search engine">
</figure>

<h2 id="working-with-other-applications">
  Working with other applications
  <a href="#working-with-other-applications" class="heading-anchor" aria-label="Direct link to Working with other applications"><span aria-hidden="true">#</span></a>
</h2>
<p>Alfred has ended being the tool that brings my apps to focus and smoothes
over differences between apps.</p>
<h3 id="give-my-most-common-apps-a-keybinding">
  Give my most common apps a keybinding
  <a href="#give-my-most-common-apps-a-keybinding" class="heading-anchor" aria-label="Direct link to Give my most common apps a keybinding"><span aria-hidden="true">#</span></a>
</h3>
<p>Instead of <code>cmd+tab</code> between the various apps I&rsquo;m using I have bound specific
keybindings to my most used app, so I can quickly swap between
them. <a href="https://dev.to/rstacruz/switching-apps-slow-down-my-productivity-and-how-i-fixed-it-2anb">Hat tip to Rico Sta. Cruz</a>
who blogged about this a couple of years ago and who I picked it up from.</p>
<p>The big benefit I have found here is just the ease of being mid-thinking and
wanting to switch back to another app, whether it&rsquo;s to jot down a quick note, to
finish that Regex you were visualizing on <a href="https://regex101.com/">Regex 101</a>, or
to get back to Slack to paste that thing your colleague asked for. It feels so
seamless compared to tabbing between.</p>
<p>This is using <a href="https://www.alfredapp.com/workflows/">Alfred&rsquo;s Workflows</a>, and
they&rsquo;re part of their advanced set of options. You can do keybindings that work
across all of macOS as well as actions based on what you&rsquo;re typing.</p>
<figure><img src="/img/2024/04/15/07-app-shortcuts.png"
    alt="The custom app shortcuts workflow">
</figure>

<h3 id="spotify-controller">
  Spotify controller
  <a href="#spotify-controller" class="heading-anchor" aria-label="Direct link to Spotify controller"><span aria-hidden="true">#</span></a>
</h3>
<p>I have been using these keybindings since before Alfred, in Quicksilver, and
there are other workflows for Spotify but since I had these I never bothered
installing anything else.</p>
<p>The cool extra in this workflow is that I added a keyword to open the
current playing song on <a href="https://genius.com">Genius.com</a> because I like
reading the lyrics.</p>
<p>This is an example of something where the automation is <em>far from necessary,</em>
but, I enjoyed adding it. It&rsquo;s something I do every other week and knowing I
can just go straight into the song nearly every time is great.</p>
<figure><img src="/img/2024/04/15/08-spotify-keybindings.png"
    alt="Spotify keybinding and keyword configuration">
</figure>

<p>My <a href="https://github.com/gaqzi/alfred-workflows/blob/master/Spotify%20keyboard%20shortcuts.alfredworkflow">Spotify workflow</a> is on Github if you want to install it, or <a href="https://gist.github.com/gaqzi/b3de88050bf1caaf8d2661233b51a1ae">here&rsquo;s a gist</a>
if you&rsquo;re just curious how I made &ldquo;open on genius.&rdquo;</p>
<h3 id="global-microphone-muteunmute-shortcuts">
  Global microphone mute/unmute shortcuts
  <a href="#global-microphone-muteunmute-shortcuts" class="heading-anchor" aria-label="Direct link to Global microphone mute/unmute shortcuts"><span aria-hidden="true">#</span></a>
</h3>
<p>I regularly use Google Meet, Slack, and Zoom for talking with people, and these
apps all use different shortcuts to mute. So instead of keeping the app
focused and remembering the various shortcuts I now just leave myself unmuted
everywhere and directly mute/unmute the OS through Alfred. My mic has a visual
indicator when it&rsquo;s on. +I have a notification posted, so I can see the current
status on the screen.</p>
<p>As I started using this workflow I realized that sometimes the microphone
bugs out but swapping it between the built-in and back will fix it. So after
a while I made a script to help swap as well.</p>
<p>And finally, I realized that sometimes my virtual soundcard which removes
background noise (<a href="https://krisp.ai">krisp.ai</a>) hangs and needs to be
restarted, so another keybinding to quickly restart the soundcard.</p>
<p>The only downside of this workflow is that others can&rsquo;t as clearly see when
I want to speak by unmuting myself in the current app, so in those rare cases
I&rsquo;ll use the mute in the app itself. Because optimizing my workflow
shouldn&rsquo;t come at the pain of everyone else, we live in a society. 🙂</p>
<figure><img src="/img/2024/04/15/09-mic-switch.png"
    alt="The mic switch workflow setup">
</figure>

<p>This <a href="https://github.com/gaqzi/alfred-workflows/blob/master/Toggle%20mute%20mic.alfredworkflow">mute/unmute workflow</a> is available on Github,
and <a href="https://gist.github.com/gaqzi/f299047706c10b2616ba15c94cabf1fe">here&rsquo;s a gist</a> if you want to see the toggle code. My
dotfiles got the <a href="https://github.com/gaqzi/conf/blob/master/bin/swap-mic-input">swap mic script</a> and the <a href="https://github.com/gaqzi/conf/blob/master/bin/%2Crestart-krisp">restart krisp script</a>.</p>
<h2 id="improvement-to-my-day-to-day-workflow">
  Improvement to my day-to-day workflow
  <a href="#improvement-to-my-day-to-day-workflow" class="heading-anchor" aria-label="Direct link to Improvement to my day-to-day workflow"><span aria-hidden="true">#</span></a>
</h2>
<h3 id="text-replacement--snippets">
  Text replacement / snippets
  <a href="#text-replacement--snippets" class="heading-anchor" aria-label="Direct link to Text replacement / snippets"><span aria-hidden="true">#</span></a>
</h3>
<p>Snippets are short pieces of text that expand into something else. It can be
a static string, or it can be dynamic and I use both kinds as I work. For me
they fall into these categories</p>
<ol>
<li>&ldquo;Named paste&rdquo;, things that are hard to remember or unwieldy and are now not</li>
<li>Dynamic replacement, something that follows a pattern and I want to swap
between. Generally these use the clipboard</li>
<li>Generated inputs, I need the current time in a specific format or some
other piece of data</li>
</ol>
<p>You configure snippets by summoning Alfred and hitting <code>cmd+,</code> which opens
Settings, then go into Features -&gt; Snippets. Snippets work by specifying a
keyword, in my default bundle I require that my keywords are prefixed with <code>\\</code>,
meaning that Alfred will expand my snippets if it sees <code>\\&lt;keyword&gt;</code> and with
the example keyword <code>exp</code> you&rsquo;d then type <code>\\exp</code> to add it. If you need to type
the exact string for some reason it&rsquo;s easiest to add a space somewhere before
you type the last character and then go back and remove it.</p>
<figure><img src="/img/2024/04/15/11-snippets-config.png"
    alt="How to view or create snippets">
</figure>

<p>My trigger for creating a snippet is finding that I keep typing or
pasting the same thing again and again.</p>
<p>Let&rsquo;s look at how I use them in a couple of different places.</p>
<h4 id="gmail">
  GMail
  <a href="#gmail" class="heading-anchor" aria-label="Direct link to GMail"><span aria-hidden="true">#</span></a>
</h4>
<p>Finding emails from &ldquo;unusual senders:&rdquo; I label the majority of emails I get
at work as they are notifications or otherwise automated emails. So if I get
something that isn&rsquo;t labeled it&rsquo;s probably a human or something I need to
look into, and it can sometimes get hidden in a sea of everything else.</p>
<p><code>&lt;prefix&gt;gmailn</code> in the search bar turns into <code>is:inbox is:unread has:nouserlabels</code> which only shows unread emails in the inbox which doesn&rsquo;t
have a label.</p>
<p>When I&rsquo;m processing my labels, which are effectively buckets of things to do,
I often go into a label and want to see only the unread items, so I can open
the first and then go through them one-by-one. So open the label, focus on
the search bar, and type in <code>&lt;prefix&gt;unr</code> to give me <code>is:unread</code> and then
get to that focus.</p>
<h4 id="jira-tickets">
  Jira tickets
  <a href="#jira-tickets" class="heading-anchor" aria-label="Direct link to Jira tickets"><span aria-hidden="true">#</span></a>
</h4>
<p>If I&rsquo;m writing a message on Slack and I need to reference a ticket I think
it&rsquo;s nice to give a link even if I only have the jira ticket ID, so I made a
snippet that adds the current clipboard item at the end of my company&rsquo;s Jira
instance in a Markdown link. Now it looks nice where markdown is and the
other person doesn&rsquo;t have to open it up themselves.</p>
<p>Copy <code>WRK-123</code> and then type <code>&lt;prefix&gt;jiramd</code> which replaces it with
<code>[WRK-123](https://jira.deliveryhero.com/browse/WRK-123)</code>.</p>
<p>The Alfred snippet configuration</p>
<div class=" copy-enabled">
  <pre tabindex="0"><code>[{clipboard:trim}](https://jira.example.com/browse/{clipboard:trim})</code></pre>
</div>
<figure><img src="/img/2024/04/15/12-snippet-jiramd.png"
    alt="Configuring the jiramd snippet in Alfred">
</figure>

<h4 id="roam-research">
  Roam Research
  <a href="#roam-research" class="heading-anchor" aria-label="Direct link to Roam Research"><span aria-hidden="true">#</span></a>
</h4>
<p>Roam is my notetaking app and where most of my thinking happen and I have a
whole slew of replacements for how I work with Roam Research and most of them
are to help me keep my workflow consistent (using the right tags)
and to make common actions easier and faster.</p>
<ul>
<li><code>&lt;prefix&gt;rts</code> turns into the current time in bold since I practice
interstitial journaling. Example <code>**15:03**</code>. Snippet configuration: <code>** {time:short}**</code></li>
<li><code>&lt;prefix&gt;b&lt;shortcode&gt;</code> for how I bucket tasks so when I spend time on a
particular bucket I can find the things I need to do. I.e. my bucket  &ldquo;Life in
Production&rdquo; (on-call, observability, continuous delivery, etc.) is prefixed
with <code>&lt;prefix&gt;bl</code> and that turns into <code>[🥬]([[Bucket/Life in Production]])</code></li>
<li><code>&lt;prefix&gt;&lt;INITIALS&gt;</code> to turn into the name of my most frequent
collaborators at work, so I can tag what I&rsquo;ve said to them or a task we
need to do.</li>
</ul>
<h3 id="emoji-search">
  Emoji search
  <a href="#emoji-search" class="heading-anchor" aria-label="Direct link to Emoji search"><span aria-hidden="true">#</span></a>
</h3>
<p>Spending a lot of time communicating across continents involves timezones
and people rarely hearing your voice, so I have gotten used to peppering my
inputs with emojis to help since it&rsquo;s so easy to come off sounding like an
ass otherwise.</p>
<p>And because some websites or applications don&rsquo;t have a good search for
emoji and this way I only have to learn one keyboard shortcut and normalize it
across places. This way I don&rsquo;t have to remember how Slack named this emoji vs.
Miro vs. Google Docs vs. Confluence vs. other random website. I just learn it in
Alfred and then paste it straight into the textbox I wanted.</p>
<figure><img src="/img/2024/04/15/10-search-emoji.png"
    alt="Searching for the rocket emoji">
</figure>

<p>This is an external Workflow made by <a href="https://github.com/jsumners">James Sumners</a>, and you can download it
from the <a href="https://github.com/jsumners/alfred-emoji">workflow&rsquo;s Github page.</a></p>
<h3 id="generate-uuids-on-the-fly">
  Generate uuids on the fly
  <a href="#generate-uuids-on-the-fly" class="heading-anchor" aria-label="Direct link to Generate uuids on the fly"><span aria-hidden="true">#</span></a>
</h3>
<p>As I was writing the tying it up section I realized that I had a recent pain
which where I kept jumping between apps to create new UUIDs. I was running
the following command on the CLI and then pasting it into some yaml files in
my editor.</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">uuidgen <span class="p">|</span> tr <span class="s1">&#39;[:upper:]&#39;</span> <span class="s1">&#39;[:lower:]&#39;</span> <span class="p">|</span> tr -d <span class="s1">&#39;\n&#39;</span> <span class="p">|</span> pbcopy</span></span></code></pre></div>
</div>
<p>So I instead created a new workflow that is triggered by a snippet that runs
this for me.</p>
<figure><img src="/img/2024/04/15/15-snippet-uuidgen.png"
    alt="Configuring the uuidgen snippet">
</figure>

<p><strong>Note:</strong> To make it behave just like a regular snippet you need to
configure the <em>Copy to clipboard</em> output to <code>Automatically paste to the frontmost app</code> and <code>Mark item as transient in clipboard</code>.</p>
<figure><img src="/img/2024/04/15/16-snippet-uuidgen-clipboard-config.png"
    alt="How configure the Copy to clipboard output">
</figure>

<p>The <a href="https://github.com/gaqzi/alfred-workflows/blob/master/uuidgen.alfredworkflow">uuidgen workflow</a> is available on Github.</p>
<h2 id="other-workflows">
  Other workflows
  <a href="#other-workflows" class="heading-anchor" aria-label="Direct link to Other workflows"><span aria-hidden="true">#</span></a>
</h2>
<p>Some other workflows I have installed since they save me time.</p>
<h3 id="calculate-anything">
  Calculate Anything
  <a href="#calculate-anything" class="heading-anchor" aria-label="Direct link to Calculate Anything"><span aria-hidden="true">#</span></a>
</h3>
<p>I installed this for two reasons: to quickly translate cooking recipes using
imperial units into metric and currency conversion. Super convenient and now I
can finally get how much 16 floz is in ml (473.176) without needing to go
online.</p>
<figure><img src="/img/2024/04/15/13-calculate-anything.png"
    alt="Calculate Anything converting 16 floz to ml">
</figure>

<p>By <a href="https://github.com/biati-digital">Biati Digital</a> and available in
the <a href="https://alfred.app/workflows/biatidigital/calculate-anything/">Alfred Gallery</a>.</p>
<h3 id="epoch-converter">
  Epoch converter
  <a href="#epoch-converter" class="heading-anchor" aria-label="Direct link to Epoch converter"><span aria-hidden="true">#</span></a>
</h3>
<p>There was a time when I kept looking at unix timestamps and needed to quickly
get when it was, so copying and then <code>ts &lt;paste&gt;</code> gave me when it was and
<code>ts</code> without anything will give you the current unix timestamp.</p>
<figure><img src="/img/2024/04/15/14-epoch-converter.png"
    alt="Epoch Converter showing the current unix timestamp">
</figure>

<p>By <a href="https://github.com/snooze92">Julien Lehuen</a> and available in
the <a href="https://alfred.app/workflows/julienlehuen/epoch-converter/">Alfred Gallery</a>.</p>
<h2 id="tying-it-up-and-how-i-figure-out-what-to-add">
  Tying it up and how I figure out what to add
  <a href="#tying-it-up-and-how-i-figure-out-what-to-add" class="heading-anchor" aria-label="Direct link to Tying it up and how I figure out what to add"><span aria-hidden="true">#</span></a>
</h2>
<p>I hope the above gives you some ideas or inspiration for what you could do
to improve your day-to-day computer usage. These are things that I&rsquo;ve pulled
together over years, and similarly I have a <a href="https://github.com/gaqzi/conf">bin/ folder</a> with other types of
automation I&rsquo;ve accrued, hehe. 😅</p>
<p>Now, how have I accrued these things? I generally try to reflect on the work
I do and the biggest help to it has been scheduling 30min every Friday to
reflect on the week. This session covers everything from updating my <a href="https://jvns.ca/blog/brag-documents/">brag
document</a> to reflecting on what work I felt I repeated a lot and whether
there&rsquo;s anything there to spend time on in the future. Pretty much,
what annoyed me when working and can I do something about it?</p>
<p>If I come up with something that I can&rsquo;t deal with right now then I&rsquo;ll
record it in Roam under <code>#hack-idea</code>, whether it&rsquo;s Friday or not, and when I
feel like hacking on something I&rsquo;ll look there. Because sometimes you just
need something quick to hack on. 🙂</p>
<p>I&rsquo;d love to hear what your favorite day-to-day automations are
on <a href="https://hachyderm.io/@gaqzi">Mastodon</a>!</p>
]]></content:encoded></item><item><title>How to make Docker resume downloads …download that final 100KB and not 200MB again</title><link>https://bjorn.now/blog/2024/02/01/how-to-make-docker-pull-resume-layer-downloads/?utm_medium=feed</link><pubDate>Thu, 01 Feb 2024 17:00:00 +0700</pubDate><guid>https://bjorn.now/blog/2024/02/01/how-to-make-docker-pull-resume-layer-downloads/</guid><description>In the Docker Desktop app you can go into Features in Development and check Use containerd for pulling and storing images.
Or you can do add the following to Docker’s daemon.json file:
{ "features": { "containerd-snapshotter": true } } This comes from a comment in a ticket for resuming downloads when they fail.</description><content:encoded><![CDATA[<p>In the Docker Desktop app you can go into <code>Features in Development</code> and check
<code>Use containerd for pulling and storing images</code>.</p>
<p>Or you can do add the following to Docker&rsquo;s <code>daemon.json</code> file:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="s2">&#34;features&#34;</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="s2">&#34;containerd-snapshotter&#34;</span><span class="o">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div>
</div>
<p>This comes from <a href="https://github.com/docker/for-linux/issues/1187#issuecomment-1457279396">a comment</a> in a ticket for <a href="https://github.com/docker/for-linux/issues/1187">resuming downloads when they
fail.</a></p>
]]></content:encoded></item><item><title>Sticky blocks in Roam — floating along in your sidebar</title><link>https://bjorn.now/blog/2022/02/05/sticky-blocks-in-roam-research/?utm_medium=feed</link><pubDate>Sat, 05 Feb 2022 16:30:00 +0800</pubDate><guid>https://bjorn.now/blog/2022/02/05/sticky-blocks-in-roam-research/</guid><description>I use Roam Research as my primary way of thinking and keeping track of tasks. My current workflow has me creating a list of all tasks I want to get done, and then I drag them to either Done or some follow-up/waiting area for future action. So I only see things I can act on now.
My list of things to action can get quite long, and when I’m processing follow-up items, I would have a hard time dragging them to Done because it was too far away in the sidebar. So I wished I would make the Done float with me, so I could always have a quick way of pulling it there.</description><content:encoded><![CDATA[<p>I use <a href="https://roamresearch.com/">Roam Research</a> as my primary way of thinking and keeping track of
tasks. My current workflow has me creating a list of all tasks I want
to get done, and then I drag them to either <code>Done</code> or some follow-up/waiting
area for future action. So I only see things I can act on now.</p>
<p>My list of things to action can get quite long, and when I&rsquo;m processing
follow-up items, I would have a hard time dragging them to <code>Done</code> because it
was too far away in the sidebar. So I wished I would make the <code>Done</code> float
with me, so I could always have a quick way of pulling it there.</p>
<p>While looking at the custom styling in the <a href="https://twitter.com/RoamBookClub">Roam Book Club</a> graph, I found
the <code>#sticky</code> tag, which will make a block sticky over the children in the
block. So I took that CSS and modified it slightly to support making a
block float, so I could have it stay with me in the sidebar.</p>
<p>An example of how it looks in my sidebar before my new tags:
<figure><img src="/img/2022/02/05/01-bare-listing.png"
    alt="Unmodified list">
</figure>
</p>
<p>With the <code>#sticky</code> tag from the Roam Book Club, I can make for example
<code>Tasks</code> float when I&rsquo;m scrolling inside the tasks. This can be super helpful
for keeping track of where you are (they use it for daily chat pages) but
not quite what I need:
<figure><img src="/img/2022/02/05/02-sticky.png"
    alt="#sticky">
</figure>
</p>
<p>Introducing <code>#sticky-block</code>, which will make the block and all its children
float along at the top of the page, so I can always drag things there quickly:
<figure><img src="/img/2022/02/05/03-sticky-block.png"
    alt="#sticky-block">
</figure>
</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-css" data-lang="css"><span class="line"><span class="cl"><span class="c">/* To make blocks float, a constant in the sidebar */</span>
</span></span><span class="line"><span class="cl"><span class="p">.</span><span class="nc">roam-block-container</span><span class="o">[</span><span class="nt">data-page-links</span><span class="o">*=</span><span class="s2">&#34;sticky-block&#34;</span><span class="o">]</span>
</span></span><span class="line"><span class="cl"><span class="c">/* To make the a block float over its children. 
</span></span></span><span class="line"><span class="cl"><span class="c">   So you see which block you&#39;re currently inside.  
</span></span></span><span class="line"><span class="cl"><span class="c">   The weird \&#34; is because it would match both sticky and stick-block and   
</span></span></span><span class="line"><span class="cl"><span class="c">   double up the rendering. 
</span></span></span><span class="line"><span class="cl"><span class="c">   */</span>
</span></span><span class="line"><span class="cl"><span class="o">,</span> <span class="p">.</span><span class="nc">roam-block-container</span><span class="o">[</span><span class="nt">data-page-links</span><span class="o">*=</span><span class="s2">&#34;sticky\&#34;&#34;</span><span class="o">]</span> <span class="o">&gt;</span> <span class="p">.</span><span class="nc">rm-block-main</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="k">position</span><span class="p">:</span> <span class="kc">sticky</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">top</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">z-index</span><span class="p">:</span> <span class="mi">11</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">background</span><span class="p">:</span> <span class="kc">white</span><span class="p">;</span> <span class="c">/* Might have to be adjusted for your theme */</span>
</span></span><span class="line"><span class="cl">  <span class="k">padding-top</span><span class="p">:</span> <span class="mi">4</span><span class="kt">px</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">padding-bottom</span><span class="p">:</span> <span class="mi">2</span><span class="kt">px</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">margin-bottom</span><span class="p">:</span> <span class="mi">10</span><span class="kt">px</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">box-shadow</span><span class="p">:</span> 
</span></span><span class="line"><span class="cl">    <span class="mi">0</span> <span class="mi">1</span><span class="kt">px</span> <span class="mi">1</span><span class="kt">px</span> <span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.034</span><span class="p">),</span> 
</span></span><span class="line"><span class="cl">    <span class="mi">0</span> <span class="mi">1</span><span class="kt">px</span> <span class="mi">1</span><span class="kt">px</span> <span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.048</span><span class="p">),</span> 
</span></span><span class="line"><span class="cl">    <span class="mi">0</span> <span class="mf">12.5</span><span class="kt">px</span> <span class="mi">10</span><span class="kt">px</span> <span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">),</span> 
</span></span><span class="line"><span class="cl">    <span class="mi">0</span> <span class="mf">12.3</span><span class="kt">px</span> <span class="mf">7.9</span><span class="kt">px</span> <span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.072</span><span class="p">),</span> 
</span></span><span class="line"><span class="cl">    <span class="mi">0</span> <span class="mf">7.8</span><span class="kt">px</span> <span class="mf">10.4</span><span class="kt">px</span> <span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.086</span><span class="p">),</span> 
</span></span><span class="line"><span class="cl">    <span class="mi">0</span> <span class="mi">5</span><span class="kt">px</span> <span class="mi">120</span><span class="kt">px</span> <span class="nb">rgba</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.12</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c">/* Hides the tag since it&#39;s not important in the output, and there is 
</span></span></span><span class="line"><span class="cl"><span class="c">special styling so it&#39;s clear that something extra is going on. */</span>
</span></span><span class="line"><span class="cl"><span class="nt">span</span><span class="p">.</span><span class="nc">rm-page-ref</span><span class="o">[</span><span class="nt">data-tag</span><span class="o">=</span><span class="s2">&#34;sticky-block&#34;</span><span class="o">],</span>
</span></span><span class="line"><span class="cl"><span class="nt">span</span><span class="p">.</span><span class="nc">rm-page-ref</span><span class="o">[</span><span class="nt">data-tag</span><span class="o">=</span><span class="s2">&#34;sticky&#34;</span><span class="o">]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="k">display</span><span class="p">:</span> <span class="kc">none</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div>
</div>
<p><strong>Note:</strong> This CSS currently does not support having both <code>#sticky-block</code> and
<code>#sticky</code> for the same page, they will overlap each other, and the second
element will block the first. I don&rsquo;t currently need this, so I haven&rsquo;t spent
the time. :)</p>
]]></content:encoded></item><item><title>How to find your Apple Watch when you've misplaced it — How I ended up being a sonar bear</title><link>https://bjorn.now/blog/2015/11/14/how-to-ping-a-lost-apple-watch/?utm_medium=feed</link><pubDate>Sat, 14 Nov 2015 21:03:42 +0800</pubDate><guid>https://bjorn.now/blog/2015/11/14/how-to-ping-a-lost-apple-watch/</guid><description>I just misplaced my Apple Watch in my apartment. Walking around looking for it, and getting frustrated, I was thinking, “There ought to be a way to make it make some sound, then I can play Marco Polo with the watch”. But my Google-fu failed me: no obvious way to “ping my watch”. There’s functionality for pinging the phone from the watch though.
But there’s a way to make some noise: testing out the alert volume in the companion app on the phone.</description><content:encoded><![CDATA[<p>I just misplaced my Apple Watch in my apartment. Walking around looking for it,
and getting frustrated, I was thinking, &ldquo;There ought to be a way to make it make
some sound, then I can play <a href="https://en.wikipedia.org/wiki/Marco_Polo_(game)">Marco Polo</a> with the watch&rdquo;. But my Google-fu
failed me: no obvious way to &ldquo;ping my watch&rdquo;. There&rsquo;s functionality for
<a href="https://www.youtube.com/watch?v=KYf4q4y7dM4">pinging the phone</a> from the watch though.</p>
<p>But there&rsquo;s a way to make some noise: testing out the alert volume in the
companion app on the phone.</p>
<h2 id="steps">
  Steps
  <a href="#steps" class="heading-anchor" aria-label="Direct link to Steps"><span aria-hidden="true">#</span></a>
</h2>
<ol>
<li>
<p>Verify that your Watch is paired:</p>
<ol>
<li>Settings</li>
<li>Bluetooth</li>
<li>My Devices should show your Watch:
<figure><img src="/img/2015/11/bluetooth-settings.png"
          alt="Bluetooth settings on an iPhone">
      </figure>
</li>
</ol>
</li>
<li>
<p>Open the Apple Watch app:</p>
<ol>
<li>Sounds &amp; Haptics</li>
<li>Drag the slider for alert volume to max</li>
<li>Tap the knob on the slider.<br>
The watch will make a sound every time you tap the knob.
<figure><img src="/img/2015/11/alert-volume-settings.png"
          alt="Alert volume settings">
      </figure>
</li>
</ol>
</li>
<li>
<p>Don&rsquo;t cry yourself to sleep over losing an expensive toy in the mess that is
your own apartment.</p>
</li>
</ol>
]]></content:encoded></item><item><title>Keeping your Varnish farms configuration in sync</title><link>https://bjorn.now/blog/2011/01/07/keeping-your-varnish-farm-in-sync/?utm_medium=feed</link><pubDate>Fri, 07 Jan 2011 01:21:46 +0000</pubDate><guid>https://bjorn.now/blog/2011/01/07/keeping-your-varnish-farm-in-sync/</guid><description>I spend some of my free time helping out with server administration and programming for the Swedish Pirate Party, Piratpartiet (look ma, X-Varnish), and we use Varnish for our caches. At the moment it’s just used on some of our projects, but we’re going to migrate most of our projects to be behind our Varnish caches.
The thing is though that we got two hosts running the exact same configuration, and we’d like to keep those hosts in sync. A quick search on Google gave me nothing for syncing varnish configuration over several hosts, or a farm as it were. So I took matters into my own hands and wrote varnishsync, a little bash script that uses rsync and ssh to sync the configuration folder and then to load and use the new configuration.</description><content:encoded><![CDATA[<p>I spend some of my free time helping out with server administration and
programming for the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Piratpartiet">Swedish Pirate Party</a>, <a href="http://www.piratpartiet.se/">Piratpartiet</a> (<em>look ma</em>,
X-Varnish), and we use <a href="http://www.varnish-cache.org/">Varnish</a> for our caches. At the moment it&rsquo;s just used on
some of our projects, but we&rsquo;re going to migrate most of our projects to be
behind our Varnish caches.</p>
<p>The thing is though that we got two hosts running the exact same configuration,
and we&rsquo;d like to keep those hosts in sync. A quick search on Google gave me
nothing for syncing varnish configuration over several hosts, or a farm as it
were. So I took matters into my own hands and wrote <a href="https://github.com/gaqzi/varnishsync">varnishsync</a>, a little bash
script that uses rsync and ssh to sync the configuration folder and then to load
and use the new configuration.</p>
<p>Please have a look at the <a href="https://github.com/gaqzi/varnishsync">Github project</a> for the latest version
and usage, and if you&rsquo;ve any questions or suggestions drop a line here or on
Github.</p>
]]></content:encoded></item><item><title>How to: Setting up a Wikileaks mirror</title><link>https://bjorn.now/blog/2010/12/05/howto-setting-up-a-wikileaks-mirror/?utm_medium=feed</link><pubDate>Sun, 05 Dec 2010 21:11:18 +0000</pubDate><guid>https://bjorn.now/blog/2010/12/05/howto-setting-up-a-wikileaks-mirror/</guid><description>Yesterday I wrote a quick step-by-step guide for installing apache and setting your system up for Wikileaks mass-mirror project in Swedish and I’ve had requests for it to be translated into English.
This guide assumes you’re running Ubuntu or a Debian based system.
I’ve made a script that does all the steps below, feel free to use it!
The script: http://sanitarium.se/files/wikileaks-mirror.sh
Usage: wget http://sanitarium.se/files/wikileaks-mirror.sh &amp;&amp; chmod +x wikileaks-mirror.sh &amp;&amp; ./wikileaks-mirror.sh
Installing Apache and adding the wikileaks user # # is the prompt as root:</description><content:encoded><![CDATA[<p>Yesterday I wrote a quick step-by-step guide for installing apache and setting
your system up for <a href="http://213.251.145.96/Mass-mirroring-Wikileaks.html">Wikileaks mass-mirror project</a> in Swedish and
I&rsquo;ve had requests for it to be translated into English.</p>
<p>This guide assumes you&rsquo;re running Ubuntu or a Debian based system.</p>
<p>I&rsquo;ve made a script that does all the steps below, feel free to use it!<br>
The script: <a href="http://sanitarium.se/files/wikileaks-mirror.sh">http://sanitarium.se/files/wikileaks-mirror.sh</a><br>
Usage: <code>wget http://sanitarium.se/files/wikileaks-mirror.sh &amp;&amp; chmod +x wikileaks-mirror.sh &amp;&amp; ./wikileaks-mirror.sh</code></p>
<h1 id="installing-apache-and-adding-the-wikileaks-user">
  Installing Apache and adding the wikileaks user
  <a href="#installing-apache-and-adding-the-wikileaks-user" class="heading-anchor" aria-label="Direct link to Installing Apache and adding the wikileaks user"><span aria-hidden="true">#</span></a>
</h1>
<p><code>#</code> is the prompt as root:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">youruser$ sudo -s  </span></span></code></pre></div>
</div>
<p>Install apache if it&rsquo;s not installed</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># apt-get install apache2  </span></span></span></code></pre></div>
</div>
<p>Add a wikileaks user, write down where the home folder is created.</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># adduser --disabled-password wikileaks  </span>
</span></span><span class="line"><span class="cl"><span class="c1"># su wikileaks  </span>
</span></span><span class="line"><span class="cl">wikileaks$ mkdir ~/.ssh ~/www  
</span></span><span class="line"><span class="cl">wikileaks$ chmod <span class="m">0700</span> ~/.ssh  
</span></span><span class="line"><span class="cl">wikileaks$ wget http://213.251.145.96/IMG/id_rsa.pub -O ~/.ssh/authorized_keys  
</span></span><span class="line"><span class="cl">wikileaks$ <span class="nb">exit</span>  </span></span></code></pre></div>
</div>
<p>Time to add the apache site for wikileaks</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># cd /etc/apache2/sites-available/   </span>
</span></span><span class="line"><span class="cl"><span class="c1"># wget http://sanitarium.se/files/wikileaks   </span></span></span></code></pre></div>
</div>
<p>Open the file <code>wikileaks</code> with an editor and change the path to the wikileaks users home folder if it&rsquo;s not <code>/home/wikileaks</code>.<br>
This file assumes you want to host wikileaks.org, if you want to host wikileaks.yourdomain.com you&rsquo;ll need to set <code>ServerName</code> accordingly and if necessary <code>ServerAlias</code>, ServerAlias is optional and you can remove that row if you don&rsquo;t use it.<br>
When that is done you just need to activate the site in apache:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># a2ensite wikileaks  </span></span></span></code></pre></div>
</div>
<p>And reload apache so it knows that the new site has been added:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># /etc/init.d/apache2 reload  </span></span></span></code></pre></div>
</div>
<p>The <code>wikileaks</code> file downloaded from this server looks like this:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&lt;VirtualHost *:80&gt;
</span></span><span class="line"><span class="cl">    DocumentRoot /home/wikileaks/www
</span></span><span class="line"><span class="cl">    ServerName wikileaks.org
</span></span><span class="line"><span class="cl">    ServerAlias www.wikileaks.org
</span></span><span class="line"><span class="cl">    ErrorLog /dev/null
</span></span><span class="line"><span class="cl">    CustomLog /dev/null common
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">    &lt;Directory /home/wikileaks/www&gt;
</span></span><span class="line"><span class="cl">        AllowOverride None
</span></span><span class="line"><span class="cl">    &lt;/Directory&gt;
</span></span><span class="line"><span class="cl">&lt;/VirtualHost&gt;</span></span></code></pre></div>
</div>
<h1 id="now-tell-wikileaks-about-your-mirror">
  Now tell Wikileaks about your mirror
  <a href="#now-tell-wikileaks-about-your-mirror" class="heading-anchor" aria-label="Direct link to Now tell Wikileaks about your mirror"><span aria-hidden="true">#</span></a>
</h1>
<p>Go to the <a href="http://213.251.145.96/Mass-mirroring-Wikileaks.html">form</a> and fill it as the picture, set the IP-address of your server in the IP-field:<br>
<figure><img src="/img/2010/installning-hos-wikileaks.png"
    alt="Wikileaks mirror settings">
</figure>
</p>
<p>If you&rsquo;re having any troubles don&rsquo;t hesitate to ask in the comments!</p>
]]></content:encoded></item><item><title>How to: Sätta upp en Wikileaksspegling</title><link>https://bjorn.now/blog/2010/12/04/howto-satta-upp-en-wikileaksspegling/?utm_medium=feed</link><pubDate>Sat, 04 Dec 2010 21:27:26 +0000</pubDate><guid>https://bjorn.now/blog/2010/12/04/howto-satta-upp-en-wikileaksspegling/</guid><description>A translation of this post is available in English.
En kommentar i Rick Falkvinges inlägg Fullt krig om informationen så efterfrågades en snabbguide för att dra igång en Wikileaksspegling i ett vanligt Linuxssystem.
Jag utgår från Ubuntu eftersom det är vanligt och vad jag själv använder.
Uppdatering 2010-12-05: Jag har gjort ett script som utför alla stegen nedan, använd gärna det!
Filen: http://sanitarium.se/files/wikileaks-mirror.sh
Användning: wget http://sanitarium.se/files/wikileaks-mirror.sh &amp;&amp; chmod +x wikileaks-mirror.sh &amp;&amp; ./wikileaks-mirror.sh
Installera Apache # # är prompten som root:</description><content:encoded><![CDATA[<p><a href="/blog/2010/12/05/howto-setting-up-a-wikileaks-mirror/">A translation of this post is available in English.</a></p>
<p>En <a href="http://rickfalkvinge.se/2010/12/04/fullt-krig-om-informationen/#comment-57303">kommentar</a> i Rick Falkvinges inlägg <a href="http://rickfalkvinge.se/2010/12/04/fullt-krig-om-informationen/">Fullt krig om informationen</a>
så efterfrågades en snabbguide för att dra igång en Wikileaksspegling i ett
vanligt Linuxssystem.</p>
<p>Jag utgår från Ubuntu eftersom det är vanligt och vad jag själv använder.</p>
<p><strong>Uppdatering 2010-12-05:</strong> Jag har gjort ett script som utför alla stegen nedan, använd gärna det!<br>
Filen: <a href="http://sanitarium.se/files/wikileaks-mirror.sh">http://sanitarium.se/files/wikileaks-mirror.sh</a><br>
Användning: <code>wget http://sanitarium.se/files/wikileaks-mirror.sh &amp;&amp; chmod +x wikileaks-mirror.sh &amp;&amp; ./wikileaks-mirror.sh</code></p>
<h1 id="installera-apache">
  Installera Apache
  <a href="#installera-apache" class="heading-anchor" aria-label="Direct link to Installera Apache"><span aria-hidden="true">#</span></a>
</h1>
<p><code>#</code> är prompten som root:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">dinanvändare$ sudo -s  </span></span></code></pre></div>
</div>
<p>Installera apache om det inte är installerat</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># apt-get install apache2  </span></span></span></code></pre></div>
</div>
<p>Lägg till en användare för Wikileak och anteckna var wikileaks hemmap skapas!</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># adduser --disabled-password wikileaks  </span>
</span></span><span class="line"><span class="cl"><span class="c1"># su wikileaks  </span>
</span></span><span class="line"><span class="cl">wikileaks$ mkdir ~/.ssh ~/www  
</span></span><span class="line"><span class="cl">wikileaks$ chmod <span class="m">0700</span> ~/.ssh  
</span></span><span class="line"><span class="cl">wikileaks$ wget http://213.251.145.96/IMG/id_rsa.pub -O ~/.ssh/authorized_keys  
</span></span><span class="line"><span class="cl">wikileaks$ <span class="nb">exit</span>  </span></span></code></pre></div>
</div>
<p>Nu är det dags att lägga till siten för wikileaks</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># cd /etc/apache2/sites-available/   </span>
</span></span><span class="line"><span class="cl"><span class="c1"># wget http://sanitarium.se/files/wikileaks   </span></span></span></code></pre></div>
</div>
<p>Öppna filen <code>wikileaks</code> med en editor och ändra sökvägen till användaren wikileaks hemmapp om det är något annat än <code>/home/wikileaks</code>.<br>
Den här filen förutsätter att du vill hosta wikileaks.org, om du vill hosta wikileaks.dindomän.se eller något sådant så får du ändra ServerName och eventuellt ServerAlias.<br>
När det är klart är det bara att aktivera siten för apache:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># a2ensite wikileaks  </span></span></span></code></pre></div>
</div>
<p>Och till sist ladda om apache så det är redo att ta emot information:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># /etc/init.d/apache2 reload  </span></span></span></code></pre></div>
</div>
<p>Innehållet i filen <code>wikileaks</code> som du tankar från den här servern är:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&lt;VirtualHost *:80&gt;
</span></span><span class="line"><span class="cl">    DocumentRoot /home/wikileaks/www
</span></span><span class="line"><span class="cl">    ServerName wikileaks.org
</span></span><span class="line"><span class="cl">    ServerAlias www.wikileaks.org
</span></span><span class="line"><span class="cl">    ErrorLog /dev/null
</span></span><span class="line"><span class="cl">    CustomLog /dev/null common
</span></span><span class="line"><span class="cl">    
</span></span><span class="line"><span class="cl">    &lt;Directory /home/wikileaks/www&gt;
</span></span><span class="line"><span class="cl">        AllowOverride None
</span></span><span class="line"><span class="cl">    &lt;/Directory&gt;
</span></span><span class="line"><span class="cl">&lt;/VirtualHost&gt;</span></span></code></pre></div>
</div>
<h1 id="hur-du-säger-till-wikileaks-att-allt-är-klart">
  Hur du säger till Wikileaks att allt är klart
  <a href="#hur-du-s%c3%a4ger-till-wikileaks-att-allt-%c3%a4r-klart" class="heading-anchor" aria-label="Direct link to Hur du säger till Wikileaks att allt är klart"><span aria-hidden="true">#</span></a>
</h1>
<p>Surfa in på <a href="http://213.251.145.96/Mass-mirroring-Wikileaks.html">formuläret</a> och fyll i det enligt nedan, byt ut ip-adress mot IP:t för din server:<br>
<figure><img src="/img/2010/installning-hos-wikileaks.png"
    alt="Wikileaks mirror settings">
</figure>
</p>
<p>Om det är några oklarheter eller funderingar så fråga på i kommentarsfältet
nedan så ska jag försöka hjälpa till att reda ut!</p>
<p><strong>Uppdatering:</strong> <a href="http://twitter.com/rouhivuori">Henrik Rouhivuori</a>
upplyste om att <code>aptitude</code> inte finns i Ubuntu 10.10 så jag ändrade till <code>apt-get</code>
istället. Övertydligt att jag fortfarande hänger på 10.04. :)</p>
<p><strong>Uppdatering 2:</strong>
Henrik Holst
berättade att du kan välja att inaktivera lösenordsinloggning när du skapar
nya användare, så nu görs det istället för att rekommendera ett slumpmässigt
långt lösenord!</p>
<p><strong>Uppdatering 3:</strong>
David Vrensk
påminner om att <code>sshd</code> är lite petig på att det bara är användaren som ska ha
rättigheter till <code>.ssh</code>-mappen.</p>
<p><strong>Uppdatering 4:</strong> Av bara farten så hade jag missat att lägga till att man
måste skapa mappen <code>www</code> som wikileaks-filen pekar på, samt <code>common</code> efter
loggraden. Tack till <a href="http://harfagre.wordpress.com/">Gustav Wetter</a> som jobbet igenom hela guiden!</p>
]]></content:encoded></item><item><title>How to disable bold fonts in xterm — Why sometimes repeating yourself really does get the message through</title><link>https://bjorn.now/blog/2010/02/21/how-to-disable-bold-fonts-in-xterm/?utm_medium=feed</link><pubDate>Sun, 21 Feb 2010 22:36:19 +0000</pubDate><guid>https://bjorn.now/blog/2010/02/21/how-to-disable-bold-fonts-in-xterm/</guid><description>I’ve so far in all my travels never found a terminal I like better than xterm, maybe urxvt, but I’ve had a problem disabling bold fonts for a very long time. Update: Seems this is a known bug for xterm.
There are a lot of X resource configuration options that makes you think you can disable bold fonts, but alas, I’ve had no luck with any of them. But if you set the same font for both normal and bold fonts it’ll work! This little gem of knowledge I found as an off-hand remark on a configuration page by Emil Mikulic, thank you!</description><content:encoded><![CDATA[<p>I&rsquo;ve so far in all my travels never found a terminal I like better than <a href="http://en.wikipedia.org/wiki/Xterm">xterm</a>, maybe <a href="http://en.wikipedia.org/wiki/Rxvt-unicode">urxvt</a>, but I&rsquo;ve had a problem disabling bold fonts for a very long time. <strong>Update:</strong> Seems this is a <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=347790">known bug for xterm</a>.</p>
<p>There are a lot of X resource configuration options that makes you think you can disable bold fonts, but alas, I&rsquo;ve had no luck with any of them. But if you set <strong>the same font</strong> for both normal and bold fonts it&rsquo;ll work! This little gem of knowledge I found as an off-hand remark on a <a href="http://dmr.ath.cx/notes/xterm.html">configuration page</a> by <a href="http://dmr.ath.cx/">Emil Mikulic</a>, thank you!</p>
<p>I like the normal <code>fixed</code> font, I&rsquo;ve tried many terminal fonts but I&rsquo;ve always gotten back to it. So I simply tucked:</p>
<pre><code>xterm*font: fixed
xterm*boldFont: fixed
</code></pre>
<p>Into my <code>~/.Xresources</code> and afterwards ran <code>xrdb -load ~/.Xresources</code> and started up a new xterm loaded with awesomeness!</p>
<figure><img src="/img/2010/xterms.png"
    alt="xterm with bold font and xterm without bold font">
</figure>

<p>The before and after shot.</p>
]]></content:encoded></item></channel></rss>