<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Bruno Calza - Microblog</title>
  <link href="https://brunocalza.me/microblog/" />
  <link type="application/atom+xml" rel="self" href="https://brunocalza.me/microblog-feed.xml" />
  <updated>2026-04-09T20:17:58+00:00</updated>
  <id>https://brunocalza.me/microblog/</id>
  <author>
    <name></name>
  </author>
  
    <entry>
      <title>April 9, 2026</title>
      <link href="https://brunocalza.me/microblog/2026/04/09/jekyll-graphviz-plugin.html" />
      <id>https://brunocalza.me/microblog/2026/04/09/jekyll-graphviz-plugin</id>
      <updated>2026-04-09T20:17:58+00:00</updated>
      <content type="html">
        &lt;p&gt;All right! I’ve discovered a Graphviz plugin for Jekyll (&lt;a href=&quot;https://github.com/DerekStride/jekyll-graphviz&quot;&gt;jekyll-graphviz&lt;/a&gt;). I can simply embed Graphviz code in my blogs now, without the need to pre-render them. And with LLMs for Graphviz code generation, it becomes very smooth to generate the examples I want.&lt;/p&gt;

&lt;p&gt;For example, a pet’s inner monologue:&lt;/p&gt;

&lt;div class=&quot;graphviz-wrapper&quot;&gt;

&lt;!-- Generated by graphviz version 2.43.0 (0)
 --&gt;
&lt;!-- Title: %3 Pages: 1 --&gt;
&lt;svg role=&quot;img&quot; aria-label=&quot;graphviz-1e9bee4f16418110d43c41811cf83d30&quot; width=&quot;409pt&quot; height=&quot;729pt&quot; viewBox=&quot;0.00 0.00 409.04 729.00&quot;&gt;
&lt;title&gt;graphviz-1e9bee4f16418110d43c41811cf83d30&lt;/title&gt;
&lt;desc&gt;
digraph {
  node [shape=ellipse]
  
  &amp;quot;Sleep&amp;quot; -&amp;gt; &amp;quot;Hear noise&amp;quot; -&amp;gt; &amp;quot;Investigate&amp;quot;
  &amp;quot;Investigate&amp;quot; -&amp;gt; &amp;quot;It&amp;#39;s nothing&amp;quot; -&amp;gt; &amp;quot;Sleep&amp;quot;
  &amp;quot;Investigate&amp;quot; -&amp;gt; &amp;quot;It&amp;#39;s food!&amp;quot; -&amp;gt; &amp;quot;Eat&amp;quot;
  &amp;quot;Eat&amp;quot; -&amp;gt; &amp;quot;Still hungry?&amp;quot; 
  &amp;quot;Still hungry?&amp;quot; -&amp;gt; &amp;quot;Stare at human&amp;quot; [label=&amp;quot;yes&amp;quot;]
  &amp;quot;Still hungry?&amp;quot; -&amp;gt; &amp;quot;Sleep&amp;quot; [label=&amp;quot;no&amp;quot;]
  &amp;quot;Stare at human&amp;quot; -&amp;gt; &amp;quot;Human gives food&amp;quot; -&amp;gt; &amp;quot;Eat&amp;quot;
  &amp;quot;Stare at human&amp;quot; -&amp;gt; &amp;quot;Human ignores&amp;quot; -&amp;gt; &amp;quot;Knock something off table&amp;quot; -&amp;gt; &amp;quot;Human gives food&amp;quot;
}
&lt;/desc&gt;

&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 725)&quot;&gt;
&lt;title&gt;%3&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;transparent&quot; points=&quot;-4,4 -4,-725 405.04,-725 405.04,4 -4,4&quot; /&gt;
&lt;!-- Sleep --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Sleep&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;206&quot; cy=&quot;-703&quot; rx=&quot;36.29&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;206&quot; y=&quot;-699.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Sleep&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Hear noise --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Hear noise&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;117&quot; cy=&quot;-630&quot; rx=&quot;61.19&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;117&quot; y=&quot;-626.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Hear noise&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Sleep&amp;#45;&amp;gt;Hear noise --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Sleep&amp;#45;&amp;gt;Hear noise&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M187.55,-687.29C175.3,-677.51 158.97,-664.48 145.1,-653.42&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;147.27,-650.68 137.27,-647.18 142.91,-656.15 147.27,-650.68&quot; /&gt;
&lt;/g&gt;
&lt;!-- Investigate --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Investigate&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;115&quot; cy=&quot;-557&quot; rx=&quot;63.09&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;115&quot; y=&quot;-553.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Investigate&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Hear noise&amp;#45;&amp;gt;Investigate --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Hear noise&amp;#45;&amp;gt;Investigate&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M116.51,-611.81C116.29,-603.79 116.01,-594.05 115.76,-585.07&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;119.26,-584.93 115.48,-575.03 112.26,-585.12 119.26,-584.93&quot; /&gt;
&lt;/g&gt;
&lt;!-- It&amp;#39;s nothing --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;It&amp;#39;s nothing&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;186&quot; cy=&quot;-470&quot; rx=&quot;63.89&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;186&quot; y=&quot;-466.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;It&amp;#39;s nothing&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Investigate&amp;#45;&amp;gt;It&amp;#39;s nothing --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Investigate&amp;#45;&amp;gt;It&amp;#39;s nothing&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M129.02,-539.21C139.43,-526.75 153.78,-509.57 165.47,-495.57&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;168.27,-497.68 172,-487.76 162.9,-493.19 168.27,-497.68&quot; /&gt;
&lt;/g&gt;
&lt;!-- It&amp;#39;s food! --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;It&amp;#39;s food!&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;52&quot; cy=&quot;-470&quot; rx=&quot;51.99&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;52&quot; y=&quot;-466.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;It&amp;#39;s food!&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Investigate&amp;#45;&amp;gt;It&amp;#39;s food! --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Investigate&amp;#45;&amp;gt;It&amp;#39;s food!&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M102.55,-539.21C93.4,-526.87 80.82,-509.89 70.5,-495.97&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;73.18,-493.71 64.42,-487.76 67.56,-497.88 73.18,-493.71&quot; /&gt;
&lt;/g&gt;
&lt;!-- It&amp;#39;s nothing&amp;#45;&amp;gt;Sleep --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;It&amp;#39;s nothing&amp;#45;&amp;gt;Sleep&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M187.47,-488.01C190.91,-527.75 199.5,-626.95 203.66,-675.03&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;200.18,-675.35 204.52,-685.01 207.15,-674.75 200.18,-675.35&quot; /&gt;
&lt;/g&gt;
&lt;!-- Eat --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Eat&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;90&quot; cy=&quot;-397&quot; rx=&quot;27&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;90&quot; y=&quot;-393.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Eat&lt;/text&gt;
&lt;/g&gt;
&lt;!-- It&amp;#39;s food!&amp;#45;&amp;gt;Eat --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;It&amp;#39;s food!&amp;#45;&amp;gt;Eat&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M61,-452.17C65.61,-443.56 71.32,-432.9 76.44,-423.32&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;79.68,-424.68 81.32,-414.22 73.51,-421.38 79.68,-424.68&quot; /&gt;
&lt;/g&gt;
&lt;!-- Still hungry? --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Still hungry?&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;260&quot; cy=&quot;-324&quot; rx=&quot;70.69&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;260&quot; y=&quot;-320.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Still hungry?&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Eat&amp;#45;&amp;gt;Still hungry? --&gt;
&lt;g id=&quot;edge7&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Eat&amp;#45;&amp;gt;Still hungry?&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M112.22,-386.72C138.27,-375.84 182.09,-357.54 215.27,-343.68&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;216.87,-346.8 224.75,-339.72 214.18,-340.34 216.87,-346.8&quot; /&gt;
&lt;/g&gt;
&lt;!-- Still hungry?&amp;#45;&amp;gt;Sleep --&gt;
&lt;g id=&quot;edge9&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Still hungry?&amp;#45;&amp;gt;Sleep&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M266.9,-342.2C271.98,-356.39 278,-377.18 278,-396 278,-631 278,-631 278,-631 278,-654.19 258.83,-672.35 240.27,-684.5&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;238.29,-681.61 231.58,-689.81 241.94,-687.58 238.29,-681.61&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;287&quot; y=&quot;-509.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;no&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Stare at human --&gt;
&lt;g id=&quot;node8&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Stare at human&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;260&quot; cy=&quot;-237&quot; rx=&quot;83.39&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;260&quot; y=&quot;-233.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Stare at human&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Still hungry?&amp;#45;&amp;gt;Stare at human --&gt;
&lt;g id=&quot;edge8&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Still hungry?&amp;#45;&amp;gt;Stare at human&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M260,-305.8C260,-294.16 260,-278.55 260,-265.24&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;263.5,-265.18 260,-255.18 256.5,-265.18 263.5,-265.18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;272.5&quot; y=&quot;-276.8&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;yes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Human gives food --&gt;
&lt;g id=&quot;node9&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Human gives food&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;250&quot; cy=&quot;-18&quot; rx=&quot;94.78&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;250&quot; y=&quot;-14.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Human gives food&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Stare at human&amp;#45;&amp;gt;Human gives food --&gt;
&lt;g id=&quot;edge10&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Stare at human&amp;#45;&amp;gt;Human gives food&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M289.81,-220.19C339.47,-191.76 429.98,-129.68 391,-73 377.35,-53.16 355.33,-40.6 332.72,-32.66&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;333.6,-29.27 323.01,-29.53 331.46,-35.93 333.6,-29.27&quot; /&gt;
&lt;/g&gt;
&lt;!-- Human ignores --&gt;
&lt;g id=&quot;node10&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Human ignores&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;254&quot; cy=&quot;-164&quot; rx=&quot;81.79&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;254&quot; y=&quot;-160.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Human ignores&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Stare at human&amp;#45;&amp;gt;Human ignores --&gt;
&lt;g id=&quot;edge12&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Stare at human&amp;#45;&amp;gt;Human ignores&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M258.54,-218.81C257.86,-210.79 257.04,-201.05 256.28,-192.07&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;259.76,-191.7 255.43,-182.03 252.79,-192.29 259.76,-191.7&quot; /&gt;
&lt;/g&gt;
&lt;!-- Human gives food&amp;#45;&amp;gt;Eat --&gt;
&lt;g id=&quot;edge11&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Human gives food&amp;#45;&amp;gt;Eat&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M165.31,-26.31C126.93,-34.77 90,-52.62 90,-90 90,-325 90,-325 90,-325 90,-339.35 90,-355.33 90,-368.49&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;86.5,-368.78 90,-378.78 93.5,-368.78 86.5,-368.78&quot; /&gt;
&lt;/g&gt;
&lt;!-- Knock something off table --&gt;
&lt;g id=&quot;node11&quot; class=&quot;node&quot;&gt;
&lt;title&gt;Knock something off table&lt;/title&gt;
&lt;ellipse fill=&quot;none&quot; stroke=&quot;black&quot; cx=&quot;250&quot; cy=&quot;-91&quot; rx=&quot;131.88&quot; ry=&quot;18&quot; /&gt;
&lt;text text-anchor=&quot;middle&quot; x=&quot;250&quot; y=&quot;-87.3&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;Knock something off table&lt;/text&gt;
&lt;/g&gt;
&lt;!-- Human ignores&amp;#45;&amp;gt;Knock something off table --&gt;
&lt;g id=&quot;edge13&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Human ignores&amp;#45;&amp;gt;Knock something off table&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M253.03,-145.81C252.58,-137.79 252.03,-128.05 251.52,-119.07&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;255.01,-118.82 250.95,-109.03 248.02,-119.21 255.01,-118.82&quot; /&gt;
&lt;/g&gt;
&lt;!-- Knock something off table&amp;#45;&amp;gt;Human gives food --&gt;
&lt;g id=&quot;edge14&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;Knock something off table&amp;#45;&amp;gt;Human gives food&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M250,-72.81C250,-64.79 250,-55.05 250,-46.07&quot; /&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;253.5,-46.03 250,-36.03 246.5,-46.03 253.5,-46.03&quot; /&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>April 4, 2026</title>
      <link href="https://brunocalza.me/microblog/2026/04/04/my-attempt-to-understand-turboquant.html" />
      <id>https://brunocalza.me/microblog/2026/04/04/my-attempt-to-understand-turboquant</id>
      <updated>2026-04-04T22:53:03+00:00</updated>
      <content type="html">
        &lt;p&gt;Google announced a new quantization algorithm called TurboQuant that enables massive compression of KV cache on a LLM without compromising quality. My attempt here is to understand as best as I can what TurboQuant is, given that I don’t know too much about LLMs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is vector quantization and why it is needed?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose you have a vector of 32-bit floats with dimension &lt;em&gt;d&lt;/em&gt;, each vector coordinate takes 4 bytes. If &lt;em&gt;d&lt;/em&gt; is very high, as is usually the case in LLMs, you face a memory problem. The solution to that problem is to reduce its overall size by compressing it. That is called vector quantization.&lt;/p&gt;

