<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Posts on Ctrl &#43; Champagne</title>
    <link>/posts/</link>
    <description>Recent content in Posts on Ctrl &#43; Champagne</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 29 Mar 2026 14:00:00 +0000</lastBuildDate>
    <atom:link href="/posts/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Jumping the queue? Yes, but in constant time</title>
      <link>/posts/fast_queue/</link>
      <pubDate>Sun, 29 Mar 2026 14:00:00 +0000</pubDate>
      <guid>/posts/fast_queue/</guid>
      <description>&lt;h2 id=&#34;the-problem&#34;&gt;The Problem&lt;/h2&gt;&#xA;&lt;p&gt;Classic interview setup: you walk in, sit down, and the interviewer says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;ldquo;Design a &lt;code&gt;FastQueue&lt;/code&gt; class. It stores entries, where each entry has a &lt;code&gt;long id&lt;/code&gt; and a &lt;code&gt;String family&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You need three operations, all in O(1) time: &lt;code&gt;add(entry)&lt;/code&gt;, &lt;code&gt;removeLast()&lt;/code&gt;, and &lt;code&gt;removeLast(family)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Space complexity is O(N) for all operations.&amp;rdquo;&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s unpack that. You have a queue of entries, each tagged with a family group.&#xA;At any point, you can eject the oldest entry within a given family, all in constant-time.&lt;/p&gt;</description>
    </item>
    <item>
      <title>JUnit 5 Tricks Recap</title>
      <link>/posts/junit/</link>
      <pubDate>Wed, 11 Jun 2025 13:45:56 +0000</pubDate>
      <guid>/posts/junit/</guid>
      <description>&lt;h2 id=&#34;junit-lay-of-the-land--mutation-testing&#34;&gt;JUnit: Lay of the Land &amp;amp; Mutation testing&lt;/h2&gt;&#xA;&lt;p&gt;Alright, what do we know about unit tests?&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;A unit test verifies an individual unit of code works as expected,&lt;/li&gt;&#xA;&lt;li&gt;It is small, fast and isolate a &lt;em&gt;single functionality&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;They are generally named based on what the test verifies, e.g. &lt;code&gt;testInvalidAccountIdThrowsException&lt;/code&gt;; they are &lt;em&gt;independent&lt;/em&gt;&#xA;from each other even though grouped in the&#xA;same class as related tests.&lt;/p&gt;&#xA;&lt;p&gt;We create them in the same package structure as the source code but under the &lt;code&gt;src/test/java&lt;/code&gt; directory. With Maven,&#xA;tests can be run using lifecycle phases like &lt;code&gt;test&lt;/code&gt;, &lt;code&gt;install&lt;/code&gt;, etc.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bron to Clique</title>
      <link>/posts/aoc24_23/</link>
      <pubDate>Fri, 06 Jun 2025 13:45:56 +0000</pubDate>
      <guid>/posts/aoc24_23/</guid>
      <description>&lt;h2 id=&#34;discovery-of-bron-kerbosch-in-aoc24-23&#34;&gt;Discovery of Bron-Kerbosch in AoC24-23&lt;/h2&gt;&#xA;&lt;p&gt;For part 2 of this challenge, I am actually ashamed of showing here what I initially tried to program without knowing what a&#xA;clique was, nor that an algorithm existed to find the maximal cliques in a graph&amp;hellip;&#xA;Maybe one day when I add a Premium Pass to this blog, a few privileged users could see the &lt;em&gt;pépite&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;/posts/aoc24_23/23.jpeg&#34; alt=&#34;text&#34;&gt;&lt;/p&gt;&#xA;&lt;h3 id=&#34;part-1---the-piece-of-&#34;&gt;Part 1 - the piece of 🍰&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;As The Historians wander around a secure area at Easter Bunny HQ, you come across posters for a LAN party scheduled for today! &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Maybe you can find it; you connect to a nearby datalink port and download a map of the local network (your puzzle input).&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;The network map provides a list of every connection between two computers. For example:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;kh-tc&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;qp-kh&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;de-cg&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ka-co&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Each line of text in the network map represents a single connection; the line kh-tc represents a connection between the &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;computer named kh and the computer named tc. Connections aren&amp;#39;t directional; tc-kh would mean exactly the same thing.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;LAN parties typically involve multiplayer games, so maybe you can locate it by finding groups of connected computers. &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Start by looking for sets of three computers where each computer in the set is connected to the other two computers.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;If the Chief Historian is here, and he&amp;#39;s at the LAN party, it would be best to know that right away. You&amp;#39;re pretty &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sure his computer&amp;#39;s name starts with t, so consider only sets of three computers where at least one computer&amp;#39;s name &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;starts with t. That narrows the list down to 7 sets of three inter-connected computers:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;co,de,ta&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;co,ka,ta&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;de,ka,ta&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;qp,td,wh&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;tb,vc,wq&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;tc,td,wh&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;td,wh,yn&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Find all the sets of three inter-connected computers. How many contain at least one computer with a name that starts &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;with t?&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;initial-thoughts&#34;&gt;Initial Thoughts&lt;/h4&gt;&#xA;&lt;p&gt;Setting the &amp;ldquo;starts with t&amp;rdquo; requirement aside, the list of computers given is a list of edges connecting two computers&#xA;(nodes).&lt;/p&gt;</description>
    </item>
    <item>
      <title>We all need a Holiday Destination Finder</title>
      <link>/posts/asynch/</link>
      <pubDate>Sat, 12 Apr 2025 13:45:56 +0000</pubDate>
      <guid>/posts/asynch/</guid>
      <description>&lt;h2 id=&#34;tiptoeing-through-the-asynch-door-with-the-completionstage-interface-jse17&#34;&gt;Tiptoeing Through the Asynch Door with the CompletionStage Interface JSE17&lt;/h2&gt;&#xA;&lt;p&gt;When it comes to holidays, I&amp;rsquo;m as spontaneous as they come. I enjoy not planning&#xA;and picking the best option available just before or even while traveling.&lt;/p&gt;&#xA;&lt;p&gt;So I needed a holiday&amp;hellip; and a reason to explore Java&amp;rsquo;s async magic.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;/posts/asynch/hols.jpg&#34; alt=&#34;text&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;We&amp;rsquo;ll get to this Holiday Finder but first let&amp;rsquo;s get the theory&#xA;out of the way, shall we?&lt;/p&gt;&#xA;&lt;h3 id=&#34;diving-right-in&#34;&gt;Diving Right In&lt;/h3&gt;&#xA;&lt;p&gt;Considering two API calls A &amp;amp; B, API A is called first, and then API B.&#xA;This is what synchronous code does: it waits before executing the next task and things run &lt;em&gt;in order&lt;/em&gt;.&#xA;However, could the thread blocked on the API response be doing some other work instead?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Welcome to the Code Aviary: Where Ducks Debug and Canaries Die</title>
      <link>/posts/birds/</link>
      <pubDate>Sun, 06 Apr 2025 13:45:56 +0000</pubDate>
      <guid>/posts/birds/</guid>
      <description>&lt;h2 id=&#34;your-survival-guide-to-feathered-philosophies-in-software-development&#34;&gt;Your survival guide to feathered philosophies in software development&lt;/h2&gt;&#xA;&lt;h3 id=&#34;rubber-duck-debugging&#34;&gt;Rubber Duck Debugging&lt;/h3&gt;&#xA;&lt;p&gt;Alright, we&amp;rsquo;re starting easy and light for this one.&lt;/p&gt;&#xA;&lt;p&gt;It was popularised by the &lt;em&gt;Pragmatic Programmer&lt;/em&gt; written by Andrew Hunt and David Thomas (an alumnus of Imperial College London).&#xA;The idea is rather simple: instead of spending hours trying to debug something obscure,&#xA;explain the code line-by-line to an inanimate object - a rubber duck named Chucky maybe? - to help you work out what the problem is.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Poor Man&#39;s Load Balancer</title>
      <link>/posts/dnslb/</link>
      <pubDate>Thu, 03 Apr 2025 13:45:56 +0000</pubDate>
      <guid>/posts/dnslb/</guid>
      <description>&lt;h2 id=&#34;domain-name-system-traffic-distribution-on-a-budget&#34;&gt;Domain Name System: traffic distribution on a budget&lt;/h2&gt;&#xA;&lt;h3 id=&#34;its-not-magic&#34;&gt;It&amp;rsquo;s not magic&lt;/h3&gt;&#xA;&lt;p&gt;What happens when you type &lt;code&gt;leane.dev&lt;/code&gt; in&#xA;your browser?&lt;/p&gt;&#xA;&lt;p&gt;As a regular reader of this blog, I am allowing myself to take your &lt;em&gt;everyday&lt;/em&gt; example.&lt;/p&gt;&#xA;&lt;p&gt;You want to access the server hosting this blog, but how do you reach it? On the Internet, routing&#xA;is done by finding the path to a given Internet Protocol - IP. Thing is: you don&amp;rsquo;t know my IP,&#xA;not directly. It&amp;rsquo;s easier to remember the hostname: leane.dev. Yet, the browser manages to display&#xA;the blog to you.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Lambdas &amp; Single Abstract Method Interfaces</title>
      <link>/posts/fi/</link>
      <pubDate>Mon, 24 Mar 2025 11:45:56 +0000</pubDate>
      <guid>/posts/fi/</guid>
      <description>&lt;h2 id=&#34;quick-tour-of-java-functional-interfaces&#34;&gt;Quick Tour of Java Functional Interfaces&lt;/h2&gt;&#xA;&lt;p&gt;A functional interface is an interface with just one abstract method, such as&#xA;Runnable, Comparator, Callable, etc.&#xA;The main benefit of functional interfaces, with the introduction&#xA;of lambdas in Java 8, is that they allow you to pass behavior (code) to a function the same way you&amp;rsquo;d pass data (objects) to a method.&#xA;This means we can pass a lambda expression when a method is accepting a functional interface.&#xA;Since there is only one function to override, it is possible to infer which function to implement when using a lambda expression.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Finishing your thoughts since... you started typing</title>
      <link>/posts/trie/</link>
      <pubDate>Tue, 18 Mar 2025 13:45:56 +0000</pubDate>
      <guid>/posts/trie/</guid>
      <description>&lt;h2 id=&#34;typeahead-system&#34;&gt;Typeahead System&lt;/h2&gt;&#xA;&lt;h3 id=&#34;a-little-background&#34;&gt;A little background&lt;/h3&gt;&#xA;&lt;p&gt;An autocomplete system, also called typeahead, is a feature often experienced&#xA;by users while typing in a search bar (or your IDE for that matter).&#xA;The software suggests the rest of a word or word sequence based on what&#xA;the user has already typed.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;/posts/trie/autocomp.png&#34; alt=&#34;text&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;These suggestions can be ranked depending on how often/popular a search is. Remember that gorgeous Versace dress&#xA;J-Lo wore for the Grammy Awards back in 2000? Everyone googled it - in fact it became the most popular search query at the&#xA;time and - fun fact - prompted Google engineers to develop the image search!&#xA;The objective is to make user searches more efficient and reduce the amount of typing required, while keeping the&#xA;suggestions relevant with current search trends.&lt;/p&gt;</description>
    </item>
    <item>
      <title>No Huff and Puff—Just Compress!</title>
      <link>/posts/huffman/</link>
      <pubDate>Sun, 16 Mar 2025 13:45:56 +0000</pubDate>
      <guid>/posts/huffman/</guid>
      <description>&lt;h2 id=&#34;the-huffmans-algorithm&#34;&gt;The Huffman&amp;rsquo;s Algorithm&lt;/h2&gt;&#xA;&lt;p&gt;The Huffman&amp;rsquo;s algorithm was born in 1952 as a way to perform a lossless compression&#xA;on data files. Its efficiency comes from the frequency analysis of characters&#xA;present in the text to encode: shorter codes are used to encode more frequent characters&#xA;while longer codes are used to encore less frequent ones.&lt;/p&gt;&#xA;&lt;p&gt;It constitutes the foundation of modern text compression.&lt;/p&gt;&#xA;&lt;p&gt;You can read more on variable-length encoding and tree representations&#xA;under the Design tag on this blog.&lt;/p&gt;</description>
    </item>
    <item>
      <title>When Strings go wrong</title>
      <link>/posts/encoding/</link>
      <pubDate>Tue, 04 Mar 2025 13:45:56 +0000</pubDate>
      <guid>/posts/encoding/</guid>
      <description>&lt;h2 id=&#34;encoding-for-web-apps-internationalisation&#34;&gt;Encoding for Web apps internationalisation&lt;/h2&gt;&#xA;&lt;h3 id=&#34;some-theory-about-information-content--entropy&#34;&gt;Some theory about Information Content &amp;amp; Entropy&lt;/h3&gt;&#xA;&lt;p&gt;Encoding is the process of converting data from one form into another using&#xA;an &lt;em&gt;unambiguous&lt;/em&gt; mapping. It can refer to transforming human-readable characters into a machine-readable format.&#xA;The main question it raises is: how many bits do I need to encode &amp;lsquo;a&amp;rsquo; (and the rest of the characters)?&lt;/p&gt;&#xA;&lt;p&gt;The Information Content (Shannon information) quantifies the amount of &amp;ldquo;uncertainty&amp;rdquo; associated&#xA;with a particular piece of information.&lt;/p&gt;</description>
    </item>
    <item>
      <title>`x = Pépin, y = x` I&#39;m Pépin too, says y</title>
      <link>/posts/valueref/</link>
      <pubDate>Tue, 25 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/valueref/</guid>
      <description>&lt;h2 id=&#34;pass-by-value-or-reference-the-great-debate&#34;&gt;Pass-by-Value or Reference: the Great Debate&lt;/h2&gt;&#xA;&lt;h3 id=&#34;background-on-heap-and-stack&#34;&gt;Background on Heap and Stack&lt;/h3&gt;&#xA;&lt;p&gt;The stack referred to when talking about memory is the same as the run-time call stack. It is&#xA;composed of stack frames and stores &lt;em&gt;things&lt;/em&gt;. It controls the function calls and program execution by&#xA;storing in its frames the function parameters, the return address, local variables - among other things.&#xA;The stack has a fixed-size so in some cases, for instance deep recursion, it can run out of memory.&#xA;Remember this one time you forgot a stopping condition in your code and got a &lt;code&gt;StackOverflowError&lt;/code&gt; or&#xA;&lt;code&gt;RecursionError&lt;/code&gt;: that&amp;rsquo;s the call stack telling you it&amp;rsquo;s full.&#xA;Stack frames only exist during the execution of a function. This means everything stored in it becomes&#xA;unavailable after the function has returned. This makes the allocation and de-allocation of memory&#xA;automatic, which helps prevent memory leaks.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sorting Spree</title>
      <link>/posts/lc_23/</link>
      <pubDate>Sun, 23 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/lc_23/</guid>
      <description>&lt;h2 id=&#34;lc23---merge-k-sorted-lists&#34;&gt;LC23 - Merge k Sorted Lists&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem-statement&#34;&gt;Problem Statement&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.&#xA;Merge all the linked-lists into one sorted linked-list and return it.&#xA;&#xA;# Definition for singly-linked list.&#xA;# class ListNode:&#xA;#     def __init__(self, val=0, next=None):&#xA;#         self.val = val&#xA;#         self.next = next&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;smelling-like-merge-sort-in-the-air&#34;&gt;Smelling like merge sort in the air?&lt;/h3&gt;&#xA;&lt;p&gt;We know each list is already in sorted order. Does it remind us of the merge step from a classic merge-sort algorithm?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why compare when you can just count?</title>
      <link>/posts/buckersort/</link>
      <pubDate>Sun, 23 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/buckersort/</guid>
      <description>&lt;h2 id=&#34;the-bucket-sort-algorithm&#34;&gt;The Bucket Sort algorithm&lt;/h2&gt;&#xA;&lt;h3 id=&#34;lc75---example-of-sorting-colors&#34;&gt;LC75 - example of Sorting Colors&lt;/h3&gt;&#xA;&lt;p&gt;The problem statement is as below.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;are adjacent, with the colors in the order red, white, and blue.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;You must solve this problem without using the library&amp;#39;s sort function.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Solution&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;sortColors&lt;/span&gt;(self, nums: List[int]) &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;None&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;        Do not return anything, modify nums in-place instead.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;        &amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;# bucket sort &lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        value_range &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#75715e&#34;&gt;#red, white or blue&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        counts &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; value_range&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; i, n &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; enumerate(nums):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            counts[n] &lt;span style=&#34;color:#f92672&#34;&gt;+=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        i &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; value, freq &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; enumerate(counts):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            print(value, freq)  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; _ &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(freq):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                nums[i] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; value&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                i &lt;span style=&#34;color:#f92672&#34;&gt;+=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;quick-rundown&#34;&gt;Quick rundown&lt;/h3&gt;&#xA;&lt;p&gt;The bucket sort algorithm relies on the fact that values belong to a known range. In this example it is &lt;code&gt;[0,2] ∈ Z&lt;/code&gt;.&#xA;The input arrays have already been prepared, by &lt;em&gt;encoding&lt;/em&gt; categorical values into numerical ones. The same&#xA;thing could be said about a different numerical range where the start of range is re-indexed or shifted back to 0.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Valentine&#39;s Matchmaker Algorithm 💖</title>
      <link>/posts/lc_765/</link>
      <pubDate>Sat, 22 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/lc_765/</guid>
      <description>&lt;h2 id=&#34;lc765---couples-holding-hands&#34;&gt;LC765 - Couples holding hands&lt;/h2&gt;&#xA;&lt;h3 id=&#34;problem-statement&#34;&gt;Problem Statement&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;There are n couples sitting in 2n seats arranged in a row and want to hold hands.&#xA;The people and seats are represented by an integer array row where row[i] is the ID of the person sitting in the ith seat. &#xA;The couples are numbered in order, the first couple being (0, 1), the second couple being (2, 3), &#xA;and so on with the last couple being (2n - 2, 2n - 1).&#xA;&#xA;Return the minimum number of swaps so that every couple is sitting side by side. &#xA;A swap consists of choosing any two people, then they stand up and switch seats.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;initial-solution&#34;&gt;Initial solution&lt;/h3&gt;&#xA;&lt;p&gt;The below solution provides an O(n) time complexity and memory.&#xA;Relatively simply, checking for every pair of people, if the left-hand side person is not seated next to its beloved, then we swap the right person next to them.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Scan It Like You Mean It 🚀</title>
      <link>/posts/vulnscan/</link>
      <pubDate>Sun, 16 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/vulnscan/</guid>
      <description>&lt;h2 id=&#34;automated-vulnerability-scanning-for-dependencies--packages&#34;&gt;Automated Vulnerability Scanning for Dependencies &amp;amp; Packages&lt;/h2&gt;&#xA;&lt;h3 id=&#34;do-we-need-to-explain-why&#34;&gt;Do we need to explain why?&lt;/h3&gt;&#xA;&lt;p&gt;🔥💥💣🚨⚡☠️🧨&lt;/p&gt;&#xA;&lt;p&gt;That&amp;rsquo;s what I thought.&lt;/p&gt;&#xA;&lt;h3 id=&#34;configure-your-pipeline-with-snyk&#34;&gt;Configure your pipeline with Snyk&lt;/h3&gt;&#xA;&lt;p&gt;There is a plethora of tools available out there for security scans and/or vulnerable&#xA;dependencies - Dependabot, Trivy, sonarQube/Lint, Anchore, etc. Most of which can be&#xA;integrated into your IDE or CI/CD.&lt;/p&gt;&#xA;&lt;p&gt;For this use case, Snyk has been selected.&#xA;Snyk is able to scan code, open-source dependencies, container images, and infrastructure as code&#xA;configurations to helps developers prioritize and fix security vulnerabilities.&#xA;The free version comes with a max limit scans per month.&lt;/p&gt;</description>
    </item>
    <item>
      <title>topic=logFormatting context=distributedSystems</title>
      <link>/posts/javalog/</link>
      <pubDate>Fri, 14 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/javalog/</guid>
      <description>&lt;h2 id=&#34;structured-logging-in-java-for-distributed-systems&#34;&gt;Structured logging in Java for distributed systems&lt;/h2&gt;&#xA;&lt;h3 id=&#34;where-do-applications-log-end-up-anyway&#34;&gt;Where do applications log end up anyway?&lt;/h3&gt;&#xA;&lt;p&gt;Applications typically write to standard output. Logs can either be handled&#xA;by the app&amp;rsquo;s supervising process or be passed to the next supervision&#xA;layer to be processed. For example Kubernetes collects logs&#xA;written to &lt;code&gt;stdout&lt;/code&gt; and &lt;code&gt;stderr&lt;/code&gt; by containers and stores them in node-specific&#xA;log files (usually &lt;code&gt;/var/log/containers&lt;/code&gt; based on name).&#xA;From there, they can be accessed by tools like kubectl logs.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Automating Digital Certificates renewal</title>
      <link>/posts/digitcert/</link>
      <pubDate>Tue, 11 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/digitcert/</guid>
      <description>&lt;h2 id=&#34;kubernetes-cert-manager-for-letsencrypt-certificates&#34;&gt;Kubernetes cert-manager for LetsEncrypt certificates&lt;/h2&gt;&#xA;&lt;h3 id=&#34;digital-certificates-raison-dêtre-and-usage&#34;&gt;Digital Certificates raison d&amp;rsquo;être and usage&lt;/h3&gt;&#xA;&lt;p&gt;Certificates are exchanged as part of the TLS handshake.&#xA;This allows the client to ensure the entity it is trying to establish a connection with is authentically the &lt;em&gt;genuine&lt;/em&gt; server.&lt;/p&gt;&#xA;&lt;p&gt;Note: see other posts under this tag for a few words on TLS handshakes and mentions of the attacks it protects against.&lt;/p&gt;&#xA;&lt;p&gt;A certificate contains: the issuer details, its expiration date, the entity&amp;rsquo;s public key for asymmetric encryption and a signature (encrypted server&amp;rsquo;s public key).&lt;/p&gt;</description>
    </item>
    <item>
      <title>The QUICk brown fox jumps over the lazy dog</title>
      <link>/posts/quic/</link>
      <pubDate>Mon, 10 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/quic/</guid>
      <description>&lt;h2 id=&#34;the-fast-alternative-to-tcptls&#34;&gt;The &lt;em&gt;fast&lt;/em&gt; alternative to TCP+TLS&lt;/h2&gt;&#xA;&lt;h3 id=&#34;what-is-quic&#34;&gt;What is QUIC?&lt;/h3&gt;&#xA;&lt;p&gt;The Quick UDP Internet Connection (QUIC) protocol is an encrypted connection protocol operating on the Layer 4 - Transport Layer of the OSI model.&lt;/p&gt;&#xA;&lt;p&gt;Developed at Google around 2012, it has only been adopted as a standard by IETF in 2021.&lt;/p&gt;&#xA;&lt;p&gt;The current and widely used solution of HTTPS using TLS is built is on top of the TCP protocol.&#xA;The &lt;a href=&#34;https://en.wikipedia.org/wiki/Transmission_Control_Protocol&#34;&gt;TCP handshake&lt;/a&gt; and the &lt;a href=&#34;https://en.wikipedia.org/wiki/Transport_Layer_Security&#34;&gt;TLS handshake&lt;/a&gt; need to be completed to establish a path to communicate between a server and a client.&#xA;As a result, multiple rounds trips to initiate a connection and negotiate the encryption parameters are required - two at the very least, depending on the TLS version used.&lt;/p&gt;</description>
    </item>
    <item>
      <title>AoC24 - Some stone blinking</title>
      <link>/posts/aoc24_11/</link>
      <pubDate>Sun, 09 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/aoc24_11/</guid>
      <description>&lt;h2 id=&#34;who-said-aoc25-11-should-be-complicated&#34;&gt;Who said AoC25-11 should be complicated?&lt;/h2&gt;&#xA;&lt;h3 id=&#34;the-challenge&#34;&gt;The Challenge&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;The ancient civilization on Pluto created stones that change every time you blink. Each stone follows specific transformation rules:&#xA;- A stone marked 0 becomes 1.&#xA;- A stone with an even number of digits splits into two stones, each half of the original number.&#xA;- Any other stone is replaced by a new one, with its number multiplied by 2024.&#xA;The stones remain in order, and their transformations continue with each blink. For example, the sequence [0, 1, 10, 99, 999] would change to [1, 2024, 1, 0, 9, 9, 2021976] after one blink.&#xA;Part 1: blink 25 times. Part 2: blink 75 times.&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Full description available &lt;a href=&#34;https://adventofcode.com/2024/day/11&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>HSTS &amp; .dev domain</title>
      <link>/posts/hsts/</link>
      <pubDate>Sat, 08 Feb 2025 13:45:56 +0000</pubDate>
      <guid>/posts/hsts/</guid>
      <description>&lt;h2 id=&#34;a-brief-overview-of-hsts-protocol-or-why-i-chose-the-dev-domain&#34;&gt;A brief overview of HSTS protocol or why I chose the .dev domain&lt;/h2&gt;&#xA;&lt;h3 id=&#34;quick-intro&#34;&gt;Quick intro&lt;/h3&gt;&#xA;&lt;p&gt;What happens when you&amp;rsquo;re back from a family weekend in a cabin in the woods with no internet?&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;d probably check my dog&amp;rsquo;s instagram account first.&#xA;On the browser: instagram.com and &amp;hellip; my browser is making a call to &lt;code&gt;http://instagram.com&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Exactly! I haven&amp;rsquo;t explicitly used &lt;code&gt;https&lt;/code&gt;, so where does this leave me? Exposed to all sorts of man-in-the-middle attacks that wikipedia can list for us in a scary way - &lt;a href=&#34;https://en.wikipedia.org/wiki/Session_hijacking%22&#34;&gt;session hijacking&lt;/a&gt;, &lt;a href=&#34;https://en.wikipedia.org/wiki/Downgrade_attack&#34;&gt;protocol downgrade attack&lt;/a&gt;, etc.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
