<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Erik André Jakobsen</title><description>The personal site of Erik André Jakobsen</description><link>https://eaj.no/</link><item><title>Open Graph images with Astro and Typst</title><link>https://eaj.no/posts/open-graph-images-with-typst</link><guid isPermaLink="true">https://eaj.no/posts/open-graph-images-with-typst</guid><description>Typst is good for more than academic papers and resumes.</description><pubDate>Mon, 09 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Links to blog articles look better when they’re accompanied by an image.
If the HTML head has a &lt;code&gt;meta&lt;/code&gt; tag like this, it will happen automatically:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;meta&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt;  property&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;og:image&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt;  content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;https://eaj.no/posts/graph-images-with-typst/og.png&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My previous, tedious workflow for these kinds of images was to go to &lt;a href=&quot;https://unsplash.com&quot;&gt;unspash.com&lt;/a&gt;,
search for something like &lt;em&gt;structure&lt;/em&gt; or &lt;em&gt;archive&lt;/em&gt;, and then select an image
I thought would fit the theme of the post. Being both boring and error-prone,
I abandonded that process and set up a pipeline that generates image cards at build-time instead.
They look like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/posts/open-graph-images-with-typst/og.png&quot; alt=&quot;The generated OpenGraph image for this blog post&quot;&gt;&lt;/p&gt;
&lt;p&gt;Let me show you how I did it.&lt;/p&gt;
&lt;h2 id=&quot;typst&quot;&gt;Typst&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://typst.app&quot;&gt;Typst&lt;/a&gt; is a tool that generates high-quality documents from a simple markup language.
A lovechild of &lt;a href=&quot;https://en.wikipedia.org/wiki/LaTeX&quot;&gt;LaTeX&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Markdown&quot;&gt;Markdown&lt;/a&gt;,
it works great for math whilst also keeping the day-to-day text formatting syntax bearable.
As a small taste, this snippet (adapted from &lt;a href=&quot;https://github.com/typst/typst/blob/84cca406aafe7f830ed3f37f1cc6f0c8b6b65a03/README.md&quot;&gt;the Typst README&lt;/a&gt;)&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;typ&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#set&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; page&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 10cm&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; height&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; auto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; margin&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1cm&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#set&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; heading&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;numbering&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;I.&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#let&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fib_1 &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#let&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fib_2 &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-light-font-weight:bold;--shiki-dark:#9CABCA;--shiki-dark-font-weight:inherit&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-light-font-weight:bold;--shiki-dark:#98BB6C;--shiki-dark-font-weight:inherit&quot;&gt; The Fibonacci sequence&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;The Fibonacci sequence is defined through the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;recurrence relation &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;n = F&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;n-1&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; + F&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;n-2&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;with &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;1 = #fib_1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; and &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;F&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;2 = #fib_2&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;It can also be expressed in _closed form:_&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  F&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;n = &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;1 &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; sqrt&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; phi&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, quad&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  phi&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;alt = (1 + &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;sqrt&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; 2.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;$&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;produces this fine document:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;The output of typst compile --format png --ppi 144 typst-example.typ&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;567&quot; height=&quot;334&quot; src=&quot;/_astro/typst-example.5LnWMFjg_Zy2nPw.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;By default the &lt;code&gt;typst&lt;/code&gt; CLI will create a PDF, but it can also make PNGs. The above image was created with the command&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;typst&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; compile&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#7FB4CA&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#98BB6C&quot;&gt;    --format&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; png&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#7FB4CA&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#98BB6C&quot;&gt;    --ppi&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 250&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#7FB4CA&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;    typst-example.typ&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But if you’d rather create something with a bit more pizzazz, by all means. How about&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;typ&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#set&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; page&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1200pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; height&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 630pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; margin&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 80pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt; rgb&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;#FF1493&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#set&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Comic Sans MS&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; white&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;no&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;#grid&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  rows&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1fr&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; auto&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;  align&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;left &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; horizon&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 72pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; weight&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 800&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Typst very nice&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  })&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;  text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Would typst again&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which yields&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;This is clearly much better&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2400&quot; height=&quot;1260&quot; src=&quot;/_astro/fancy-typst.BxEfxVjE_8ItYQ.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;Fantastic.&lt;/p&gt;
&lt;p&gt;If all of my posts were titled &lt;em&gt;“Typst very nice”,&lt;/em&gt; we’d be done, but, alas.
Luckily, typst accepts inputs to a document with &lt;code&gt;--input key=value&lt;/code&gt;,
which is put in a &lt;code&gt;sys.inputs&lt;/code&gt; dictionary for the template to read.
So the template becomes&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;typ&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#set&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; page&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1200pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; height&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 630pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; margin&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 80pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt; rgb&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;#FF1493&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#set&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;font&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Comic Sans MS&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; white&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;no&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;#let&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; title &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;inputs&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;at&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;You forgot the title :(&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;// Reading the input here ☝️&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;#grid&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  rows&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1fr&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; auto&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;  align&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;left &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; horizon&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt; if&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; title&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 70&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt; else&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 72pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      weight&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 800&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      title&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  })&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;  text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24pt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Would typst again&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which, when rendered with&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;typst&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; compile&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#7FB4CA&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#98BB6C&quot;&gt;    --format&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; png&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#7FB4CA&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#98BB6C&quot;&gt;    --ppi&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 144&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#7FB4CA&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#98BB6C&quot;&gt;    --input&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; title=&quot;Look ma, from the CLI!&quot;&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; fancy-typst-with-input.typ&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;becomes&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;It’s … perfect.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2400&quot; height=&quot;1260&quot; src=&quot;/_astro/fancy-typst-with-input.B9yxbOiI_1D5FbV.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;Perfection.&lt;/p&gt;
&lt;p&gt;Let’s move on to generating the images at build-time.&lt;/p&gt;
&lt;h2 id=&quot;astro&quot;&gt;Astro&lt;/h2&gt;
&lt;p&gt;This site is built with &lt;a href=&quot;https://astro.build&quot;&gt;Astro, a static site generator&lt;/a&gt;.
Articles are written in Markdown, which is then bundled into a
&lt;a href=&quot;https://docs.astro.build/en/guides/content-collections/&quot;&gt;Content Collection&lt;/a&gt;
by Astro. The details are irrelevant, what matters is that this lets me
define metadata which I can query through a Javascript API.&lt;/p&gt;
&lt;p&gt;The source code for the page template is at &lt;code&gt;src/pages/posts/[id].astro&lt;/code&gt;.
There are a few notable things about this file path:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;That it is in the &lt;code&gt;src/pages/&lt;/code&gt; directory tells Astro that this should be rendered as a page.&lt;/li&gt;
&lt;li&gt;The remainder of the path, &lt;code&gt;/posts/[id]&lt;/code&gt;, tells Astro where to put the page.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;[id]&lt;/code&gt; being in brackets means &lt;code&gt;id&lt;/code&gt; is a dynamic parameter which must be defined at build time.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In other words, Astro needs to know every ID when building the site—it can’t generate infinitely many
IDs. A function called &lt;code&gt;getStaticPaths&lt;/code&gt; exported from the template defines the set:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ts&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; GetStaticPathsResult&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;astro&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; getCollection&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;astro:content&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getStaticPaths&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Promise&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;GetStaticPathsResult&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; posts &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getCollection&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;posts&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; posts&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    params&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; post&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    props&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; post &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }))&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That is, fetch every article, and use its &lt;code&gt;id&lt;/code&gt; as the &lt;code&gt;id&lt;/code&gt; parameter.
This is the object returned for the current page:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ts&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;  params&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;open-graph-images-with-typst&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;  props&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; post&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;    /* Everything the template needs to render a post */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default Astro will generate an HTML file, but it can also return other
kinds of responses. Together with this blog post I also put
the following snippet at &lt;code&gt;src/pages/api/build-info.json.ts&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ts&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; APIRoute&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;astro&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; GET &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; data &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getLatestJjMetadata&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Response&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;JSON&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;stringify&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    headers&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;content-type&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;application/json&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  })&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; satisfies&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; APIRoute&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getLatestJjMetadata&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Promise&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  changeId&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; string&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  committedAt&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;  // Implementation cut for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that there are no parameters in brackets, so this will create a
single JSON file at build time:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;❯&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; tree&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; dist/api&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;dist/api&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;└──&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; build-info.json&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And just like that, this blog &lt;a href=&quot;/api/build-info.json&quot;&gt;now has a JSON api&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that the file extension is included in the path, i.e. &lt;code&gt;.json.ts&lt;/code&gt;. This is
because when the dev server is running it sets the appropriate &lt;code&gt;content-type&lt;/code&gt; header
to let the browser know what to do with the response, but once the page is built
the result is a file with &lt;code&gt;.ts&lt;/code&gt; stripped off. The browser
then interprets the remaining file extension to know what content to expect at the path.&lt;/p&gt;
&lt;p&gt;You probably see where this is going: Create an API route which takes a post ID
as a parameter and ends in &lt;code&gt;.png.ts&lt;/code&gt;, gets the post title using the Astro Content Collection API,
generates an image, and returns it in a response with the appropriate &lt;code&gt;content-type&lt;/code&gt; header.&lt;/p&gt;
&lt;p&gt;You got it. Here’s the open graph image endpoint in its entirety, defined at
&lt;code&gt;src/pages/posts/[id]/og.png.ts&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ts&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; APIRoute&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; GetStaticPaths&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; InferGetStaticPropsType&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;astro&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; getCollection&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;astro:content&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; execFile&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;node:child_process&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; promisify&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;node:util&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; OPEN_GRAPH_TEMPLATE_PATH&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;@/utils&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; execFileAsync &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; promisify&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;execFile&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; getStaticPaths &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; posts &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getCollection&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;posts&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; posts&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    params&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; post&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    props&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; title&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; post&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }))&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; satisfies&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; GetStaticPaths&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Props&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; InferGetStaticPropsType&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;typeof&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; getStaticPaths&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; GET &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt; props &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; stdout &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; execFileAsync&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;    &quot;typst&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      &quot;compile&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      OPEN_GRAPH_TEMPLATE_PATH&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      &quot;-&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      &quot;--format&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      &quot;png&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      &quot;--ppi&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      &quot;144&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      &quot;--input&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;      `title=&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;props&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    ]&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; encoding&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;buffer&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Response&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Uint8Array&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;stdout&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    headers&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;content-type&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;image/png&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  })&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; satisfies&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; APIRoute&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Props&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now go to &lt;code&gt;eaj.no/posts/open-graph-images-with-typst/og.png&lt;/code&gt;, et voilà:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/posts/open-graph-images-with-typst/og.png&quot; alt=&quot;The generated OpenGraph image from the above code&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;extra-credit-cache-busting&quot;&gt;Extra credit: Cache busting&lt;/h2&gt;
&lt;p&gt;When a sharing platform loads the image for an article, it might very well be cached for a long time.
Even if you decide to completely redo your entire branding, LinkedIn might insist on displaying your
previous hideous design unless you handle it. A simple trick is to use a throwaway
search parameter that doesn’t do anything other than make the URL unique:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/some-image.png?v=whatever&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A straightforward (but silly) solution for creating this parameter is to generate a random string of characters every time
the site is built, ensuring your image is always fetched anew.
I landed on using a hash of the typst template and the title, so that the cache key only
changes whenever the actual content does:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ts&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; createHash&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;node:crypto&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; readFileSync&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;node:fs&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; openGraphImageCacheBuster&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; string&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; string&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; template &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; readFileSync&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;OPEN_GRAPH_TEMPLATE_PATH&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; createHash&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;sha256&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;    .&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;template&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;    .&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;    .&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;digest&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;hex&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;    .&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;slice&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>Om å få sine egne greier på internett</title><link>https://eaj.no/posts/om-a-fa-sine-egne-greier-pa-internett</link><guid isPermaLink="true">https://eaj.no/posts/om-a-fa-sine-egne-greier-pa-internett</guid><description>Legg ned kubernetesen, det finnes ingen &lt;em&gt;best practice&lt;/em&gt; der vi skal.</description><pubDate>Fri, 13 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;For nesten seks år siden skrev jeg &lt;a href=&quot;/posts/why-you-should-learn-plain-html-and-css-first/&quot;&gt;min aller første blogpost&lt;/a&gt;,
hvor jeg argumenterte for at før en kaster seg hodestups inn i det siste og heteste
frontendrammeverket, så burde en ha litt peiling på mer grunnleggende
HTML og CSS – de fundamentale byggesteinene. Jeg har sagt mye dumt i livet,
men dette er vel noe av det mer oppegående. Jeg mener fremdeles at det er en god idé, jeg
er glad jeg gjorde det selv, og jeg prioriterer fremdeles å se &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Popover_API&quot;&gt;hva som er mulig med HTML
og CSS&lt;/a&gt;
før jeg skriver Javascript for å løse en oppgave.&lt;/p&gt;
&lt;p&gt;Men når støvet har lagt seg, tastaturet har fått hvile, og det har vært på tide
å sende all denne HTML-en, CSS-en og kanskje til og med Javascripten,
til andres nettlesere, da har jeg gått i akkurat samme felle som jeg advarte
mot for seks år siden: Hoppet bukk over grunnmuren
og kjørt rett på click-to-deploy løsninger som Netlify, Vercel,
Heroku og lignende.&lt;/p&gt;
&lt;p&gt;På et vis er det forståelig: Jeg bet allerede over for mye nytt å lære meg på
en gang den gangen for lenge siden, om jeg ikke skulle tukle med serverdrift også.
Og &lt;em&gt;GitHub Pages&lt;/em&gt; bare funker!&lt;/p&gt;
&lt;p&gt;Og senere, når jeg begynte å få betalt for å drive med utvikling,
så kom jeg som regel inn i prosjekter hvor vi enten kjørte på en Platform as a
Service, øh, &lt;em&gt;-plattform,&lt;/em&gt; eller så var det en egen avdeling i bedriften som var
ansvarlig for deploy-pipline og Kubernetes og alt sånt. Det eneste &lt;em&gt;jeg&lt;/em&gt; behøvde
å gjøre var å skrive &lt;code&gt;git push&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;nok-er-nok&quot;&gt;Nok er nok&lt;/h2&gt;
&lt;p&gt;Jeg har i det siste &lt;a href=&quot;/posts/hei-clojure&quot;&gt;funnet glede i å lære meg Clojure&lt;/a&gt;, og
hadde hin dagen snekret sammen en pitteliten kodesnutt hvor jeg bruker http-kit
og hiccup til å vise IP-en til den besøkende. Ikke noe revolusjonerende, men
et lite lekeprosjekt som i alle fall lar meg dyppe tærne i Clojures web-vann og
kjenne på temperaturen.&lt;/p&gt;
&lt;p&gt;Etter hvert ville jeg ha dette på internett, og da
stod (egentlig satt) jeg der: Det er ikke så mange click-to-deploy tjenester
for Clojure, og jeg &lt;em&gt;nekter&lt;/em&gt; å skrive 40 linjer Docker for 20 linjer Clojure.&lt;/p&gt;
&lt;p&gt;Dette ble dråpen som fikk begeret til å renne over. Jeg leide billigste mulige
server fra Hetzner, sa ja takk til Debian, gav den en SSH-nøkkel, og fikk en
IP-adresse tilbake. Jeg kopierte koden over med &lt;code&gt;rsync&lt;/code&gt;, installerte Clojure, installerte
&lt;a href=&quot;https://caddyserver.com/&quot;&gt;Caddy&lt;/a&gt; og skrev 3 linjer konfigurasjon, satte opp
&lt;code&gt;ufw&lt;/code&gt; for å ikke slippe inn hvem som helst hvor som helst, knotet meg gjennom
akkurat nok &lt;code&gt;systemd&lt;/code&gt; til å få en tjeneste opp og gå men ikke nok til å ha
sterke meninger om det, og så … &lt;a href=&quot;https://ip.eaj.no/&quot;&gt;bare virket det&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Og når jeg først var så godt i gang så bygget jeg bloggen på min lokale maskin
(den benytter &lt;a href=&quot;https://astro.build/&quot;&gt;Astro&lt;/a&gt; til å lage en site som kun er
&lt;a href=&quot;https://parenteser.mattilsynet.io/lange-flate-filer/&quot;&gt;lange flate filer&lt;/a&gt;),
kopierte &lt;code&gt;dist&lt;/code&gt;-mappen til min rykende ferske server, og la til dette i &lt;code&gt;Caddyfile&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;eaj.no {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  root /var/www/blog&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  file_server&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Så var det bare å endre litt på DNS hos min domeneregistrar, og så fungerte
fader meg det også.&lt;/p&gt;
&lt;p&gt;Og la gå, dette er kanskje ikke like beinhardt som å &lt;a href=&quot;https://mirawelner.com/posts/website_howto.html&quot;&gt;ha hele dritten på en
Raspberry Pi skapet&lt;/a&gt;, men
det er jo likevel litt tilfredsstillende at ordene du leser nå har sitt
opphav fra en pitteliten VM i Finland. Og at neste gang jeg har et lite
prosjekt jeg vil dele, så vet jeg akkurat hvordan – og SQLite er helt fint,
det.&lt;/p&gt;
&lt;p&gt;Serveren har i alle fall litt å gå på.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;uptime | cut -d &apos;,&apos; -f 4-6&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  load average: 0.00, 0.00, 0.00&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item><item><title>Hei, Clojure!</title><link>https://eaj.no/posts/hei-clojure</link><guid isPermaLink="true">https://eaj.no/posts/hei-clojure</guid><description>Løse tanker etter noen uker med Clojure.</description><pubDate>Mon, 16 Feb 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;De siste ukene har jeg putlet litt med Clojure, og det er mye å like.&lt;/p&gt;
&lt;p&gt;Alt er verdier (inkludert funksjoner og ting som &lt;code&gt;if&lt;/code&gt;), verdier er uforanderlige
(&lt;em&gt;immutable,&lt;/em&gt; om du vil), vi har en pipe-makro som Elixirs &lt;code&gt;|&amp;gt;&lt;/code&gt;
(det vil si, vi har to! og det kalles ikke en &lt;em&gt;pipe macro&lt;/em&gt;, men en &lt;em&gt;thread macro&lt;/em&gt;
her til gards), og språket er dynamisk. Det siste er selvfølgelig omdiskutert,
men Clojure kler det på en måte som er vanskelig å sette fingeren på.&lt;/p&gt;
&lt;p&gt;Clojure er en Lisp, som jeg først trodde skulle være mer utfordrende enn det viste seg å være.
Det er ikke &lt;em&gt;så&lt;/em&gt; vanskelig å skrive parentesen på venstre side av funksjonsnavnet,
og når jeg fikk litt dreisen på &lt;a href=&quot;https://paredit.org/&quot;&gt;Paredit&lt;/a&gt; (ja, og så Emacs da),
gikk det fra å være esoterisk til å &lt;em&gt;føles&lt;/em&gt; rett: Som om det var slik det alltid var
meningen at kode skulle skrives.&lt;/p&gt;
&lt;p&gt;Det er også andre kvaliteter jeg ikke
forventet, men som bare gjør meg enda mer glad i språket:&lt;/p&gt;
&lt;p&gt;En er &lt;span class=&quot;small-caps&quot;&gt;repl&lt;/span&gt;-et: Jeg trodde jeg visste
hva det var. Read, Eval, Print, Loop.
Skriv litt kode inn i terminalen og se hva det blir, hurra meg rundt og
gratulerer med dagen:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;clojure&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;user=&amp;gt; &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Det der har jeg sett før, tenkte jeg.&lt;/p&gt;
&lt;p&gt;Bare at det er ikke det en &lt;em&gt;clojurian&lt;/em&gt; mener når hen snakker om sitt
elskede &lt;span class=&quot;small-caps&quot;&gt;repl&lt;/span&gt;.
Nei, i Clojure lever &lt;span class=&quot;small-caps&quot;&gt;repl&lt;/span&gt;et &lt;em&gt;rett i editoren din&lt;/em&gt;,
og lar deg kna og jobbe med koden din til du har fått den som du vil.
Vrient å forklare, men magisk når det faller på plass.&lt;/p&gt;
&lt;h2 id=&quot;fine-folk-&quot;&gt;Fine folk …&lt;/h2&gt;
&lt;p&gt;Skaperen, Rich Hickey, har &lt;a href=&quot;https://www.youtube.com/watch?v=SxdOUGdseq4&quot;&gt;flere&lt;/a&gt;
&lt;a href=&quot;https://www.youtube.com/watch?v=f84n5oFoZBc&quot;&gt;legendariske&lt;/a&gt;
&lt;a href=&quot;https://www.youtube.com/watch?v=YR5WdGrpoug&quot;&gt;foredrag&lt;/a&gt; som alle handler
mer om ideer og refleksjoner og vår relasjon til å
bruke og skape programvare, enn de handler om &lt;em&gt;the latest &lt;span class=&quot;small-caps&quot;&gt;
Blazingly Fast&lt;/span&gt; framework™.&lt;/em&gt;
Han er også opptatt av å ta imot nybegynnere med åpne armer, og &lt;a href=&quot;https://www.youtube.com/watch?v=MLDwbhuNvZo&quot;&gt;verdien
av å lære bort og å hjelpe hverandre&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Denne tenkemåten er i stor grad omfavnet av hele Clojure-fellesskapet:
&lt;a href=&quot;http://clojurians.net/&quot;&gt;Clojure-Slacken&lt;/a&gt; har for eksempel
en egen &lt;code&gt;#gratitude&lt;/code&gt;-kanal hvor det oppfordres til å offentlige takke
andre medlemmer av fellesskapet for alle bidrag og hjelp.&lt;/p&gt;
&lt;h2 id=&quot;-med-gode-ideer&quot;&gt;… med gode ideer&lt;/h2&gt;
&lt;p&gt;Heller enn å si seg fornøyd med at du må skrive Javascript for å lage en
web-app, så laget de &lt;a href=&quot;https://clojurescript.org/&quot;&gt;ClojureScript&lt;/a&gt;.
Og i stedet for å godta at &lt;code&gt;updated_at&lt;/code&gt;- og &lt;code&gt;parent_id&lt;/code&gt;-felter i en relasjonell database
er så bra som det blir, så fikk vi &lt;a href=&quot;https://www.datomic.com/&quot;&gt;Datomic&lt;/a&gt;.
Og om du vil rendre ting til en nettleser kan du bruke &lt;a href=&quot;https://github.com/weavejester/hiccup&quot;&gt;Hiccup&lt;/a&gt;,
som gjør at du heller enn å skrive&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;figure&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;image-banner&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;img&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;/elephant.jpg&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; alt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Elephant at sunset&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;figcaption&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;An elephant at sunset&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;figcaption&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;figure&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;kan skrive&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;clojure&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:figure.image-banner&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:img &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:src &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;/elephant.jpg&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;        :alt &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Elephant at sunset&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:figcaption &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;An elephant at sunset&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ved å representere DOM-treet med Clojures egne datastrukturer
har en også gitt seg selv tilgang til å bruke hele det rike
standardbiblioteket. Vakkert!&lt;/p&gt;
&lt;h2 id=&quot;et-levende-norsk-fagmiljø&quot;&gt;Et levende norsk fagmiljø&lt;/h2&gt;
&lt;p&gt;Jeg har hørt om Clojure ved flere anledninger tidligere, men fikk
for alvor øynene opp for språket etter å ha kommet over
&lt;a href=&quot;https://parenteser.mattilsynet.io/&quot;&gt;&lt;em&gt;Parenteser&lt;/em&gt;&lt;/a&gt;, en fantastisk
fin fagblogg fra Team Servering hos Mattilsynet.
Den ble startet av &lt;a href=&quot;https://magnars.com/&quot;&gt;Magnar Sveen&lt;/a&gt; og
&lt;a href=&quot;https://cjohansen.no/&quot;&gt;Christian Johansen&lt;/a&gt;, to ringrever som lenge
har jobbet med å spre det glade budskap: De står også bak
&lt;a href=&quot;https://www.zombieclj.no/&quot;&gt;ZombieClj&lt;/a&gt;, en screencast med undertittelen
&lt;em&gt;Zombier, Clojure og to tomsinger fra Østfold&lt;/em&gt; som åpenbart ikke trenger
ytterligere innsalg.&lt;/p&gt;
&lt;p&gt;Siden starten har Team Servering vokst betraktelig, og det er nå
en hel håndfull med folk som deler sine tanker om samarbeid,
utvikling, og Clojure. Alle er også å finne på &lt;code&gt;#clojure-norway&lt;/code&gt;-kanalen
på Slack, som, ikke overraskende, også er en trivelig plass.&lt;/p&gt;
&lt;p&gt;Christian er også en ildsjel som omsetter
mange av ideene til åpen kildekode, og jeg gleder meg til å bruke
&lt;a href=&quot;https://github.com/cjohansen/replicant&quot;&gt;Replicant&lt;/a&gt;
og &lt;a href=&quot;https://github.com/cjohansen/nexus&quot;&gt;Nexus&lt;/a&gt; til mitt neste web-prosjekt.
Og da er det ikke så dumt å ha &lt;a href=&quot;https://github.com/cjohansen/portfolio&quot;&gt;Portfolio&lt;/a&gt;
for å jobbe med komponent-utvikling og &lt;a href=&quot;https://github.com/cjohansen/dataspex&quot;&gt;Dataspex&lt;/a&gt;
for å følge med på data-flyten. Og ikke minst, å gjøre det hele godt
hjulpet av Magnar og resten av Team Serverings
&lt;a href=&quot;https://github.com/magnars/emacsd-reboot&quot;&gt;emacs-konfig&lt;/a&gt;, som også er villig delt.&lt;/p&gt;
&lt;p&gt;For så trivelig kan det altså være å programmere.&lt;/p&gt;
</content:encoded></item><item><title>Being very careful isn&apos;t a valid strategy</title><link>https://eaj.no/posts/being-very-careful-isnt-a-valid-strategy</link><guid isPermaLink="true">https://eaj.no/posts/being-very-careful-isnt-a-valid-strategy</guid><description>As an alternative to being very careful to not shoot yourself in the foot, may I suggest not buying a gun.</description><pubDate>Tue, 23 Dec 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Here’s a snippet of JavaScript:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; decrementHealth&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  player&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;health&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here’s how I’d write the same thing in Elixir:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; decrement_health&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;  Map&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;update!&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;1 &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And for good measure, and since I’ve just started picking it up, how about some Clojure:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;clj&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defn&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; decrement-health &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  (&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player :health dec&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The point of these examples isn’t to showcase the differences in syntax
(even though it is hard to argue against the elegance of a LISP).
The point is what happens at the call site:
The JS version modifies the original &lt;code&gt;player&lt;/code&gt; object whereas the other
versions don’t. That is, in JavaScript you’ll see&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;decrementHealth&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; // { health: 9 }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the other languages, the original player value
is unchanged:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;clj&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;user=&amp;gt; &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:health &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;#&apos;user/player&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;user=&amp;gt; &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;decrement-health&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:health &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;user=&amp;gt; player&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:health &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In contrast to the JS function,
they are both &lt;a href=&quot;https://en.wikipedia.org/wiki/Pure_function&quot;&gt;pure&lt;/a&gt;,
which makes them simpler to test, easier to reason about, and
means you can confidently call them without worrying about messing
with your program state in unintended ways.&lt;/p&gt;
&lt;p&gt;Now, it &lt;em&gt;is&lt;/em&gt; possible to write a pure JavaScript function which
does the same:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; decrementHealth&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    ...&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;health&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But what if instead of &lt;code&gt;health&lt;/code&gt; being a number, it’s an object
containing other attributes as well? Something like&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;  health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    current&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    max&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Well, then we’d have to do&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; decrementHealth&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    ...&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;      ...&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      current&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;health&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;current&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this is still messy when compared to&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; decrement_health&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;  put_in&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;current&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;health&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;current &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;clj&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defn&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; decrement-health &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;player&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  (&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;update-in&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; player &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:health :current&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dec&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and still, the point isn’t really the syntax.&lt;/p&gt;
&lt;p&gt;The point is that state modification should be intentional and obvious,
and certain tools force your hand in making it so.
If I want to have a state object that changes over time, I’ll have to
use a GenServer in Elixir, or an atom in Clojure, or stick the value in a database—all
clear signposts that this is a piece of state which will change with time.
But using a map, the most obvious data structure to group and label related
data, isn’t, and &lt;em&gt;it shouldn’t be&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;And whilst it is possible to write code that makes the same guarantees
with Javscript, or Python, or whatever mutable language with functional
capabilities you find yourself using, doing so is predicated on a strategy
of &lt;em&gt;being very careful.&lt;/em&gt; It’s the programming equivalent of pulling out as a birth
control strategy: sooner or later it will fail, and you will have to face
the consequences.&lt;/p&gt;
&lt;p&gt;At the very least, &lt;a href=&quot;https://immerjs.github.io/immer/&quot;&gt;put on a condom&lt;/a&gt;.&lt;/p&gt;
</content:encoded></item><item><title>80% of Norwegian Public Sector to Use Chainsaws by End of Year, Government Says</title><link>https://eaj.no/posts/public-sector-chainsaws</link><guid isPermaLink="true">https://eaj.no/posts/public-sector-chainsaws</guid><description>We cannot afford to be left behind as everybody else will begin using chainsaws for everything.</description><pubDate>Wed, 13 Aug 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Norway’s &lt;em&gt;Ministry of Digitalisation and Public Governance&lt;/em&gt; today announced that it would require &lt;a href=&quot;https://www.regjeringen.no/no/aktuelt/okt-bruk-av-ki-i-staten/id3097740/&quot;&gt;80% of the public sector&lt;/a&gt; to adopt &lt;a href=&quot;https://www.scottsmitelli.com/articles/large-chainsaw-model/&quot;&gt;chainsaws&lt;/a&gt; by the end of 2025.&lt;/p&gt;
&lt;p&gt;“We are very excited about the future of chainsaws” says the labour party head of the ministry, who definitely has a lot of experience with chainsaws, can definitely explain how they work, and also definitely didn’t first learn about them a few months ago at a business school breakfast seminar.&lt;/p&gt;
&lt;p&gt;“Chainsaws is a technology that has served the forestry industry for several decades, and with the latest advancements in chainsaw technology it is now possible for anyone to use one. They have become so user friendly one can become an expert in an afternoon!”&lt;/p&gt;
&lt;p&gt;When prompted to provide examples of how, say, the child welfare service would be expected to apply chainsaws in their daily operations, the ministry leader smiles, blinks, and slowly reverses out of the room.&lt;/p&gt;
&lt;p&gt;In one incident, a local government worker eager to use the new chainsaw technology &lt;a href=&quot;https://www.nrk.no/tromsogfinnmark/brukte-ki-for-a-lage-ny-skolestruktur-i-tromso_-flere-feil-oppdaget-1.17359090&quot;&gt;seriously wounded several co-workers in a horrible accident&lt;/a&gt;.
In an official statement the responisible minister of the digitalisation ministry said that &lt;a href=&quot;https://www.linkedin.com/posts/karianne-tung-021649143_troms%C3%B8-kommune-brukte-kunstig-intelligens-activity-7311361041844637696-OxW1&quot;&gt;“even though things didn’t go exactly according to plan, we applaud every effort to use the new tech.”&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The official press contact for the Ministry of Digitalisation and Public Governance has since refused to comment, referring to their &lt;a href=&quot;https://www.regjeringen.no/no/tema/statlig-forvaltning/it-politikk/KI-strategi/id2639883/&quot;&gt;online chainsaw strategy document&lt;/a&gt; for further information.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;postscript&quot;&gt;Postscript&lt;/h2&gt;
&lt;p&gt;The original concept of using chainsaws as an analogy for generative AI comes from &lt;a href=&quot;https://www.scottsmitelli.com/articles/large-chainsaw-model/&quot;&gt;this excellent essay by Scott Smitelli&lt;/a&gt;.
He has graciously allowed me to steal it for this post.&lt;/p&gt;
</content:encoded></item><item><title>A little Slack notifier in Elixir</title><link>https://eaj.no/posts/slack-messages-in-elixir</link><guid isPermaLink="true">https://eaj.no/posts/slack-messages-in-elixir</guid><description>Lots of happy little functions with pattern matching and keyword lists.</description><pubDate>Mon, 21 Jul 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I recently made a Slack bot that notifies us whenever someone fills out our lead form:&lt;/p&gt;
&lt;picture class=&quot;dark&quot; data-astro-cid-adc2dwka=&quot;true&quot;&gt;&lt;source srcset=&quot;/_astro/slack-bot-dark.Ban1Dy86_ohvAD.webp&quot; type=&quot;image/webp&quot;&gt;&lt;img src=&quot;/_astro/slack-bot-dark.Ban1Dy86_20E4qw.png&quot; alt data-astro-cid-adc2dwka=&quot;true&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1050&quot; height=&quot;318&quot;&gt;&lt;/picture&gt;&lt;picture class=&quot;light&quot; data-astro-cid-adc2dwka=&quot;true&quot;&gt;&lt;source srcset=&quot;/_astro/slack-bot-light.C3ZhUUVr_Z1FEaAk.webp&quot; type=&quot;image/webp&quot;&gt;&lt;img src=&quot;/_astro/slack-bot-light.C3ZhUUVr_2x0HSH.png&quot; alt data-astro-cid-adc2dwka=&quot;true&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1050&quot; height=&quot;318&quot;&gt;&lt;/picture&gt;
&lt;p&gt;Let me show you how it works.&lt;/p&gt;
&lt;h2 id=&quot;first-you-need-a-slack-app&quot;&gt;First you need a Slack app&lt;/h2&gt;
&lt;p&gt;Well, first you need a Slack account and a workspace, but I’ll assume you got that far already.&lt;/p&gt;
&lt;p&gt;Rather than me fumbling through how to create a Slack app here I’ll just &lt;a href=&quot;https://docs.slack.dev/quickstart&quot;&gt;give you this link to the docs&lt;/a&gt;
where they do a better job explaining it anyway.&lt;/p&gt;
&lt;p&gt;For this simple use case I’m ignoring most of their API, and the only feature we’ll be using are
&lt;a href=&quot;https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks&quot;&gt;incoming webhooks&lt;/a&gt;—that is,
we ask Slack for an endpoint, where each endpoint will correspond to a different channel in our Workspace.
When we make a &lt;code&gt;POST&lt;/code&gt; to that endpoint with our message as the payload, the message will be, err, &lt;em&gt;posted&lt;/em&gt; in
the channel belonging to that endpoint.&lt;/p&gt;
&lt;p&gt;The webhook URL is the only thing needed to post whatever in your internal Slack, so Keep It Secret, Keep It Safe.&lt;/p&gt;
&lt;h2 id=&quot;okay-i-have-a-webhook-how-do-i-send-a-message&quot;&gt;Okay, I have a webhook, how do I send a message&lt;/h2&gt;
&lt;p&gt;The simplest possible message payload is something like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;json&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#D27E99&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;message goes here&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using &lt;a href=&quot;https://httpie.io/docs/cli&quot;&gt;the excellent HTTPie CLI&lt;/a&gt; we can send a message like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;fish&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ http POST \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;      # I know I just said to keep the URL secret,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;      # but by the time you read this I&amp;#39;ll have deleted this one:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;      https&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;://hooks.slack.com/services/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 \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;      text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;what&amp;#39;s up nerds&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;HTTP&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;/1.1 200 OK&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;access-control-allow-origin&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;*&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;content-length&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;: 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;content-type&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;: text/html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# a bunch more response headers ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;ok&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;lo and behold:&lt;/p&gt;
&lt;picture class=&quot;dark&quot; data-astro-cid-adc2dwka=&quot;true&quot;&gt;&lt;source srcset=&quot;/_astro/simple-message-dark.C65Q_S8z_ZlAGn1.webp&quot; type=&quot;image/webp&quot;&gt;&lt;img src=&quot;/_astro/simple-message-dark.C65Q_S8z_YKpvO.png&quot; alt data-astro-cid-adc2dwka=&quot;true&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;572&quot; height=&quot;136&quot;&gt;&lt;/picture&gt;&lt;picture class=&quot;light&quot; data-astro-cid-adc2dwka=&quot;true&quot;&gt;&lt;source srcset=&quot;/_astro/simple-message-light.DjxVMkkB_2iD50H.webp&quot; type=&quot;image/webp&quot;&gt;&lt;img src=&quot;/_astro/simple-message-light.DjxVMkkB_Z1ATHtM.png&quot; alt data-astro-cid-adc2dwka=&quot;true&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;572&quot; height=&quot;136&quot;&gt;&lt;/picture&gt;
&lt;h2 id=&quot;booo&quot;&gt;Booo!&lt;/h2&gt;
&lt;p&gt;Got it, we want &lt;em&gt;fancy&lt;/em&gt; messages.
This is where &lt;a href=&quot;https://api.slack.com/reference/block-kit/blocks&quot;&gt;blocks&lt;/a&gt; come in.
In our payload each block is a JSON object.
For instance, this is a heading:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;json&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#D27E99&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#D27E99&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;This is important&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To send that in a message, we’d need to specify a list under the &lt;code&gt;blocks&lt;/code&gt;
attribute of our payload, which is also how we use multiple blocks:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;json&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#D27E99&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#FFA066&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#FFA066&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;This is important&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;section&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#FFA066&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#FFA066&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#9CABCA&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Has anybody seen my boat&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Saving the above JSON to a file called &lt;code&gt;message.json&lt;/code&gt; we can &lt;code&gt;POST&lt;/code&gt; it to
our webhook like so:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;fish&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ http POST \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;      https&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;://hooks.slack.com/services/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 \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      @message.json&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;HTTP&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;/1.1 200 OK&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;access-control-allow-origin&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;*&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;content-length&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;: 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;content-type&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;: text/html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# more response headers ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;ok&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and now we’re getting somewhere:&lt;/p&gt;
&lt;picture class=&quot;dark&quot; data-astro-cid-adc2dwka=&quot;true&quot;&gt;&lt;source srcset=&quot;/_astro/boat-dark.B1tNFQkj_eW0F2.webp&quot; type=&quot;image/webp&quot;&gt;&lt;img src=&quot;/_astro/boat-dark.B1tNFQkj_Z1O6kaL.png&quot; alt data-astro-cid-adc2dwka=&quot;true&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;596&quot; height=&quot;200&quot;&gt;&lt;/picture&gt;&lt;picture class=&quot;light&quot; data-astro-cid-adc2dwka=&quot;true&quot;&gt;&lt;source srcset=&quot;/_astro/boat-light.BaSD-KEA_ZhDRYF.webp&quot; type=&quot;image/webp&quot;&gt;&lt;img src=&quot;/_astro/boat-light.BaSD-KEA_1Keojz.png&quot; alt data-astro-cid-adc2dwka=&quot;true&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;596&quot; height=&quot;200&quot;&gt;&lt;/picture&gt;
&lt;h2 id=&quot;i-dont-want-to-type-all-that-out&quot;&gt;I don’t want to type all that out&lt;/h2&gt;
&lt;p&gt;Nobody does, which is why we have been gifted the &lt;a href=&quot;https://app.slack.com/block-kit-builder/&quot;&gt;block kit builder&lt;/a&gt;:
Slack’s official way of using a GUI to compose messages of blocks, giving you the JSON you need.&lt;/p&gt;
&lt;p&gt;Now, we &lt;em&gt;could&lt;/em&gt; use the builder to structure our message the way we want it, copy the JSON
and paste it into a file on our server, and use string interpolation to insert dynamic values
where we need them.&lt;/p&gt;
&lt;p&gt;But that’s gross, so we’re not going to do that.&lt;/p&gt;
&lt;h2 id=&quot;enter-elixir&quot;&gt;Enter Elixir&lt;/h2&gt;
&lt;p&gt;I’ll call my module &lt;code&gt;SlackNotifier&lt;/code&gt;, and I’ll make a function called
&lt;code&gt;format_message/1&lt;/code&gt;.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref=&quot;true&quot; aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; I want to be able to do&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;This is important&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and it should handle all of the boring stuff.&lt;/p&gt;
&lt;p&gt;This is the full test suite it should pass:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackNotifierTest&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  use&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; ExUnit&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Case&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  alias&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackNotifier&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  describe &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;format_message&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    test &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;header tag is correctly formatted&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;What a nice header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      assert result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;               blocks&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                 %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;What a nice header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; emoji&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                 }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;               ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;             }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;    end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    test &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;mrkdwn tag is correctly formatted&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;        SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Lots of goodies in here&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;Multiple lines, even!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      assert result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;               blocks&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                 %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;mrkdwn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Lots of goodies in here&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;Multiple lines, even!&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                 }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;               ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;             }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;    end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    test &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;section with nested fields is correctly formatted&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;        SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;          section&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*This* is a field&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;And this is another field!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      assert result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;               blocks&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                 %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;section&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   fields&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                     %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;mrkdwn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*This* is a field&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                     }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                     %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;mrkdwn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;And this is another field!&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                     }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                   ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                 }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;               ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;             }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;    end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    test &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;a more complicated message with several types is correctly formatted&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;        SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;          header&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Very important message!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;          section&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;            mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*Calling all test runners*&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;            mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Uh, nevermind.&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;          ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      assert result &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;               blocks&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                 %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                     type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                     text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Very important message!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                     emoji&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                   }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                 }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                 %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;section&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                   fields&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                     %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;mrkdwn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*Calling all test runners*&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                     }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;                     %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;mrkdwn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;                       text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Uh, nevermind.&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                     }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                   ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;                 }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;               ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;             }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;    end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Implementing this is quite pleasant, using two attributes of Elixir:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A keyword list, which is what we’re passing as the argument to &lt;code&gt;format_message/1&lt;/code&gt;,
is syntax sugar for a list of 2-tuples where the first element is an atom and the second
element is the value associated with that keyword. That is,
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;answer&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 42&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; question&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
is equivalent to
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [{&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;answer&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 42&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;question&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;A function can have multiple clauses, where each clause pattern matches on the
shape of its arguments.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This means we can use the familiar Elixir pattern of writing lots of small functions, each
focusing on a narrow set of implementation details.
For instance, this is the function that formats a &lt;code&gt;header&lt;/code&gt; block:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_block&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_binary&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        emoji&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To format a whole message, we take our keyword lists (which, remember, is just a list of 2-tuples)
and map over it to create our blocks:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;spec &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Keyword&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ::&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  formatted_blocks &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Enum&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; &amp;amp;format_block&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; formatted_blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After the dust has settled, this is our message formatting code:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  @&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;spec &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Keyword&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ::&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    formatted_blocks &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Enum&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; &amp;amp;format_block&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; formatted_blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_block&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_binary&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        emoji&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_block&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_binary&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;mrkdwn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_block&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;section&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fields&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_list&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    formatted_fields &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Enum&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; &amp;amp;format_block&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;section&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      fields&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; formatted_fields&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;what-about-sending-it&quot;&gt;What about sending it?&lt;/h2&gt;
&lt;p&gt;All that remains is issuing a &lt;code&gt;POST&lt;/code&gt; to our webhook endpoint, and we are done.
Since our URL is sensitive, we’ll use an environment variable to get it.
In the appropriate config file we add this line:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# e.g. config/runtime.exs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;config &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; webhook_url&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; System&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;get_env&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;SLACK_WEBHOOK_URL&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and to get it in our module we make a helper:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; webhook_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    Application&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;fetch_env!&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-light-font-style:italic;--shiki-dark:#FF5D62;--shiki-dark-font-style:inherit&quot;&gt; __MODULE__&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Keyword&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;fetch!&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;webhook_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the &lt;a href=&quot;https://hex.pm/packages/req&quot;&gt;excellent &lt;code&gt;req&lt;/code&gt; HTTP client&lt;/a&gt;, sending the message
is as simple as&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  @&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;spec &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;send_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ::&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;ok&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Req&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Response&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Exception&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; send_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    webhook_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Req&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We could call it a day here, but HTTP requests are fragile and bound to fail sooner or later.
It would be a bummer if somebody wants to try our product, but we don’t notice because
Salesforce is having an outage.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref=&quot;true&quot; aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; Let’s go for the extra credit.&lt;/p&gt;
&lt;h2 id=&quot;extra-credit-background-jobs&quot;&gt;Extra credit: Background jobs&lt;/h2&gt;
&lt;p&gt;The definitive background job library for Elixir is &lt;a href=&quot;https://hexdocs.pm/oban/Oban.html&quot;&gt;Oban&lt;/a&gt;.
Again, I’ll simply defer to the &lt;a href=&quot;https://hexdocs.pm/oban/installation.html&quot;&gt;installation instructions&lt;/a&gt;
instead of re-iterating them here. My only recommendation is to check out the
&lt;a href=&quot;https://hexdocs.pm/igniter/readme.html&quot;&gt;Igniter installation option&lt;/a&gt; if you haven’t already—it
really makes it painless.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;config/config.exs&lt;/code&gt;, I created a separate queue for our Slack worker:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;config &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Oban&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;  engine&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Oban&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Engines&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Basic&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;  queues&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; slack&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;  repo&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Repo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The worker module is dead simple:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackWorker&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  use&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Oban&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Worker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; queue&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;slack&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  @&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;impl &lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Oban&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Worker&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; perform&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Oban&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Job&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;message&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}})&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;send_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And in our original &lt;code&gt;SlackNotifier&lt;/code&gt;, this helper schedules a message:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; schedule_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackWorker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Oban&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;insert&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that’s all we need!&lt;/p&gt;
&lt;p&gt;When someone fills out the lead form, we create an &lt;code&gt;InterestedOrganization&lt;/code&gt; struct.
In our slack notifier, this function is responsible for creating and scheduling the
message:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; schedule_new_interested_organization_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;        %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;InterestedOrganization&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; interested_organization&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      )&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      header&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; ønsker å teste Dreng :tada:&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      section&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*Kontaktperson*&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;contact_person&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*E-post*&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;email &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Ikke oppgitt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*Telefon*&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;phone &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Ikke oppgitt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; schedule_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Oban also provides lovely testing tools, so we can make sure we have lined up the job
when we want to, and also that we don’t send any notifications by mistake if something else failed:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  test &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;create_interested_organization/1 enqueues a slack notification when successful&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;ok&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; _interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;      Organizations&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;create_interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Company&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        contact_person&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        phone&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;40000123&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    assert_enqueued&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;worker&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackWorker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; queue&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;slack&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  test &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;a slack notification is not enqueued when create_interested_organization/1 fails&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; _reason&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;      Organizations&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;create_interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    refute_enqueued&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;worker&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackWorker&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For completeness, this is the Slack notifier in its entirety:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA;overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackNotifier&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  alias&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Organizations&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;InterestedOrganization&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; schedule_new_interested_organization_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;        %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;InterestedOrganization&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; interested_organization&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      )&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      header&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; ønsker å teste Dreng :tada:&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      section&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*Kontaktperson*&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;contact_person&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*E-post*&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;email &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Ikke oppgitt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;*Telefon*&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;interested_organization&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;phone &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;Ikke oppgitt&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; schedule_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  @&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;spec &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Keyword&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ::&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    formatted_blocks &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Enum&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; &amp;amp;format_block&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;blocks&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; formatted_blocks&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_block&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_binary&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;plain_text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;        emoji&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_block&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;mrkdwn&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_binary&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;mrkdwn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      text&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; content&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; format_block&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;section&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; fields&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_list&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    formatted_fields &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Enum&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; &amp;amp;format_block&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      type&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &amp;quot;section&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      fields&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; formatted_fields&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; schedule_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    Dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;SlackWorker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Oban&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;insert&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  @&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;spec &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;send_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ::&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;ok&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Req&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Response&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Exception&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;t&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; send_message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    webhook_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Req&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; message&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; webhook_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    Application&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;fetch_env!&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;dreng&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-light-font-style:italic;--shiki-dark:#FF5D62;--shiki-dark-font-style:inherit&quot;&gt; __MODULE__&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Keyword&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;fetch!&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;webhook_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now go forth and absolutely &lt;em&gt;hammer&lt;/em&gt; those Salesforce servers.&lt;/p&gt;
&lt;hr/&gt;
&lt;section data-footnotes=&quot;true&quot; class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;The &lt;code&gt;/1&lt;/code&gt; after the function name means that the function accepts one argument. The number of arguments accepted by a function is known as its &lt;em&gt;arity&lt;/em&gt;. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;You did know &lt;a href=&quot;https://web.archive.org/web/20210121200732/https://investor.salesforce.com/press-releases/press-release-details/2020/Salesforce-Signs-Definitive-Agreement-to-Acquire-Slack/default.aspx&quot;&gt;Salesforce acquired Slack in 2020&lt;/a&gt;? &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded></item><item><title>Finding the right person (in Postgres)</title><link>https://eaj.no/posts/sql-name-search</link><guid isPermaLink="true">https://eaj.no/posts/sql-name-search</guid><description>Don&apos;t go looking for the one. Unless the person you&apos;re looking for is stored in a PosgreSQL database. Then you actually have to search.</description><pubDate>Wed, 02 Apr 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Even though Patrick McKenzie &lt;a href=&quot;https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/&quot;&gt;lists a lot of good reasons not to&lt;/a&gt;, a project I am contributing to stores people’s names like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; people&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;    -- The beefy first column is the PostgreSQL way of specifying&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;    -- an autoincrementing integer primary key&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    id &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;integer&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; GENERATED&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; BY&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; IDENTITY&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    first_name &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; NOT NULL&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    middle_name &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    last_name &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; NOT NULL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Besides the issues mentioned in McKenzie’s article, this schema also makes it not-very-straightforward to find people by searching for their name. Take, for instance, me:&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;INSERT INTO&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    people (first_name, middle_name, last_name)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;VALUES&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Erik&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;André&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Jakobsen&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s take a look at some of the problems.&lt;/p&gt;
&lt;h2 id=&quot;prelude&quot;&gt;Prelude&lt;/h2&gt;
&lt;p&gt;To create a testing ground, &lt;a href=&quot;https://hexdocs.pm/ecto/getting-started.html&quot;&gt;I followed Ecto’s getting started guide&lt;/a&gt; to set up an Elixir project called &lt;code&gt;Friends&lt;/code&gt; with a PostgreSQL database. Next, I created the &lt;code&gt;people&lt;/code&gt; table with an Ecto migration. If you’re following along, make sure you get your Ecto project set up and then execute this in your command line:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;❯ mix ecto.gen.migration create_people&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;* creating priv/repo/migrations/20250326160917_create_people.exs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This gives us a file where we can create our table.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt;Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt;Migrations&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;CreatePeople&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  use&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Migration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; change&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    create table &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;people&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      add &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; null&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      add &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      add &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; null&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;    end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We’ll also need an Ecto schema, i.e. a fancy struct which represents entities in our database. A &lt;code&gt;changeset&lt;/code&gt; function which lets us validate the data comes in handy as well:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  use&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Schema&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  import&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Changeset&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  schema &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;people&quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    field &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    field &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    field &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; changeset&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-light-font-style:italic;--shiki-dark:#FF5D62;--shiki-dark-font-style:inherit&quot;&gt;__MODULE__&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; params &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    person&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; cast&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;params&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; validate_required&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;([&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, create a module called &lt;code&gt;Friends.People&lt;/code&gt; which will use our schema to interact with our database. To start, we’ll have a simple function to insert new friends:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  alias&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  alias&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Repo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; create&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;params&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;changeset&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;params&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;insert&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We’re now ready to load our project in a REPL with &lt;code&gt;iex -S mix&lt;/code&gt; and call the function to insert a very nice name into the database:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ iex &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; mix&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Erlang&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;OTP&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 27&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;erts&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;15.2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;bit&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;smp&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;ds&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;threads&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;jit&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Compiling&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; files&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;ex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Generated&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; friends app&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Interactive&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Elixir&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1.18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; press &lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Ctrl&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;C&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; to &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;exit&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;type &lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; ENTER&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; help&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Erik&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;André&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Jakobsen&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;17&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:57&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;813&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;debug&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; QUERY&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; OK&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; source&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;people&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; db&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;1ms decode&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;9ms queue&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;7ms idle&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;741&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;3ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; INTO&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;people&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;first_name&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;middle_name&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;last_name&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; VALUES&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; RETURNING&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;id&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Erik&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;André&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Jakobsen&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;ok&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Erik&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;André&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Jakobsen&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;finally-now-lets-find-that-son-of-a-bitch&quot;&gt;Finally! Now let’s find that son of a bitch&lt;/h2&gt;
&lt;p&gt;A reasonable first attempt at a search function might look something like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  alias&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  alias&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Repo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  import&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Query&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; # 👈 import Ecto.Query to access the Query DSL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;  # ✂️ create function cut&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_binary&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    name_pattern &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;%&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      where&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;        ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;          fragment&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;            &quot;? || &apos; &apos; || ? || &apos; &apos; || ?&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;            p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;            p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;            p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;          )&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;          ^name_pattern&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;all&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That is, wrap the query in &lt;code&gt;%&lt;/code&gt; and use string concatenation and &lt;code&gt;ILIKE&lt;/code&gt; to search for the name. Calling &lt;code&gt;find_people_by_name(&quot;Erik&quot;)&lt;/code&gt; will issue a query pretty close to this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;	p&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;	people &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;WHERE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;	p&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; ILIKE &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;%Erik%&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it works pretty well! I can search for my complete name, and be lazy about capitalization:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; recompile &lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# recompile the project without leaving the REPL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Compiling&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; file&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;ex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Generated&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; friends app&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;ok&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;erik andré jakobsen&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# debug log cut&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Erik&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;André&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Jakobsen&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Searching for any one of my names works fine as well.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;jakobsen&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;App&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Erik&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;André&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Jakobsen&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Great! We’re done here. I’m making some coffee.&lt;/p&gt;
&lt;h2 id=&quot;not-everyone-has-a-middle-name-you-know&quot;&gt;Not everyone has a middle name you know&lt;/h2&gt;
&lt;p&gt;What? Oh, I’m sure that’s still fine.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;José&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Valim&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;ok&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;José&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;   last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Valim&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;José Valim&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Right.&lt;/p&gt;
&lt;p&gt;To get a better idea of what’s going on, let’s run a SQL query straight in Postgres:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ psql &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;U postgres &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;d friends_repo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;psql (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;17&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 17&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;DBngin&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;app&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;Type&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;help&quot;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; help.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;friends_repo&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos;José&apos;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; NULL&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos;Valim&apos;&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; AS&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; full_name;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;full_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;-----------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; row&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Err, so &lt;code&gt;&apos;something&apos; || NULL&lt;/code&gt; is &lt;code&gt;NULL&lt;/code&gt;. According to &lt;a href=&quot;https://stackoverflow.com/questions/34934762/string-concatenation-with-a-null-seems-to-nullify-the-entire-string-is-that-de#comment57603605_34934762&quot;&gt;some person on Stack Overflow™&lt;/a&gt; this is part of the SQL standard, and I’m not about to &lt;a href=&quot;https://webstore.ansi.org/standards/iso/isoiec90752023?source=blog&amp;amp;_gl=1*pes2ee*_gcl_au*Mjg1NDMyNzYzLjE3NDMwMDc0NzY.&quot;&gt;spend hundreds of dollars veryfing that&lt;/a&gt;, so we’ll just accept it as a fact of life and move on.&lt;/p&gt;
&lt;p&gt;Postgres has &lt;a href=&quot;https://www.postgresql.org/docs/current/functions-string.html&quot;&gt;a lot of string functions&lt;/a&gt; that could help out. Maybe &lt;code&gt;concat&lt;/code&gt;, which makes the slightly more sensible choice of simply ignoring nulls, is the answer?&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;friends_repo&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt; concat&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;José&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Valim&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; full_name;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  full_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;-------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; José  Valim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; row&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s &lt;em&gt;closer&lt;/em&gt;, but we’re left with two spaces between the names instead of one, which messes things up&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;friends_repo&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; FROM&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; people &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt; concat&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;(first_name, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, middle_name, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, last_name) ILIKE &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;José Valim&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; id | first_name | middle_name | last_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;----+------------+-------------+-----------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; rows&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Happily, the Postgres people have thought about this, and they give us &lt;span style=&quot;display: inline-block&quot;&gt;&lt;code&gt;concat_ws&lt;/code&gt;.&lt;/span&gt; The first argument is used as a separator when concatenating the following arguments, and nulls are ignored.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sql&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;friends_repo&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;# &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; concat_ws(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;José&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Valim&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; full_name;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; full_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; José Valim&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; row&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We update our search function to use it:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; when&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_binary&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  name_pattern &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;%&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;  from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    where&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;        fragment&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;          &quot;concat_ws(&apos; &apos;, ?, ?, ?)&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;          p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;          p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;          p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;        )&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;        ^name_pattern&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;  |&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;all&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And would you look at that:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; recompile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Compiling&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; file&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;ex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Generated&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; friends app&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;ok&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;José Valim&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;José&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Valim&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, where did I put that coff—&lt;/p&gt;
&lt;h2 id=&quot;i-didnt-even-know-you-had-a-middle-name&quot;&gt;I didn’t even know you &lt;em&gt;had&lt;/em&gt; a middle name!&lt;/h2&gt;
&lt;p&gt;Oh don’t worry, just run a search without it.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; App&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_people_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;erik jakobsen&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;…&lt;/p&gt;
&lt;p&gt;Alright, so back to the drawing board, and away from raw SQL. Rather than taking the name search and using it as-is, we’ll split it up and iteratively build a query.&lt;/p&gt;
&lt;p&gt;In Ecto, queries are simply data structures that can be stored in variables, and the query can be extended as many times as we need:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; query &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; from p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;#Ecto.Query&amp;lt;from p0 in Friends.People.Person&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; query &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; from p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; query&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; where&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;josé&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;#Ecto.Query&amp;lt;from p0 in Friends.People.Person,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# where: ilike(p0.first_name, &quot;josé&quot;)&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;all&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;José&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Valim&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For our purposes, we first make a private function which accepts a name and partial query, and extends the latter with an &lt;code&gt;OR&lt;/code&gt; query on all three name columns using the former:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_name_to_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  name_pattern &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;%&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  from p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; query&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    where&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; ^name_pattern&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;        ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; ^name_pattern&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;        ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; ^name_pattern&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using a &lt;a href=&quot;https://hexdocs.pm/elixir/Kernel.SpecialForms.html#for/1-the-reduce-option&quot;&gt;comprehension with the &lt;code&gt;:reduce&lt;/code&gt; option&lt;/a&gt;, we build a query using all names individually, and then use &lt;em&gt;that&lt;/em&gt; to search the database:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; find_people_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  names &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; String&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  query &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;    for&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; name &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; names&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; reduce&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      partial_query &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_name_to_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; partial_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;    end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;  Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;all&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s break up what that &lt;code&gt;for&lt;/code&gt; comprehension is doing a little more. In the &lt;code&gt;do&lt;/code&gt; block we are calling this function with query:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;partial_query &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_name_to_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; partial_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For each iteration, the &lt;code&gt;partial_query&lt;/code&gt; will be the query we have built up so far. In the first iteration we haven’t started yet, so this is where Elixir will use the &lt;code&gt;from(p in Person)&lt;/code&gt; expression that we passed to the &lt;code&gt;reduce&lt;/code&gt; option. That means that once we’re done building our query for &lt;span style=&quot;display: inline-block&quot;&gt;&lt;code&gt;&quot;erik jakobsen&quot;&lt;/code&gt;,&lt;/span&gt; we’ll have something like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;from p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;  where&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%erik%&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%erik%&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%erik%&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%jakobsen%&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%jakobsen%&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      ilike&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%jakobsen%&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This gives us what we want:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;erik jakobsen&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Erik&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;André&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Jakobsen&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Happy now?&lt;/p&gt;
&lt;h2 id=&quot;whats-with-the-é-s&quot;&gt;What’s with the é-s?&lt;/h2&gt;
&lt;p&gt;Fair enough.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;jose&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Postgres has our backs once again, this time with the &lt;a href=&quot;https://www.postgresql.org/docs/current/unaccent.html&quot;&gt;&lt;code&gt;unaccent&lt;/code&gt; extension&lt;/a&gt;. To use it with our database, we’ll need another migration to add it:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;❯ mix ecto.gen.migration add_unaccent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;* creating priv/repo/migrations/20250326174022_add_unaccent.exs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In it, we use &lt;code&gt;execute/2&lt;/code&gt; to add the extension.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defmodule&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt;Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#98BB6C&quot;&gt;Migrations&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;AddUnaccent&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  use&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Migration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; change&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    execute &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;CREATE EXTENSION IF NOT EXISTS unaccent&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;DROP EXTENSION unaccent&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first argument to &lt;code&gt;execute&lt;/code&gt; is what to do when running our migration:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ mix ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;migrate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:01&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;986&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Running&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 20250326174022&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Migrations&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;AddUnaccent&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;change&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; forward&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:01&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;987&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; execute &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;CREATE EXTENSION IF NOT EXISTS unaccent&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:02&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;242&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Migrated&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 20250326174022&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;2s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the second tells Ecto what to do in case we change our minds and want to roll back&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ mix ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;rollback&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;43&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:42&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;534&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Running&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 20250326174022&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Migrations&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;AddUnaccent&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;change&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; backward&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;43&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:42&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;535&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; execute &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;DROP EXTENSION unaccent&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;43&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:42&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;537&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Migrated&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 20250326174022&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;0s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But we’re not rolling back, so, uuh, undo the undo please.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ mix ecto&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;migrate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;44&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:04&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;214&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Running&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 20250326174022&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Repo&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Migrations&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;AddUnaccent&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;change&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; forward&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;44&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:04&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;215&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; execute &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;CREATE EXTENSION IF NOT EXISTS unaccent&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;44&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:04&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;220&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;info&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Migrated&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 20250326174022&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;0s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, throw around &lt;code&gt;unaccent&lt;/code&gt; in our query builder with great abandon:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;defp&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_name_to_query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; query&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  name_pattern &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;%&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#98BB6C&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;%&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  from p &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; query&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    where&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;      fragment&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;unaccent(?) ILIKE unaccent(?)&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; ^name_pattern&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;        fragment&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;unaccent(?) ILIKE unaccent(?)&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;middle_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; ^name_pattern&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; or&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;        fragment&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;unaccent(?) ILIKE unaccent(?)&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; p&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; ^name_pattern&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Look, it’s beautiful:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;jose&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;José&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; nil&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Valim&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;erik andre&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  %&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    __meta__&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; #Ecto.Schema.Metadata&amp;lt;:loaded, &quot;people&quot;&amp;gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Erik&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;André&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;    last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Jakobsen&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;isnt-this-all-very-slow&quot;&gt;Isn’t this all very slow?&lt;/h2&gt;
&lt;p&gt;That depends!&lt;/p&gt;
&lt;p&gt;The project I’m working on only stores about 2000 names, so queries finish pretty much instantly.&lt;/p&gt;
&lt;p&gt;But, as an experiment, I added &lt;a href=&quot;https://hexdocs.pm/faker/readme.html&quot;&gt;the Faker library&lt;/a&gt;, used it to generate five million fake names, each of which sounds English, Spanish, French or Italian at random, and inserted each into my database:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;async_stream&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;  1&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;..&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;5_000_000&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  fn&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; _&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    faker &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;      Enum&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;([&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;        Faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;En&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;        Faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Es&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;        Faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Fr&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;        Faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Person&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;It&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;      ])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;    Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      first_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      middle_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;first_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt;      last_name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; faker&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;last_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;|&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Stream&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;run&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We all have hobbies.&lt;/p&gt;
&lt;p&gt;Searching for my name again&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; finishes in about 1.5 seconds (notice the &lt;code&gt;db=1541.1ms&lt;/code&gt; below), which, frankly, isn’t great:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;elixir&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;iex&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Friends&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;People&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;find_by_name&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Erik André Jakobsen&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;59&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;:42&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;242&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;debug&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; QUERY&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; OK&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; source&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;people&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; db&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1541&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;1ms decode&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;1ms queue&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;0ms idle&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;6ms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# ✂️ cut&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;First off, having a database with that many names in it sounds to me like you either have a very &lt;em&gt;good kind of problem&lt;/em&gt;, or that the authorities are looking for you.&lt;/p&gt;
&lt;p&gt;In any case, if my project took off (it won’t), we would have to make some changes.&lt;/p&gt;
&lt;p&gt;For one, we don’t even have an index on any of this. We could, for instance precompute and store an unqouted full name column with a &lt;a href=&quot;https://www.postgresql.org/docs/current/gin.html&quot;&gt;GIN index&lt;/a&gt;, and then implement a search using &lt;a href=&quot;https://www.postgresql.org/docs/9.0/pgtrgm.html&quot;&gt;trigrams&lt;/a&gt;. Or set up something like &lt;a href=&quot;https://github.com/quickwit-oss/tantivy&quot;&gt;tantivy&lt;/a&gt;. Or give Ansible some money. Or rent a more powerful server.&lt;/p&gt;
&lt;p&gt;These are all left as an exercise for the reader.&lt;/p&gt;
&lt;hr&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;I am, after all, a selfish bastard. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;See previous footnote. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded></item><item><title>The Perils of Default Arguments in Python</title><link>https://eaj.no/posts/the-perils-of-default-arguments-in-python</link><guid isPermaLink="true">https://eaj.no/posts/the-perils-of-default-arguments-in-python</guid><description>Default function arguments can be very useful. They can also be horrible.</description><pubDate>Wed, 12 Mar 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;all-is-well&quot;&gt;All is well&lt;/h2&gt;
&lt;p&gt;If Python was your first programming language, this is probably pretty close to one the first functions you ever wrote:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;py&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;    print&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Hello, &lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;!&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you save it to a file called &lt;code&gt;greet.py&lt;/code&gt; and run &lt;code&gt;python -i greet.py&lt;/code&gt;, you can call the function from the REPL:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ python &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;i greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Irving&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Hello&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Irving!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you try to run it without any arguments, Python is upset.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;Traceback&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;most recent call last&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  File &lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;&amp;lt;python-input-1&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; line &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;    greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;    ~~~~~^^&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;TypeError&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; missing &lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; required positional argument&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos;name&apos;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Python (as well as most other sane languages)&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; requires you to pass all parameters that are listed in the function signature whenever you call it. If you want a parameter to be optional, this can be achieved by defining a &lt;em&gt;default argument value&lt;/em&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; name &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;there&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;    print&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Hello, &lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;!&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we load the Python REPL with our new and shiny function, we’re able to call the &lt;code&gt;greet&lt;/code&gt; without any arguments:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ python &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;i greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Hello&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; there!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Be aware that &lt;code&gt;None&lt;/code&gt; still counts as a value, so the default argument won’t have any effect in this case:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; greet&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt;None&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Hello&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We also see that the types we dutifully specified don’t have any runtime effects. As noted in the &lt;a href=&quot;https://docs.python.org/3/library/typing.html&quot;&gt;official documentation on typing&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Other than that, all is well.&lt;/p&gt;
&lt;h2 id=&quot;sometimes-all-is-not-well&quot;&gt;Sometimes, all is &lt;em&gt;not&lt;/em&gt; well&lt;/h2&gt;
&lt;p&gt;Oh.&lt;/p&gt;
&lt;p&gt;The default value is evaluated only once, at the point of definition in the defining scope. That is a very roundabout way of saying that if you do this&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;py&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;default_url &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;eaj.no&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; some_function&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;():&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;    # Create an inner scope&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    default_url &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;example.com&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; default_url&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; get_post_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;post_id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt; base_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; default_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;base_url&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;/posts/&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;post_id&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#FFA066&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the default argument value for &lt;code&gt;base_url&lt;/code&gt; will be &lt;code&gt;&quot;eaj.no&quot;&lt;/code&gt;, and not &lt;code&gt;&quot;example.com&quot;&lt;/code&gt;. Notably, we can also pass a variable as the default argument value.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;__defaults__&lt;/code&gt; attribute of a function holds a tuple containing all its default arguments.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; Taking a look at the &lt;code&gt;get_post_url&lt;/code&gt; function, we confirm the the default argument value is &lt;code&gt;&quot;eaj.no&quot;&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; get_post_url&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;__defaults__&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;eaj.no&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We could have called it, but we’re not here to take the easy way out.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-3&quot; id=&quot;user-content-fnref-3&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;For immutable values, like strings or integers, this works perfectly. Mutable values, however, mean trouble.&lt;/p&gt;
&lt;p&gt;Here is a function that adds a lowercase version of a string to a set, and then returns the set.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;py&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt; container&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    container&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; container&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we decide that having to provide a &lt;code&gt;set&lt;/code&gt; to the container is a chore, we might try to do this instead:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;py&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;    value&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;    container&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;  # Default value added here 👀&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    container&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; container&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have saved ourselves a bit of typing, and substituted it for a world of pain and suffering. As we learned above, the default set will be defined &lt;em&gt;once&lt;/em&gt;, and from this point on be brotherly shared by all call sites.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; some_set &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;ABC&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; definitely_another_set &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;oh NO&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt; print&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;definitely_another_set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;abc&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos;oh no&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;__defaults__&lt;/code&gt; makes it clear:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;__defaults__&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;oh no&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos;abc&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Playing around in the REPL, the mistake is immediate and obvious. But, if the function was just moderately more complex, or the call sites were scattered around around different modules in a larger project, debugging the issues that would undoubtably appear would most likely be a frustrating endeavor.&lt;/p&gt;
&lt;p&gt;This is one of those bugs where testing doesn’t really help. That’s not to say this behavior is &lt;em&gt;untestable&lt;/em&gt;—this test would clearly fail:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; test_that_add_lower_doesnt_affect_other_sets&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    first_set &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;abc&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    second_set &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;def&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    assert&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; first_set &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;abc&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    assert&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; second_set &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;def&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But if you’re unfamiliar the issues with mutable default arguments, &lt;em&gt;how would you even know to write this test?&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;theres-more&quot;&gt;There’s more&lt;/h2&gt;
&lt;p&gt;Even immutable default values can cause trouble. All available types in the &lt;a href=&quot;https://docs.python.org/3/library/datetime.html#available-types&quot;&gt;&lt;code&gt;datetime&lt;/code&gt; module&lt;/a&gt; are immutable, but this code does not behave the way one might expect:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; datetime &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_future_date&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;    candidate_date&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt; today&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;date &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;today&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; bool&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; candidate_date &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; today&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It would work fine for a day, but after that it would start giving incorrect results. This is not a problem if the program never runs for very long, but a long-lived web server would be a different story.&lt;/p&gt;
&lt;p&gt;In short, default arguments should never be used for values that are required to change between function calls.&lt;/p&gt;
&lt;p&gt;Here’s another piece of broken code:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dataclasses &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; uuid &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; UUID&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; uuid4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E59645;--shiki-dark:#9CABCA&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#E59645;--shiki-dark:#7E9CD8&quot;&gt;dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    product_id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; UUID&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; uuid4&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are using &lt;a href=&quot;https://docs.python.org/3/library/dataclasses.html&quot;&gt;the &lt;code&gt;dataclass&lt;/code&gt; decorator from the standard Python library&lt;/a&gt; to create a class representing a product. The decorator automatically creates the &lt;code&gt;__init__&lt;/code&gt;, &lt;code&gt;__repr__&lt;/code&gt; and &lt;code&gt;__eq__&lt;/code&gt; methods, saving us a bit of boilerplate.&lt;/p&gt;
&lt;p&gt;You have probably seen the problem: All products will get the same ID.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Banana&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Banana&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; product_id&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;UUID&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;e5da25ee-4b96-45e8-8cd4-80d8de116dd4&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Apple&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Apple&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; product_id&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;UUID&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;e5da25ee-4b96-45e8-8cd4-80d8de116dd4&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the positive side, &lt;a href=&quot;https://eieio.games/blog/writing-down-every-uuid/&quot;&gt;remembering every UUID in our database&lt;/a&gt; will be much easier this way.&lt;/p&gt;
&lt;h2 id=&quot;so-what-do-i-do-mr-smartypants&quot;&gt;So what do I do, Mr. Smartypants&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;None&lt;/code&gt; as a sentinel value and conditionally create the mutable default value in the function body instead. This is the fixed version of &lt;code&gt;add_lower&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; add_lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;    value&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt; container&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; container &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;        container &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    container&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; container&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same technique works for &lt;code&gt;is_future_date&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; datetime &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; is_future_date&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;    candidate_date&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt; today&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;date &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; bool&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; today &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#FFA066&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;        today &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dt&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;date&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;today&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; candidate_date &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; today&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This way, each function call will create the mutable or time-sensitive value at each function call if it is not provided at the call site.&lt;/p&gt;
&lt;p&gt;For the dataclass example, Python already provides some guardrails. If we try to provide a mutable default value for any of the fields, we’ll get a &lt;code&gt;ValueError&lt;/code&gt;. This is an updated (and even more broken) version of our previous product class:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dataclasses &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; uuid &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; UUID&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; uuid4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E59645;--shiki-dark:#9CABCA&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#E59645;--shiki-dark:#7E9CD8&quot;&gt;dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    variants&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; list&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; []&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; # Added mutable default value here 👀&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    product_id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; UUID&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; uuid4&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running this file give us&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;fish&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;❯ python bad_dataclass.py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;Traceback&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;most&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; recent call last&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;  File&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;/private/tmp/bad_dataclass.py&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;, line 5, &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; &amp;lt;module&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    @dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;     ^^^^^^^^^&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# stracktrace cut ✂️&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;ValueError&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;: mutable default &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;lt;class&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos;list&apos;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; field variants is not allowed: use default_factory&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When defining a dataclass, the Python runtime will check if each of the given default values are hashable. If it encounters an unhashable value it assumes that is also mutable, and raises an error. Helpfully, the error message tells us what to do.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dataclasses &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; dataclass&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; field  &lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;# 👈 Updated import&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; uuid &lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#FFA066&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; UUID&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; uuid4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E59645;--shiki-dark:#9CABCA&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#E59645;--shiki-dark:#7E9CD8&quot;&gt;dataclass&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt; str&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    variants&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; list&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; field&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;default_factory&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;list&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;  # ✅ default factory&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;    product_id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#DCD7BA&quot;&gt; UUID&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; field&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;default_factory&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#7E9CD8&quot;&gt;uuid4&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt;  # ✅ default factory&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this, each product get their own variant list and a unique ID:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Banana&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Banana&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; variants&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; product_id&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;UUID&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;89ebfb63-0d33-474c-a38a-d65c3b08eda1&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Apple&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Apple&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; variants&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[]&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; product_id&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;UUID&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;a1c88200-530c-42ab-bf82-6a6de7fd6e85&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; banana &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Banana&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; apple &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Product&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Apple&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; apple&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;variants&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;Aroma&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; apple&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;variants&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&apos;Aroma&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; banana&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;variants&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;[]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At least, this will have to suffice until you can rewrite everything in Rust.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-4&quot; id=&quot;user-content-fnref-4&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;You know who I’m talking about. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;Python functions are objects. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-3&quot;&gt;
&lt;p&gt;I must also regret to inform you that it is possible to assign an arbitrary tuple to the &lt;code&gt;__defaults__&lt;/code&gt; attribute. However, if I ever come across a code base where this is abused and &lt;code&gt;git blame&lt;/code&gt; tells me it is &lt;em&gt;your&lt;/em&gt; fault, I will personally come to your house and make you write 20 000 words about why that was a terrible decision. &lt;a href=&quot;#user-content-fnref-3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-4&quot;&gt;
&lt;p&gt;Or are we doing Zig now? &lt;a href=&quot;#user-content-fnref-4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded></item><item><title>How To Make a Countdown Timer With JavaScript</title><link>https://eaj.no/posts/how-to-make-a-countdown-timer-with-java-script</link><guid isPermaLink="true">https://eaj.no/posts/how-to-make-a-countdown-timer-with-java-script</guid><description>Visualize your impending doom. Or birthday!</description><pubDate>Wed, 06 May 2020 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Exam season is upon us, and deadlines are looming closer and closer.
It is often hard to keep track of just how close they are, and sometimes we need a reminder.
Let’s make one with JavaScript.&lt;/p&gt;
&lt;p&gt;The inspiration for this came from a Norwegian news article counting down the days, hours, minutes and seconds until &lt;a href=&quot;https://www.nrk.no/osloogviken/oslo-apner-skjenkingen-1.15001011&quot;&gt;bars were allowed to reopen after the COVID-19 lockdown&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can see a &lt;a href=&quot;https://jakobsen.github.io/countdown-timer/&quot;&gt;live demo&lt;/a&gt; of what we’ll be making, counting down until new year’s eve. The source code is as always available on &lt;a href=&quot;https://github.com/jakobsen/countdown-timer/&quot;&gt;Github&lt;/a&gt;. Note that the code is slightly modified to automatically set the correct year, but it is otherwise identical to what we’ll write in this post.&lt;/p&gt;
&lt;h2 id=&quot;set-up-the-project&quot;&gt;Set up the project&lt;/h2&gt;
&lt;p&gt;Make a folder for your project, and create three files. I’ll do it using the terminal, you can of course do it however you want.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;mkdir&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; countdown-timer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F07171;--shiki-dark:#7E9CD8&quot;&gt;cd&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; countdown-timer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;touch&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; index.html&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; style.css&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; script.js&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;html--css&quot;&gt;HTML &amp;amp; CSS&lt;/h2&gt;
&lt;p&gt;The HTML and CSS for this project are pretty simple. This main idea for the HTML is to create a container for our entire timer. Each ticker and it’s label will be together in a &lt;code&gt;html›&amp;lt;div /&amp;gt;&lt;/code&gt; to easily space them out. Finally, we put each ticker in a &lt;code&gt;html›&amp;lt;div /&amp;gt;&lt;/code&gt; and it’s label in a &lt;code&gt;html›&amp;lt;span /&amp;gt;&lt;/code&gt; so we can easily grab onto them with both JavaScript and CSS.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;html›&amp;lt;body /&amp;gt;&lt;/code&gt; of my HTML document looks like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;countdown&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;days&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;days&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;hours&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;hours&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;minutes&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;minutes&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;seconds&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;00&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;seconds&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;script.js&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that we’re also including our (for now empty) script in the final line. We’ll use that to change the inner text of the &lt;code&gt;html›&amp;lt;div class=&quot;time&quot; /&amp;gt;&lt;/code&gt; elements, which for now are just all set to zero.&lt;/p&gt;
&lt;p&gt;This is what our website now looks like:
&lt;img alt=&quot;Countdown site with no styling&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;927&quot; height=&quot;563&quot; src=&quot;/_astro/countdown1.SuumGyTJ_Z1mcWRl.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;It looks pretty terrible, so let’s fix that. First, link our stylesheet with a &lt;code&gt;html›&amp;lt;link /&amp;gt;&lt;/code&gt; tag in the &lt;code&gt;html›&amp;lt;head /&amp;gt;&lt;/code&gt; of &lt;code&gt;index.html&lt;/code&gt;. I also chose to import the popular Roboto font from Google Fonts. This is what’s between the &lt;code&gt;html›&amp;lt;head /&amp;gt;&lt;/code&gt; tags in my HTML file:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; charset&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;viewport&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;width=device-width, initial-scale=1.0&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;link&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt;  href&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;https://fonts.googleapis.com/css2?family=Roboto:wght@300;500&amp;amp;display=swap&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt;  rel&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; rel&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;style.css&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Simple countdown&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There’s also two &lt;code&gt;html›&amp;lt;meta /&amp;gt;&lt;/code&gt; tags, put there by VS Code, my text editor. The first lets the browser know we are using the UTF-8 text encoding, whilst the second makes sure the site is properly scaled on mobile screens.&lt;/p&gt;
&lt;p&gt;This is the complete HTML file:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;DOCTYPE&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; html&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; charset&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;viewport&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;width=device-width, initial-scale=1.0&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;link&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt;      href&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;https://fonts.googleapis.com/css2?family=Roboto:wght@300;500&amp;amp;display=swap&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt;      rel&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; rel&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;style.css&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Simple countdown&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;countdown&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;days&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;days&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;hours&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;hours&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;minutes&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;minutes&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;box&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;time&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;seconds&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;seconds&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;script.js&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We’ll give the site a dark background and make the text white. We want the counter to be centered on the page, both vertically and horizontally. To achieve this, give the body a height, make it a flexbox, and use both the &lt;code&gt;css›justify-content&lt;/code&gt; and &lt;code&gt;css›align-items&lt;/code&gt; properties. We also set &lt;code&gt;css›margin: 0&lt;/code&gt; so we don’t get a scrollbar in some browsers.&lt;/p&gt;
&lt;p&gt;We use the universal selector &lt;code&gt;css›*&lt;/code&gt; and apply &lt;code&gt;css›box-sizing: border-box;&lt;/code&gt; to ensure that any &lt;code&gt;border&lt;/code&gt; and &lt;code&gt;padding&lt;/code&gt; will be included when the browser calculates the height and width of an element.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#E6C384&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  box-sizing&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; border-box&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#E6C384&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  color&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#957FB8&quot;&gt;fefefe&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  background-color&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#957FB8&quot;&gt;222&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  margin&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  min-height&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;vh&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  justify-content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  align-items&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-family&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &apos;Roboto&apos;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; sans-serif&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We want the different tickers in a single row, with equal spacing between them. Again, flexbox is my preferred way of doing it.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;countdown&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  width&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 500&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  justify-content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; space-between&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we’ll add some rules so that the boxes don’t change in width when the numbers tick down, center the text, and set some font sizes.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;box&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  text-align&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  min-width&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;time&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-weight&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 500&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1.2&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-weight&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 300&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The complete CSS file is now&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#E6C384&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  box-sizing&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; border-box&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#E6C384&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  color&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#957FB8&quot;&gt;fefefe&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  background-color&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#9CABCA&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#4CBF99;--shiki-dark:#957FB8&quot;&gt;222&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  margin&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  min-height&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;vh&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  justify-content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  align-items&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-family&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;Roboto&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; sans-serif&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;countdown&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  width&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 500&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  justify-content&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; space-between&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;box&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  text-align&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-light-font-style:italic;--shiki-dark:#FFA066;--shiki-dark-font-style:inherit&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  min-width&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;time&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-weight&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 500&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#E6C384&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-size&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1.2&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#E6C384&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#7AA89F&quot;&gt;  font-weight&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 300&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and our site looks a lot better:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Countdown site with styling&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;912&quot; height=&quot;563&quot; src=&quot;/_astro/countdown2.DFvercoe_ZVmJUU.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;It’s time to make it tick.&lt;/p&gt;
&lt;h2 id=&quot;javascript&quot;&gt;JavaScript&lt;/h2&gt;
&lt;p&gt;The first thing we’ll do in &lt;code&gt;script.js&lt;/code&gt; is to create variables for each of our ticker elements.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;days&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;hours&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;minutes&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;seconds&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To make sure I haven’t done a silly mistake like make a typo, I like to &lt;code&gt;js›console.log()&lt;/code&gt; all of my newly defined variables.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;days&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;seconds&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you open your console, you should see something like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Output of console.log&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;927&quot; height=&quot;637&quot; src=&quot;/_astro/countdown3.UrIL-QA-_10vyWV.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;It may look a little different, depending on your browser. As long as it doesn’t say &lt;code&gt;js›null&lt;/code&gt;, you’re alright. When you have confirmed that you have defined the variables correctly, remove the &lt;code&gt;console.log()&lt;/code&gt; statements.&lt;/p&gt;
&lt;p&gt;This is our plan for what to do next:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Define a function that accepts a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date&quot;&gt;&lt;code&gt;Date&lt;/code&gt; object&lt;/a&gt; as a parameter and returns the days, hours, minutes and seconds remaining until that date.&lt;/li&gt;
&lt;li&gt;Define a function that accepts a &lt;code&gt;Date&lt;/code&gt; object, uses the previous function to get the values we need for our tickers, and updates the &lt;code&gt;js›innerText&lt;/code&gt; to display the correct value.&lt;/li&gt;
&lt;li&gt;Call our function every second to get a countdown.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To complete our first objective, we will use the &lt;code&gt;js›Date.now()&lt;/code&gt; method.
This gives us the number of milliseconds elapsed since &lt;a href=&quot;https://en.wikipedia.org/wiki/Unix_time&quot;&gt;January 1, 1970&lt;/a&gt;.
We can get the corresponding value for an arbitrary date &lt;code&gt;js›myDate&lt;/code&gt; by calling &lt;code&gt;js›myDate.getTime()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So the start of our function will be&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const getTimeDifference = (targetDate) =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  const diff = targetDate.getTime() - Date.now();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The variable &lt;code&gt;diff&lt;/code&gt; will hold the number of milliseconds between now and whenever &lt;code&gt;targetDate&lt;/code&gt; is. Note that if &lt;code&gt;targetDate&lt;/code&gt; is set to some date in the past (which will happen at some point, anyway), this value will be negative. In that case, the countdown timer should just display zeros. We implement this with an &lt;code&gt;js›if&lt;/code&gt;-statement.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getTimeDifference&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  let&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  if&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      seconds&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We return an &lt;code&gt;js›Object&lt;/code&gt; to make it easier to unpack the values when we call the function.&lt;/p&gt;
&lt;p&gt;Next, we’ll use a bit of math to convert milliseconds remaining into something a bit more human-friendly. We’ll use &lt;code&gt;js›Math.floor()&lt;/code&gt; and the modulo operator, both of which you might or might not be familiar with.&lt;/p&gt;
&lt;p&gt;The method &lt;code&gt;Math.floor()&lt;/code&gt; accepts a number as an argument, and returns the biggest integer that is smaller than or equal to this number. For positive numbers, this means it removes anything that comes after the decimal point.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2.3&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; // 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;199.9999999&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; // 199&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; // 4&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The modulo operator &lt;code&gt;%&lt;/code&gt; returns the remainder after performing whole-number division. For instance, if you divide 5 by 2 you get 2, with a remainder of 1, so &lt;code&gt;js›5 % 2 == 1&lt;/code&gt;. Some more examples:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; // 3&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 11&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; // 4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#ADAEB1;--shiki-light-font-style:italic;--shiki-dark:#727169;--shiki-dark-font-style:inherit&quot;&gt; // 0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To get the correct number of whole days remaining, divide the number of milliseconds remaining by the number of milliseconds in a day, and round down to the nearest integer.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Of course, we can do a similar calculation for hours, minutes and seconds. However, this will include the number of days remaining as well—for instance, if we are counting down to a time 1 day and 1 hour away, this would calculate that there are 1 days and 25 hours remaining. We fix it with the modulo &lt;code&gt;%&lt;/code&gt; operator, only giving us the remainder after we have removed the corresponding days, hours, and minutes down the line:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1000&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now all that remains is to &lt;code&gt;js›return&lt;/code&gt; our values, and our function is done.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getTimeDifference&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  let&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  if&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      seconds&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1000&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s make another function to update the timer on our site. This is pretty straightforward: We get the correct values using &lt;code&gt;js›getTimeDifference()&lt;/code&gt;, and then update the &lt;code&gt;.innerText&lt;/code&gt; for the corresponding HTML elements.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; updateTime&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getTimeDifference&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  daysElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  hoursElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  minutesElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  secondsElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the second line we use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring&quot;&gt;object destructuring&lt;/a&gt;, a great syntax feature in JavaScript that allows us to assign several variables at once from an object.&lt;/p&gt;
&lt;p&gt;At this point we can test our function. Let’s define a date that is a year from now and call our function, to make sure it works. Add the following lines to then end of &lt;code&gt;script.js&lt;/code&gt;(feel free to change the date):&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;2021-05-06 16:30:00&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;updateTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should see something like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A test of our countdown timer. 364 days, 23 hours, 59 minutes and 8 seconds.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;912&quot; height=&quot;563&quot; src=&quot;/_astro/countdown4.BIeQVcrD_Z2gsGdb.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;It works! However, I’d prefer any single digit value for hours, minutes or seconds to start with a leading zero. We can do this by combining the JavaScript methods &lt;code&gt;js›.toString()&lt;/code&gt; and &lt;code&gt;js›.padStart()&lt;/code&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart&quot;&gt;The latter&lt;/a&gt; is a prototype method of strings, so we first need to convert our numeric values to strings using &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString&quot;&gt;the former&lt;/a&gt;. If you want, edit your function so that it looks like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; updateTime&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getTimeDifference&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  daysElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  hoursElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;padStart&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;0&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  minutesElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;padStart&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;0&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  secondsElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;padStart&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;0&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first argument to &lt;code&gt;.padStart()&lt;/code&gt; is the minimum length of the string. The second argument is the character to use to increase it (if necessary) until it reaches this length. Our countdown timer now looks like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Test of countdown timer with leading zeros. 364 days, 23 hours, 51 minutes and 09 seconds.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;912&quot; height=&quot;563&quot; src=&quot;/_astro/countdown5.DPpbKOxN_Z2ikLl1.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;Finally, we need to update the timer every second. Luckily, there is a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval&quot;&gt;built-in method called &lt;code&gt;js›setInterval()&lt;/code&gt;&lt;/a&gt; which lets us do just that.&lt;/p&gt;
&lt;p&gt;Edit &lt;code&gt;script.js&lt;/code&gt; so it ends with the following three lines:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;2021-05-06 16:30:00&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;updateTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;setInterval&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;updateTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1000&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In &lt;code&gt;js›setInterval()&lt;/code&gt; the first argument is the function to execute every time, and the second argument is the delay between each execution in milliseconds. Any following arguments will be passed as arguments to the function, so we pass &lt;code&gt;js›targetDate&lt;/code&gt; as a third argument.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note that passing arguments to the callback function in &lt;code&gt;js›setInterval()&lt;/code&gt; is not supported in Internet Explorer 9 and lower. If you need to support these browsers, Mozilla Developer Network suggest a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval#Callback_arguments&quot;&gt;number of workarounds&lt;/a&gt;. The most obvious one in our case is to include the &lt;code&gt;targetDate&lt;/code&gt; as a local variable inside the definition of &lt;code&gt;updateTime&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The complete &lt;code&gt;script.js&lt;/code&gt; file is now&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; daysElement &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;days&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hoursElement &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;hours&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutesElement &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;minutes&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; secondsElement &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;seconds&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getTimeDifference&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  let&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;getTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;now&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  if&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;      seconds&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;    }&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; Math&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;diff &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1000&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 60&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-light-font-weight:inherit;--shiki-dark:#957FB8;--shiki-dark-font-weight:bold&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; updateTime&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds &lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; getTimeDifference&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  daysElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; days&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  hoursElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; hours&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;padStart&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;0&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  minutesElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; minutes&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;padStart&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;0&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;  secondsElement&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#E6C384&quot;&gt;innerText&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; seconds&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#9CABCA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;padStart&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt; &quot;0&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#957FB8&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate &lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;2021-05-06 16:30:00&quot;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;updateTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#7E9CD8&quot;&gt;setInterval&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;updateTime&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A37ACC;--shiki-dark:#D27E99&quot;&gt; 1000&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt; targetDate&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#9CABCA&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#5C6166B3;--shiki-dark:#9CABCA&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that we both call &lt;code&gt;js›updateTime()&lt;/code&gt; directly and inside &lt;code&gt;js›setInterval()&lt;/code&gt;. If we only did it with &lt;code&gt;js›setInterval()&lt;/code&gt; it would take a second to update the webpage, and it would look like our countdown was frozen at 0.&lt;/p&gt;
&lt;p&gt;If you save this file and open up &lt;code&gt;index.html&lt;/code&gt; with a browser, you should see a timer ticking! When I set it to my exam date and open it up, I see the following:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;An animated gif showing the countdown in action. A little more than four days are remaining.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1001&quot; height=&quot;607&quot; src=&quot;/_astro/countdown6.CxCARxF7_Z2tarxr.webp&quot;&gt;&lt;/p&gt;
&lt;p&gt;I really should get back to studying.&lt;/p&gt;
</content:encoded></item><item><title>Why you should learn plain HTML and CSS first</title><link>https://eaj.no/posts/why-you-should-learn-plain-html-and-css-first</link><guid isPermaLink="true">https://eaj.no/posts/why-you-should-learn-plain-html-and-css-first</guid><description>Don&apos;t try to run before you can crawl.</description><pubDate>Fri, 01 May 2020 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This site is made using &lt;a href=&quot;https://gatsbyjs.org&quot;&gt;Gatsby&lt;/a&gt;.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; It is a &lt;a href=&quot;https://www.netlify.com/blog/2020/04/14/what-is-a-static-site-generator-and-3-ways-to-find-the-best-one/&quot;&gt;static site generator&lt;/a&gt; based on &lt;a href=&quot;https://reactjs.org/&quot;&gt;React&lt;/a&gt;, a Javascript library that is designed for building web applications. This allows me to write each article as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Markdown&quot;&gt;Markdown&lt;/a&gt; file, a file format that is mostly plain text with a few simple syntax rules for specifying styles such as &lt;em&gt;italic&lt;/em&gt; text. This file is then compiled into HTML by Gatsby, so that I don’t have to.&lt;/p&gt;
&lt;p&gt;Yet, I’m saying you should go through the trouble of learning HTML and CSS. If tools like Gatsby and React exist, why on earth would you do that?&lt;/p&gt;
&lt;p&gt;For one, using web frameworks don’t absolve you of writing HTML and CSS. This is a snippet from the file that defines the header that is on every page of this site:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes ayu-light kanagawa-wave&quot; style=&quot;background-color:#f8f9fa;--shiki-dark-bg:#1F1F28;color:#5c6166;--shiki-dark:#DCD7BA; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;jsx&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; className&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;brand&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Link&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; to&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;img&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;logo&lt;/span&gt;&lt;span style=&quot;color:#FA8532;--shiki-dark:#9CABCA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; alt&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#EBA400;--shiki-dark:#957FB8&quot;&gt; className&lt;/span&gt;&lt;span style=&quot;color:#F2A191;--shiki-dark:#E6C384&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#86B300;--shiki-dark:#98BB6C&quot;&gt;&quot;logo&quot;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#5C6166;--shiki-dark:#DCD7BA&quot;&gt;Erik André Jakobsen&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#22A4E6;--shiki-dark:#7AA89F&quot;&gt;Link&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#55B4D4;--shiki-dark:#E6C384&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#55B4D480;--shiki-dark:#9CABCA&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It isn’t pure HTML—I use a variable for the image &lt;code&gt;src&lt;/code&gt; for the logo, for instance—but just looking at this small snippet, you would be excused for thinking it is.&lt;/p&gt;
&lt;p&gt;The site is also styled using CSS.&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; If you use the button in the top right corner to toggle between dark and light mode, all that happens is that a little bit of Javascript adds a &lt;code&gt;class=&quot;dark&quot;&lt;/code&gt; attribute to the &lt;code&gt;&amp;lt;body /&amp;gt;&lt;/code&gt;, changing a few of the colors. There is no Framework ‘magic’.&lt;/p&gt;
&lt;p&gt;Next, frameworks aren’t the end-all, be-all of the modern web. If all you need is a landing page for your small business or your friend’s band, pulling out React would be like using a cannon to kill a bug. Sure, you &lt;em&gt;can&lt;/em&gt;, but why go through all that trouble when you could achieve the same result using much simpler tools?&lt;/p&gt;
&lt;p&gt;Finally, having a good understanding of HTML and CSS will give you a much deeper understanding of what more advanced tools are actually doing. You’ll probably get through the beginner tutorials for Gatsby without a lot of knowledge of how CSS works, but you’ll be copy-and-pasting a lot of code that you don’t understand.&lt;/p&gt;
&lt;p&gt;So how do you go about learning it? Personally I have enjoyed the tutorials by Brad Traversy on &lt;a href=&quot;https://www.udemy.com/&quot;&gt;Udemy&lt;/a&gt;, as well as the online course by &lt;a href=&quot;https://www.codecademy.com/&quot;&gt;Codecademy&lt;/a&gt;. Don’t just blindly go through them and then move on, however. &lt;strong&gt;Make something!&lt;/strong&gt; When you are building something from scratch there is nowhere to hide, and no solution manual for when you don’t understand something. If you want something to happen, you just have to figure it out, &lt;em&gt;really&lt;/em&gt; learning it in the process.&lt;/p&gt;
&lt;hr&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;My previous site, where this was first published, was made with Gatsby. This one uses &lt;a href=&quot;https://astro.build/&quot;&gt;Astro&lt;/a&gt;. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;It still is, but there is no theme button anymore. This site also has a dark and a light theme, but it follows your system theme with &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-color-scheme&quot;&gt;the &lt;code&gt;prefers-color-scheme&lt;/code&gt; media feature&lt;/a&gt;. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded></item></channel></rss>