&lt;p&gt;The simplest way of doing that is by mapping each coordinate of the vector to a known prespecified set, called &lt;em&gt;codebook&lt;/em&gt;. For example, let’s say our vector is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[0.76, -0.28, 0.10, 0.57]&lt;/code&gt; and we defined the &lt;em&gt;codebook&lt;/em&gt; as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[-1.0, -0.5, 0.0, 0.5, 1.0]&lt;/code&gt;, then we can map each coordinate to the index of the &lt;em&gt;codebook&lt;/em&gt; whose value is closest to the coordinate. In this case, that would result in the following vector &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[4, 1, 2, 3]&lt;/code&gt; . Because we only need 3 bits to represent the indices of the &lt;em&gt;codebook&lt;/em&gt;, we can say we reduced the memory footprint from 128 bits to 12 bits. You can also see that when we try to get our vector back, we lose information: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.76&lt;/code&gt; became &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1.0&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-0.28&lt;/code&gt; became &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-0.5&lt;/code&gt;, and so forth. Doing that kind of compression adds a lot of error, so the challenge is figuring out a &lt;em&gt;codebook&lt;/em&gt; that minimizes that error. We’re mainly interested in&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Mean Squared Error (MSE):&lt;/strong&gt; How different is the reconstructed vector from the original?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Inner product error:&lt;/strong&gt; If we compute the dot product between two vectors, how much does the dot product change after one of the vectors is quantized?&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am not really familiar with vector quantization algorithms but it looks like a common approach is trying to learn from &lt;strong&gt;trained model weights&lt;/strong&gt; using &lt;strong&gt;K-means&lt;/strong&gt; algorithm. Essentially, the &lt;em&gt;codebook&lt;/em&gt; is the centroid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google’s idea&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of trying to figure out the &lt;em&gt;codebook&lt;/em&gt; by looking at the data, they randomly transform the input by applying a random matrix. That may seem crazy but what happens is that by doing that kind of transformation you can make it so that your data falls into a very known distribution (in this case Beta distribution). Because your data is well-behaved, you can &lt;strong&gt;mathematically compute the optimal quantizer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Google proved that a &lt;em&gt;b-bit&lt;/em&gt; quantizer has an MSE upper-bound of $\frac{\sqrt{3}\times \pi}{2} * \frac{1}{ 4 ^b}$. Specifically, for $b = 1, 2, 3, 4$ we have $0.36, 0.117, 0.03, 0.009$, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MSE optimized quantizers are biased&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The above idea works to get the optimal MSE quantizer. But they found out that those quantizers are biased towards the &lt;strong&gt;Inner product error&lt;/strong&gt;. They figured out a solution with a two stage algorithm that first applies the above idea with a bit-width one less than their target budget and then applies a 1-bit quantizer called &lt;em&gt;Quantized Johnson-Lindenstrauss&lt;/em&gt; on the residual error. I am not familiar with QJL, so I’ll keep it as a black box for now. But the essence is applying two quantization strategies, one with $(b-1)$ bits to get the optimal MSE quantizer and the other with 1 bit to fix the bias produced by the first one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://research.google/blog/turboquant-redefining-ai-efficiency-with-extreme-compression/&quot;&gt;https://research.google/blog/turboquant-redefining-ai-efficiency-with-extreme-compression/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://x.com/TheVixhal/status/2039770532657377656&quot;&gt;https://x.com/TheVixhal/status/2039770532657377656&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2504.19874&quot;&gt;https://arxiv.org/pdf/2504.19874&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://gist.github.com/aaaddress1/a226e5e401b02a935805fabc97552db1&quot;&gt;https://gist.github.com/aaaddress1/a226e5e401b02a935805fabc97552db1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


      </content>
    </entry>
  
    <entry>
      <title>April 4, 2026</title>
      <link href="https://brunocalza.me/microblog/2026/04/04/tried-gemma4-on-llamacpp.html" />
      <id>https://brunocalza.me/microblog/2026/04/04/tried-gemma4-on-llamacpp</id>
      <updated>2026-04-04T14:23:15+00:00</updated>
      <content type="html">
        &lt;p&gt;After my failed attempts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama&lt;/code&gt; and LM Studio (&lt;a href=&quot;/microblog/2026/04/03/gibberish-results-running-gemma4-on-my-integrated-gpu/&quot;&gt;Gibberish results running gemma4 on my integrated GPU&lt;/a&gt; and &lt;a href=&quot;/microblog/2026/04/04/tried-gemma4-on-lm-studio/&quot;&gt;Tried gemma4 on LM Studio&lt;/a&gt;), this time I tried &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;llama.cpp&lt;/code&gt; as the inference engine. To my surprise it ran just fine on my integrated &lt;strong&gt;GPU&lt;/strong&gt;.  I mean, slow, but fine without errors. I ran the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gemma:e2b&lt;/code&gt; version with&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./llama-cli &lt;span class=&quot;nt&quot;&gt;-hf&lt;/span&gt; ggml-org/gemma-4-E2B-it-GGUF
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can control how many layers are offloaded to GPU with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-ngl&lt;/code&gt; flag. For example, if we set it to 10:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./llama-cli &lt;span class=&quot;nt&quot;&gt;-hf&lt;/span&gt; ggml-org/gemma-4-E2B-it-GGUF &lt;span class=&quot;nt&quot;&gt;-ngl&lt;/span&gt; 10 &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can see &lt;em&gt;offloaded 10/36 layers to GPU&lt;/em&gt; in the logs. You can set it to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;all&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./llama-cli &lt;span class=&quot;nt&quot;&gt;-hf&lt;/span&gt; ggml-org/gemma-4-E2B-it-GGUF &lt;span class=&quot;nt&quot;&gt;-ngl&lt;/span&gt; all &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and you’ll see &lt;em&gt;offloaded 36/36 layers to GPU&lt;/em&gt; in the logs. &lt;strong&gt;GPU&lt;/strong&gt; &lt;strong&gt;usage&lt;/strong&gt; could be checked with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;intel_gpu_top&lt;/code&gt; program.&lt;/p&gt;

