<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://barabazs.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://barabazs.dev/" rel="alternate" type="text/html" /><updated>2026-08-10T05:54:51+00:00</updated><id>https://barabazs.dev/feed.xml</id><title type="html">Barabazs’s Blog</title><subtitle></subtitle><entry><title type="html">TIL: git-delta hyperlinks require less v581+</title><link href="https://barabazs.dev/posts/2025/08/25/til-git-delta-hyperlinks-require-less-v581" rel="alternate" type="text/html" title="TIL: git-delta hyperlinks require less v581+" /><published>2025-08-25T11:00:00+00:00</published><updated>2025-08-25T11:00:00+00:00</updated><id>https://barabazs.dev/posts/2025/08/25/til-git-delta-hyperlinks-require-less-v581</id><content type="html" xml:base="https://barabazs.dev/posts/2025/08/25/til-git-delta-hyperlinks-require-less-v581"><![CDATA[<p>I was puzzled why my git-delta was showing malformed hyperlink escape sequences like <code>8;;https://github.com/...8;;</code> instead of proper clickable links. The escape sequences were being truncated and
weren't following the proper hyperlink protocol.</p>
<p>This issue only occured in devcontainers, not on my local machine. The git-delta configuation, git config, and terminal settings were identical. And even the versions were the same.</p>
<p>The issue was simply that less version was too old: I had less 551 on Debian 11 (Bullseye), but hyperlinks require version ≥ 581.</p>
<p>Here's what different Debian versions ship with:</p>
<ul>
<li>Debian 11 (Bullseye): less 551 ❌ (truncates escape sequences)</li>
<li>Debian 12 (Bookworm): less 590 ✅</li>
<li>Debian 13 (Trixie): less 668 ✅</li>
</ul>
<p>The older less version wasn't just failing to make links clickable, it was mangling the escape sequences entirely, showing raw partial sequences instead of either clickable links or clean text.</p>
<p>The fix was simply compiling a newer less version:</p>
<h1 id="download-and-compile-latest-less">Download and compile latest less</h1>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl <span class="nt">-L</span> <span class="nt">-o</span> less-679.tar.gz <span class="s2">"https://www.greenwoodsoftware.com/less/less-679.tar.gz"</span>
<span class="nb">tar</span> <span class="nt">-xzf</span> less-679.tar.gz <span class="o">&amp;&amp;</span> <span class="nb">cd </span>less-679
./configure <span class="nt">--prefix</span><span class="o">=</span>/usr/local <span class="o">&amp;&amp;</span> make <span class="o">&amp;&amp;</span> <span class="nb">sudo </span>make <span class="nb">install</span>
</code></pre></div></div>
<p>Now <code>git show</code> and <code>git log</code> display proper clickable hyperlinks instead of garbled escape sequences.</p>
<p>Thank you Claude Code for finding and fixing the issue in less than 5 minutes.</p>]]></content><author><name>Barabazs</name></author><category term="posts" /><category term="TIL" /><category term="git-delta" /><category term="less" /><category term="devcontainer" /><summary type="html"><![CDATA[I was puzzled why my git-delta was showing malformed hyperlink escape sequences like 8;;https://github.com/...8;; instead of proper clickable links. The escape sequences were being truncated and weren't following the proper hyperlink protocol.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://barabazs.dev/assets/images/og/posts/til-git-delta-hyperlinks-require-less-v581.png" /><media:content medium="image" url="https://barabazs.dev/assets/images/og/posts/til-git-delta-hyperlinks-require-less-v581.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TIL: Diffing a File with Clipboard Content</title><link href="https://barabazs.dev/posts/2025/04/06/til-diffing-a-file-with-clipboard-content" rel="alternate" type="text/html" title="TIL: Diffing a File with Clipboard Content" /><published>2025-04-06T08:40:00+00:00</published><updated>2025-04-06T08:40:00+00:00</updated><id>https://barabazs.dev/posts/2025/04/06/til-diffing-a-file-with-clipboard-content</id><content type="html" xml:base="https://barabazs.dev/posts/2025/04/06/til-diffing-a-file-with-clipboard-content"><![CDATA[<p>I often need to <em>diff</em> a file and some pasted text from another application or a remote source. Until now, I was using Meld to paste the text into a new file and then <em>diff</em> that.</p>
<p>Don't ask me why, I just never bothered to look for the appropriate syntax to do this in the CLI.</p>
<p>Here's how to do it:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>diff &lt;<span class="o">(</span>pbpaste<span class="o">)</span> path/to/file
</code></pre></div></div>]]></content><author><name>Barabazs</name></author><category term="posts" /><category term="TIL" /><summary type="html"><![CDATA[I often need to diff a file and some pasted text from another application or a remote source. Until now, I was using Meld to paste the text into a new file and then diff that.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://barabazs.dev/assets/images/og/posts/til-diffing-a-file-with-clipboard-content.png" /><media:content medium="image" url="https://barabazs.dev/assets/images/og/posts/til-diffing-a-file-with-clipboard-content.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Consuming and Producing Aineko messages with Pydantic models</title><link href="https://barabazs.dev/posts/2023/12/08/aineko-message-processing-with-pydantic" rel="alternate" type="text/html" title="Consuming and Producing Aineko messages with Pydantic models" /><published>2023-12-08T10:00:00+00:00</published><updated>2023-12-08T10:00:00+00:00</updated><id>https://barabazs.dev/posts/2023/12/08/aineko-message-processing-with-pydantic</id><content type="html" xml:base="https://barabazs.dev/posts/2023/12/08/aineko-message-processing-with-pydantic"><![CDATA[<h2 id="introduction">Introduction</h2>
<p>A common pattern across <a href="https://www.aineko.dev/">Aineko</a> nodes is to consume and produce messages. Messages are implemented as dictionaries, and are passed around between nodes using datasets.
This offers a lot of flexibility, but all that flexibility can come at a cost when it comes to complex pipelines. The more datasets you have, the harder it is to keep track of the messages that are being passed around.</p>
<p>I'll describe my own approach to this problem, which is to use <a href="https://docs.pydantic.dev/latest/">Pydantic</a> models to define the messages. Pydantic is a library that allows you to define data models with type annotations, validation, and parsing out of the box.</p>
<h2 id="how-to-use-them">How to use them</h2>
<p>My personal approach is to define a model for each dataset that is used in the pipeline. In most circumstances a dataset will only be used for a specific message type.
More complex pipelines might use a single dataset for multiple message types, but even these can be handled with a single model or a model hierarchy.</p>
<p>I store these models in a separate file, and import them in the modules that need them.
The project structure looks roughly like this:</p>
<pre><code>...  
├── nodes
│   ├── node1.py 
│   ├── node2.py
├── models
│   ├── messages.py
├── ...
</code></pre>
<p>Defining a model is simple. Let's imagine we have a dataset called <code>simple_event</code>, which is used to pass around simple event messages. The original message has the following structure:</p>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
    </span><span class="nl">"score"</span><span class="p">:</span><span class="w"> </span><span class="mf">0.8</span><span class="p">,</span><span class="w">
    </span><span class="nl">"event_source"</span><span class="p">:</span><span class="w"> </span><span class="s2">"node1"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"detected_at"</span><span class="p">:</span><span class="w"> </span><span class="mi">1623345600</span><span class="p">,</span><span class="w">
    </span><span class="nl">"payload"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
        </span><span class="nl">"foo"</span><span class="p">:</span><span class="w"> </span><span class="s2">"bar"</span><span class="w">
    </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>We can define a model for this message like this:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># path: messages.py
</span><span class="kn">from</span> <span class="nn">pydantic</span> <span class="kn">import</span> <span class="n">BaseModel</span>

<span class="k">class</span> <span class="nc">SimpleEventMessage</span><span class="p">(</span><span class="n">BaseModel</span><span class="p">):</span>
    <span class="s">"""Message model for the Simple Event messages."""</span>

    <span class="n">score</span><span class="p">:</span> <span class="nb">float</span>
    <span class="n">event_source</span><span class="p">:</span> <span class="nb">str</span>
    <span class="n">detected_at</span><span class="p">:</span> <span class="nb">int</span>
    <span class="n">payload</span><span class="p">:</span> <span class="nb">dict</span>

</code></pre></div></div>
<p>Now let's see how we can use this model in our nodes. We'll be producing a message in node1, and consuming it in node2.</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># path: node1.py
</span><span class="kn">from</span> <span class="nn">aineko.internals.node</span> <span class="kn">import</span> <span class="n">AbstractNode</span>

<span class="kn">from</span> <span class="nn">models.messages</span> <span class="kn">import</span> <span class="n">SimpleEventMessage</span>

<span class="k">class</span> <span class="nc">Node1</span><span class="p">(</span><span class="n">AbstractNode</span><span class="p">):</span>

    <span class="k">def</span> <span class="nf">_execute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">params</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">dict</span><span class="p">]</span> <span class="o">=</span> <span class="bp">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
        <span class="c1"># ... Code that does something ...
</span>        <span class="n">message</span> <span class="o">=</span> <span class="n">SimpleEventMessage</span><span class="p">(</span>
            <span class="n">score</span><span class="o">=</span><span class="mf">0.8</span><span class="p">,</span>
            <span class="n">event_source</span><span class="o">=</span><span class="s">"node1"</span><span class="p">,</span>
            <span class="n">detected_at</span><span class="o">=</span><span class="n">time</span><span class="p">.</span><span class="n">time</span><span class="p">(),</span>
            <span class="n">payload</span><span class="o">=</span><span class="p">{</span><span class="s">"foo"</span><span class="p">:</span> <span class="s">"bar"</span><span class="p">},</span>
        <span class="p">)</span>
        
        <span class="bp">self</span><span class="p">.</span><span class="n">producers</span><span class="p">[</span><span class="s">"simple_event"</span><span class="p">].</span><span class="n">produce</span><span class="p">(</span><span class="n">message</span><span class="p">.</span><span class="nb">dict</span><span class="p">())</span>

</code></pre></div></div>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># path: node2.py
</span><span class="kn">from</span> <span class="nn">aineko.internals.node</span> <span class="kn">import</span> <span class="n">AbstractNode</span>
<span class="kn">from</span> <span class="nn">pydantic</span> <span class="kn">import</span> <span class="n">ValidationError</span>

<span class="kn">from</span> <span class="nn">models.messages</span> <span class="kn">import</span> <span class="n">SimpleEventMessage</span>

<span class="k">class</span> <span class="nc">Node2</span><span class="p">(</span><span class="n">AbstractNode</span><span class="p">):</span>

    <span class="k">def</span> <span class="nf">_execute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">params</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">dict</span><span class="p">]</span> <span class="o">=</span> <span class="bp">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="bp">None</span><span class="p">:</span>
        <span class="n">message</span> <span class="o">=</span> <span class="bp">self</span><span class="p">.</span><span class="n">consumers</span><span class="p">[</span><span class="s">"simple_event"</span><span class="p">].</span><span class="n">consume</span><span class="p">()</span>
        
        <span class="k">if</span> <span class="n">message</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">None</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">event_msg</span> <span class="o">=</span> <span class="n">SimpleEventMessage</span><span class="p">(</span><span class="o">**</span><span class="n">message</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">ValidationError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>  
            <span class="bp">self</span><span class="p">.</span><span class="n">log</span><span class="p">(</span>
                <span class="sa">f</span><span class="s">"Error parsing SimpleEventMessage: </span><span class="si">{</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)</span><span class="si">}</span><span class="s">"</span><span class="p">,</span>
                <span class="n">level</span><span class="o">=</span><span class="s">"error"</span><span class="p">,</span>
            <span class="p">)</span>
            <span class="bp">self</span><span class="p">.</span><span class="n">log</span><span class="p">(</span><span class="sa">f</span><span class="s">"Message: </span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s">"</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="s">"error"</span><span class="p">)</span>
            <span class="k">return</span> <span class="bp">None</span>

        <span class="c1"># Now we can use the message as a regular python object
</span>        <span class="k">if</span> <span class="n">event_msg</span><span class="p">.</span><span class="n">score</span> <span class="o">&gt;</span> <span class="mf">0.5</span><span class="p">:</span>
            <span class="p">...</span>

</code></pre></div></div>
<h2 id="conclusion">Conclusion</h2>
<p>Using pure dictionaries for messages offers an unopinionated approach, but it has some drawbacks:</p>
<ul>
<li>No type safety</li>
<li>No validation</li>
<li>No IDE completion</li>
<li>Less suitable for complex messages (think nested dictionaries, optional fields, etc.)</li>
</ul>
<p>Pydantic models solve all these problems, and are very easy to use.</p>
<h2 id="notes">Notes</h2>
<ul>
<li>The consume's return type is <code>Optional[dict]</code>, so we need to unpack it before passing it to the model.</li>
<li>The <code>produce</code> method expects a <code>dict</code>, so we need to convert the model to a dictionary before producing it.</li>
<li>The <code>**</code> operator is used to unpack the dictionary into keyword arguments, which is a correct and efficient way to instantiate a Pydantic model.</li>
<li>The Aineko version used in this example is 0.2.5, which is the latest version at the time of writing this article.</li>
<li>I'm an early engineer at <a href="https://www.aineko.dev/">Aineko</a>, but the opinions expressed in this article are my own.</li>
</ul>]]></content><author><name>Barabazs</name></author><category term="posts" /><category term="aineko" /><category term="pydantic" /><summary type="html"><![CDATA[Introduction A common pattern across Aineko nodes is to consume and produce messages. Messages are implemented as dictionaries, and are passed around between nodes using datasets. This offers a lot of flexibility, but all that flexibility can come at a cost when it comes to complex pipelines. The more datasets you have, the harder it is to keep track of the messages that are being passed around.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://barabazs.dev/assets/images/og/posts/aineko-message-processing-with-pydantic.png" /><media:content medium="image" url="https://barabazs.dev/assets/images/og/posts/aineko-message-processing-with-pydantic.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>