&lt;p&gt;I uploaded an image of a kitten to the model. And it was able to identify it just fine.&lt;/p&gt;


      </content>
    </entry>
  
    <entry>
      <title>April 4, 2026</title>
      <link href="https://brunocalza.me/microblog/2026/04/04/tried-gemma4-on-lm-studio.html" />
      <id>https://brunocalza.me/microblog/2026/04/04/tried-gemma4-on-lm-studio</id>
      <updated>2026-04-04T14:10:16+00:00</updated>
      <content type="html">
        &lt;p&gt;I also tried &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gemma4&lt;/code&gt; on LM Studio, but it failed to load the model, not really sure why. See &lt;a href=&quot;/microblog/2026/04/03/gibberish-results-running-gemma4-on-my-integrated-gpu/&quot;&gt;Gibberish results running gemma4 on my integrated GPU&lt;/a&gt; on my failed attempt at running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gemma4&lt;/code&gt; on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Phi3.5 3.8B&lt;/strong&gt; model worked though. I did a test by setting &lt;strong&gt;GPU&lt;/strong&gt; offloading to 0. You can see the usage of &lt;strong&gt;GPU&lt;/strong&gt; going from 100% to a very low number using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;intel_gpu_top&lt;/code&gt;.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>April 3, 2026</title>
      <link href="https://brunocalza.me/microblog/2026/04/03/gibberish-results-running-gemma4-on-my-integrated-gpu.html" />
      <id>https://brunocalza.me/microblog/2026/04/03/gibberish-results-running-gemma4-on-my-integrated-gpu</id>
      <updated>2026-04-03T17:14:57+00:00</updated>
      <content type="html">
        &lt;p&gt;I’ve never really tried running LLM models on my machine. Decided to see if I could run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gemma4&lt;/code&gt;. So, I’ve installed &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama&lt;/code&gt;, and the first thing I noticed was a warning that it would run the models on my &lt;strong&gt;CPU&lt;/strong&gt;, not my &lt;strong&gt;GPU&lt;/strong&gt;, because it did not detect any &lt;strong&gt;NVIDIA GPU&lt;/strong&gt;. So I went on a journey trying to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gemma4&lt;/code&gt; on my &lt;strong&gt;Intel Meteor Lake&lt;/strong&gt; integrated &lt;strong&gt;GPU&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It turned out not to be that hard. You must set an environment flag on your ollama service.&lt;/p&gt;

&lt;p&gt;Edit the service:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl edit ollama
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And add:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Service]
Environment=&quot;OLLAMA_VULKAN=1&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When I ran the model &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama run gemma4&lt;/code&gt; and gave a prompt, it responded with a lot of  gibberish. So, I removed the flag and ran again, and the model behaved just fine.&lt;/p&gt;

&lt;p&gt;I wasn’t sure whether the flag worked. Trying to find that out, I came across &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama ps&lt;/code&gt;. That command showed how much compute was going to the &lt;strong&gt;CPU&lt;/strong&gt; and how much to the &lt;strong&gt;GPU&lt;/strong&gt;. With &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OLLAMA_VULKAN=1&lt;/code&gt;, it showed a &lt;strong&gt;68%/32% split&lt;/strong&gt; (in which &lt;strong&gt;68%&lt;/strong&gt; going to the &lt;strong&gt;CPU&lt;/strong&gt;). And with the flag disabled, it showed 100% &lt;strong&gt;CPU&lt;/strong&gt; usage. That meant that, for some reason, Ollama decided to split the model, which forced the data to move between &lt;strong&gt;CPU&lt;/strong&gt; and &lt;strong&gt;GPU&lt;/strong&gt;, and in that movement, something must have gone wrong.&lt;/p&gt;

&lt;p&gt;To test whether the split was the problem, I ran a smaller model &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama run phi3.5:3.8b&lt;/code&gt; . And this time &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama ps&lt;/code&gt; showed compute was &lt;strong&gt;100% GPU&lt;/strong&gt;, and the model worked just fine.&lt;/p&gt;

&lt;p&gt;I’d love to know why &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama&lt;/code&gt; decided split like that. I have 54 GiB of memory in my system, maybe &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ollama&lt;/code&gt; could not see through &lt;strong&gt;Vulkan&lt;/strong&gt; driver how much of that was being allocated to GPU and it thought it would not have enough? And the second question is, even with the split, it should be working; there must be a bug somewhere that introduces the gibberish.&lt;/p&gt;


      </content>
    </entry>
  
    <entry>
      <title>September 11, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/09/11/c-concepts.html" />
      <id>https://brunocalza.me/microblog/2025/09/11/c-concepts</id>
      <updated>2025-09-11T16:28:07+00:00</updated>
      <content type="html">
        &lt;p&gt;I implemented a templated class in C++. One of its methods had an equality check, which made me wonder how C++ handled the fact that my generic type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T&lt;/code&gt; might not support the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;==&lt;/code&gt; operator.&lt;/p&gt;

&lt;p&gt;Let’s consider the following class to illustrate:&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;template&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;typename&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;nl&quot;&gt;public:&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;is&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You see the equality check &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;value == v&lt;/code&gt; there. But &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v&lt;/code&gt; can be of any type. How does C++ handle that? Is there a way of enforcing that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T&lt;/code&gt; must support &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;==&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;So let’s consider the following &lt;em&gt;struct&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Foo&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Foo&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So, the program below compiles just fine.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;foo1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Which is weird because we know that if we call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;foo1.is&lt;/code&gt; the program will likely break.&lt;/p&gt;

&lt;p&gt;Let’s call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;foo1.is&lt;/code&gt;, then:&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;foo1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;foo1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;is&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now the program fails to compile:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;main.cpp: In instantiation of ‘bool A&amp;lt;T&amp;gt;::is&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;T&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;with T &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; Foo]’:
main.cpp:35:25:   required from here
main.cpp:20:20: error: no match &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; ‘operator&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;’ &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;operand types are ‘Foo’ and ‘Foo’&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
   20 |       &lt;span class=&quot;k&quot;&gt;return &lt;/span&gt;value &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; v&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      |              ~~~~~~^~~~
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So, it is only when we call the function that executes the unsupported operation that the compiler complains. I wondered if there was a way to enforce this requirement at the time of object instantiation, and there is.
C++20 introduced &lt;a href=&quot;https://en.cppreference.com/w/cpp/language/constraints.html&quot;&gt;concepts&lt;/a&gt;, a way of specifying requirements explicitly. We can add the concept &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;std::equality_comparable&lt;/code&gt; to our template:&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;concepts&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;template&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;equality_comparable&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; 
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  
  &lt;span class=&quot;nl&quot;&gt;public:&lt;/span&gt; 
  &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;   
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  
  &lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;is&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  
  &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and we get a compilation error at the instantiation:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;main.cpp: In &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; ‘int main&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;’:
main.cpp:35:10: error: template constraint failure &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; ‘template  requires  equality_comparable class A’
   35 |     A&amp;lt;Foo&amp;gt; foo1 &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; Foo&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      |          ^
main.cpp:35:10: note: constraints not satisfied
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we now add support for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;==&lt;/code&gt; operator in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Foo&lt;/code&gt;, the program compiles:&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Foo&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;operator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>September 8, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/09/08/look-for-bugs.html" />
      <id>https://brunocalza.me/microblog/2025/09/08/look-for-bugs</id>
      <updated>2025-09-08T17:43:43+00:00</updated>
      <content type="html">
        &lt;p&gt;From &lt;a href=&quot;https://matklad.github.io/2025/09/04/look-for-bugs.html&quot;&gt;Look Out For Bugs&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The key is careful, slow reading. What you actually are doing is building the mental model of a program inside your head. Reading the source code is just an instrument for achieving that goal. I can’t emphasize this enough: programming is all about building a precise understanding inside your mind, and then looking for the diff between your brain and what’s in git.&lt;/p&gt;
&lt;/blockquote&gt;

      </content>
    </entry>
  
    <entry>
      <title>August 12, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/08/12/automatic-database-migrations-with-pgadvisorylock.html" />
      <id>https://brunocalza.me/microblog/2025/08/12/automatic-database-migrations-with-pgadvisorylock</id>
      <updated>2025-08-12T21:12:10+00:00</updated>
      <content type="html">
        &lt;p&gt;When you are implementing a Continuous Delivery pipeline, one of the issues you have to deal with is database migrations. You want to be able to automatically run the migrations. But if you have multiple instances of your app running, you have to make sure only one instance is able to run that migration. If you’re on Postgres, an easy way to solve this is to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pg_advisory_lock&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You acquire a lock by providing an integer that can represent anything, run the migration logic, then release the lock:&lt;/p&gt;

&lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pg_advisory_lock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- run migration logic&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pg_advisory_unlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Any concurrent process that attempts to run the same logic will be blocked until the lock is released.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>August 4, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/08/04/tail-call-optimization.html" />
      <id>https://brunocalza.me/microblog/2025/08/04/tail-call-optimization</id>
      <updated>2025-08-04T20:03:27+00:00</updated>
      <content type="html">
        &lt;p&gt;I have always accepted the fact that a recursive implementation can be easily optimized by the compiler if the recursive call is in the tail position, but I never understood why. That can be easily understood in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; if we reimplement a recursive function using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;goto&lt;/code&gt;. For example, let’s implement a recursive function that counts the number of numbers between two numbers:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Refactoring that to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;goto&lt;/code&gt;, we can see that by having a recursive &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;count&lt;/code&gt; call as the last action, it’s easy to optimize to keep the same stack frame while transitioning the state across iterations.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;iterate:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;goto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;iterate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>July 18, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/07/18/create-an-image-file-from-an-image-copied-to-the-clipboard.html" />
      <id>https://brunocalza.me/microblog/2025/07/18/create-an-image-file-from-an-image-copied-to-the-clipboard</id>
      <updated>2025-07-18T21:38:43+00:00</updated>
      <content type="html">
        &lt;p&gt;Here’s way of creating an image file from an image copied to the clipboard&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xclip &lt;span class=&quot;nt&quot;&gt;-selection&lt;/span&gt; clipboard &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; image/png &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; image.png
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>July 8, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/07/08/the-plight-of-the-misunderstood-memory-ordering.html" />
      <id>https://brunocalza.me/microblog/2025/07/08/the-plight-of-the-misunderstood-memory-ordering</id>
      <updated>2025-07-08T15:10:33+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://www.grayolson.me/blog/posts/misunderstood-memory-ordering/&quot;&gt;The plight of the misunderstood memory ordering&lt;/a&gt;. Interesting article that explains a common misunderstanding about the purpose of memory ordering when using atomics. The point of the article is that memory ordering is not about the atomic value being shared across threads, but about what to expect to happen &lt;strong&gt;around&lt;/strong&gt; the atomic value being accessed. The purpose is to synchronize the relative ordering between atomic accesses made to one atomic value with memory accesses made to any other value.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>July 7, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/07/07/good-enough-programming.html" />
      <id>https://brunocalza.me/microblog/2025/07/07/good-enough-programming</id>
      <updated>2025-07-07T15:06:53+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://danielbmarkham.com/good-enough-programming/&quot;&gt;Good Enough Programming&lt;/a&gt;. Interesting post about the reasons we modify code and when we can call a software good enough.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Let’s say that last week you wrote an app that people love and use every day. What are the reasons you would touch it again? Why would you go back in and change anything?&lt;/p&gt;

  &lt;p&gt;There are only three:&lt;/p&gt;

  &lt;ol&gt;
    &lt;li&gt;You want to add new things so that people like it more in the future&lt;/li&gt;
    &lt;li&gt;You want to fix broken things, things people currently do not like&lt;/li&gt;
    &lt;li&gt;You want to make your work easier. It looks difficult to maintain if one day you have to go back to fix or add things&lt;/li&gt;
  &lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;Good enough software is that which delivers the value and you can walk away from it. Essentially, 1 and 2 are taken care of.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>July 1, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/07/01/bloom-filters-by-example.html" />
      <id>https://brunocalza.me/microblog/2025/07/01/bloom-filters-by-example</id>
      <updated>2025-07-01T02:11:38+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://llimllib.github.io/bloomfilter-tutorial/&quot;&gt;Bloom Filters by Example&lt;/a&gt;. I’ve heard of &lt;strong&gt;Bloom Filters&lt;/strong&gt; a bunch of times but never took the time to understand how it works. For some reason I thought it would be hard, so I never really tried. Decided to read this article today and it turned out to be a pretty simple data structure. A &lt;strong&gt;Bloom Filter&lt;/strong&gt; is a &lt;strong&gt;Bit Vector&lt;/strong&gt;, let’s use a bit vector of size 16 as an example:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Indexes:   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
Bits:     &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We add items to our set by applying &lt;em&gt;n&lt;/em&gt; hash functions and using the results to set the bits of the bit vector.&lt;/p&gt;

&lt;p&gt;For example, suppose we have a hash function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;h1&lt;/code&gt;. If we hash “apple” with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;h1&lt;/code&gt;, we might get a large number like:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;h1&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apple&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 74329
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;But our bit array only has 16 positions. So we reduce it to a valid index with:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;index &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 74329 % 16 &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This means: Set bit at index 9 to 1.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Indexes:   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
Bits:     &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt;✖][ &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So, if we use 3 hashes in our &lt;strong&gt;Bloom Filter&lt;/strong&gt; implementation, we may end up with the following configuration:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Indexes:   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
Bits:     &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt;✖][✖][ &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt;✖][ &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;][&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To check if an item is in the set, hash it with the same functions and see if all the resulting bit positions are set to 1 in the array. If they aren’t you know for sure, the item is not in the set.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 26, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/26/custom-query-parser-in-express.html" />
      <id>https://brunocalza.me/microblog/2025/06/26/custom-query-parser-in-express</id>
      <updated>2025-06-26T21:47:20+00:00</updated>
      <content type="html">
        &lt;p&gt;I was looking for a way to support dot notation in the parameters of my query string in my HTTP endpoint. For example, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/search?user.name=Bruno&amp;amp;car.name=Honda+Civic&lt;/code&gt;. I wanted &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;req.query&lt;/code&gt; to be parsed in a structured way so that I could do&lt;/p&gt;

&lt;div class=&quot;language-typescript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;userName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{},&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;car&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;carName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It turns out you can set a custom query parser in your Express app. Additionally, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qs&lt;/code&gt;, a query string parser already used in Express, supports the dot notation. Here’s how to implement it:&lt;/p&gt;

&lt;div class=&quot;language-typescript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Use custom query parser&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;query parser&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;qs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;allowDots&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here’s a simple demo implementation:&lt;/p&gt;

&lt;div class=&quot;language-typescript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Response&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;as &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;qs&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;qs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;express&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Use custom query parser&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;query parser&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;qs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;allowDots&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}));&lt;/span&gt;

&lt;span class=&quot;kr&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;SearchQuery&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;car&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;/search&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{},&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;SearchQuery&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;userName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;car&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;carName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{},&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;userName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;User name:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;userName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;carName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Car name:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;carName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;userName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;carName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;PORT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`Server is running on port &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;PORT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 26, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/26/avoiding-redirects-in-axios.html" />
      <id>https://brunocalza.me/microblog/2025/06/26/avoiding-redirects-in-axios</id>
      <updated>2025-06-26T21:30:04+00:00</updated>
      <content type="html">
        &lt;p&gt;I had a failing test when Axios made a request to one of my API endpoints. The test reported a failure to connect to the server. That was weird because I was sure the server was up and running. It turned out the endpoint I was testing implemented an HTTP redirect to an unavailable location. Axios was following the redirect and trying to connect to that location, which is why I was seeing a failure to connect to the server.&lt;/p&gt;

&lt;p&gt;To avoid that, we can configure Axios not to follow redirects&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nf&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;should redirect to correct location&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;async &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;axios&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;http://example.com&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;maxRedirects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;validateStatus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

  &lt;span class=&quot;nf&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;toBeGreaterThanOrEqual&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;toBeLessThan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;toBe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;https://expected.com/target&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 24, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/24/error-handling-in-typescript.html" />
      <id>https://brunocalza.me/microblog/2025/06/24/error-handling-in-typescript</id>
      <updated>2025-06-24T00:01:39+00:00</updated>
      <content type="html">
        &lt;p&gt;I’m not very familiar with TypeScript patterns for handling errors. I was wondering what would be an interesting way to define domain-specific error types so that I can be very specific on what happened inside a function execution.&lt;/p&gt;

&lt;p&gt;Consider a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createUser&lt;/code&gt; function that creates a user. We can create a generic Rust-like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Result&lt;/code&gt; type:&lt;/p&gt;

&lt;div class=&quot;language-typescript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 
  &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;E&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then define domain-specific error types as a discriminated union:&lt;/p&gt;

&lt;div class=&quot;language-typescript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;CreateUserError&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;EmailAlreadyExists&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;InvalidEmailFormat&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;WeakPassword&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;reason&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;createUser&lt;/code&gt; function becomes:&lt;/p&gt;

&lt;div class=&quot;language-typescript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createUser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;CreateUserError&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;isValidEmail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;InvalidEmailFormat&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;isStrongPassword&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;WeakPassword&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;reason&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Too short&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;emailExists&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;EmailAlreadyExists&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 18, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/18/codespell.html" />
      <id>https://brunocalza.me/microblog/2025/06/18/codespell</id>
      <updated>2025-06-18T20:50:05+00:00</updated>
      <content type="html">
        &lt;p&gt;Today I learned about &lt;a href=&quot;https://github.com/codespell-project/codespell&quot;&gt;codespell&lt;/a&gt;. A CLI tool for checking and fixing misspellings. I can check and fix if any of my blog posts have any misspellings with&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;codespell &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-w&lt;/span&gt; _posts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 17, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/17/lock-free-rust.html" />
      <id>https://brunocalza.me/microblog/2025/06/17/lock-free-rust</id>
      <updated>2025-06-17T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://yeet.cx/blog/lock-free-rust/&quot;&gt;Lock-Free Rust: How to Build a Rollercoaster While It’s on Fire&lt;/a&gt;. In this article a lock-free array is built in Rust using atomics and memory ordering control. It’s useful to understand that lock-free algorithms are not so easy to build. You have to understand memory ordering semantics and how to apply them.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 17, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/17/why-locks-have-worse-performance.html" />
      <id>https://brunocalza.me/microblog/2025/06/17/why-locks-have-worse-performance</id>
      <updated>2025-06-17T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;strong&gt;Why locks typically have worse performance than atomics?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The main reason is that locks can rely on syscalls like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;futex&lt;/code&gt; to put threads to sleep when there’s contention, which introduces overhead such as context switches. In contrast, atomic operations are low-level CPU instructions executed entirely in user space, avoiding these costly transitions. Additionally, locks tend to serialize access to larger critical sections, while atomics enable more fine-grained concurrency, reducing contention and improving performance in many scenarios.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 16, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/16/atomics-and-concurrency.html" />
      <id>https://brunocalza.me/microblog/2025/06/16/atomics-and-concurrency</id>
      <updated>2025-06-16T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://redixhumayun.github.io/systems/2024/01/03/atomics-and-concurrency.html&quot;&gt;Atomics And Concurrency&lt;/a&gt;. This article explains the importance of memory ordering when writing concurrent programs using atomics. Essentially, data races can occur because compilers and CPUs may reorder instructions. As a result, threads operating on shared data might observe operations in an unintended order.&lt;/p&gt;

&lt;p&gt;Some programming languages, such as C++ and Rust, give you finer control over the memory model by exposing detailed options through their atomics APIs. In C++, for example, the memory models include:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Relaxed: no ordering guarantees&lt;/li&gt;
  &lt;li&gt;Sequentially consistent: enforces ordering on paired operations for specific variables&lt;/li&gt;
  &lt;li&gt;Release–Acquire: introduces a global ordering barrier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other languages, like Go, don’t provide this level of control. Instead, Go implements a sequentially consistent memory model under the hood.&lt;/p&gt;

&lt;p&gt;Russ Coss does a great job explaining hardware memory models, how different programming languages exposes memory models control and Go’s memory model in the following articles:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://research.swtch.com/hwmm&quot;&gt;Hardware Memory Models&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://research.swtch.com/plmm&quot;&gt;Programming Language Memory Models&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://research.swtch.com/gomm&quot;&gt;Updating the Go Memory Model&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 13, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/13/embeddings-are-underrated.html" />
      <id>https://brunocalza.me/microblog/2025/06/13/embeddings-are-underrated</id>
      <updated>2025-06-13T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://technicalwriting.dev/ml/embeddings/overview.html&quot;&gt;Embeddings are underrated&lt;/a&gt;. Blog post on how underrated embeddings is for technical writers.&lt;/p&gt;

&lt;p&gt;I’m still not very familiar with the world of embeddings, it was nice to see concepts. Essentially embeddings is a way of semantically representing text as a multidimensional vector of floats, making it easier to compare similarity across texts.&lt;/p&gt;

&lt;p&gt;Word embeddings was introduced in the foundational paper &lt;a href=&quot;https://arxiv.org/pdf/1301.3781&quot;&gt;Word2Vec&lt;/a&gt;, and is also how Large Language Models represent words and capture semantic relationships, although in more complex and advanced way.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jalammar.github.io/illustrated-word2vec/&quot;&gt;The Illustrated Word2vec&lt;/a&gt; illustrates the inner workings of Word2Vec.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 13, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/13/systems-correctness-practices-at-aws.html" />
      <id>https://brunocalza.me/microblog/2025/06/13/systems-correctness-practices-at-aws</id>
      <updated>2025-06-13T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://cacm.acm.org/practice/systems-correctness-practices-at-amazon-web-services/&quot;&gt;Systems Correctness Practices at Amazon Web Services&lt;/a&gt;. Article on the portifolio of formal methods used across AWS.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Our experience at AWS with TLA+ revealed two significant advantages of applying formal methods in practice. First, we could identify and eliminate subtle bugs early in development—bugs that would have eluded traditional approaches such as testing. Second, we gained the deep understanding and confidence needed to implement aggressive performance optimizations while maintaining systems correctness.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here’s a list of techniques they use:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;P programming language to model and specify distributed systems. It was used, for example, on migrating Simple Storage Service (S3) from eventual to strong read-after-write consistency.&lt;/li&gt;
  &lt;li&gt;Dafne programming language to prove that the Cedar authorization policy language implementation satisfies a variety of security properties&lt;/li&gt;
  &lt;li&gt;A tool called Kani was used by the Firecracker team to prove key properties of security boundaries&lt;/li&gt;
  &lt;li&gt;Fault Injection Service that injects simulated faults, from API errors to I/O pauses and failed instances&lt;/li&gt;
  &lt;li&gt;Also property-based testing, deterministic simulation, and continuous fuzzing or random test-input generation&lt;/li&gt;
&lt;/ul&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 11, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/11/compiler-explorer-and-nsjail.html" />
      <id>https://brunocalza.me/microblog/2025/06/11/compiler-explorer-and-nsjail</id>
      <updated>2025-06-11T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;I read &lt;a href=&quot;https://xania.org/202506/how-compiler-explorer-works&quot;&gt;How Compiler Explorer Works in 2025&lt;/a&gt; and a lightweight process isolation tool called &lt;a href=&quot;https://nsjail.dev/&quot;&gt;nsjail&lt;/a&gt; caught my eye.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 5, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/05/ai-coding-tweet.html" />
      <id>https://brunocalza.me/microblog/2025/06/05/ai-coding-tweet</id>
      <updated>2025-06-05T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;Interesting &lt;a href=&quot;https://x.com/karpathy/status/1930305209747812559&quot;&gt;tweet&lt;/a&gt; that resonates a lot with how I feel about the use of AI for coding. I can type faster, but not sure if I can deliver faster.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 2, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/02/switching-away-from-oop.html" />
      <id>https://brunocalza.me/microblog/2025/06/02/switching-away-from-oop</id>
      <updated>2025-06-02T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=ToBF_mLxEcI&quot;&gt;Switching away from OOP | Casey Muratori&lt;/a&gt;. Casey Muratori always has strong takes against OOP. I thought it was worth making a note about this one:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;The lie is if something is object oriented it will be easier for someone else to integrate, because it’s all encapsulated. The truth is the opposite. The more walled off something is the harder it is for someone to integrate because there’s nothing they can do with it. The only things they can do are things you’ve already thought of and provided an interface for and anything you forgot, they’re powerless. They have to wait for an update.&lt;/p&gt;
&lt;/blockquote&gt;

      </content>
    </entry>
  
    <entry>
      <title>June 2, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/06/02/how-to-build-an-agent.html" />
      <id>https://brunocalza.me/microblog/2025/06/02/how-to-build-an-agent</id>
      <updated>2025-06-02T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://ampcode.com/how-to-build-an-agent&quot;&gt;How to Build an Agent&lt;/a&gt;. I went through this tutorial today. It is very good for grasping the basics of how a coding agent works.&lt;/p&gt;

&lt;p&gt;I really like how he presents what an agent is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;An LLM with access to tools, giving it the ability to modify something outside the context window. An LLM with access to tools? What’s a tool? The basic idea is this: you send a prompt to the model that says it should reply in a certain way if it wants to use “a tool”. Then you, as the receiver of that message, “use the tool” by executing it and replying with the result. That’s it. Everything else we’ll see is just abstraction on top of it.&lt;/p&gt;
&lt;/blockquote&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 30, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/30/thoughts-on-thinking.html" />
      <id>https://brunocalza.me/microblog/2025/05/30/thoughts-on-thinking</id>
      <updated>2025-05-30T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://dcurt.is/thinking&quot;&gt;Thoughts on thinking&lt;/a&gt;. Nice blog post on how the use of AI makes the author feel about his relationship to writing and understanding.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Intellectual rigor comes from the journey: the dead ends, the uncertainty, and the internal debate. Skip that, and you might still get the insight–but you’ll have lost the infrastructure for meaningful understanding. Learning by reading LLM output is cheap. Real exercise for your mind comes from building the output yourself.&lt;/p&gt;
&lt;/blockquote&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 30, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/30/how-i-use-amp.html" />
      <id>https://brunocalza.me/microblog/2025/05/30/how-i-use-amp</id>
      <updated>2025-05-30T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://ampcode.com/how-i-use-amp&quot;&gt;Amp Is Now Available. Here Is How I Use It.&lt;/a&gt;. A blog post from Thorsten Ball, that works at Amp, describing his use of Amp. I kind of like compiling this kind of of “how I use LLMs” articles. There’s always something new you learn that you can use to refine your coding experience. Here’s a couple of examples that caught my eyes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Review&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Run `git diff` to see the code someone else wrote. Review it thoroughly and give me a report
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Code search&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Find the code that ensures unauthenticated users can view the /how-to-build-an-agent page too
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Interact with that database&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Update my user account (email starts with thorsten) to have unlimited invites
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 29, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/29/llm-step-by-step-thinking.html" />
      <id>https://brunocalza.me/microblog/2025/05/29/llm-step-by-step-thinking</id>
      <updated>2025-05-29T19:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Dk36u4NGeSU&quot;&gt;The Biggest “Lie” in AI? LLM doesn’t think step-by-step&lt;/a&gt;. Interesting video trying to make the point that the process in which a model arrives to a mathematical evaluation answer is not necessarily the process the model describes when asked to describe how it achieved the answer. In other words, the verbalization of the reasoning is not necessarily how they model reason, and it could be the case the verbalization might not even be key to reasoning.&lt;/p&gt;

&lt;p&gt;What I found odd about the video is that it kind of makes a claim that that is the reason LLMs don’t think like humans do. However, I’d say humans also can think without verbalizing, and, actually, verbalizing the thought process could even be difficult in some cases.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 29, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/29/cline-browser-testing.html" />
      <id>https://brunocalza.me/microblog/2025/05/29/cline-browser-testing</id>
      <updated>2025-05-29T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;Today I learned that Cline is able to open the browser and manually test your web app. I found that amazing. Here’s a &lt;a href=&quot;https://x.com/sdrzn/status/1850880547825823989&quot;&gt;demo&lt;/a&gt; from Cline’s founder Saoud Rizwan. Seems to be using Puppeteer under the hood.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 29, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/29/nova-javascript-engine.html" />
      <id>https://brunocalza.me/microblog/2025/05/29/nova-javascript-engine</id>
      <updated>2025-05-29T15:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://github.com/trynova/nova&quot;&gt;Nova&lt;/a&gt;. Interesting JavaScript engine written in Rust using data-oriented design and Entity-Component-System architecture.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 29, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/29/why-cline-doesnt-index-codebase.html" />
      <id>https://brunocalza.me/microblog/2025/05/29/why-cline-doesnt-index-codebase</id>
      <updated>2025-05-29T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://cline.bot/blog/why-cline-doesnt-index-your-codebase-and-why-thats-a-good-thing&quot;&gt;Why Cline Doesn’t Index Your Codebase (And Why That’s a Good Thing)&lt;/a&gt;. An interesting blog post by Cline on why they don’t use a RAG-based approach, which is common is similar products such as Cursor, to handle large codebases. In essence, their rational boils down to:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;they don’t think a RAG-based approach offers better codebase search results&lt;/li&gt;
  &lt;li&gt;it’s a pain to keep the index up-to-date&lt;/li&gt;
  &lt;li&gt;security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They say though that it may make sense for a product charging $20/month.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 25, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/25/rust-riscv-compilation.html" />
      <id>https://brunocalza.me/microblog/2025/05/25/rust-riscv-compilation</id>
      <updated>2025-05-25T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;Today, I worked on a small example on how to compile a Rust program targeting a RISC-V architecture. Essentially, you add the correct target&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rustup target add riscv64gc-unknown-linux-gnu
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;then configure the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;linker&lt;/code&gt; to use the appropriate GNU GCC linker and also the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;runner&lt;/code&gt; to QEMU, and statically link the C libraries.&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;[target.riscv64gc-unknown-linux-gnu]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;linker&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;riscv64-linux-gnu-gcc&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;rustflags&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;-C&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;&quot;target-feature&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;+crt-static&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;]&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;runner&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;qemu-riscv64&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can run the program with&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cargo run &lt;span class=&quot;nt&quot;&gt;--target&lt;/span&gt; riscv64gc-unknown-linux-gnu
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 25, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/25/uuidv7-postgresql-18.html" />
      <id>https://brunocalza.me/microblog/2025/05/25/uuidv7-postgresql-18</id>
      <updated>2025-05-25T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://www.thenile.dev/blog/uuidv7&quot;&gt;UUIDv7 Comes to PostgreSQL 18&lt;/a&gt;.  A blog post from &lt;a href=&quot;https://www.thenile.dev/&quot;&gt;Nile&lt;/a&gt; that discusses the new UUID version that will come with the next PostgreSQL release.&lt;/p&gt;

&lt;p&gt;Essentially, in regard to the use of UUIDs in databases, there are 3 common concerns: &lt;strong&gt;sorting&lt;/strong&gt;, &lt;strong&gt;index locality&lt;/strong&gt; and &lt;strong&gt;size&lt;/strong&gt;. The new version solves the &lt;strong&gt;sorting&lt;/strong&gt; and &lt;strong&gt;index locality&lt;/strong&gt; by using Unix Epoch timestamp as the most significant 48 bits, keeping the other 74 bits for random values.&lt;/p&gt;

&lt;p&gt;By calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uuidv7()&lt;/code&gt;, a new UUIDv7 can be generated with the timestamp set to current time. An optional interval can be passed to generate a value for a different time&lt;/p&gt;

&lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuidv7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTERVAL&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;1 day&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 24, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/24/cpu-governor-pop-os.html" />
      <id>https://brunocalza.me/microblog/2025/05/24/cpu-governor-pop-os</id>
      <updated>2025-05-24T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;So, I have a Lemur Pro 13 notebook running Pop!_OS. Since I first started using it, I noticed the fan noise gets very loud quite frequently. It took me a while to figure out the cause, but I finally discovered the reason: it was running in maximum performance mode.&lt;/p&gt;

&lt;p&gt;The CPU performance is managed by a component of the operating system called the governor, which controls how the CPU frequency is adjusted based on system load.&lt;/p&gt;

&lt;p&gt;In Pop!_OS, there are two available governors: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;performance&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;powersave&lt;/code&gt;. You can check which ones are available with:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
performance powersave
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;You can check the current governor for each CPU core by running:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /sys/devices/system/cpu/cpu&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;/cpufreq/scaling_governor
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To change the governor to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;powersave&lt;/code&gt; for all CPUs, run:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;powersave | &lt;span class=&quot;nb&quot;&gt;sudo tee&lt;/span&gt; /sys/devices/system/cpu/cpu&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;/cpufreq/scaling_governor
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 24, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/24/risc-v-assembly-in-10-minutes.html" />
      <id>https://brunocalza.me/microblog/2025/05/24/risc-v-assembly-in-10-minutes</id>
      <updated>2025-05-24T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=GWiAQs4-UQ0&quot;&gt;You Can Learn RISC-V Assembly in 10 Minutes | Getting Started RISC-V Assembly on Linux Tutorial
&lt;/a&gt;. I’ve watched this video today to get a sense of how to program a simple thing using RISC-V assembly. It turned out pretty simple. In the video, it writes a simple Hello World! program. I went just a bit further and tried a program that prints the number 0 through 9.&lt;/p&gt;

&lt;p&gt;With &lt;a href=&quot;https://github.com/riscv-collab/riscv-gnu-toolchain&quot;&gt;GNU toolchain for RISC-V&lt;/a&gt;, you can easily compile your program&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;riscv64-linux-gnu-as hello.s &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; hello.o
riscv64-linux-gnu-gcc &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; hello hello.o &lt;span class=&quot;nt&quot;&gt;-nostdlib&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-static&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qemu&lt;/code&gt; you can run it&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;qemu-riscv64 ./hello
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here’s what I ended up with&lt;/p&gt;

&lt;div class=&quot;language-s highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;.section&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;.data&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;char_buffer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;.byte&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Reserve one byte for ASCII character output&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;.section&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;.text&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;.global&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Initialize loop control&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# t0 = counter (0 to 9)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# t1 = limit (10)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# counter = 0&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# limit = 10&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Load address of char_buffer into t2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;la&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;char_buffer&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Print current digit as ASCII&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# syscall: write&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# fd: stdout&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addi&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;48&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# convert digit to ASCII (&apos;0&apos; + t0)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sb&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# store character into buffer&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mv&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# buffer address&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# length = 1 byte&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ecall&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# make syscall to write digit&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Print newline character&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# syscall: write&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# fd: stdout&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# ASCII for newline &apos;\n&apos;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sb&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# store newline into buffer&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mv&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# buffer address&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# length = 1 byte&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ecall&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# make syscall to write newline&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Loop control&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;addi&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# increment counter&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bne&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# continue if t0 != t1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# Exit program&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# -------------------------------&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;93&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# syscall: exit&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# exit code 0&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ecall&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 16, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/16/notes-on-amp.html" />
      <id>https://brunocalza.me/microblog/2025/05/16/notes-on-amp</id>
      <updated>2025-05-16T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;Some more notes on Amp. I bought five dollars worth of credits, and two prompts have consumed 75% of it. The problem is that it does a lot more than you asked for, consuming lots of credits. Also, there’s no way of bringing your own key.&lt;/p&gt;

&lt;p&gt;Tweet that came out:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Gave @AmpCode a spin. Burned through my free credits fast, so I bought more. Two prompts later… five bucks gone 😅&lt;/p&gt;
&lt;/blockquote&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 15, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/15/earlyriders.html" />
      <id>https://brunocalza.me/microblog/2025/05/15/earlyriders</id>
      <updated>2025-05-15T21:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://www.earlyriders.com/&quot;&gt;EarlyRiders&lt;/a&gt; is a bitcoin-denominated investment fund.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;At Early Riders we raise our fund in Bitcoin, maintain our capital in Bitcoin, require our portfolio companies to maintain Bitcoin reserves, and return capital to our limited partners in Bitcoin. Our goal is to return more Bitcoin to our limited partners than they invested in the fund:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The fund’s core philosophy is that if entrepreneurs are looking through the lens of an asset that appreciates over time, and everything is denominated according to that asset, they’ll need to spend the money with a high level of discernment and scrutiny.&lt;/p&gt;

&lt;p&gt;I found that very interesting. I’ve always felt that the ease of raising large amounts of money made misallocating capital in startups a non-event.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 15, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/15/llms-get-lost-in-multi-turn-conversation.html" />
      <id>https://brunocalza.me/microblog/2025/05/15/llms-get-lost-in-multi-turn-conversation</id>
      <updated>2025-05-15T19:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://arxiv.org/pdf/2505.06120&quot;&gt;LLMs Get Lost In Multi-Turn Conversation&lt;/a&gt; (&lt;a href=&quot;https://news.ycombinator.com/item?id=43991256&quot;&gt;via&lt;/a&gt;). In this paper, large-scale simulation experiments are performed, and performance degradation is found in multi-turn LLM settings when compared to single-turn settings. From abstract:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Analysis of 200,000+ simulated conversations decomposes the performance degradation into two components: a minor loss in aptitude and a significant increase in unreliability. We find that LLMs often make assumptions in early turns and prematurely attempt to generate final solutions, on which they overly rely. In simpler terms, we discover that when LLMs take a wrong turn in a conversation, they get lost and do not recover.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The main explanations for this effect could be:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;premature and incorrect assumptions early in the conversation&lt;/li&gt;
  &lt;li&gt;over-relying on previous incorrect responses, compounding the error&lt;/li&gt;
  &lt;li&gt;overly adjusting responses to the first and last turn, forgetting middle turns&lt;/li&gt;
  &lt;li&gt;overly verbose responses, muddling the context, and confusing next turns&lt;/li&gt;
&lt;/ul&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 15, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/15/alphaevolve.html" />
      <id>https://brunocalza.me/microblog/2025/05/15/alphaevolve</id>
      <updated>2025-05-15T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;&lt;a href=&quot;https://deepmind.google/discover/blog/alphaevolve-a-gemini-powered-coding-agent-for-designing-advanced-algorithms/&quot;&gt;AlphaEvolve: A Gemini-powered coding agent for designing advanced algorithms&lt;/a&gt; (&lt;a href=&quot;https://news.ycombinator.com/item?id=43985489&quot;&gt;via&lt;/a&gt;). Google presents AlphaEvolve, an evolutionary coding agent that combines Gemini models, automated evaluators, and an evolutionary framework to design and discover advanced algorithms.&lt;/p&gt;

&lt;p&gt;A more technical explanation can be found in the paper &lt;a href=&quot;https://storage.googleapis.com/deepmind-media/DeepMind.com/Blog/alphaevolve-a-gemini-powered-coding-agent-for-designing-advanced-algorithms/AlphaEvolve.pdf&quot;&gt;AlphaEvolve: A coding agent for scientific and
algorithmic discovery&lt;/a&gt;.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 15, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/15/ai-and-productivity.html" />
      <id>https://brunocalza.me/microblog/2025/05/15/ai-and-productivity</id>
      <updated>2025-05-15T15:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;I had this thought&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;There’s a difference between AI writing a percentage of someone’s code and AI making them more productive. That person remains the author - they still need to understand and verify the code. AI might do most of the writing, but productivity may stay the same.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This clarifies what the “vibe” part of “vibe coding” means. The amount you’re vibing is inversely proportional to the amount you’re understanding and verifying.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 15, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/15/trying-out-amp.html" />
      <id>https://brunocalza.me/microblog/2025/05/15/trying-out-amp</id>
      <updated>2025-05-15T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;Today I tried out &lt;a href=&quot;https://ampcode.com/&quot;&gt;Amp&lt;/a&gt;. It’s a VS Code extension AI code agent. It felt a bit less intrusive than Cline, although somewhat slower. Also, I don’t understand the web product proposal where you can have a team and people competing on AI usage.&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 14, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/14/what-is-npx.html" />
      <id>https://brunocalza.me/microblog/2025/05/14/what-is-npx</id>
      <updated>2025-05-14T17:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;What the heck is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npx&lt;/code&gt;, which is occasionally used in JavaScript projects? It’s a CLI tool that comes with NodeJS that allows you to run
NodeJS scripts without installing them globally. For example,&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npx &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; whats-the-weather paris
The current weather &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;Paris is &lt;span class=&quot;s1&quot;&gt;&apos;few clouds&apos;&lt;/span&gt; with a temperature of 19°°C.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

      </content>
    </entry>
  
    <entry>
      <title>May 13, 2025</title>
      <link href="https://brunocalza.me/microblog/2025/05/13/first-time-with-pnpm.html" />
      <id>https://brunocalza.me/microblog/2025/05/13/first-time-with-pnpm</id>
      <updated>2025-05-13T13:00:00+00:00</updated>
      <content type="html">
        &lt;p&gt;First time working in a project with &lt;a href=&quot;https://pnpm.io/&quot;&gt;pnpm&lt;/a&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pnpm&lt;/code&gt; is a JavaScript package manager written in Typescript. It is faster than &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yarn&lt;/code&gt;, and it makes use of a content-addressable filesystem to store files and hard links, avoiding duplication and saving disk space.&lt;/p&gt;

      </content>
    </entry>
  
</feed>
