{"@attributes":{"version":"2.0"},"channel":{"title":"Kshitij's Weblog","link":"https:\/\/kxsh.dev\/","description":"Recent content on Kshitij's Weblog","generator":"Hugo","language":"en-US","managingEditor":"hi@kxsh.dev (Kshitij Saraogi)","webMaster":"hi@kxsh.dev (Kshitij Saraogi)","copyright":"\u00a9 2016 - 2026 Kshitij Saraogi","lastBuildDate":"Thu, 12 Nov 2026 16:00:52 +0100","item":[{"title":"Strings in C","link":"https:\/\/kxsh.dev\/posts\/2026-11-12-cstrings\/","pubDate":"Thu, 12 Nov 2026 16:00:52 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-11-12-cstrings\/","description":"<p>Strings in C are peculiar. They are especially strange once you are familiar with\nstrings in another higher-level programming language. I want to share an approach\nthat makes my life easier whenever I write tiny C programs.<\/p>\n<h2 id=\"context\">Context<\/h2>\n<p>How are strings represented in C?<\/p>\n<p>Technically, strings do not exist in C. They are implemented as a convention built\non top of pointers. Specially, a pointer to a character value that terminates with\na special NUL character is considered a &ldquo;string&rdquo; in C. A programmer is expected\nto bookkeep the access to avoid reading beyond the end of a string. Morever, the\nonly way to compute the length of a string is to scan the characters linearly.<\/p>\n<p>Pascal used another convention. It required the first character of a string to\nspecify its length. Ex: &ldquo;13Hello, World&rdquo;.<\/p>\n<p>Modern programming languages store the length of the string as metadata.\nThis metadata costs a few bytes in the memory.<\/p>\n<h2 id=\"motivation\">Motivation<\/h2>\n<ul>\n<li>\n<p><strong>Read heavy usescases<\/strong>. Usually, a string is created once but read in various ways.\nEx: Parsing user input, and tokenizing it.<\/p>\n<\/li>\n<li>\n<p><strong>String Processing<\/strong>. Few operations like splitting string on a delimiter,\njoining a collection of strings into a single string are elementary on a string.\nStandard libraries in most high-level programming languages provide such functions.<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"enter-stringview\">Enter <code>StringView<\/code><\/h2>\n<p><strong>Idea<\/strong>: Create a &ldquo;view&rdquo; (or window) on top an underlying buffer of bytes.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-c\" data-lang=\"c\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ String_View represents a view on a C String.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ This helper type makes it easier to operate on C Strings like a modern\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ programming language. The internal representation wraps around a C String with\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ a measure of the length of the string.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">typedef<\/span> <span style=\"color:#8839ef\">struct<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">const<\/span> <span style=\"color:#d20f39\">char<\/span> <span style=\"color:#04a5e5;font-weight:bold\">*<\/span>data;\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">size_t<\/span> count;\n<\/span><\/span><span style=\"display:flex;\"><span>} String_View;\n<\/span><\/span><\/code><\/pre><\/div><p>These views are merely pointers with metadata for bookkeeping.\nMost importantly, the size of this data type is independent of the size of the\nstring is provides a window to. On my 64-bit machine, a variable takes a fixed\n16 bytes.<\/p>\n<p>A constructor helps create a new window into a C String.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-c\" data-lang=\"c\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ Construct a view on the C String ignoring the NUL terminator.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ Ex: Hello, World0\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ ^ ^\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ data\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ count = 12 (excluding the NUL char)\n<\/span><\/span><\/span><span style=\"display:flex;\"><span>String_View <span style=\"color:#1e66f5\">new_string_view<\/span>(<span style=\"color:#8839ef\">const<\/span> <span style=\"color:#d20f39\">char<\/span> <span style=\"color:#04a5e5;font-weight:bold\">*<\/span>cstr) {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">return<\/span> (String_View){\n<\/span><\/span><span style=\"display:flex;\"><span> .data <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> cstr,\n<\/span><\/span><span style=\"display:flex;\"><span> .count <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#1e66f5\">strlen<\/span>(cstr),\n<\/span><\/span><span style=\"display:flex;\"><span> };\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>Converting a window into a C String requires cloning and memory allocation.\nWe do not know whether the underlying string ends with our string view.\nThus, we cannot simply append a NUL character to build a C String.\nConsequently, we create a copy of the string defined in the current string view.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-c\" data-lang=\"c\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ Convert a String_View into a C String.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">char<\/span> <span style=\"color:#04a5e5;font-weight:bold\">*<\/span><span style=\"color:#1e66f5\">to_cstring<\/span>(String_View ss) {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">char<\/span> <span style=\"color:#04a5e5;font-weight:bold\">*<\/span>s <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#1e66f5\">strndup<\/span>(ss.data, ss.count);\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">return<\/span> s;\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><h3 id=\"utilities\">Utilities<\/h3>\n<p>We can define some common string manipulation operations on top of the string window:<\/p>\n<ul>\n<li>Chopping specific number of characters from either ends of the window<\/li>\n<li>Trimming whitespaces<\/li>\n<li>Splitting by a delimiter<\/li>\n<li>Equality checks between two windows<\/li>\n<\/ul>\n<p>You can find the implementation as a single C file <a href=\"https:\/\/gist.github.com\/kshitij10496\/9fea1c856f9e7e3e6adc885790e45958\">on GitHub Gist<\/a>.\nI use this file as part of a unity build in almost all my current experiements (shell, db).<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>We need to evaluate the tradeoffs between the native C Strings and this concept of\nString windows. Personally, I find the DevEx (simplicity) when working with windows\nworth the extra memory usage (for now).<\/p>\n<p>NOTE: Most of the library functions (wrappers around syscalls) expect C Strings as input.\nDepending on the usecase, we might have to deal with C Strings at times.<\/p>\n<p>My default approach is as follows:<\/p>\n<ul>\n<li>Convert C Strings to String windows as soon as possible in the code.<\/li>\n<li>Perform most of the string manipulation operation on the windows.<\/li>\n<li>If needed, convert the windows to C Strings at the call sites (mostly library calls).<\/li>\n<\/ul>\n<h2 id=\"resources\">Resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/youtu.be\/y8PLpDgZc0E?si=En0vDd28NlYSKpSF\">C Strings are Terrible - YouTube Tsoding<\/a><\/li>\n<li><a href=\"https:\/\/www.joelonsoftware.com\/2001\/12\/11\/back-to-basics\/\">Back to Basics - Joel Spolsky<\/a><\/li>\n<\/ul>"},{"title":"Review: 2026 Week #45 (Nov 2 - Nov 8)","link":"https:\/\/kxsh.dev\/posts\/2026-11-08-weekly\/","pubDate":"Sun, 08 Nov 2026 11:12:52 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-11-08-weekly\/","description":"<p>Happy Diwali to everybody celebrating.<\/p>\n<p>I tried HYROX training on Thursday morning.\nThat was bloody intense hour of workout. My legs were sore until Friday evening.<\/p>\n<p>I started a new project this week - diving deeper into Operating Systems.\nSpecifically, I am reading the OSTEP book to understand the components that\nbuild up a system. Mapping these concepts with UNIX (via Advanced UNIX Programming)\nto get some hands-on experience.<\/p>\n<p><a href=\"https:\/\/github.com\/kshitij10496\/yacsh\">yacsh<\/a> is an experiemental UNIX shell I\nam writing to get more familiar with the CPU virtualization primitives (Processes)\nprovided by the OS. No LLM slop, of course.<\/p>\n<p>During implementation, I realized my C chops are rusty so reading up <a href=\"https:\/\/beej.us\/guide\/bgc\/html\/split\/index.html\">Beej&rsquo;s\nGuide to C<\/a> whenever I am out\nof depth. I have few more notes about this process. I am editing them whenever\nI get time. I shall try to publish them as independent blog posts in the upcoming\nweeks.<\/p>\n<h3 id=\"media-diet\">Media Diet<\/h3>\n<ul>\n<li><a href=\"https:\/\/fosscomics.com\/posts\/11.%20BSD%20Unix%20Part%201%20-%20Unix%20Code%20Goes%20to%20UC%20Berkeley\/\">BSD Unix, Part 1 - Unix Code Goes to UC Berkeley<\/a> by Joone Hur<\/li>\n<\/ul>\n<p>Really enjoyed this trilogy about the history of BSD.\nLegend of a programmer - Bill Joy!<\/p>\n<ul>\n<li><a href=\"https:\/\/youtu.be\/uGEDSGCUkXk?si=TArXpDPayFhFK7CZ\">The Blaze - Cercle<\/a><\/li>\n<\/ul>\n<p>I rediscovered this set on a Slack channel at work.\nIt is a fairly decent background score for focussed work (for me).<\/p>\n<ul>\n<li><a href=\"https:\/\/mitchellh.com\/writing\/libghostty-1-0\">Libghostty 1.0<\/a> by Mitchell Hashimoto<\/li>\n<\/ul>\n<p>I have been waiting for this release for a while now. Finally, it&rsquo;s here.\nA stable version of the library behind Ghostty terminal emulator.\n<code>ghostling<\/code> is a tiny, demo terminal emulator built using the <code>libghostty<\/code> library.\nI vaguely know the components involved - graphics rendering (CPU\/GPU), VT sequences,\nstate management (terminal and renderer). Ideally, this project should help me\nunderstand the concepts involved in the terminal emulator space. I suppose I\nhave another itch to scratch, and a project in my backlog.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=A4npHgFlfZo\">At 77, she\u2019s still running marathons against all odds<\/a> by DW Cultures<\/li>\n<\/ul>\n<p>Inspirational stuff! I would be blessed to even consider running the Marathon\ndistance at that age.<\/p>\n<ul>\n<li><a href=\"https:\/\/chalmovsky.com\/posts\/wtf-ubuntu\">WTF Ubuntu?<\/a><\/li>\n<\/ul>\n<p>Canonical is not urgent enough about updating the Ubuntu distro with the security\npatch to the Linux Kernel. This lethargic attitude is particularly strange considering\nall the recent cybersecurity issues affecting the web.<\/p>\n<ul>\n<li><a href=\"https:\/\/collabfund.com\/blog\/confidence\/\">Confidence isn\u2019t about having more, it\u2019s about calibrating the right amount<\/a> by Ted Lamade<\/li>\n<\/ul>\n<blockquote>\n<p>confidence is calibrated by pursuing hard things and experiencing difficult moments.<\/p>\n<\/blockquote>\n<p>Cocky personalities have always rubbed me the wrong way. Some people should definitely\nhesitate.<\/p>"},{"title":"Review: 2026 Week #44 (Oct 26 - Nov 1)","link":"https:\/\/kxsh.dev\/posts\/2026-11-01-weekly\/","pubDate":"Sun, 01 Nov 2026 21:50:50 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-11-01-weekly\/","description":"<p>Autumn is here. My hands get quite cold even after a short bike ride to the gym.\nTime to bring out my Buffs and gloves to keep the cold away.<\/p>\n<p>I was able to work out every single day this week. So I am pretty happy about it.\nThe body has adjusted well to the end of DST, and I woke up consistently around 6 AM.<\/p>\n<p>After work, I re-read The Old Man and The Sea by Hemingway for the third time.<\/p>"},{"title":"Review: 2026 Week #43 (October 19 - October 25)","link":"https:\/\/kxsh.dev\/posts\/2026-10-25-weekly\/","pubDate":"Sun, 25 Oct 2026 20:01:22 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-10-25-weekly\/","description":"<p>I did not go running a single day this week.\nBut excited to start a new strength program.\nAnd a weekly spinning class for indoor cardio.<\/p>\n<h3 id=\"media-diet\">Media Diet<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=NYej-KstgTg\">The Birth &amp; Rise of India&rsquo;s IT Outsourcing Industry<\/a> by Asianometry\nThis is a great watch to better understand the background of IT (mostly software) industry in India.\nTata is a really old player in this space. Also, how Infosys came into the picture.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=PM3SP19FQ3w\">The simple idea that could save our groundwater<\/a> by DW Planet A\nWe need more potable water with the population boom. Summers are hotter and drier. Groundwater aquifers are still a major source of freshwater. These ground-water tables are running low. This video presents a couple of ways the company responsible for Berlin&rsquo;s water supply (Berliner Wasserbetriebe) filters water for the city.<\/p>\n<\/li>\n<li>\n<p>New album drops: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Happiness_Anytime?useskin=vector\">Happiness Anytime from Leon Bridges<\/a>, and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fudge_%28album%29?useskin=vector\">FUDGE from Michael Kiwanuka<\/a> got my Soul music hooked up for this Fall.<\/p>\n<\/li>\n<\/ul>"},{"title":"Review: 2026 Week #42 (October 12 - October 19)","link":"https:\/\/kxsh.dev\/posts\/2026-10-18-weekly\/","pubDate":"Sun, 18 Oct 2026 19:59:31 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-10-18-weekly\/","description":"<p>I had plans every single evening this last week.\nFortunately, I could bike to attend to all my commitments. So I consider these commutes as working out.<\/p>\n<p>On Wednesday, I finally sat for a <em>Leben in Deutschland<\/em> test.\nAs part of the prep, I learnt a bit about the modern political setup of Germany.\nOf the 16 German states, Berlin, Hamburg and Bremen are the city states.\nIt took me months to book my seat for the test. I expect to get the results in\nanother month. There&rsquo;s German bureaucracy for you.<\/p>\n<p>On Thursday, a colleague organized a walk through the Festival of Lights.\nWe walked for about 2 hours and the roads were cordoned off due to the crowd.\nDespite the crowd, I had a great experience. Here is a shot:<\/p>\n<figure><img src=\"https:\/\/kxsh.dev\/posts\/2026-10-18-weekly\/festival-of-lights-fernsehturm.jpeg\"\n alt=\"Fernsehturm lit up during the Festival of Lights, Berlin\"><figcaption>\n <p>Fernsehturm during the Festival of Lights, Berlin<\/p>\n <\/figcaption>\n<\/figure>\n\n<p>Yesterday, I tagged along with a friend for his first Half Marathon.\nIt was cold, drizzling, and windy. But I am proud he got it done.\nUpdate: Check out his race report <a href=\"https:\/\/minhajthekhan.github.io\/posts\/sportscheck-half-marathon-2026\/\">here<\/a>.<\/p>\n<iframe\n src=\"https:\/\/connect.garmin.com\/embed\/activity\/24760423450\" title=\"Activity Embed\"\n width=\"100%\"\n height=\"500\"\n frameborder=\"0\"\n loading=\"lazy\"\n><\/iframe>\n\n<p>I intend to relax a bit this upcoming week, and spend more time reading.<\/p>\n<h3 id=\"media-diet\">Media Diet<\/h3>\n<ul>\n<li><a href=\"https:\/\/go.dev\/blog\/http-connection-reuse\">Better HTTP\/1 connection reuse<\/a><\/li>\n<\/ul>\n<p>This is a really nice breakdown of the problems with HTTP\/1.0 protocol.\nThe server-side monkey patching needed to use established, open TCP connections\nacross multiple HTTP requests.<\/p>\n<ul>\n<li><a href=\"https:\/\/webmasters.stackexchange.com\/questions\/88659\/how-can-cloudflare-offer-a-free-cdn-with-unlimited-bandwidth\/88685#88685\">How can CloudFlare offer a free CDN with unlimited bandwidth?<\/a><\/li>\n<\/ul>\n<p>Discovered this excellent answer from Matthew Prince about Cloudflare&rsquo;s business strategy.<\/p>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Odyssey_%282026_film%29?useskin=vector\">The Odyssey<\/a><\/li>\n<\/ul>\n<p>I watched the movie this afternoon. I understood that the movie was Nolan&rsquo;s adoption\nof the epic. So I expected the story to diverge from the epic. However, the narrative\nlacked subtlety. This was a major let down. A better use of 3 hours would be to\nread Homer&rsquo;s Odyssey instead.<\/p>"},{"title":"Review: 2026 Week #41 (October 5 - October 11)","link":"https:\/\/kxsh.dev\/posts\/2026-10-11-weekly\/","pubDate":"Sun, 11 Oct 2026 21:28:56 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-10-11-weekly\/","description":"<p>I felt pretty lethargic last week. Since Thursday I have been sick.<\/p>\n<h2 id=\"links\">Links<\/h2>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=TgUMME8J2Hg\">Make Your Art.<\/a><\/strong> by vlogbrothers.<\/li>\n<\/ul>\n<p>John Green with another reminder to stay human despite the craziness of the world.\nArt is a way to connect humans through time and space.\nTo make and share art demands vulnerability.\nJohn implores us to find the courage to be vulnerable.<\/p>"},{"title":"Race Report: Berlin Marathon 2026","link":"https:\/\/kxsh.dev\/posts\/2026-09-28-marathon\/","pubDate":"Mon, 28 Sep 2026 17:15:38 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-09-28-marathon\/","description":"<p>I ran the Berlin Marathon on Sunday, 27th September 2026.\nThis is a race report to document my experience.<\/p>\n<hr>\n<p>This summer I did not run consistently enough to build endurance. Not that I was\ninjured. Perhaps, I was lazy. Perhaps, I am going through a <em>phase<\/em> with running.\nGoing into this weekend, I doubted I could even run the marathon distance.<\/p>\n<p>I had two choices:<\/p>\n<ol>\n<li>Skip the race.<\/li>\n<li>Run underprepared and risk failing.<\/li>\n<\/ol>\n<p>Then a colleague, running her first marathon, reminded me that it&rsquo;s a privilege\nto run at all. That shifted something. I decided to show up at the start line and\ntake whatever came. If I failed (whatever that means), I could live with it. I might\neven learn something about myself in the process.<\/p>\n<p>Once I started running, I tried to stay present. Only run the kilometer I was in.\nAvoid thinking about how far I had to go. I overthink, so I was surprised\nto hold a single thought for whole stretches. A few topics I reflected on:<\/p>\n<ul>\n<li>&ldquo;What should I work on next?&rdquo;<\/li>\n<li>&ldquo;What&rsquo;s holding me back?&rdquo;<\/li>\n<li>&ldquo;Is <a href=\"https:\/\/youtu.be\/vDjW_dRyKXY?si=ZDkt3hChFMpX94KT&amp;t=3605\">Total Optimism<\/a> the optimal strategy in the face of uncertainty?&rdquo;<\/li>\n<\/ul>\n<p><strong>What worked well?<\/strong><\/p>\n<ul>\n<li>Set my watch to only show my heart rate.<\/li>\n<li>Drink water at almost every aid station.<\/li>\n<li>Eat bananas every 10k.<\/li>\n<li>A shot of Schnapps at 3.5k. Not recommended, but YOLO.<\/li>\n<li>Take the pickle offered by a stranger around 22k.<\/li>\n<li>Smile. It helped me stay positive.<\/li>\n<\/ul>\n<p><strong>What did not go well?<\/strong><\/p>\n<ul>\n<li>Not enough training; Not enough training; Not enough training.<\/li>\n<li>Too hot for the marathon again.<\/li>\n<li>The wristband machines broke down at bib pickup, so I made a second trip on Saturday.<\/li>\n<\/ul>\n<p>My friends showed up to cheer me on along the course. Their support stopped me\nfrom drifting into a negative headspace. I owe them at least a round of beers.\nThanks also to the volunteers, the Berlin crowd with their speakers, and funny\nplacards, and my fellow runners for the insipiration. It was not a PB, but I\nam glad I showed up.<\/p>\n<iframe\n src=\"https:\/\/connect.garmin.com\/embed\/activity\/24517930050\" title=\"Activity Embed\"\n width=\"100%\"\n height=\"500\"\n frameborder=\"0\"\n loading=\"lazy\"\n><\/iframe>\n"},{"title":"Review: 2026 Week #38 (September 14 - September 20)","link":"https:\/\/kxsh.dev\/posts\/2026-09-20-weekly\/","pubDate":"Sun, 20 Sep 2026 12:17:29 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-09-20-weekly\/","description":"<p>On Wednesday, I participated in a Hackathon together with Ankit.\nThe event was organized (and sponsored) by Cursor and hosted by Taxfix.\nDespite reaching the venue 10 mins before time, there was a long queue and I could\nbarely get in time to grab a slice of pizza. Unfortunately, Ankit had to make\ndo with only beers. We teamed up with a couple of other folks to form a team of 4.\nWith only a single track, the event felt more like brainstorming on behalf of the\nTaxfix product team.<\/p>\n<p>Context: Filing taxes is an annual task. Most users postpone tax filing as late as possible.\nChallenge: Make users visit the Taxfix app more frequently.<\/p>\n<p>As a user of Taxfix for the last 5 years, this is a not a painpoint for me.\nI failed to understand the core problem to solve for here.\nWhy should I use something that needs to work annually?\nWhat is the value proposition for the user to visit an app?\nI discussed this with a Product Manager from Taxfix onsite. But I could not get\nany clarity. Thus, I decided not to invest my energy into the hackathon.<\/p>\n<p>Ankit conjured up an idea to ease tax filing for Freelancers and SMEs.\nThe team went ahead with building something (I did not engage actively).<\/p>\n<p>Meanwhile, I networked with other people at the venue.\nSimon, from the Cursor team, shared how the Cursor team is evaluating Merge Queues\nfor CI\/CD.<\/p>\n<h2 id=\"projects\">Projects<\/h2>\n<h3 id=\"ostep\"><a href=\"https:\/\/pages.cs.wisc.edu\/~remzi\/OSTEP\/\">OSTEP<\/a><\/h3>\n<p>I focused on the CPU Virtualization section this week.\nParticularly, I read about the various Scheduling policies that exist.\nScheduling workloads on a Multi-CPU system (any modern machine) is unsurprisingly\ncomplicated. But now I have a mental model for the Completely Fair Scheduler in\nLinux.<\/p>\n<h3 id=\"ksh\"><a href=\"https:\/\/codeberg.org\/kxsh\/ksh\">ksh<\/a><\/h3>\n<p>The CPU virtualization section of the OSTEP book suggests building a shell.\nThe idea is to familiarize myself with the Process abstraction.\nI remember building shells back at university.\nBut it was very unstructured and I didnot appreciate the fundamental concepts enough.\nThus, I am giving it another try.<\/p>\n<h2 id=\"links\">Links<\/h2>\n<ul>\n<li><strong><a href=\"https:\/\/galileo-unbound.blog\/2026\/09\/16\/a-short-history-of-the-information-age\/\">A Short History of the Information Age<\/a><\/strong> by David D. Nolte.<\/li>\n<\/ul>\n<p>Useful reference to build the context around the innovation that went into building\nthe current state of tech.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/gruhn.me\/blog\/2026-09-14\/?roundabout=37580\">The beauty of roundabouts<\/a><\/strong> by Niklas Gruhn.<\/li>\n<\/ul>\n<p>A good analogy for solving problems (road intersections) with simple solutions\n(roundabouts) rather than complicated &ldquo;orchestrated&rdquo; solutions (traffic lights).<\/p>"},{"title":"Review: 2026 Week #37 (September 7 - September 13)","link":"https:\/\/kxsh.dev\/posts\/2026-09-13-weekly\/","pubDate":"Sun, 13 Sep 2026 12:24:17 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-09-13-weekly\/","description":"<p>My parents made it safely back home to India.\nNow, I am easing back into my routine. That includes regular weekly updates.<\/p>\n<p>On Tuesday, I attended a meetup on <a href=\"https:\/\/luma.com\/oretqk1d?tk=5l12dt\">AI for Analytics<\/a>.\nA couple of takeaways:<\/p>\n<ul>\n<li>Using RBAC (on DB) can be an option to sandbox AI Agents.<\/li>\n<li>Building Agentic systems (or workflows) still lacks reliable patterns.<\/li>\n<\/ul>\n<p>A YouTube channel, Gamers Nexus, published an expose on LG TVs used for snooping.\nI am following how this drama is unfolding as I recently bought a LG C5.<\/p>"},{"title":"Building Web Apps: Part 0 - Introduction","link":"https:\/\/kxsh.dev\/posts\/2026-09-09-webdev\/","pubDate":"Wed, 09 Sep 2026 21:07:07 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-09-09-webdev\/","description":"<p>I specialize in building (and maintaining) backend systems as a software engineer.\nspecializing in backend systems.\nthe past 6 years. In the present era of AI, it is difficult to ignore the potential of LLMs.<\/p>\n<p>Hence, I want to collect my thoughts and document my preferences for building simple\napps for the web platform.<\/p>\n<p>Web frameworks like Rails are incredibly powerful to prototype an idea quickly.\nHowever, I have always irked at the conventions they introduce.<\/p>\n<p>Thus, I yearned for simpler implementation that allow me to build a mental model\nof the request and application lifecycles.<\/p>\n<p>For almost 10 years I have built services in Go, mostly HTTP.\nThe lack of an opionated framework and lots of building blocks from the Go standard library provide me with the level of freedom I desired. Of course, the caveat is that its easier to make mistakes.\nI have made them, learnt from them and tried not to repeat them.<\/p>\n<p>Server Side Rendering works for majority of the use cases when building a web application.\nFor an mobile &ldquo;app&rdquo; experience, of course, we need to JavaScript.\nHowever, simplicity is<\/p>\n<hr>\n<ol>\n<li>Serve HTTP traffic.<\/li>\n<li>Serve HTML over HTTP.<\/li>\n<\/ol>\n<ul>\n<li>Model Blog Entities.<\/li>\n<li>Serve HTML Templates.<\/li>\n<li>DB Integration.<\/li>\n<li>Testing.<\/li>\n<\/ul>"},{"title":"Review: 2026 Week #31 (July 27 - August 02)","link":"https:\/\/kxsh.dev\/posts\/2026-08-01-weekly\/","pubDate":"Sat, 01 Aug 2026 15:37:33 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-08-01-weekly\/","description":"<p>What is on your mind?<\/p>\n<p>TODO: Show a dynamic writing prompt.<\/p>"},{"title":"Review: 2026 Week #29-#30 (July 13 - July 26)","link":"https:\/\/kxsh.dev\/posts\/2026-07-27-weekly\/","pubDate":"Mon, 27 Jul 2026 11:49:44 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-07-27-weekly\/","description":"<p>My parents are visiting me in Berlin this summer.\nI took a couple weeks of vacation to spend time with them.\nThus, I spent a lot of time away from my computer.<\/p>\n<p>They landed in Munich after boarding an overnight flight from Delhi.\nFrom Munich, we did a day trip to visit the iconic <a href=\"https:\/\/en.wikipedia.org\/wiki\/Neuschwanstein_Castle?useskin=vector\">Neuschwanstein Castle<\/a>.\nThe weather was excellent, and my parents seemed to enjoy the natural beauty of Bavaria.<\/p>\n<p>On our way back to Berlin, I reserved seats on an ICE Sprinter for them to\nexperience the countryside while cruising at ~300 kmph.<\/p>\n<p>Within Berlin, thus far, we have been visting museums, temples and IKEA to set up\nthe apartment as per their liking. We also went on an informative 2.5 hr boat cruise in the Spree.\nMy parents had their first Neapolitan pizza yesterday - classic Margherita.\nThey liked the freshness of the ingredients, despite not being a fan of refined flour.<\/p>\n<p>I am excited for them to experience the European culture.<\/p>"},{"title":"Review: 2026 Week #28 (July 6 - July 12)","link":"https:\/\/kxsh.dev\/posts\/2026-07-12-weekly\/","pubDate":"Sun, 12 Jul 2026 21:47:14 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-07-12-weekly\/","description":"<p>Watching the Quarter Final round of the ongoing FIFA World Cup 2026 messed up my\nsleeping schedule. I watched 3 of the 4 matches with friends over drinks so the\ninvestment was worth it for social reasons.<\/p>\n<p>I played beach Volleyball with friends on Saturday morning.\nUnfortunately, I injured my left shoulder and sprained my left ankle.\nSo I had to skip a couple of runs this week.<\/p>"},{"title":"Review: 2026 Week #27 (June 29 - July 5)","link":"https:\/\/kxsh.dev\/posts\/2026-07-05-weekly\/","pubDate":"Sun, 05 Jul 2026 22:19:54 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-07-05-weekly\/","description":"<p>I got back from a friend&rsquo;s wedding last weekend.\nMonday was mostly about physical recovery.<\/p>\n<p>Thanks to the weather, I ran every day this week for a total of 55k. The body is adjusting well thus far. On Saturday, I joined a couple of friends for Pickelball.<\/p>\n<p>Meanwhile, I am looking to set up a home theatre - OLED TV, Speakers (at least). Inclining towards LG C5.<\/p>"},{"title":"Review: 2026 Week #25 (June 15 - June 21)","link":"https:\/\/kxsh.dev\/posts\/2026-06-21-weekly\/","pubDate":"Sun, 21 Jun 2026 15:04:04 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-06-21-weekly\/","description":"<p>Ever time and energy consuming work continues.\nI took Friday off work, and spent some time in the evening revisiting Go.<\/p>\n<p>I watched the OG talk by Rob Pike announcing <a href=\"https:\/\/youtu.be\/rKnDgT73v8s?si=23x4fKMW2qEYgsVi\">The Go Programming Language<\/a>, and re-read the <a href=\"https:\/\/go.dev\/doc\/effective_go\">Effective Go<\/a> after more than a couple of years.<\/p>"},{"title":"Review: 2026 Week #24 (June 8 - June 14)","link":"https:\/\/kxsh.dev\/posts\/2026-06-14-weekly\/","pubDate":"Sun, 14 Jun 2026 14:12:59 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-06-14-weekly\/","description":"<p>I picked up the <a href=\"https:\/\/pages.cs.wisc.edu\/~remzi\/OSTEP\/\">Operating Systems: Three Easy Pieces<\/a> on Friday evening.\nRead through a couple of chapters on CPU Virtualization and Concurrency.\nMy solutions to the exercises and homework can be found in <a href=\"https:\/\/codeberg.org\/kxsh\/ostep\">this Codeberg repo<\/a>.<\/p>\n<h2 id=\"links\">Links<\/h2>\n<ul>\n<li><strong><a href=\"https:\/\/tombedor.dev\/human-attention-and-human-effort\/\">If You are Asking for Human Attention, Demonstrate Human Effort<\/a><\/strong> by <strong>Tom Bedor<\/strong><\/li>\n<\/ul>\n<p>Using LLM generated output can boost productively in a lot of scenarios.\nHowever, all of us need to be deliberate when using it, especially in team collaboration environment.\nSpeed (even velocity) can not justify for a lack of understanding.\nThis note is a reminder to myself to be mindful when working with LLMs.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=UlXpOGIpITM\">Kubernetes and retiring at the top with Kelsey Hightower<\/a><\/strong> by <strong>The Pragmatic Engineer<\/strong><\/li>\n<\/ul>\n<p>I listened to this 2 hour long podcast during my runs.\nKelsey&rsquo;s journey is inspirational, though I could not relate to it.\nNo major takeaways; just fun.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/seths.blog\/2026\/06\/art-is-a-verb\/\">Art is a verb<\/a><\/strong> by Seth Godin<\/li>\n<\/ul>\n<p>Change is an integral part of Art.<\/p>"},{"title":"Review: 2026 Week #23 (June 1 - June 7)","link":"https:\/\/kxsh.dev\/posts\/2026-06-07-weekly\/","pubDate":"Sun, 07 Jun 2026 23:41:57 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-06-07-weekly\/","description":"<p>This week was a breeze! I spent a lot of my spare time working out and running.\nStarted re-reading <a href=\"https:\/\/www.goodreads.com\/en\/book\/show\/35541721-safe-haven\">Safe Haven<\/a> by Mark Spitznagel.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/jasonzweig.com\/three-ways-to-get-paid\/#replace-with-the-found-url\">Three Ways to Get Paid<\/a><\/strong> by Jason Zweig<\/li>\n<\/ul>\n<p>Rediscovered this beautiful piece.<\/p>"},{"title":"Review: 2026 Week #22 (May 25 - May 31)","link":"https:\/\/kxsh.dev\/posts\/2026-05-31-weekly\/","pubDate":"Sun, 31 May 2026 16:25:26 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-05-31-weekly\/","description":"<p>Monday marked the last public holiday for this summer.\nDespite the short work week, it was quite stressful.<\/p>\n<p>I participated in a Capture The Flag event organized by Cresta on Wednesday evening.\nDid not enjoy the experience as the atmosphere was quite competitive rather than\ncollaborative.<\/p>\n<p>Tough luck Arsenal for the CL Final yesterday!<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=i_qy52fplBE\">How Bicycle Helmets Are Engineered to Protect Your Brain<\/a><\/strong> by engineerguy<\/li>\n<\/ul>\n<p>Great intro to how helmets work. Good to understand why they are a one-time purchase.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=-14t6_yu-7w\">The &ldquo;Trick&rdquo; that Compilers Use for Long Division - Computerphile<\/a><\/strong> by Computerphile<\/li>\n<\/ul>\n<p>Magic numbers in the compilers.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=yYLg9Kmx8e8\">Inside Apple&rsquo;s Secretive Trade-In Program<\/a><\/strong> by Apple Explained<\/li>\n<\/ul>\n<p>I wonder whether the second hand phones from official partners are worth it.<\/p>"},{"title":"Review: 2026 Week #21 (May 18 - May 24)","link":"https:\/\/kxsh.dev\/posts\/2026-05-24-weekly\/","pubDate":"Sun, 24 May 2026 14:19:56 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-05-24-weekly\/","description":"<p>The weekend was pretty hot and humid. I had a hard time running.\nBut I still got this week&rsquo;s weekly mileage (44k) in the bag.\nAlso on Friday evening, I picked up my new bike from Decathlon - Elops 500 Yellow.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=L4jdjPR75wQ\">FULLY AUTOMATED COMPUTER MUSIC<\/a><\/strong> by TodePond<\/li>\n<\/ul>\n<p>Beautifully illustrates the point of automating ourselves out of joy.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/specular.fi\/post\/what-is-busybox\">What is BusyBox?<\/a><\/strong> by Specular<\/li>\n<\/ul>\n<p>BusyBox is a collection of tools\/binaries shipped with Alpine.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/tante.cc\/2026\/05\/20\/on-google-declaring-war-on-the-web\/?utm_source=the-index&amp;utm_medium=newsletter\">On Google declaring war on the Web<\/a><\/strong> by tante\nTime to de-google my digital life as much as possible.\nI need specific tools that work reliably, especially in the AI slop era.<\/li>\n<\/ul>"},{"title":"Effort","link":"https:\/\/kxsh.dev\/posts\/2023-05-28-effort\/","pubDate":"Sun, 17 May 2026 16:50:06 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-05-28-effort\/","description":"<p>It\u2019s summer in Berlin. Some days were bright and sunny. Others were cloudy and\nwindy. But I have thoroughly enjoyed all my runs this past week. My body is\ngradually adapting to the new daily routine.<\/p>\n<p>My primary focus is just to build the rhythm. I am not worrying about anything\nelse. As I lace up my shoes, I simply immerse myself in the present moment.\nMuch like the accumulation of tiny drops that eventually fill a glass to the\nbrim, I hope these runs will contribute to a fulfilling outcome.<\/p>\n<p>The central concept of my training is the notion of effort. Neither pace nor\ndistance hold significance if they are misaligned with the appropriate level\nof exertion. Some days, running feels like a smooth, effortless flow. While\nothers are just a slog. Every run requires adjustments based on my perceived\neffort. The ability to do so is a valuable skill to learn. Through this\nprocess, I gain a deeper understanding of my true self, and embrace a humble\nawareness of my own capabilities and limitations. Consequently, I find no\npoint in comparing myself to anyone but my past self.<\/p>\n<p>Running is fun again, and I\u2019m grateful to experience this feeling once again.\nFurthermore, I have a strong gut feeling - it\u2019s going to be a good season.\nBut I can not get ahead of myself. Next step - Week 2.<\/p>\n<h2 id=\"workouts\">Workouts<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.strava.com\/activities\/9119919362\">Run 1 - 5k Recovery<\/a><\/li>\n<li><a href=\"https:\/\/www.strava.com\/activities\/9124599076\">Run 2 - 8k Easy<\/a><\/li>\n<li><a href=\"https:\/\/www.strava.com\/activities\/9138582378\">Run 3 - 5k Recovery<\/a><\/li>\n<li><a href=\"https:\/\/www.strava.com\/activities\/9147730383\">Run 4 - 6x800m Yasso Repeats<\/a><\/li>\n<li><a href=\"https:\/\/www.strava.com\/activities\/9154680580\">Run 5 - 16k Progressive Long Run<\/a><\/li>\n<\/ul>\n<h2 id=\"albums\">Albums<\/h2>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Highway_to_Hell?useskin=vector\">Highway to Hell<\/a> by AC\/DC<\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Ill_Communication?useskin=vector\">Ill Communication<\/a> by Beastie Boys<\/li>\n<\/ul>\n<h2 id=\"inspirations\">Inspirations<\/h2>\n<p>Shoutout to <a href=\"https:\/\/www.youtube.com\/@hardestgeezer\">Hardest Geezer<\/a> stomping out 1\u2019s and 2\u2019s on his way across Africa.<\/p>"},{"title":"Rhythm","link":"https:\/\/kxsh.dev\/posts\/2023-06-04-rhythm\/","pubDate":"Sun, 17 May 2026 16:45:48 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-06-04-rhythm\/","description":"<p>This week was simply about building up from the previous one.<\/p>\n<p>My shins started to hurt on Monday. This has bothered me during each and every\nrun this past week. Often, I had to stop in the middle of runs just to collect\nmyself, and go again. A couple of times, I felt like my feet were just going to\ncollapse. It was a bit scary to feel that weak.<\/p>\n<p>My body just needs more time to adjust to meet my demands from it. The best\nthing I can do is to pay close attention to how my body responds. However, my\nresolve is strong. I am not going to cut down on the training plan. The only\nway is through this pain.<\/p>\n<p>I hope things will take a better turn in the upcoming week.\nFor now, ice and rest are the need of the hour.<\/p>\n<h2 id=\"workouts\">Workouts<\/h2>\n<ul>\n<li>5k Recovery<\/li>\n<li>5k Easy<\/li>\n<li>8k Easy<\/li>\n<li>8k Pace<\/li>\n<li>17.5k Long Run<\/li>\n<\/ul>\n<h2 id=\"albums\">Albums<\/h2>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/45:33?useskin=vector\">45:33<\/a> by LCD Soundsystem<\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Sound_of_Silver?useskin=vector\">Sound of Silver<\/a> by LCD Soundsystem<\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Fear_of_a_Blank_Planet?useskin=vector\">Fear of a Blank Planet<\/a> by Porcupine Tree<\/li>\n<\/ul>"},{"title":"Consistency","link":"https:\/\/kxsh.dev\/posts\/2023-06-11-consistency\/","pubDate":"Sun, 17 May 2026 16:40:07 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-06-11-consistency\/","description":"<p>Lately, I have been feeling strong. Body is somehow holding itself together so far.<\/p>\n<p>3 weeks into the training cycle and I have met all of my expectations so far.\nI am quite satisfied with this. It is getting hot out here so I try to run in\nthe cooling shade of trees.<\/p>\n<p>Endurance is not a get-rich-quick scheme. We cannot develop this ability over\nnight. To be fair, at least I can not, for sure, perhaps others are gifted with\nsuperhuman abilities to do so. However, I have learnt that endurance demands\npatience and continual efforts. Almost as if you are building a deep,\nmeaningful relationship. Over the last couple of years, I have started to value\nsuch seemingly, slow projects in all areas of my life.<\/p>\n<p>As expected, there are going to be enough good days to balance out the bad days.\nMy focus is simply to make it through the tough days. Take it slow, if I must.\nBuild consistency. This requires a bit of discipline, and a lot of mental energy.<\/p>\n<p>Step by step, we will get there, quite literally.<\/p>\n<h2 id=\"workouts\">Workouts<\/h2>\n<ul>\n<li>Run 1 - 5k Recovery<\/li>\n<li>Run 2 - 10k Tempo<\/li>\n<li>Run 3 - 5k Easy<\/li>\n<li>Run 4 - 10k Intervals (4x1600m)<\/li>\n<li>Run 5 - 13k Progressive Long Run<\/li>\n<\/ul>\n<h2 id=\"albums\">Albums<\/h2>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Your_Wilderness?useskin=vector\">Your Wilderness<\/a> by <a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Pineapple_Thief?useskin=vector\">The Pineapple Thief<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Weezer_%28Blue_Album%29?useskin=vector\">Blue Album<\/a> by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Weezer?useskin=vector\">Weezer<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Chronicle%3A_The_20_Greatest_Hits?useskin=vector\">Chronicle<\/a> by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Creedence_Clearwater_Revival?useskin=vector\">Creedence Clearwater Revivial<\/a><\/li>\n<\/ul>"},{"title":"Void","link":"https:\/\/kxsh.dev\/posts\/2023-06-20-void\/","pubDate":"Sun, 17 May 2026 16:35:39 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-06-20-void\/","description":"<p>Lately, I have not been thinking during my runs.<\/p>\n<p>Let me be specific - no non-ordinary thoughts pop into my head when I\u2019m out.<\/p>\n<p>Sure, I think about the general stuff like the weather, the route I want to\ntake, the album I want to listen to, whether my clothing is appropriate for the\nrun or not. There are plenty of things that seem important and occupy so much\nof my headspace. Most definitely, not all of them are necessary. Even though\nthey might affect me emotionally, I just do not care about them anymore. I\nunderstand that I cannot hold it all within me if I want to endure. Perhaps,\nit\u2019s just a practice of detachment.<\/p>\n<p>The time I spend on the runs just flew by. One moment, I was getting familiar\nwith the run, and all of a sudden it was time to stop. This might not be\nsomething profound, but perhaps it\u2019s significant.<\/p>\n<p>Anyways, more miles under my feet.<\/p>\n<h2 id=\"workouts\">Workouts<\/h2>\n<ul>\n<li>Run 1 - 5k Recovery Run<\/li>\n<li>Run 2 - 10k Easy<\/li>\n<li>Run 3 - 10k Tempo<\/li>\n<li>Run 4 - 5k Recovery Run<\/li>\n<li>Run 5 - 21.45k Pl\u00e4nterwaldlauf<\/li>\n<\/ul>\n<h2 id=\"inspiration\">Inspiration<\/h2>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=g1E46mpIynY\">Tracksmith: That\u2019s Running - Time, Alone<\/a><\/p>\n<h2 id=\"albums\">Albums<\/h2>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Songs_for_the_Deaf?useskin=vector\">Songs for the Deaf<\/a> by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Queens_of_the_Stone_Age?useskin=vector\">Queens of Stone Age<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Earth_Is_Not_a_Cold_Dead_Place?useskin=vector\">The Earth Is Not a Cold Dead Place<\/a> by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Explosions_in_the_Sky?useskin=vector\">Explosions in the Sky<\/a><\/li>\n<\/ul>"},{"title":"Week#01: Starting from Zero","link":"https:\/\/kxsh.dev\/posts\/2026-05-17-run\/","pubDate":"Sun, 17 May 2026 14:47:49 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-05-17-run\/","description":"<p>I kicked off the summer training block this week.\nThe plan is to train for 20 weeks culminating in a Marathon.<\/p>\n<p>It is worth a moment to write down what I hope to achieve, at least capture my\ndesires. My primary goal is to connect more with myself. The world demands my\nconstant attention. Its challenging to keep up with the rapidly changing\nenvironment around us. This drains a lot of my energy.<\/p>\n<p>Putting my physical body through the motion creates a dedicated time for me to\n<em>be<\/em>. Running demands fully awareness of both my physical capabilities, and\nlimitations. Surprisingly, I almost always feel positive after a run. Most\nlikely, this is Placebo Effect. Perhaps, it is just beyond my understanding.<\/p>\n<p>Like every season, I only intend to consistently put in honest, hardwork into\nthis challenge, and approach it with curiosity. My hope is that I am able to\neffectively collaborate with my body. In the process, I would only be grateful\nto discover deeper knowledge.<\/p>\n<p>For the spiritually leaning, I suppose you could call it an exercise in\npracticing the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Advaita_Vedanta?useskin=vector\">&ldquo;Advaita Vedanta&rdquo;<\/a>\nor <a href=\"https:\/\/en.wikipedia.org\/w\/index.php?title=Nondualism&amp;useskin=vector\">nondualism<\/a>.<\/p>\n<p>Metrics like time don&rsquo;t matter.<\/p>\n<h2 id=\"runs\">Runs<\/h2>\n<table>\n <thead>\n <tr>\n <th>Day<\/th>\n <th>Distance<\/th>\n <th>Type<\/th>\n <\/tr>\n <\/thead>\n <tbody>\n <tr>\n <td>Tuesday<\/td>\n <td>8.06k<\/td>\n <td>Tempo<\/td>\n <\/tr>\n <tr>\n <td>Wednesday<\/td>\n <td>6.01k<\/td>\n <td>Easy<\/td>\n <\/tr>\n <tr>\n <td>Thursday<\/td>\n <td>8.10k<\/td>\n <td>Intervals 6x800m (Rest 200m)<\/td>\n <\/tr>\n <tr>\n <td>Saturday<\/td>\n <td>5.90k<\/td>\n <td>Easy<\/td>\n <\/tr>\n <tr>\n <td>Sunday<\/td>\n <td>16.36k<\/td>\n <td>Long Run (Progressive)<\/td>\n <\/tr>\n <tr>\n <td><strong>Total<\/strong><\/td>\n <td><strong>44.42k<\/strong><\/td>\n <td><\/td>\n <\/tr>\n <\/tbody>\n<\/table>"},{"title":"Review: 2026 Week #20 (May 11 - May 17)","link":"https:\/\/kxsh.dev\/posts\/2026-05-17-weekly\/","pubDate":"Sun, 17 May 2026 14:04:22 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-05-17-weekly\/","description":"<p>It&rsquo;s Pollen season in Berlin. They are swirling all around on the streets.\nI must have swallowed atleast a couple of them during the run this morning.<\/p>\n<p>I went to the Golang Meetup hosted by Talon.one on Wednesday.\nOne of the co-organizers is an ex-colleague from OneFootball.\nSo catching up on what has been up to.\nOne of the talks was about the AutoPR project - wrapper around coding harness CLIs.\nAnd the other was about the memory allocator in Go.\nThis talk was quite technical, and I was out of depth.\nNeed to read up a bit more of such low-level details.<\/p>\n<p>I played the Factorio (Demo) for a couple of hours last Sunday evening on my Mac.\nI found the game extremely complex, but I could relate to a few of the challenges\ncommon to the genre of Factory games. Computer Science topics such as queuing\ntheory, resource management, and concurrency form the core.\nLearning to apply engineering principles in a domain outside of software, is\nrewarding - resiliency through redundancy.\nDespite it being a time sink, I decided to buy a copy of the game.\nLet see when I find time to play it.<\/p>\n<p>With the summer approaching, I ordered a new bike at Decathlon yesterday.\nHowever, I can only expect to pick it up in another 10 days.<\/p>\n<h2 id=\"content\">Content<\/h2>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=svCnShDvgQg\">Two Roads to Durable Agents: Replay vs. Snapshot \u2014 Eric Allam, Trigger.dev<\/a><\/strong> by AI Engineer<\/li>\n<\/ul>\n<p>Developing and deploying web apps has evolved from CGI, LAMP stack to complex\nside effects usecases implemented through async comms outside the request-response\ncycle.<\/p>\n<p>I need to play with Trigger.dev to evaluate the platform for agentic workloads.\nBut this talk was quite insightful about the space of building LLM powered apps.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=JahBXEUx-wk\">4 Ways Fractals Changed Tech Forever<\/a><\/strong> by SciShow<\/li>\n<\/ul>\n<p>Maestro Benoit B. Mandelbrot!<\/p>"},{"title":"Review: 2026 Week #19 (May 4 - May 10)","link":"https:\/\/kxsh.dev\/posts\/2026-05-10-weekly\/","pubDate":"Sun, 10 May 2026 21:41:54 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-05-10-weekly\/","description":"<p>Last chill week before the official Marathon training block.\nI attended the PostgreSQL May Meetup on Thursday for a couple of talks:<\/p>\n<ul>\n<li>\n<p>One about datalake architecture using the <code>pg_lake<\/code> extension.<\/p>\n<\/li>\n<li>\n<p>Few neat PostgreSQL features such as Ranges.<\/p>\n<\/li>\n<li>\n<p><strong><a href=\"https:\/\/lpar.ath0.com\/posts\/2026\/05\/the-vi-family\/\">The vi family<\/a><\/strong> by lpar.<\/p>\n<\/li>\n<\/ul>\n<p>Reference material on history the Vim text editor.\nStarting off from <code>vi<\/code> to <code>vim<\/code> to <code>Neovim<\/code>.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=Q9GAJ_ka4l4\">Ticking Timebomb in Mac OS<\/a><\/strong> by The PrimeTime<\/li>\n<\/ul>\n<p>When we close a TCP connection, the port is not immediately available for reuse. Why? It waits a small amount of time to allow for any existing packet on the internet to arrive. This reduces the risk of corrupting any new connections due to stale packets.\n<code>TIME_WAIT<\/code> configures this. (default = 30s)<\/p>\n<ul>\n<li>\n<p><strong><a href=\"https:\/\/noahbogart.com\/posts\/2026-05-03-losing-skills\/\">Losing Skills<\/a><\/strong> by Noah Bogart\nSkills are like muscles, only growing through consistency, struggle, and progressive overload. Does that make LLMs steroids?<\/p>\n<\/li>\n<li>\n<p><strong><a href=\"https:\/\/thebuild.com\/blog\/2026\/05\/06\/what-a-data-lake-actually-is-and-why-you-probably-dont-need-one\/\">What a Data Lake Actually Is (and why you probably don\u2019t need one)<\/a><\/strong> by Christophe Pettus\nExcellent, simple explanation of the current landscape of data architectures.\nWarning: The content reeks of LLM-generated slop.<\/p>\n<\/li>\n<\/ul>"},{"title":"Review: 2026 Week #18 (Apr 27 - May 3)","link":"https:\/\/kxsh.dev\/posts\/2026-05-03-weekly\/","pubDate":"Sun, 03 May 2026 13:52:15 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-05-03-weekly\/","description":"<p>May 1st is synonymous with street raves in Berlin.\nGrab beers from a Sp\u00e4ti, find your friends, and be a part of the craziness.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=xPmQxYIi5fA&amp;list=PLCl5BUbK0jXt5l18S5UNAoUc4eQ2PJDye\">Event Sourcing Explained using Football<\/a><\/strong> by Metaphorically Speaking<\/li>\n<\/ul>\n<p>Core concepts related to Event Sourcing:<\/p>\n<ul>\n<li>\n<p>Event Stream<\/p>\n<\/li>\n<li>\n<p>Projections<\/p>\n<\/li>\n<li>\n<p>Aggregate<\/p>\n<\/li>\n<li>\n<p><strong><a href=\"https:\/\/bcantrill.dtrace.org\/2026\/04\/12\/the-peril-of-laziness-lost\/\">The peril of laziness lost<\/a><\/strong> by Bryan Cantrill<\/p>\n<\/li>\n<\/ul>\n<p>Laziness is a virtue as it is born out of time constraints. LLMs lack this virtue. Hence, they are only a tool to help software engineers. We should use them to apply our engineering rigor.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.abareplace.com\/blog\/ai_fastfood\/\">The age of fast food \u2014 Aba Search &amp; Replace<\/a><\/strong> by<\/li>\n<\/ul>\n<p>AI generated content (code, &ldquo;art&rdquo;) is analogous to fast-food.\nAs low-effort and accessible as fast food may be, we need nutritious food to sustain our bodies in the long term. Assuming we intend to work on long-term projects, it only makes sense to not default to fast slop.<\/p>"},{"title":"Review: 2026 Week #16 - #17 (Apr 13 - Apr 26)","link":"https:\/\/kxsh.dev\/posts\/2026-04-26-weekly\/","pubDate":"Sun, 26 Apr 2026 13:27:51 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-04-26-weekly\/","description":"<p>I am back in Berlin after an extended weekend trip to Portugal with the boys.\nLots of alcohol and Pasteis de Nata.<\/p>\n<p>The big news of the week - Sub-2 hour marathon barrier has been broken by\nSebastian Sawe and Yomif Kejelcha at London Marathon 2026.\nTigst Assefa also set the world record for women&rsquo;s marathon category.\nCongratulations to all the finishers! This is simply inspirational work.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/lemire.me\/blog\/2026\/04\/09\/a-brief-history-of-c-c-programming-languages\/\">A brief history of C\/C++ programming languages<\/a><\/strong> by Daniel Lemire<\/li>\n<\/ul>\n<p>Concise walkthrough the evolution of programming languages starting from C, Fortran, and Pascal.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/dylanbutler.dev\/blog\/protect-your-shed\/\">Protect Your Shed<\/a><\/strong> by Dylan Butler<\/li>\n<\/ul>\n<p>While I do not necessarily agree with everything written in this article, I\nunderstand it as a Call-to-Arms for building side projects. Especially, as a\nway to pursue curiosity.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=PPJ6NJkmDAo\">How Secure Is Tap To Pay?<\/a><\/strong> by Veritasium<\/li>\n<\/ul>\n<p>Highly encourage iPhone users to watch this video.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/buttondown.com\/jaffray\/archive\/columnar-storage-is-normalization\/\">Columnar Storage is Normalization<\/a><\/strong> by Justin Jaffray<\/li>\n<\/ul>\n<p>Data layout is an implementation detail that has significant performance implications.\nRelational databases have traditionally used a row-oriented data layout.\nColumnar storages, popular for analytical workloads, store data in a column-oriented format.\nSQL should not be coupled to a specific data layout.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=AW_X6soZbQY\">If you\u2019re a senior engineer, watch this\u2026<\/a><\/strong> by Let&rsquo;s Get Rusty<\/li>\n<\/ul>\n<p>This video is a signal in the contemporary AI-hyped world: Either go deeper and\nmaster the fundamentals or elevate yourself to an &ldquo;orchestrator&rdquo; role.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=tLsoelNl3To\">Sliding Window Algorithm for Tech Interviews - Full Course<\/a><\/strong> by freeCodeCamp.org<\/li>\n<\/ul>\n<p>Good intro to Sliding Window techniques with problems.\nIn the upcoming week, I intend to solve related problems on LeetCode (for practice).<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/chriscoyier.net\/2026\/04\/24\/its-an-assumed-truth-that-safari-is-better-for-battery-life-without-data-to-support-it\/\">It\u2019s an assumed truth that Safari is better for battery life \u2014 without data to support it.<\/a><\/strong> by Chris Coyier<\/li>\n<\/ul>\n<p>Though not a scientific study, the experiment provides a counterpoint to the\npropaganda about Safari being more energy efficient than Chrome.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/ky.fyi\/posts\/ai-burnout\">Do I belong in tech anymore?<\/a><\/strong> by<\/li>\n<\/ul>\n<p>I related hard with this article. For the last 3 months, I have been in a similar\nstate of &ldquo;funk&rdquo;. I understand I do not have the answers - but I am choosing to\nfocus on my strengths - pursue my curiosity, and stay optimistic about the future.<\/p>"},{"title":"Review: 2026 Week #15 (Apr 06 - Apr 12)","link":"https:\/\/kxsh.dev\/posts\/2026-04-14-weekly\/","pubDate":"Tue, 14 Apr 2026 15:13:01 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-04-14-weekly\/","description":"<p>Apologies for the delay - time management skill issue.\nI will be AFK upcoming weekend.<\/p>\n<p>Alcohol in my blood after a month.\nI use the Untappd app on my phone to track my drinks.<\/p>\n<p>After about 10 weeks, I charged my TRMNL device on Sunday.\nThe e-ink display product is extremely efficient to communicating static information.\nOnce we have color display figured out, I can imagine a lot of billboards replaced\nby an e-ink product.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/live\/Bic2KjFFj6w?si=vx5tg9kSYil9xgpt\">Omacon 2026<\/a><\/strong><\/li>\n<\/ul>\n<p>DHH is a great story teller, in addition to being a legendary programmer.\nHis optimism for product building is infectious.\nI need to get my hands on a secondhand Thinkpad or Framework to try out Omarchy.<\/p>\n<p>Prime &#x2764;&#xfe0f; - I am inspired by this guy. Only if I could be half as competent as he is.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/ploum.net\/2026-04-10-rien-a-penser.html\">Ne rien avoir \u00e0 penser<\/a><\/strong> by Ploum on 2026-04-10<\/li>\n<\/ul>\n<p>(translated to English )&quot;&hellip;a bit like what cigarette vendors might organize in sports clubs to train young people to smoke by offering a year of free cigarettes.&quot;<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/daverupert.com\/2026\/04\/make-something\/\">Before I go: People like it when other people make things<\/a><\/strong> by Dave Rupert<\/li>\n<\/ul>\n<p>I subscribe to this perspective. Making is a positive sum game when its driven\nby curiosity, not just financial reward. So tell me about what you are\nmaking, learning and figuring out.<\/p>"},{"title":"Review: 2026 week #14 (Mar 30 - Apr 05)","link":"https:\/\/kxsh.dev\/posts\/2026-04-05-weekly\/","pubDate":"Sun, 05 Apr 2026 10:52:30 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-04-05-weekly\/","description":"<p>This week marks Easter with an extended 4-day weekend in Germany.\nThus, its easier to schedule time for workouts and running.\nI went for the Parkrun at Hasenheide yesterday.<\/p>\n<p>Due to Daylights Savings Time, clocks moved an hour forwards last week.\nMy sleep schedule demands more time to adapt.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/ccunpacked.dev\/\">Claude Code Unpacked<\/a><\/strong> by Claude Code Unpacked<\/li>\n<\/ul>\n<p>The source code of Claude Code leaked to the public domain.\nDespite Anthropic&rsquo;s DMCA notices, this visual guide explains the idea behind the\nCLI - all the subsystems and the overall loop.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/whoami.wiki\/blog\/personal-encyclopedias\">Personal Encyclopedias \u2014 whoami.wiki<\/a><\/strong> by Jeremy<\/li>\n<\/ul>\n<p>This is a really cool usecase for LLMs.\nI would be curious to give this a try.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=_n2vN-Bgq4U\">Three decades of curl - Daniel Stenberg - NDC Security 2026<\/a><\/strong> by NDC Conferences<\/li>\n<\/ul>\n<p>Even though Daniel is majorly responsible for the success and longetivity for the <code>curl<\/code> project, he is not its original creator.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/ilovetypography.com\/2026\/04\/03\/a-brief-history-of-the-dust-jacket\/\">A Brief History of the Dust\u00a0Jacket<\/a><\/strong> by John Boardley<\/li>\n<\/ul>\n<p>Books were sold unbound until bookbinding was mechanized.\nYet again, Japanese excels at cultural elegance with book obis.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/blog.jgc.org\/2026\/04\/maistro.html\">Maistro<\/a><\/strong> by John Graham-Cumming<\/li>\n<\/ul>\n<p>JGC introduces a new identity: <em>maistro<\/em>.<\/p>\n<p><strong>maistro<\/strong>\u00a0(n): a software engineer who uses AI tools to create software by focusing on design, architecture, testing, and features.<\/p>\n<p>Now I&rsquo;m curious to know if JGC intends to update his visiting card from &ldquo;Programmer&rdquo; to &ldquo;Maistro&rdquo; anytime soon. ;)<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.terrygodier.com\/the-last-quiet-thing\">The Last Quiet Thing<\/a><\/strong> by Terry Godier<\/li>\n<\/ul>\n<p>Shoving software into devices for the sake of making them &ldquo;smart&rdquo; is absurd.\nThis article is a good reminder to builders to be mindful of feature bloat.<\/p>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/2026-04-05-weekly\/twilight.jpeg\" alt=\"A Walk in the Evening\" title=\"A Walk in the Evening\"><\/p>"},{"title":"Review: 2026 Week #13 (Mar 23 - Mar 29)","link":"https:\/\/kxsh.dev\/posts\/2026-03-29-weekly\/","pubDate":"Sun, 29 Mar 2026 15:32:03 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-03-29-weekly\/","description":"<p>I went to cheer for my friends who ran the Berlin Half Marathon 2026 at my\nusual spot around the 17k mark - a out and back section of the course near the\n<a href=\"https:\/\/maps.app.goo.gl\/xxi37DvtD64VoPmz9\">Cafe Moskau<\/a> near Strausberger Platz.<\/p>\n<p>Cheering people on perservering through the physical pain is a positive sum game.\nIt teaches me to be humble about my limited abilities, grateful for my health,\nand empathetic about people around me. Moreover, it motivates me to push myself\nharder, and to be more disciplined in my training.<\/p>\n<p>Unwrapped a new pair of running shoes, ASICS Novablast 4, and ran a HM.\nThey feel regularly comfortable.<\/p>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/2026-03-29-weekly\/shoes.jpeg\" alt=\"ASICS Novablast 4\" title=\"ASICS Novablast 4\"><\/p>\n<hr>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=y2_BqkKTbD8\">A Trillion Transactions<\/a><\/strong> by TigerBeetle<\/li>\n<\/ul>\n<p>More of a marketing presentation, rather than their usual technical ones.\nBut really interesting to understand their goals and the First Principles approach.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=D98UJl6Ea6o\">The ancient origins of beer - Malcolm Purinton<\/a><\/strong> by TED-Ed<\/li>\n<\/ul>\n<p>Hops were added rather recently in the history of Beer evolution.\nNow, its bitterness is a key characteristic of beer.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=gJHYTlO0VwA\">Backstage: From Spreadsheet to Standard | A CNCF Documentary<\/a><\/strong> by CNCF [Cloud Native Computing Foundation]<\/li>\n<\/ul>\n<p>Pretty unremarkable documentary - that&rsquo;s a compliment.<\/p>"},{"title":"Writing My Resume in Typst","link":"https:\/\/kxsh.dev\/posts\/writing-resume-in-typst\/","pubDate":"Mon, 23 Mar 2026 21:34:37 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/writing-resume-in-typst\/","description":"<p>I ported my Resume from LaTex to <a href=\"https:\/\/typst.app\/\">Typst<\/a>.\nThis post is a review of my experience - motivation, and implementation details.<\/p>\n<h2 id=\"background\">Background<\/h2>\n<p>A decade ago, I was a clueless Uni student. Today, I am just as clueless, but a working professional. Back then, I was introduced to the trade of software development. I was hooked. I wanted to figure out if I can build a career in this field. So I opened the Job portal of every company whose product or people I admire. Every job application required me to upload a PDF document called <strong>CV\/Resume<\/strong>. Naturally, I opened Google Docs and drafted a single pager of my personal projects, exported it as a PDF, and uploaded them with my job applications.<\/p>\n<p>After a week of this, I wondered if I can find a more efficient way to format, and evolve a Resume.\nThus far in my academic journey, I had only used LaTex to write a couple of Term Papers. I valued the benefits of writing the essays in a markup language with beautiful typesetting. During lunch, I shared this with my friends and one of them suggested me to consider writing my Resume in LaTex. Thus, I spent that afternoon rewriting my Resume.<\/p>\n<p>For some obscure reason, I failed to configure Tex on my Linux machine.\nI used a WYSIWYG editor on the web - Overleaf.\nAfter copy-pasting enough LaTex markup for few hours, I compiled and exported an acceptable PDF document that passed for a Resume.<\/p>\n<p>This has been my setup for about 10 years now.\nApart from occasional touchups, I never really tweaked much.\nAlso, I never put effort into learning the arcane Tex markup.<\/p>\n<p>While watching the <a href=\"https:\/\/www.youtube.com\/watch?v=9n2s8l7mXjE\">Typst Meetup 2026: Keynote<\/a>, I resonated with the founder&rsquo;s vision of creating a modern typesetting system with focus on developer ergonomics. Thus, I was curious enough to rewrite my Resume in Typst.<\/p>\n<h3 id=\"pipeline\">Pipeline<\/h3>\n<ul>\n<li>Write the <a href=\"https:\/\/github.com\/kshitij10496\/blog\/blob\/476cbcd8f00bd8b61a9ff9b4d21f24b51b4400f8\/resume\/main.typ\">source code of the Resume<\/a> in the Typst markup language.<\/li>\n<li>Find a suitable template from the <a href=\"https:\/\/typst.app\/universe\/\">Typst Universe<\/a>.<\/li>\n<li>Check in the file along with this blog&rsquo;s source code.<\/li>\n<li>Compile the Resume to a PDF during <a href=\"https:\/\/github.com\/kshitij10496\/blog\/blob\/476cbcd8f00bd8b61a9ff9b4d21f24b51b4400f8\/build.sh#L41-L47\">the CI step<\/a> (less than 50KB).<\/li>\n<li>Serve it as a static asset on the blog.<\/li>\n<\/ul>\n<h3 id=\"experience\">Experience<\/h3>\n<p>The best feature of Typst is the <strong>tooling<\/strong>.\nThe LSP support is fantastic, and Neovim integration is seamless.\nI have set it up with LivePreview with a web browser, and it is a joy to use.\nThese improves my <strong>developer experience<\/strong> because of fast feedback loop and great integration with my editors and tools.<\/p>\n<video controls width=\"100%\">\n <source src=\"screen-recording.mp4\" type=\"video\/mp4\">\n<\/video>\n\n<h2 id=\"references\">References<\/h2>\n<ul>\n<li><a href=\"https:\/\/youtu.be\/8c5Rrfabr9w?si=JQOa6FGN3NICbUWL\">Donald Knuth: TeX and the Beauty of Typography | Lex Fridman (YouTube)<\/a><\/li>\n<li><a href=\"https:\/\/zerodha.tech\/blog\/1-5-million-pdfs-in-25-minutes\/\">1.5+ million PDFs in 25 minutes | Zerodha Tech Blog<\/a><\/li>\n<\/ul>"},{"title":"Review: 2026 Week #12 (Mar 16 - Mar 22)","link":"https:\/\/kxsh.dev\/posts\/2026-03-22-weekly\/","pubDate":"Sun, 22 Mar 2026 18:20:35 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-03-22-weekly\/","description":"<p>Sun is about to rise soon after I wake up.\nWhile I sit in my balcony sipping coffee, I feel the cool Spring breeze.\nEither I go for a run or hit the gym, before the day starts.\nThanks to this, I have increased my mileage as I look to build a strong aerobic\nbase for the upcoming season.<\/p>\n<p>Beside my gradually increasing anxiety about my role in the GenAI era, I am\ntrying to stay positive and focus on the things I can control - my learning and\ngrowth.<\/p>\n<p>Here are some of the highlights from this week:<\/p>\n<ul>\n<li>\n<p><strong><a href=\"https:\/\/www.youtube.com\/watch?v=fJlW6HVfKFU\">Trash Talk - Understanding Memory Management by Shelley Vohr<\/a><\/strong> by Wey Wey Web\nGood resource to build a mental model of how the Mark-and-Sweep GC works in V8 engine.<\/p>\n<\/li>\n<li>\n<p><strong><a href=\"https:\/\/world.hey.com\/jason\/the-bespoke-software-revolution-i-m-not-buying-it-4bfad9ec\">The bespoke software revolution? I&rsquo;m not buying it.<\/a><\/strong> by Jason Fried\nI have always found Jason&rsquo;s take align with my value system. And this was no\nsurprise. Just because the upfront resources needed to write\/generate software\nare lower than ever does not mean the overall cost of a project is significantly\nlowered. The unquantifiable measures still need to be addressed - quality,\nownership, maintenance.<\/p>\n<\/li>\n<li>\n<p><strong><a href=\"https:\/\/ploum.net\/2026-03-20-social-smolnet.html\">The Social Smolnet<\/a><\/strong> by\nI have not yet tried the Gemini protocol. But this idea is extremely cool.\nI have replaced social media with emails to connect (or stay in touch) with people.<\/p>\n<\/li>\n<\/ul>"},{"title":"Review: 2026 Week #11 (Mar 09 - Mar 15)","link":"https:\/\/kxsh.dev\/posts\/2026-03-15-weekly\/","pubDate":"Sun, 15 Mar 2026 11:15:34 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-03-15-weekly\/","description":"<blockquote>\n<p>The world breaks everyone and afterward many are strong at the broken places. But those that will not break it kills.<\/p>\n<\/blockquote>\n<p>I came across this quote from Hemingway&rsquo;s &ldquo;A Farewell to Arms&rdquo; while I was\nreviewing my notes.<\/p>\n<hr>\n<h3 id=\"project-typst\">Project: Typst<\/h3>\n<p><a href=\"https:\/\/typst.app\/\">Typst<\/a> is another markup language for typesetting documents<\/p>\n<ul>\n<li>a competitior to Latex. It&rsquo;s primary selling point is speed.\n<a href=\"https:\/\/zerodha.tech\/blog\/1-5-million-pdfs-in-25-minutes\/\">Zerodha Engineering<\/a>\nwrote an article about using Typst at their scale for generating dynamic\nfinancial documents at scale.<\/li>\n<\/ul>\n<p>Out of curiosity, I ported my Resume in Typst from LaTex with <a href=\"https:\/\/github.com\/stuxf\/basic-typst-resume-template\">basic-typst-resume-template<\/a>.\nI really enjoyed the live preview setup on my Neovim + Librewolf.\nHowever, my primary motivation is to build a pipeline to publish updates to\nthis site. Currently, I use Google Drive as my file storage. I particularly\nlike the document versioning and public file sharing\nvia a static URL. At this moment, I need to find another approach to host my\nResume which works with GitHub Actions.<\/p>\n<p>A project spilling over to the upcoming week.<\/p>\n<hr>\n<h3 id=\"project-crafting-interpreters\">Project: Crafting Interpreters<\/h3>\n<p>&ldquo;The Interpreter Book&rdquo; left a sour taste as I could not extract enough value\nfrom my time\/energy investment.\nGiven I am doubling down on upskilling my software\/CompSci chops in the face of GenAI,\nI chose the next logical step - reading the Crafting Interpreters book.<\/p>\n<p>My plan is to learn at a pace I enjoy without any deadlines.\nIf it takes a lifetime or I drop it in my middle - that&rsquo;s fine by me.\nThe goal here is to enjoy the learning process - absorb concepts, apply these\nconcepts to toy projects, and add new tools to my box.<\/p>\n<p>Go and Rust are the implementation languages of choice.<\/p>\n<hr>\n<h3 id=\"running\">Running<\/h3>\n<p>Broke into a new pair of shoes - ASICS Novablast 5 Tokyo.\nI enjoyed the snappy feedback from the new FFBlastMax foam.\nEven though they are not light, I will adding them to my rotation for speed sessions.<\/p>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/2026-03-15-weekly\/shoes.jpeg\" alt=\"ASICS Novablast 5 Tokyo\" title=\"ASICS Novablast 5 Tokyo - Mint Condition\"><\/p>\n<hr>\n<h3 id=\"reading-algorithms-to-live-by\">Reading: Algorithms to Live By<\/h3>\n<p>The next pick from my shelf is Brian Christian&rsquo;s Algorithms to Live By.\nI enjoyed reading this book back in my Uni days.\nIt&rsquo;s probably good to reread it after about a decade - to gauge what still holds\ntrue.<\/p>\n<p>Between commutes to the gym and office, I read the following chapters:<\/p>\n<ul>\n<li>Explore\/Exploit: Multi-armed bandits<\/li>\n<li>Scheduling: Premption<\/li>\n<li>Networking: AIMD in TCP. Tail Drop<\/li>\n<\/ul>\n<p>I will break them down in detail in a book review post later.<\/p>\n<hr>\n<p>Listening to GNX by Kendrick Lamar on the runs this week.<\/p>"},{"title":"Review: 2026 Week #10 (Mar 02 - Mar 08)","link":"https:\/\/kxsh.dev\/posts\/2026-03-08-weekly\/","pubDate":"Sun, 08 Mar 2026 19:13:29 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-03-08-weekly\/","description":"<p>Things started to look a bit better this past week.<\/p>\n<p>I have restarted training at the gym.\nMore importantly, the inclement weather allowed me to run outdoors after work.<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/www.youtube.com\/watch?v=fsLh-NYhOoU\">The most beautiful formula not enough people understand<\/a><\/strong> by 3Blue1Brown<\/li>\n<\/ul>\n<p>High dimensional geometry is as real and useful as 3 dimensional geometry.<\/p>\n<p>High dimensional geometry risks being counterintuitive.<\/p>\n<pre><code>- Beautiful illustration on how to think about higher dimension cubes.\n- Higher dimensional spheres are not &quot;spiky&quot; but the cubes are.\n<\/code><\/pre>\n<p>In high dimensions, essentially all mass is at the surface.<\/p>"},{"title":"Review: 2026 Week #09 (Feb 23 - Mar 01)","link":"https:\/\/kxsh.dev\/posts\/2026-03-01-weekly\/","pubDate":"Sun, 01 Mar 2026 18:14:18 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-03-01-weekly\/","description":"<p>I have been sick for the majority of the last 2 weeks - a virus going around.\nI took a few days off work to recover as I found it difficult to concentrate.\nA couple of days without digital media was refreshing.<\/p>\n<p>The downtime allowed me to read, and collect some of my thoughts on my role.\nAs usual with any personal reflection, I ended up with more questions than answers.<\/p>\n<p>It boils down to this internal conflict between deliberately developing my craft\n(which might die soon) and the utilitarian output I generate.\nWhile it&rsquo;s easier to generate value with code, software engineering is not as fun anymore.\nWith LLM based coding agents, I wonder what is the difference between me and a monkey\nat the typewriter. Sure I hear arguments about the &ldquo;bigger picture&rdquo;, &ldquo;system architecture&rdquo;, etc.\nBut it&rsquo;s undeniable coding agents are significantly capable to one-shot a lot of\nthe problems with high accuracy. In the entire process, I find it difficult to\ncontribute productively. My role is closer to an auditor rather than creator.\nAside from keeping my sharpness, there is no need to think deeply about solving\nproblems with code. Rebels refuse to adopt; proponents shove it down everybody&rsquo;s\nthroat. Still I lay here clueless about what is a worthwhile activity for me.\nWriting AGENTS.md, optimizing prompt and &ldquo;engineering&rdquo; context are more mystical\narts than hard skills.<\/p>"},{"title":"Review: 2026 Week #07 (Feb 09 - Feb 15)","link":"https:\/\/kxsh.dev\/posts\/2026-02-15-weekly\/","pubDate":"Sun, 15 Feb 2026 10:56:11 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-02-15-weekly\/","description":"<p>The clouds cleared out this morning. Just enough to let the Sun shine through.\nThe clear blue sky bring a sense of lightness<\/p>\n<p>Most of my time and energy was spent learning about the domain at work.\nI will be working mostly on the Debit Card product at TradeRepublic.<\/p>\n<p>Yesterday afternoon I completed a few tutorials on the Spring framework with Kotlin.\nI need to get familiar with the JVM for work.<\/p>\n<p>LLMs have been extemely helpful in this endeavour.\nEspecially teaching me the ropes of the new engineering ecosystem at work.<\/p>\n<p>The novelty of it all is a bit overwhelming for me.<\/p>\n<p>I did not really enjoy <a href=\"https:\/\/en.wikipedia.org\/wiki\/Marty_Supreme?useskin=vector\">Marty Supreme<\/a>.\nThe story was too forced and almost choatic.<\/p>\n<p><a href=\"https:\/\/youtu.be\/iT_1Gj5VPP0?si=UwWfWzJ0Z_FCZplT\">A Brief History of Japanese Art<\/a> was more enjoyable.\nI learnt the Maestro Hokusai used multiple pseudonyms during his career.\nHe is entombed as &ldquo;Old Man Mad About Painting&rdquo; - if I ever visit Japan, this will be on the top of my list.<\/p>"},{"title":"Review: 2026 Week #06 (Feb 02 - Feb 08)","link":"https:\/\/kxsh.dev\/posts\/2026-02-08-weekly\/","pubDate":"Sun, 08 Feb 2026 22:08:11 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-02-08-weekly\/","description":"<p>First week at the new job was equal parts exciting and draining.\nI commuted to work every day - about 45 mins one way.\nI have a lot to learn about the domain as well as the tech used at the org.<\/p>\n<p>Beside work, I did not have much time to get up to speed with the outside world.\nI started re-reading <a href=\"https:\/\/en.wikipedia.org\/wiki\/Nonviolent_Communication?useskin=vector\">Nonviolent Communication<\/a>.\nHope it comes in handy when collaborating with my new colleagues.<\/p>"},{"title":"Review: 2026 Week #05 (Jan 26 - Feb 01)","link":"https:\/\/kxsh.dev\/posts\/2026-02-01-weekly\/","pubDate":"Sun, 01 Feb 2026 21:11:21 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-02-01-weekly\/","description":"<p>On Thursday morning, I made it back to Berlin from India. My connecting flight\nfrom Munich was delayed by a couple of hours due to the snow. My body will need\na bit of time to acclimitize to the cold weather. The streets are particularly\nslippery, and I have seen a few people sliding and tripping up.\nUnfortunately, the heating in my apartment is barely working. It&rsquo;s just enough\nto heat the floor, but not comfortable enough for me to stay indoors. So I had\nto order a space heater for my room.<\/p>\n<p>Surprisingly, I wake up around 0500. Not that I am complaining, it&rsquo;s most likely\ndue to the jet lag. I spent the afternoons cleaning the apartment, and stocking\nup the pantry.<\/p>\n<p>I participated in a small hackathon organized by Zed and TRMNL on Thursday evening.\nI&rsquo;ll write and share an experience report about the event next week.<\/p>"},{"title":"Review: 2026 Week #04 (Jan 19 - Jan 25)","link":"https:\/\/kxsh.dev\/posts\/2026-01-25-weekly\/","pubDate":"Sun, 25 Jan 2026 15:33:39 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-01-25-weekly\/","description":"<p>AFK this week as I travel a bit with my family.<\/p>"},{"title":"Review: 2026 Week #03 (Jan 12 - Jan 18)","link":"https:\/\/kxsh.dev\/posts\/2026-01-18-weekly\/","pubDate":"Sun, 18 Jan 2026 18:01:05 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-01-18-weekly\/","description":"<p>I have put on sufficient weight to my mom&rsquo;s approval.\nWe celebrated Makar Sankranti by flying kites together with the family.\nMy nephews have picked up this niche hobby quite well.\nThey start scanning the afternoon skies to catch any drifting kites.\nWatching them upskill on kite flying encourages me to persevere in the challenges I face.<\/p>\n<p>I use the Anthropic API key in Opencode CLI as part of my personal agentic development setup.\nMy LLM usage crossed 20 euros worth of credits over the last month.\nThus I subscribed to the Claude Pro plan on Thursday.<\/p>\n<p>Here are a round of articles that I enjoyed this week:<\/p>\n<ul>\n<li>\n<p>Joan Westenberg makes <a href=\"https:\/\/www.joanwestenberg.com\/the-case-for-blogging-in-the-ruins\/\">The Case for Blogging in the Ruins<\/a>. In the nascent phase of the internet, personal blogs were the medium\nto share ideas and seek like minded people across the world. The technical work\nneeded to build and maintain personal websites provided a barrier to entry.\nSocial media platforms (Twitter, Facebook) &ldquo;democratized&rdquo; the ability to publish on the web.\nIn doing so, we removed the deliberate effort to build a network in favor of an algorithmic feed.\nWe have reached a point where separating signal from noise is downright impossible.\nPerhaps, the ease with which we pick up our phone and send off a tweet has destroyed the conditions that made publishing meaningful?\nPerhaps, we might be better served if revisit the medium of publishing.<\/p>\n<\/li>\n<li>\n<p>For many years, neofetch is a mainstay of my shell startup config. So I had to read\n<a href=\"https:\/\/dylan.gr\/1768295794\">a new write-up<\/a> from it&rsquo;s creator, Dylan Arpes, on becoming a full time farmer.<\/p>\n<\/li>\n<li>\n<p>An <a href=\"https:\/\/evanhahn.com\/i-set-all-376-vim-options-and-im-still-a-fool\/\">excellent post<\/a> by Evan Hahn\nabout the elusive seduction of mastering vim for efficient text editing.\nThere are no shortcuts to become a Vim poweruser. But the journey might be worthwhile.<\/p>\n<\/li>\n<\/ul>"},{"title":"Review: 2026 Week #02 (Jan 5 - Jan 11)","link":"https:\/\/kxsh.dev\/posts\/2026-01-11-weekly\/","pubDate":"Sun, 11 Jan 2026 19:13:01 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-01-11-weekly\/","description":"<p>Another relaxing week at home.\nDespite the uncharacteristic chilly weather, I cannot complain about the regular\nwarm sunshine.<\/p>\n<p>After years of using the Moka Venus, I tried the traditional aluminium based Bialetti Moka on Monday.\nBrewing a cup of decent coffee on raw flame is still a work-in-progress.<\/p>\n<p>Few articles that I enjoyed reading:<\/p>\n<ul>\n<li><a href=\"https:\/\/boz.com\/articles\/think-pavlov\">Think of Pavlov<\/a> by Andrew Bosworth<\/li>\n<\/ul>\n<p>Do the same principle of priming Pavlov&rsquo;s dog to the ringing of a bell also apply to our interactions with others?<\/p>\n<p>The author claims that we constantly train the people around us through the way we carry ourselves.<\/p>\n<p>I do not necessarily disagree with this perspective yet.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.pcloadletter.dev\/blog\/craftsmanship-is-dead\/\">Software Craftsmanship is dead<\/a> by pcloadletter<\/li>\n<\/ul>\n<p>LLM generated code makes the consideration of the tradeoff between\nvelocity of software delivery against the quality of work more crucial.<\/p>\n<p>I&rsquo;m doubling down on improving the quality of my output this year.<\/p>"},{"title":"Review: 2026 Week #01 (Dec 28 - Jan 4)","link":"https:\/\/kxsh.dev\/posts\/2026-01-04-weekly\/","pubDate":"Sun, 04 Jan 2026 15:57:58 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2026-01-04-weekly\/","description":"<p>I travelled to India this week; mostly to spend time with my family, partly to\nescape a bit of the harsh Berlin winters. As I am not carrying my laptop with me,\nI spent most of the spare time reading Homer&rsquo;s Odysseus translated to English by\nEmily Wilson.<\/p>\n<p>At home, I set up a new user account on my parent&rsquo;s Mac Air for my dev env.\nThese days I squeeze only about 1hr on this machine.<\/p>\n<p>These are few noteworthy things I stumbled on this past week:<\/p>\n<ul>\n<li><a href=\"https:\/\/live.deutsche-boerse.com\/nachrichten\/etfs-2025-wieder-ein-jahr-der-superlative\">ETFs 2025: Wieder ein Jahr der Superlative<\/a> by Deutsche Borse<\/li>\n<\/ul>\n<p>In Germany, private investors are driving the growth of the ETF segment with\n28% YoY increase in capital flow.<\/p>\n<ul>\n<li><a href=\"https:\/\/paulcalvano.com\/2024-03-19-choosing-between-gzip-brotli-and-zstandard-compression\/\">Choosing Between gzip, Brotli and zStandard Compression<\/a> by Paul Calvano<\/li>\n<\/ul>\n<p>HTTP compression is a mechanism that allows a web server to deliver text based\ncontent using less bytes. HTTP clients send the <code>Accept-Encoding<\/code> request header\nwith a list of supported compressions. HTTP servers process the incoming request\nand choose a compression technique considering client request. The <code>Content-Type<\/code>\nheader in the response specifies the technique used to compress the data.<\/p>\n<p><code>gzip<\/code> is widely adopted across the web stack.\nBrotli compression is more space efficient at the cost of compute overhead.\nzStandard, developed by Facebook, is also worth a consideration.<\/p>\n<p>In addition to choosing a compression, we also need to consider the compression\nlevel. These levels allow us to configure the tradeoff between the output data\nsize and the cost of compute needed for the compress-decompress cycle. Both of\nthese factors contribute to the latency or TTFB experienced by the end user.<\/p>\n<ul>\n<li><a href=\"https:\/\/youtu.be\/7bTlKxH3CgI?si=a9lcFbZqnumGAxih\">\nMax Richter live at Cercle Odyssey, Paris, France<\/a><\/li>\n<\/ul>\n<p>1 hr blend of classical music with techno; perfect for a pomodoro focus session.<\/p>"},{"title":"Vim User Manual 12: Clever tricks","link":"https:\/\/kxsh.dev\/posts\/2025-12-21-vim-user-manual-12\/","pubDate":"Sun, 21 Dec 2025 11:04:16 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-21-vim-user-manual-12\/","description":"<p>This chapter introduces few recipes for common editing tasks:<\/p>\n<h2 id=\"replace-a-word\">Replace a word<\/h2>\n<p>We can use the &ldquo;substitute&rdquo; command to replace all occurrences of a word with\nanother.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Replace all occurrences of a word with another.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>:%s\/from\/to\/g\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Replaces all occurrences that start with a word.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>:%s\/<span style=\"color:#1e66f5\">\\&lt;<\/span>from\/to\/g\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Replaces all occurences that end with a word.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>:%s\/from<span style=\"color:#1e66f5\">\\&gt;<\/span>\/to\/g\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Replaces all occcurrences of exact words.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>:%s\/<span style=\"color:#1e66f5\">\\&lt;<\/span>from<span style=\"color:#1e66f5\">\\&gt;<\/span>\/to\/g\n<\/span><\/span><\/code><\/pre><\/div><p>Combine the above substitute commands with a macro to replace a word in more\nthan one file.<\/p>\n<h2 id=\"count-words\">Count words<\/h2>\n<p>Use <code>g CTRL-G<\/code> to count the words in the whole file.<\/p>\n<p>We can also run this command in Visual Mode after selecting the text block.<\/p>\n<h2 id=\"find-a-man-page\">Find a man page<\/h2>\n<p>Use <code>K<\/code> to go to the man page of the word under cursor, if any exists.<\/p>\n<p>We can also use the <code>:Man<\/code> command to fetch specific man pages.<\/p>\n<h2 id=\"trim-blanks\">Trim blanks<\/h2>\n<p>Remove whitespace at the end of every line: <code>:%s\/\\s\\+$\/\/<\/code><\/p>\n<h2 id=\"find-where-a-word-is-used\">Find where a word is used<\/h2>\n<p>Vim provides a built-in command that we can use to search a set of files for a\ngiven string.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>:grep &lt;search&gt; &lt;files&gt;\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Search for &#34;err&#34; in Go files.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>:grep err *.go\n<\/span><\/span><\/code><\/pre><\/div><p>Navigate between the matches with <code>:cnext<\/code>, and <code>:cprev<\/code>.<\/p>"},{"title":"Topics in Mathematics with Applications in Finance","link":"https:\/\/kxsh.dev\/posts\/2025-12-20-fin-math\/","pubDate":"Sat, 20 Dec 2025 19:31:02 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-20-fin-math\/","description":"<p>Chapter 2 through Chapter 6 introduce us to mathematical concepts that are of\npractical use in finance. Some of the topics discusses were:<\/p>\n<ul>\n<li>Linear Algebra<\/li>\n<li>Probability<\/li>\n<li>Stochastic Processes<\/li>\n<\/ul>\n<p>I snooze through them because:<\/p>\n<ol>\n<li>My focus is to learn simple practically useful finance topics.<\/li>\n<li>I&rsquo;m already familiar with these areas of university - thanks to my uni\neducation.<\/li>\n<li>The presentation is extremely dry and mechanical as opposed to being intuitive.<\/li>\n<\/ol>\n<p>I would rather refresh my memory about these mathematical areas once I need\nthem to solve a problem or model something.<\/p>"},{"title":"Vim User Manual 11: Recovering from a Crash","link":"https:\/\/kxsh.dev\/posts\/2025-12-19-vim-user-manual-11\/","pubDate":"Fri, 19 Dec 2025 18:40:11 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-19-vim-user-manual-11\/","description":"<p>Vim provides resiliency against system crashes (either Vim crashes or the OS)\nthrough redundancy. This is achieved through the mechanism of &ldquo;swap files&rdquo;.<\/p>"},{"title":"Vim User Manual 10: Making big changes","link":"https:\/\/kxsh.dev\/posts\/2025-12-18-vim-user-manual-10\/","pubDate":"Thu, 18 Dec 2025 11:30:44 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-18-vim-user-manual-10\/","description":"<p>This chapter focuses on making either repeated changes or changes that affect\na large amount of text. In a sense, this chapter compliments <a href=\"https:\/\/kxsh.dev\/posts\/2025-12-11-vim-user-manual-04\/\">Chapter 4<\/a>.<\/p>\n<h2 id=\"macros\">Macros<\/h2>\n<ul>\n<li>Use <code>.<\/code> command to repeat just the preceding change.<\/li>\n<li>Use a macro to record and playback a sequence of commands.<\/li>\n<\/ul>\n<p>We need a <em>register<\/em> to record our macros. Here is how we do it:<\/p>\n<ol>\n<li>The &ldquo;q{register}&rdquo; command starts recording keystrokes into the register\nnamed {register}. The register name must be between a and z.<\/li>\n<li>Type your commands.<\/li>\n<li>To finish recording, press q (without any extra character).<\/li>\n<\/ol>\n<p>Execute the macro by typing the command &ldquo;@{register}&rdquo;.<\/p>\n<p>Interestingly enouhg, these registers are the same ones we use for yank and\ndelete commands. This allows us to mix recording the macros with other commands.<\/p>\n<p>We can also append to existing registers using the corresponding uppercase letter.\nFor example, we can edit existing yanked lines.<\/p>\n<p>Recipe:<\/p>\n<ul>\n<li><code>&quot;ayy<\/code> yanks the current line.<\/li>\n<li><code>&quot;Ayy<\/code> yanks the new line (after we move to it).<\/li>\n<\/ul>\n<h2 id=\"substitution\">Substitution<\/h2>\n<p>The **substitute command enables you to perform string replacements on a whole\nrange of lines.<\/p>\n<p>Command: <code>:[range]s\/from\/to\/[flags]<\/code><\/p>\n<p>This command changes only the first occurrence of &ldquo;from&rdquo; string to the &ldquo;to&rdquo; string\nin each line specified with [range].<\/p>\n<p>The &ldquo;from&rdquo; part of the substitute command is actually a pattern, similar to the\n<code>search<\/code> command.<\/p>\n<p>Flags allow us to tweak the behavior of the above command:<\/p>\n<ul>\n<li>Use the <code>g<\/code> flag to change every occurrence on the line.<\/li>\n<li>Use the <code>c<\/code> flag to confirm before Vim performs each substitution.<\/li>\n<\/ul>\n<p>The range is essentially a selection of lines that we want to execute the <code>substitute<\/code>\ncommand on. Here are few common ranges:<\/p>\n<ul>\n<li>Use <code>%<\/code> for the entire current buffer.<\/li>\n<li>Use <code>.<\/code> to only execute on the current line.<\/li>\n<li>Use <code>{start},{end}<\/code> to provide starting and ending line numbers. We can also use <em>marks<\/em> here.<\/li>\n<li>Use Visual mode to select lines of text and enter Command Mode.<\/li>\n<\/ul>\n<h2 id=\"global\">Global<\/h2>\n<p>The &ldquo;global&rdquo; command allows use to find a match for a pattern and execute a\ncommand there.<\/p>\n<p>Command: <code>:[range]global\/{pattern}\/{command}<\/code><\/p>\n<p>The mechanics are similar to the &ldquo;substitute&rdquo; command, except Vim executes a\ncommand instead of replacing text.<\/p>\n<p>We can combine the &ldquo;global&rdquo; together with the &ldquo;substitute&rdquo; command.<\/p>\n<h2 id=\"visual-block-mode\">Visual Block Mode<\/h2>\n<p>Vim provides a bunch of mechanisms to edit effectively with the Visual Block\nMode.<\/p>\n<p>Use the <code>I{string}&lt;Esc&gt;<\/code> inserts the text <code>{string}<\/code> in each line to the left of the visual block.\nUse the <code>A<\/code> command instead of <code>I<\/code> if we want to append after the right side of the block.\nUse the <code>$A<\/code> command to append text at the end of each line selected in the block.\nUse the <code>c<\/code> command to delete the block and puts us into Insert mode.\nUse the <code>C<\/code> command to delete text from the left edge of the block to the end of the line.\nUse the <code>~<\/code> command to swap case of the characters in the block.\nUse the <code>U<\/code> command to make the characters in the block uppercase.\nUse the <code>u<\/code> command to make the characters in the block lowercase.\nUse the <code>r<\/code> command to fill the whole block with one character.\nUse the <code>&gt;<\/code> command to shift the selected text to the right one shift amount\ninserting whitespace.\nUse the <code>&lt;<\/code> command to shift the selected text to the left one shift amount\ninserting whitespace.\nUse the <code>J<\/code> command to join the selected lines together into one line.<\/p>\n<h2 id=\"formatting-text\">Formatting Text<\/h2>\n<p>Use the <code>textwidth<\/code> option to automatically trim each line to fit in the\nwindow.<\/p>\n<p>NOTE: A <em>paragraph<\/em> is separated from the next paragraph by an empty line.<\/p>\n<p>Use <code>gq<\/code> operator to format the text.<\/p>\n<h2 id=\"changing-case\">Changing case<\/h2>\n<p>Use <code>gU<\/code> operator to change the case to uppercase.\nUse <code>gu<\/code> operator to change the case to lowercase.\nUse <code>g~<\/code> operator to swap cases.<\/p>\n<p>Use <code>!{motion}{program}<\/code> command tp take a block of text and filters it\nthrough an external program. In other words, it runs the system command\nrepresented by {program}, giving it the block of text represented by {motion}\nas input. The output of this command then replaces the selected block.<\/p>"},{"title":"Writing an Intepreter: Evalutation","link":"https:\/\/kxsh.dev\/posts\/2025-12-17-interpreter\/","pubDate":"Wed, 17 Dec 2025 14:40:46 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-17-interpreter\/","description":"<blockquote>\n<p>The evaluation process of an interpreter defines how the programming language\nbeing interpreted works.<\/p>\n<\/blockquote>\n<p>Evaluation is the step which makes our AST meaningful.\nWe encode the language specification in the interpreter.\nThus, each intepreter has some room for &ldquo;interpretation&rdquo; to choose compute stategies.\nEx: CPython is an interpreter of the Python programming language (or &ldquo;guest\nlanguage&rdquo;) written in the C programming language (or &ldquo;host language&rdquo;).<\/p>\n<p>NOTE: Evaluation is also where interpreter implementations diverge the most.<\/p>\n<p>The line between compilers and interpreters is a blurry one.\nClassical &ldquo;tree-walking&rdquo; interpreters just &ldquo;walk&rdquo; the AST and execute the tree\nnode instructions. However, we can also target a VM with JIT interpreter that\nconverts AST to bytecode. Such bytecode is neither machine native code nor\nassembly. Thus, our OS can not execute this artifact on the machine CPU. We need\na <em>Virtual Machine<\/em>.<\/p>\n<p>A popular variation of this idea in practice is the <strong>Just-in-Time (JIT)<\/strong>\nexecution. Instead of the AST, our parser generates &ldquo;bytecode&rdquo; for the VM.\nThe VM compiles the bytecode to machine native code right before its executed.\nEx: CPython now supports JIT compilation.<\/p>\n<p>In this chapter, we will work on a classical &ldquo;Tree-Walking&rdquo; interpreter.<\/p>\n<h2 id=\"implementation\">Implementation<\/h2>\n<p>We need a system that can represent the values our AST represents or the values\nthat we generate when evaluating the AST in memory.<\/p>\n<p>We use <em>environment<\/em> to keep track of values by associating them with a name.\nIt&rsquo;s typically implemented as a hashmap that associates strings with the\nevaluated node values.<\/p>\n<p>I implemented the code as instructed but I did not grasp it at all.\nI found it difficult to absorb the ideas presented here.<\/p>"},{"title":"Vim User Manual 09: Using the GUI","link":"https:\/\/kxsh.dev\/posts\/2025-12-17-vim-user-manual-09\/","pubDate":"Wed, 17 Dec 2025 10:10:28 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-17-vim-user-manual-09\/","description":"<p>Our terminal emulator is the default client when we run Vim.\nHowever, we can also choose to different GUI clients together with Vim.\nNeovide<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup> is one such graphical Neovim client written in Rust.\nI have not tried it but I&rsquo;m curious to know when it might be a handy tool.<\/p>\n<p>We can configure our GUI client with a set of Vim options like <code>guioptions<\/code>.\nThe MS-Window and X-Window systems use different &ldquo;standards&rdquo; for selecting text\nwith mouse. Thus, we might have to customize the relevant GUI options based on\nour OS (at least our windowing system).<\/p>\n<p>A <strong>clipboard<\/strong> can be thought of as a place to exchange text between programs.\nCuriously enough, X-Windows has two &ldquo;clipboards&rdquo;:<\/p>\n<ul>\n<li><em>Current selection<\/em>: It is the text that is currently highlighted (say with Visual mode).<\/li>\n<li><em>Real clipboard<\/em>: Not clear what this is.<\/li>\n<\/ul>\n<p>Vim ships with the following predefined clipboard registers.<\/p>\n<ul>\n<li><code>&quot;*<\/code>: Register for the current selection.<\/li>\n<li><code>&quot;+<\/code>: Register for the real clipboard.<\/li>\n<\/ul>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/neovide.dev\/\">https:\/\/neovide.dev\/<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Are we stuck with the same Desktop UX forever?","link":"https:\/\/kxsh.dev\/notes\/2025-12-16-desktop-ux\/","pubDate":"Tue, 16 Dec 2025 20:39:07 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-16-desktop-ux\/","description":"<p>The industry leaders are not leading the way for a better Desktop UX.\nEx: Apple with &ldquo;Liquid Glass&rdquo;.<\/p>\n<p>Chronology: Xerox Star -&gt; Macintosh -&gt; Windows 1.0 -&gt; Ubuntu<\/p>\n<p>Our current desktop environments have evolved through shameless (even proud)\ncopying from existing systems. What if we don&rsquo;t have anything left to &ldquo;copy&rdquo;?<\/p>\n<p>The existing ecosystem is working as a &ldquo;standard&rdquo; instead of experimenting with\nnew design ideas. We don&rsquo;t need another window manager, rather innovative\ndesign ideas.<\/p>\n<p>Good desktop UX enables new ways of moving data around.\nProgrammers and designers need to collaborate in a trusted environment to\ntackle this problem.<\/p>\n<p>Mobile UX is targetting consumers, while Desktop UX should focus on productivity.\nEx: Mobile (initiated by iPhone) prioritized scrolling over tapping - or the\ntap-and-drag event over the humble tap event. Imagine click-and-drag in our\ndesktop browsers is used for scrolling the web page instead of selecting content!\nThis design choice makes mobile phones a consumer device.<\/p>\n<p>Scott&rsquo;s rant about the domain of Design, UX and UI is worth it.\nAnalogy: Programmer:Designer::IT:UX\/UI.\nDesign is more than just visual illustrations.<\/p>"},{"title":"Vim User Manual 08: Splitting windows","link":"https:\/\/kxsh.dev\/posts\/2025-12-16-vim-user-manual-08\/","pubDate":"Tue, 16 Dec 2025 17:52:35 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-16-vim-user-manual-08\/","description":"<p>This chapter introduces the window management capabilities of Neovim.\nWe can concurrently render multiple files (or buffers) in a combination of\nwindows and tabs.<\/p>\n<p>Tabs allow us to declutter the viewport from complicated windows.<\/p>\n<p>I have not used Vim&rsquo;s Diff mode yet, but I definitely think investing time in\nthis will be beneficial to augment the code generated by AI Coding Agents.<\/p>\n<h3 id=\"commands\">Commands<\/h3>\n<ul>\n<li>\n<p>Use <code>:split<\/code> to create the new window above the current one.<\/p>\n<\/li>\n<li>\n<p>Use <code>:vsplit<\/code> to create the new window to the left of the current one.<\/p>\n<\/li>\n<li>\n<p>Use <code>:close<\/code> to close an open window.<\/p>\n<\/li>\n<li>\n<p>Use <code>CTRL-W CTRL-W<\/code> to toggle between the windows.<\/p>\n<\/li>\n<li>\n<p>Use <code>CTRL-W &lt;hjkl&gt;<\/code> to switch windows.<\/p>\n<\/li>\n<li>\n<p>Use <code>CTRL-W &lt;HJKL&gt;<\/code> to move the current window around.<\/p>\n<\/li>\n<li>\n<p>Use <code>gt<\/code> to switch tabs.<\/p>\n<\/li>\n<li>\n<p>Use <code>:tab split<\/code> to create a new tab with one window that is editing the same\nbuffer as the window.<\/p>\n<\/li>\n<\/ul>"},{"title":"Vim User Manual 07: Editing more than one file","link":"https:\/\/kxsh.dev\/posts\/2025-12-15-vim-user-manual-07\/","pubDate":"Mon, 15 Dec 2025 19:19:38 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-15-vim-user-manual-07\/","description":"<p>Vim allows us to edit multiple files in the same editing session.\nIt does so with commands to jump from one file to the other.\nThis is powerful as almost every project (software, knowledge base, manuals)\nis a collection of independent files with links between them.\nPersonally, I almost always prefer a fuzzy-file finder tool like Telescope.\nBut it is good to know the underlying mechanisms.<\/p>\n<p>The predefined file marks are worth memorizing:<\/p>\n<ul>\n<li><kbd>`&#34;<\/kbd>\n : Jump to the position where the cursor was left.<\/li>\n<li><kbd>`.<\/kbd>\n : Jump to the position where the text was changed.<\/li>\n<\/ul>\n<p>When jumping between files, the file we were previously editing is called the\n&ldquo;alternate&rdquo; file.<\/p>\n<ul>\n<li>Use <code>CTRL-^<\/code> to switch between &ldquo;alternate&rdquo; files.<\/li>\n<\/ul>\n<p>File marks with uppercase letters are global - they can be used from any file.\nThis is really handy to create shortcuts specific for a project:<\/p>\n<ul>\n<li><code>M<\/code> for Makefile.<\/li>\n<li><code>D<\/code> for Dockerfile.<\/li>\n<\/ul>\n<p>Strategy: Think of a simple connection between the mark letter and the content.<\/p>\n<p>NOTE: <code>CTRL-O<\/code> and <code>CTRL-I<\/code> can still be used to jump within the same file without\nany explicit marks.<\/p>\n<p>A <strong>Register<\/strong> is a place where Vim stores text.\nThis helps collect text snippets that can be moved around files or store a piece\nof deleted text for reuse.<\/p>\n<ul>\n<li>Use <!-- raw HTML omitted -->&quot;<!-- raw HTML omitted --><!-- raw HTML omitted -->l<!-- raw HTML omitted --> register when working with lines.<\/li>\n<\/ul>\n<p>The <code>:saveas<\/code> command can be handy in situations where I want file duplication.<\/p>"},{"title":"CPU Wars: Intel, Arm, NVIDIA, AMD & the Future","link":"https:\/\/kxsh.dev\/notes\/2025-12-15-cpu-wars\/","pubDate":"Mon, 15 Dec 2025 18:13:07 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-15-cpu-wars\/","description":"<p>A clear and concise walk through the evolution of the Instruction Set Arch (ISA)\nin the CPU marketplace.<\/p>\n<p><strong>Takeaways<\/strong><\/p>\n<ul>\n<li><code>x86<\/code> arch (shared by Intel and AMD) dominates the Desktop and Server CPU marketplace.<\/li>\n<li>ARM arch dominates the Embedded and Mobile CPU Marketplace.<\/li>\n<li>RISC-V is expected to mature and grow in the Embedded and Mobile space.<\/li>\n<li>Processor requirements are evolving with demands for GPUs, TPUs.<\/li>\n<\/ul>\n<p><strong>History<\/strong><\/p>\n<ul>\n<li>1982: Intel and AMD agree to share <code>x86<\/code> arch, thus positioning it an industry standard.<\/li>\n<li>2007: iPhone launches with an ARM processor.<\/li>\n<li>Mobile and embedded devices require a CPU design focused on energy efficiency\nrather than computing performance.<\/li>\n<\/ul>\n<p><strong>Manufacturing<\/strong><\/p>\n<ul>\n<li>Fabless manufacturing allowed for the ubiquity of computing devices all around us today.<\/li>\n<li>TSMC holds around 60% CPU manufacturing market share by revenue.<\/li>\n<li>ARM has licensed its processor architecture and core designs.<\/li>\n<li>Intel and Samsung operate their own fab plants.<\/li>\n<\/ul>\n<p><strong>Trends<\/strong><\/p>\n<ul>\n<li><code>x86<\/code> continues to lose market cap to ARM (and RISC-V).<\/li>\n<li>AMD is eating into the Intel x86 processor market. (AMD valution = ~2x Intel at the moment).<\/li>\n<\/ul>\n<p><strong>Questions<\/strong><\/p>\n<ul>\n<li>\n<p>Is it more prudent for companies to build their own CPUs E2E to build products?\nEx: Apple with ARM-based M series, AWS Graviton.<\/p>\n<\/li>\n<li>\n<p>Aside from being an Open Standard, what are the advantages of RISC-V over ARM\nthat would drive adoption in Embedded and\/or Mobile space?\nThe RISC-V ecosystem is definitely evolving but what is a better mental model to\nbet on one over the other?<\/p>\n<\/li>\n<li>\n<p>What is a small project to try RISC-V ISA - perhaps a microcontroller project?<\/p>\n<\/li>\n<\/ul>"},{"title":"Retrospective: Advent of Code 2025","link":"https:\/\/kxsh.dev\/posts\/2025-12-12-aoc\/","pubDate":"Sat, 13 Dec 2025 12:06:41 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-12-aoc\/","description":"<p>We only had 12 daily challenges this season.<\/p>\n<p>Regardless, I taught myself a bit of Kotlin.\nMy approach was to follow functional design patterns as much as possible.\nBasically, pure functions and immutable data objects.\nI believe I need to solve more problems to get comfortable with Kotlin - perhaps a web service.<\/p>\n<p>My daily schedule involved waking up around 0600 - when the day&rsquo;s puzzle was published.\nI sit at my desk with breakfast, fire up the beautiful AoC website, read the\nchallenge and attempt to solve the first part. After 30 mins or so, I would take\na short break to go brew coffee while thinking more about the problem -\noccasionally the second part. Almost always I had to redesign and refactor my\napproach to solve for the second part. I tried to understand the essence of the\nproblem, but I failed at that more often than not.<\/p>\n<p>In short, I liked the little routine I had built over the past couple of weeks.\nThanks <a href=\"https:\/\/was.tl\/\">Eric<\/a> for organising yet another season of Advent of Code!<\/p>"},{"title":"Vim User Manual 06: Using syntax highlighting","link":"https:\/\/kxsh.dev\/posts\/2025-12-13-vim-user-manual-06\/","pubDate":"Sat, 13 Dec 2025 10:08:07 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-13-vim-user-manual-06\/","description":"<p>Neovim automatically detects the &ldquo;file type&rdquo; of the currently opened file.\nIt then loads the correct syntax highlighting for this file type.\nWe also need to ensure that our terminal emulator of choice supports colors.\nCheck the value of <code>TERM<\/code> env var about this.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># On Ghostty<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>$ <span style=\"color:#04a5e5\">echo<\/span> <span style=\"color:#dc8a78\">$TERM<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>xterm-ghostty\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># On Terminal.app<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>$ <span style=\"color:#04a5e5\">echo<\/span> <span style=\"color:#dc8a78\">$TERM<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>xterm-256color\n<\/span><\/span><\/code><\/pre><\/div><p>We can explicitly specify the syntax we would like Neovim to use with the <code>modeline<\/code>\noption<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>.<\/p>\n<pre tabindex=\"0\"><code># vim: syntax=make\n<\/code><\/pre><h2 id=\"colorschemes\">Colorschemes<\/h2>\n<p>Vim\/Neovim ships with few colorschemes located at <code>$VIMRUNTIME\/colors<\/code>.<\/p>\n<p>Use the <code>colorscheme<\/code> option<sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup> for set your preferred color scheme.<\/p>\n<pre tabindex=\"0\"><code>:colorscheme retrobox\n<\/code><\/pre><p>A lot of the modern day colorschemes actually ship with multiple variants - each\nsuitable for either light or dark mode settings. We can switch between dark and\nlight colorschemes based on the background color with the <code>background<\/code> option<sup id=\"fnref:3\"><a href=\"#fn:3\" class=\"footnote-ref\" role=\"doc-noteref\">3<\/a><\/sup>:<\/p>\n<pre tabindex=\"0\"><code>:set background=dark\n:set background=light\n<\/code><\/pre><div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/neovim.io\/doc\/user\/options.html#modeline\">https:\/\/neovim.io\/doc\/user\/options.html#modeline<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/neovim.io\/doc\/user\/options.html#%27background%27\">https:\/\/neovim.io\/doc\/user\/options.html#'background'<\/a>&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:3\">\n<p><a href=\"https:\/\/neovim.io\/doc\/user\/options.html#%27background%27\">https:\/\/neovim.io\/doc\/user\/options.html#'background'<\/a>&#160;<a href=\"#fnref:3\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Advent of Code: Day 12","link":"https:\/\/kxsh.dev\/notes\/2025-12-12-aoc\/","pubDate":"Fri, 12 Dec 2025 20:38:16 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-12-aoc\/","description":"<p>Wow! I could not even figure out a brute force approach to the problem.\nI am extremely curious about how intuit a solution.\nPlease reach out if you figure something fun.<\/p>"},{"title":"Vim User Manual 05: Set your settings","link":"https:\/\/kxsh.dev\/posts\/2025-12-12-vim-user-manual-05\/","pubDate":"Fri, 12 Dec 2025 11:03:09 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-12-vim-user-manual-05\/","description":"<p>One of Vim&rsquo;s superpower is to customize it to our liking.\nIn order to do so, we need to understand the tools Vim provides us:<\/p>\n<ul>\n<li>Mappings<\/li>\n<li>Packages<\/li>\n<li>Plugins<\/li>\n<li>Options<\/li>\n<\/ul>\n<p>A <em>mapping<\/em> enables us to bind a set of Vim commands to a single key.\nWe can define these keyboard shortcuts as we see fit for our usecase.<\/p>\n<p>A <em>package<\/em> is a set of files that we can add to Vim.\nWe have 2 kinds of packages based on how they are loaded:<\/p>\n<ul>\n<li>Optional: packages that are not always loaded<\/li>\n<li>Auto: packages that are automatically loaded on the editor startup time.<\/li>\n<\/ul>\n<p>A <em>plugin<\/em> is a Vim script that is loaded automatically when Vim starts.\nWe have 2 kinds of plugins based on the files they operate on:<\/p>\n<ul>\n<li>Global: plugins used for all kinds of files. (Tutor)<\/li>\n<li>Filetype: plugins used only for specific files. (Markdown files)<\/li>\n<\/ul>\n<p>The <code>options<\/code> file lists all the configuration options (and instructions to tweak them)\nprovided by Vim.\nFor example, <code>iskeyword<\/code> option specifies which characters can appear in a word.<\/p>"},{"title":"A Code Centric Journey Into the Gleam Language","link":"https:\/\/kxsh.dev\/notes\/2025-12-11-gleam\/","pubDate":"Thu, 11 Dec 2025 19:53:34 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-11-gleam\/","description":"<p>Good pitch about Gleam.<\/p>\n<p>I have not build any web services with Gleam yet but now I&rsquo;m intrigued.\nLustre + Squirrel look like promising tools to experiment with.<\/p>"},{"title":"Advent of Code: Day 11","link":"https:\/\/kxsh.dev\/notes\/2025-12-11-aoc\/","pubDate":"Thu, 11 Dec 2025 19:07:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-11-aoc\/","description":"<p>I could barely solve part 1 today.\nAfter modeling the problem as a graph, I needed to depth-first traversal.<\/p>\n<p>The algorithmic complexity of my solution for Part 2 was exponential.<\/p>"},{"title":"Vim User Manual 04: Making small changes","link":"https:\/\/kxsh.dev\/posts\/2025-12-11-vim-user-manual-04\/","pubDate":"Thu, 11 Dec 2025 14:29:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-11-vim-user-manual-04\/","description":"<p>This chapter presents the mechanisms that enable us to <em>move text around within\nthe same buffer<\/em> and <em>make corrections such as replacements<\/em>.<\/p>\n<p>Vim provides 3 basic ways to change text:<\/p>\n<ul>\n<li>Operator-Motion<\/li>\n<li>Visual Mode<\/li>\n<li>Text Objects<\/li>\n<\/ul>\n<h2 id=\"operator-motion\">Operator-Motion<\/h2>\n<p>It allows us to manipulate text that we can move over.\nOf course, we need to use one of the predefined text manipulation operator:<\/p>\n<ul>\n<li><code>d<\/code>: Deletion<\/li>\n<li><code>c<\/code>: Change<\/li>\n<li><code>y<\/code>: Yank (or Copy)<\/li>\n<\/ul>\n<p>We combine these operators with the motions we learned before in Chapter 3.\nFor example,<\/p>\n<p><code>d4w<\/code>: Deletes four words under the cursor.<\/p>\n<p>This enables extremely powerful combinations as long as we know the command to\nmove our cursor to the desired position using Vim motions.<\/p>\n<h2 id=\"visual-mode\">Visual Mode<\/h2>\n<p>If it is not easy to decide which command will move over the text we want to change,\nwe can use Visual mode.<\/p>\n<p>We can operate on entire lines, semantic block of text or a simple text selection\nin Visual Mode.<\/p>\n<h2 id=\"text-objects\">Text Objects<\/h2>\n<p>Often we want to manipulate entire words, sentences, code blocks.\nVim provides a semantic to capture these concepts with &ldquo;text objects&rdquo;.\nWe can use notions such as &ldquo;Inner Word&rdquo; (<code>iw<\/code>) and &ldquo;A Word&rdquo; (<code>aw<\/code>).<\/p>\n<p>These text objects can be combined with the text manipulation operators and\nvisual mode to power efficient text editing.<\/p>\n<h2 id=\"general\">General<\/h2>\n<p>When we delete text (say with <code>d<\/code> or <code>x<\/code>), the text is saved into a &ldquo;register&rdquo;.\nThis text can be pasted back into the buffer using the &ldquo;Put&rdquo; command.<\/p>\n<h2 id=\"commands\">Commands<\/h2>\n<ul>\n<li>\n<p>Use <code>dd<\/code> to delete the current line under cursor.<\/p>\n<\/li>\n<li>\n<p>Use <code>cc<\/code> to change the current line under cursor.<\/p>\n<\/li>\n<li>\n<p>Use <code>yy<\/code> to yank the current line under cursor.<\/p>\n<\/li>\n<li>\n<p>Use <code>r<\/code> to replace a single character.<\/p>\n<\/li>\n<li>\n<p>Use <code>.<\/code> to repeat the last change - one of the simplest and most powerful commands.<\/p>\n<\/li>\n<li>\n<p>Use <code>o<\/code> to switch ends of a visual selection.<\/p>\n<\/li>\n<li>\n<p>Use <code>~<\/code> to switch the case of the character under the cursor.<\/p>\n<\/li>\n<li>\n<p>Use <code>I<\/code> to start Insert mode at the first non-blank character in the line.<\/p>\n<\/li>\n<li>\n<p>Use <code>A<\/code> to start Insert mode at the end of the line.<\/p>\n<\/li>\n<\/ul>"},{"title":"Size of Life","link":"https:\/\/kxsh.dev\/notes\/2025-12-11-size-of-life\/","pubDate":"Thu, 11 Dec 2025 11:46:37 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-11-size-of-life\/","description":"<p>Beautfiul illustrations to go with the relaxing background score.\nKeyboard accessibility is great too.<\/p>"},{"title":"Advent of Code: Day 10","link":"https:\/\/kxsh.dev\/notes\/2025-12-10-aoc\/","pubDate":"Wed, 10 Dec 2025 21:11:14 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-10-aoc\/","description":"<p>Similar story as yesterday.<\/p>\n<p>I was able to solve the first part eventually through a complicated approach, namely a BFS.\nBut this approach did not work with part 2.<\/p>\n<p>So I make peace with 1 star again.<\/p>"},{"title":"Advent of Code: Day 09","link":"https:\/\/kxsh.dev\/notes\/2025-12-09-aoc\/","pubDate":"Tue, 09 Dec 2025 19:58:37 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-09-aoc\/","description":"<p>Part 1 lends itself nicely to bruteforce solution.<\/p>\n<p>I could not solve Part 2. My approach:<\/p>\n<ul>\n<li>Draw the polygon outline.<\/li>\n<li>Fill the polygon.<\/li>\n<li>Find the biggest rectangle with all the points colored (either red or green).<\/li>\n<\/ul>\n<p>My solution is stuck on filling the polygon on the actual input.\nHopefully, I am able to solve this before the end of the AoC this year on Friday.<\/p>"},{"title":"Vim User Manual 03: Moving around","link":"https:\/\/kxsh.dev\/posts\/2025-12-09-vim-user-manual-03\/","pubDate":"Tue, 09 Dec 2025 11:25:21 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-09-vim-user-manual-03\/","description":"<p>This chapter is about moving the cursor within the current buffer.<\/p>\n<h2 id=\"commands\">Commands<\/h2>\n<h3 id=\"general\">General<\/h3>\n<ul>\n<li>Use <code>CTRL-G<\/code> to find more information about where you are in the file.<\/li>\n<li>Use <code>%<\/code> to move between matching parenthesis (<code>(), {}, []<\/code>)<\/li>\n<\/ul>\n<h3 id=\"general-horizontal-movements\">General Horizontal Movements<\/h3>\n<ul>\n<li>Use <code>w<\/code> to move the cursor forward one <strong>word<\/strong>.<\/li>\n<li>Use <code>b<\/code> to move the cursor backward to the start of the previous <strong>word<\/strong>.<\/li>\n<li>Use <code>e<\/code> to move to the next end of a word.<\/li>\n<li>Use <code>ge<\/code> to move to the previous end of a word.<\/li>\n<li>Use <code>$<\/code> to move the cursor to the end of a line.<\/li>\n<li>Use <code>^<\/code> to move to the first non-blank character of the line.<\/li>\n<li>Use <code>0<\/code> to move to the first character of the line.<\/li>\n<\/ul>\n<p>If we know the character we would like to jump to:<\/p>\n<ul>\n<li>Use <code>fx<\/code> to search forward (or <strong>find<\/strong>) in the line for the single character <code>x<\/code>.<\/li>\n<li>Use <code>Fx<\/code> to search to the left.<\/li>\n<li><code>tx<\/code> (<strong>to<\/strong>) stops one character before the searched character.<\/li>\n<li><code>Tx<\/code> works similarly to the left.<\/li>\n<li>Use <code>;<\/code> to move to the next occurrence of the search character.<\/li>\n<li>Use <code>.<\/code> to move to the previous occurrence of the search character.<\/li>\n<\/ul>\n<h3 id=\"general-vertical-movements\">General Vertical Movements<\/h3>\n<ul>\n<li>Use <code>gg<\/code> to move to the start of the file.<\/li>\n<li>Use <code>G<\/code> to move to the end of the file.<\/li>\n<li>Use <code>xG<\/code> to move the line number <code>x<\/code>.<\/li>\n<\/ul>\n<h3 id=\"scrolling-around\">Scrolling Around<\/h3>\n<ul>\n<li>Use <code>CTRL-U<\/code> to scroll up half a screen of text.<\/li>\n<li>Use <code>CTRL-D<\/code> to scroll down half a screen of text.<\/li>\n<li>Use <code>zz<\/code> to center the current line on the screen.<\/li>\n<\/ul>\n<p>Preference: Set the <code>scrolloff<\/code> to a non-zero value to keep a fixed buffer of\ncontext around the cursor.<\/p>\n<h3 id=\"simple-searches\">Simple Searches<\/h3>\n<ul>\n<li>Use <code>\/string<\/code> to search for a string.<\/li>\n<li>Use <code>?string<\/code> to search backwards for a string.<\/li>\n<li>Use <code>n<\/code> to find the next occurrence of the same string.<\/li>\n<li>Use <code>N<\/code> to find the previous occurrence of the same string.<\/li>\n<\/ul>\n<p>Preference: Enable Smart case search <code>smartcase=true<\/code>.<\/p>\n<p>Vim maintains the search history.\nVim uses Regex to specify what to search for.<\/p>\n<p>Shortcuts:<\/p>\n<ul>\n<li>Use <code>*<\/code> to search for the occurrence of the word currently under cursor.<\/li>\n<li>Use <code>#<\/code> to search backwards.<\/li>\n<\/ul>\n<p><strong>Searching for Whole Words<\/strong><\/p>\n<p>Default search matches for presence of a string or partial matches.<\/p>\n<p>If we want to enforce constraints such as &ldquo;word begins with&rdquo;, &ldquo;word ends with&rdquo;,\nwe need to use <code>\\&lt;<\/code> and <code>\/&gt;<\/code> respectively.<\/p>\n<p>Use <code>\/^string<\/code> and <code>\/string$<\/code> to match for <code>string<\/code> at the beginning and end of a line.<\/p>\n<h3 id=\"using-marks\">Using Marks<\/h3>\n<p>Every time we execute a command that can move the cursor further than within\nthe same line, it is called a <strong>jump<\/strong>.<\/p>\n<ul>\n<li>Use <code>:jumps<\/code> to list positions you have jumped to.<\/li>\n<\/ul>\n<p>Vim remembers the position before the jump. This position is called a <em>Mark<\/em>.\nMarks can be very useful when working on two related parts within the same file.\nVim allows us to place our own marks in the text (max 26).<\/p>\n<ul>\n<li>\n<p>Use <code>:marks<\/code> to list all marks.<\/p>\n<\/li>\n<li>\n<p>Use <code>ma<\/code> to mark the place under cursor as mark <code>a<\/code>.<\/p>\n<\/li>\n<li>\n<p>Use backtick to jump back to marks.<\/p>\n<\/li>\n<li>\n<p>Use <code>CTRL-O<\/code> and <code>CTRL-I<\/code> to jump around marks.<\/p>\n<\/li>\n<\/ul>"},{"title":"Vim User Manual 02: First Steps in Vim","link":"https:\/\/kxsh.dev\/posts\/2025-12-08-vim-user-manual-02\/","pubDate":"Mon, 08 Dec 2025 20:38:35 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-08-vim-user-manual-02\/","description":"<p>Vim is a Modal editor - Normal, Insert, Command, and Visual, that is, the same\neditor behaves differently depending on the mode it is in. I prefer to use the\nNeovim statusline shows the current mode.<\/p>\n<p>In Normal Mode, we type commands.\nIn Insert Mode, we type text.<\/p>\n<p>Vim displays the tilde (<code>~<\/code>) characters to indicate lines not in a file.<\/p>\n<p>Aside: The legendary programming limerick:<\/p>\n<blockquote>\n<p>&ldquo;A very intelligent turtle\nFound programming Unix a hurdle&rdquo;<\/p>\n<\/blockquote>\n<p>We can precede many commands with a number. The count always comes before the\ncommand it applies to.<\/p>\n<p>The manual documents more instructions to query for help more effectively with high specificity.<\/p>\n<p>Aside, I configured the following editor settings:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/kshitij10496\/kickstart.nvim\/blob\/06073539bfc59e48f72d02c97e1a6f130bf4b822\/init.lua#L192-L196\">Disable arrow keys for moving around text<\/a>.<\/li>\n<li><a href=\"https:\/\/github.com\/kshitij10496\/kickstart.nvim\/blob\/06073539bfc59e48f72d02c97e1a6f130bf4b822\/init.lua#L955-L960\">Show percentage of file progress in the statusline<\/a>.<\/li>\n<\/ul>\n<h2 id=\"commands\">Commands<\/h2>\n<ul>\n<li>Use <code>hjkl<\/code> to move around in Normal mode. Use home row as navigating the cursor is the most common operation we perform.<\/li>\n<li>Use <code>x<\/code> to delete a character under cursor.<\/li>\n<li>Use <code>dd<\/code> to delete the whole line under cursor.<\/li>\n<li>Use <code>J<\/code> to join two lines together - this deletes a line break.<\/li>\n<li>Use <code>u<\/code>, <code>CTRL-R<\/code> and <code>U<\/code> for undo and redo recent edits.<\/li>\n<li>Use <code>i<\/code>, <code>a<\/code> to insert text before and after the cursor respectively.<\/li>\n<li>Use <code>o<\/code>, <code>O<\/code> to create a new, empty line and put Vim in Insert mode below and above the cursor respectively.<\/li>\n<li>Use <code>ZZ<\/code> to save the changes and exit.<\/li>\n<li>Use <code>:q!<\/code> to force quit. (<code>!<\/code> is the override command modifier.)<\/li>\n<li>Use <code>:help CTRL-H<\/code> to display help for the <code>CTRL-H<\/code> command in <em>Normal mode<\/em>.<\/li>\n<li>Use <code>:help i_CTRL-H<\/code> to display help for the <code>CTRL-H<\/code> command in <em>Insert mode<\/em>.<\/li>\n<\/ul>"},{"title":"Vim User Manual 01: About the Manuals","link":"https:\/\/kxsh.dev\/posts\/2025-12-08-vim-user-manual-01\/","pubDate":"Mon, 08 Dec 2025 20:38:26 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-12-08-vim-user-manual-01\/","description":"<p>Vim provides 2 docs:<\/p>\n<ul>\n<li>The User Manual<\/li>\n<li>The Reference Manual<\/li>\n<\/ul>\n<p>I will be reading The User Manual (for now).<\/p>\n<p>The first chapter introduces the Vim Tutor, and navigation between documents\nwith hyperlinks. It&rsquo;s still not clear to me what are good usecases for\nbuilding hyperlinks using this approach.<\/p>\n<h2 id=\"commands\">Commands<\/h2>\n<ul>\n<li>Use <code>CTRL-]<\/code> and <code>CTRL-O<\/code> to jump around hyperlinks (aka &ldquo;tags&rdquo;) in a Vim Buffer.<\/li>\n<\/ul>"},{"title":"Advent of Code: Day 08","link":"https:\/\/kxsh.dev\/notes\/2025-12-08-aoc\/","pubDate":"Mon, 08 Dec 2025 19:42:40 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-08-aoc\/","description":"<p>Oh boy! This was tough. I feel like a hack after solving today&rsquo;s challenge.\nI failed to understand the essence of the problem and brute forced both the parts.<\/p>\n<p>I believe Part2 is somehow linked with the concept of Spanning Trees.\nBut I could not model the problem with my limited knowledge of competitive programming.\nI would be happy to learn if somebody understood the concepts involved in this problem.<\/p>"},{"title":"An Invisible Tax on the Web: Video Codecs","link":"https:\/\/kxsh.dev\/notes\/2025-12-08-av1\/","pubDate":"Mon, 08 Dec 2025 17:41:28 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-08-av1\/","description":"<p>TIL: AV1 is the more efficient, open source alternate to the patented H.264 video codec.<\/p>"},{"title":"Is It Worth It To Optimize Images For Your Site?","link":"https:\/\/kxsh.dev\/notes\/2025-12-08-image-optimization\/","pubDate":"Mon, 08 Dec 2025 16:00:03 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-08-image-optimization\/","description":"<p>I found this gem of a post from the inimitable <em>Brain Baker<\/em> about image\noptimization for websites.<\/p>\n<p>I&rsquo;m stealing the <code>ImageMagick<\/code> command.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>mogrify -sampling-factor 4:2:0 +profile <span style=\"color:#40a02b\">&#39;!icc,*&#39;<\/span> -quality <span style=\"color:#fe640b\">80<\/span> -interlace JPEG -format jpg -colorspace sRGB &lt;your-image&gt;\n<\/span><\/span><\/code><\/pre><\/div><p>The above optimization to the clicks in <a href=\"https:\/\/kxsh.dev\/posts\/2025-11-08-risk-ruin-reward\/\">Risk, Run, and Reward<\/a> reduced the size of the assets from ~2.5MB to ~1.5MB now.<\/p>"},{"title":"Advent of Code: Day 07","link":"https:\/\/kxsh.dev\/notes\/2025-12-07-aoc\/","pubDate":"Sun, 07 Dec 2025 19:36:14 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-07-aoc\/","description":"<p>Today was quite challenging.<\/p>\n<p>Part 1 was easier to approach - maintain state of the beam as it traverses down the grid.<\/p>\n<p>Par 2 was quite messy. It took me a while to figure out a wokring approach.\nI maintain a mapping of final position to the number of timelines where atleast 1 beam ends up.\nThe idea is to sum up all these values for the final line of the input.<\/p>"},{"title":"F1 Season 2025","link":"https:\/\/kxsh.dev\/notes\/2025-12-07-f1-2025\/","pubDate":"Sun, 07 Dec 2025 19:31:27 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-07-f1-2025\/","description":"<p>Congratulations to Lando Norris on winning his first F1 Drivers&rsquo; Championship. Well deserved!<\/p>"},{"title":"10 Years of Explaining Computers","link":"https:\/\/kxsh.dev\/notes\/2025-12-07-explaining-computers\/","pubDate":"Sun, 07 Dec 2025 11:38:30 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-07-explaining-computers\/","description":"<p>Kudos to Chris for consistently publishing every week for 10 year now.<\/p>"},{"title":"Advent of Code: Day 06","link":"https:\/\/kxsh.dev\/notes\/2025-12-06-aoc\/","pubDate":"Sat, 06 Dec 2025 20:06:35 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-06-aoc\/","description":"<p>Parsing the input into a 2D grid of characters was the key to today&rsquo;s challenge.\nAt least, I found this approach simpler to reason about.<\/p>\n<p>For the first part, I built each number by concatenating the characters in each\nrow of the grid. As I process each row, I add a single entry to each <code>Problem<\/code>.\nFinally, we get the operators for every individual <code>Problem<\/code>.\nEven though I would prefer immutable values, I could not design a simpler\nsolution.<\/p>\n<p>For the second part, I pretty much followed the same design as above except for\none tiny modification. As the requirements suggest that columns represent a valid\nnumber, I transpose the above grid to build the set of <code>Problem<\/code>s.<\/p>\n<p>Today was definitely a bit more challenging to solve as well as implement.\nBut I had a lot of fun.<\/p>"},{"title":"Advent of Code: Day 05","link":"https:\/\/kxsh.dev\/notes\/2025-12-05-aoc\/","pubDate":"Fri, 05 Dec 2025 14:01:35 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-05-aoc\/","description":"<p>Another easy day!<\/p>\n<p>My first attempt to solve Part 2 was naive enough to hit &ldquo;max heap allocation&rdquo;.\nSo I rewrote to compute interval overlaps.<\/p>\n<p>You can find the solution <a href=\"https:\/\/github.com\/kshitij10496\/aoc\/blob\/cbfdaa20a1f957df941a3891834daa504bf97239\/2025\/src\/day-05.kt\">on GitHub<\/a>.<\/p>"},{"title":"Advent of Code: Day 04","link":"https:\/\/kxsh.dev\/notes\/2025-12-04-aoc\/","pubDate":"Thu, 04 Dec 2025 19:33:30 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-04-aoc\/","description":"<p>Today&rsquo;s challenge was too easy.\nIt took me around 30 mins in total for both the parts.<\/p>\n<p>Regular dataclasses and mapping logic.\nI did not feel comfortable mutating existing state, so I opted for recreating\na new grid for every iteration.<\/p>\n<p><strong>Unexplored Ideas<\/strong>:<\/p>\n<ul>\n<li>Figure out more appropriate representations of the 2D arrays.<\/li>\n<\/ul>"},{"title":"Advent of Code: Day 03","link":"https:\/\/kxsh.dev\/notes\/2025-12-03-aoc\/","pubDate":"Wed, 03 Dec 2025 15:10:38 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-03-aoc\/","description":"<p>Today&rsquo;s challenge centered around <strong>string manipulation<\/strong>.<\/p>\n<p>The code implementation was pretty straight forward once I broke down the problem\non paper. Overall, it took me about 40 mins to implement the solution in code.<\/p>\n<p>My primary challenge today was to discover the appropriate <code>String<\/code> and <code>List<\/code>\nmanipulation functions provided in Kotlin&rsquo;s standard library.<\/p>\n<p>Unfortunately, my setup for the open-source Language Server for Kotlin<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup> does\nnot work out of the box. Most of the Symbols (Functions, Classes) are almost\nalways defined in a JAR file. This includes the standard library as well.\nI am not sure how this works but I suppose all the dependencies are injected\ntogether with the Kotlin runtime during compilation or the build step.<\/p>\n<p>My colleague pointed out that IntelliJ and VSCode can magically look up symbols\nwithin JAR files. With the Language Server under heavy active development,\nI expect improvements to the development experience in more editors.<\/p>\n<p>Let me know if you have recommendations about settings up Neovim\/Zed for Kotlin.<\/p>\n<h2 id=\"new-implementation-details\">New Implementation Details<\/h2>\n<ul>\n<li>Using <code>map<\/code>, <code>filter<\/code> and <code>reduce<\/code> pattern from yesterday wherever I could.<\/li>\n<\/ul>\n<h2 id=\"unexplored-ideas\">Unexplored Ideas<\/h2>\n<ul>\n<li>Concurrently execute each battery bank from the input.<\/li>\n<\/ul>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/github.com\/Kotlin\/kotlin-lsp\">https:\/\/github.com\/Kotlin\/kotlin-lsp<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"How to Vim in 2023: Tips and Tricks","link":"https:\/\/kxsh.dev\/notes\/2025-12-03-vim\/","pubDate":"Wed, 03 Dec 2025 09:14:48 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-03-vim\/","description":"<p>Filetrees are useful to create new files, delete (or rename) existing files.\nFuzzy file finder (via Telescope) is much more efficient to navigate and open specific files.<\/p>\n<p>The concept of &ldquo;alternate file&rdquo; is powerful to quickly jump across files.\nUse the keymap <code>&lt;C-^&gt;<\/code>.<\/p>\n<p>I prefer to use <code>git<\/code> from the terminal emulator rather than bind it to the text editor.<\/p>"},{"title":"Advent of Code: Day 02","link":"https:\/\/kxsh.dev\/notes\/2025-12-02-aoc\/","pubDate":"Tue, 02 Dec 2025 18:27:34 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-02-aoc\/","description":"<p>Today&rsquo;s problem can be solved with pretty simple Map, Filter, and Reduce pattern.\nSince I am not yet familiar with Kotlin idioms or standard libary patterns,\nI implemented these operations with the help of higher-order functions and regular loops.<\/p>\n<p>I am curious to learn about &ldquo;lazy&rdquo; evaluations or the generator pattern from Python.\nThis would potentially reduce memory usage by not maintaining intermediate collections of invalidIDs.<\/p>\n<p>I came across nifty regex for determining invalidIDs to replace my filtering logic.\nRegular expressions are not my cup of tea because I find them difficult to understand them once they are written.\nSo I tend to avoid them wherever possible.<\/p>"},{"title":"0 to LSP: Neovim RC From Scratch","link":"https:\/\/kxsh.dev\/notes\/2025-12-02-nvim\/","pubDate":"Tue, 02 Dec 2025 16:59:18 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-02-nvim\/","description":"<p>Prime has a lot of keymaps which can be helpful.\nI need to investigate and revisit them at some point.<\/p>"},{"title":"Advent of Code: Day 01","link":"https:\/\/kxsh.dev\/notes\/2025-12-01-aoc\/","pubDate":"Mon, 01 Dec 2025 19:04:42 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-01-aoc\/","description":"<p>Today marks Day 01 of Advent of Code 2025.\nI intend to teach myself some Kotlin in the next couple of weeks.<\/p>\n<h2 id=\"intro-to-kotlin\">Intro to Kotlin<\/h2>\n<p>I spent a couple of hours in the morning with Kotlin Tour - Beginner<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>,\nand Kotlin Koans<sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup>.\nModular arithmetic operators (<code>rem<\/code>, <code>mod<\/code> and <code>%<\/code>) are still pretty confusing to me.\nI opted for a simple project setup - daily scripts that compile to JVM executable JARs.\nAside from that, I had a lot of fun writing my first program in Kotlin.<\/p>\n<h2 id=\"keep-it-simple\">Keep It Simple<\/h2>\n<p>Looping might be a compute intensive approach.\nHowever, clever arithmetic results in hard to follow code.\nI chose readability over performance because I can afford to wait for 2s.<\/p>\n<p><a href=\"https:\/\/github.com\/kshitij10496\/aoc\/tree\/main\/2025\">Source Code is available on GitHub<\/a><\/p>\n<p>We only have 12 challenges this year around so I look forward to them.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/kotlinlang.org\/docs\/kotlin-tour-welcome.html\">https:\/\/kotlinlang.org\/docs\/kotlin-tour-welcome.html<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/play.kotlinlang.org\/koans\/Introduction\/Hello,%20world!\/Task.kt\">https:\/\/play.kotlinlang.org\/koans\/Introduction\/Hello,%20world!\/Task.kt<\/a>&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Vim as your editor - Advanced Motions P2","link":"https:\/\/kxsh.dev\/notes\/2025-12-01-vim-advanced\/","pubDate":"Mon, 01 Dec 2025 11:02:39 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-12-01-vim-advanced\/","description":"<p>Another video focusing on vertical motions<\/p>\n<ul>\n<li>Get comfortable using relative line numbers.<\/li>\n<li>Prefer navigation within the same buffer with <code>&lt;C-d&gt;<\/code> and <code>&lt;C-u&gt;<\/code>.<\/li>\n<li><code>o<\/code> to jump at the end of the visually selected text is pretty cool.<\/li>\n<li><code>&lt;C-v&gt;<\/code> for multicursor selection.<\/li>\n<li>Grokking text object manipulations is a critical skill to edit efficiently in Vim. I need to read the User Manuals to master this.<\/li>\n<li>Display function\/class names at the top of the window while scrolling with the <code>nvim-treesitter-context<\/code> plugin. This allows for a better editing experience with programming languages.<\/li>\n<li>Jumping text objects with <code>{<\/code> and <code>}<\/code> can be annoying as it is depends on the code formatting conventions. However, it&rsquo;s still helpful when we want to jump to empty lines.<\/li>\n<\/ul>\n<p>Neat trick with <code>vi{<\/code> to move around multi-paragraph functions.<\/p>"},{"title":"Vim As You Editor - Advanced Motions P1","link":"https:\/\/kxsh.dev\/notes\/2025-11-30-vim-advanced\/","pubDate":"Sun, 30 Nov 2025 12:55:47 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-30-vim-advanced\/","description":"<p>&ldquo;Master the concrete!&rdquo; \ud83d\ude02<\/p>\n<ul>\n<li><code>viw<\/code> and <code>viW<\/code> in particular are very handy for quick selection of text objects.<\/li>\n<li>Use <code>&lt;leader&gt;p<\/code> keybinding for persisting whatever I copy\/delete after first usage.<\/li>\n<li>I prefer the <code>yy<\/code> and <code>dd<\/code> keybindings to <code>Vy<\/code> and <code>Vd<\/code> when working with lines of text.<\/li>\n<\/ul>"},{"title":"Vim As Your Editor - Vertical Movements","link":"https:\/\/kxsh.dev\/notes\/2025-11-29-vim-vertical\/","pubDate":"Sat, 29 Nov 2025 08:56:23 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-29-vim-vertical\/","description":"<p>A <strong>paragraph<\/strong> is contiguous, non-whitespace block of text.<\/p>\n<ul>\n<li>\n<p><code>{<\/code>: Move to a line <em>above<\/em> the current paragraph.<\/p>\n<\/li>\n<li>\n<p><code>}<\/code>: Move to a line <em>below<\/em> the current paragraph.<\/p>\n<\/li>\n<li>\n<p><code>&lt;C-d&gt;<\/code>: Move half-page down.<\/p>\n<\/li>\n<li>\n<p><code>&lt;C-u&gt;<\/code>: Move half-page up.<\/p>\n<\/li>\n<li>\n<p><code>G<\/code>: Move to the last line.<\/p>\n<\/li>\n<li>\n<p><code>gg<\/code>: Move to the first line.<\/p>\n<\/li>\n<li>\n<p><code>:n<\/code>: Move to the specified line number <code>n<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"searching-in-the-buffer\">Searching in the buffer<\/h4>\n<ul>\n<li><code>\/<\/code>: Search for a specific string.<\/li>\n<li><code>?<\/code>: Search for a specific string (like <code>\/<\/code>) but in the reverse direction.<\/li>\n<li><code>*<\/code>: Use the current word under cursor as the search term.<\/li>\n<li><code>#<\/code>: Use the current word under cursor as the search term (like <code>*<\/code>) but in the reverse direction.\n<ul>\n<li><code>n<\/code>: Move to the next search result.<\/li>\n<li><code>N<\/code>: Move to the previous search result.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Technique: Navigate mostly with half-page motions (<code>&lt;C-d&gt;<\/code> and <code>&lt;C-u&gt;<\/code>), then relative motion for specifics.<\/p>"},{"title":"Vim As Your Editor - Horizontal","link":"https:\/\/kxsh.dev\/notes\/2025-11-28-vim-horizontal\/","pubDate":"Fri, 28 Nov 2025 16:35:28 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-28-vim-horizontal\/","description":"<p>Here are all the Vim motions focused on moving around mentioned in this video:<\/p>\n<ul>\n<li><code>_<\/code>: First non whitespace character on the current line.<\/li>\n<li><code>$<\/code>: Last character or End of the current line.<\/li>\n<li><code>0<\/code>: First character of the line.<\/li>\n<li><code>f<\/code>: Jump forward to a specified character. (e.g. <code>f(<\/code> moves the cursor on the next <code>(<\/code> character in the line)<\/li>\n<li><code>t<\/code>: Jumps upto but not on the specified character.<\/li>\n<li><code>;<\/code>: Moves the cursor to the NEXT result from the above search.<\/li>\n<li><code>,<\/code>: Moves the cursor to the PREVIOUS result from the above search.<\/li>\n<li><code>F<\/code>: Jumps backward to a specified character. (conjugates the <code>f<\/code> motion).<\/li>\n<li><code>T<\/code>: Conjugates the <code>t<\/code> motion - but moves backwards.<\/li>\n<li><code>I<\/code>: Moves the cursor to the first nonwhitespace character in Insert Mode.<\/li>\n<li><code>A<\/code>: Moves the cursor to the end of the line in Insert mode.<\/li>\n<li><code>o<\/code>: Creates a newline below the current line, and moves the cursor in Insert mode.<\/li>\n<li><code>O<\/code>: Creates a newline above the current line, and moves the cursor in Insert mode.<\/li>\n<\/ul>\n<p><strong>Buffers<\/strong> are in-memory representations of files.\n<strong>Windows<\/strong> are the chrome to render buffers.<\/p>\n<p>A window can host multiple buffers.\nA buffer can be opened in multiple windows.<\/p>"},{"title":"Vim As Your Editor - Introduction","link":"https:\/\/kxsh.dev\/notes\/2025-11-27-vim-intro\/","pubDate":"Thu, 27 Nov 2025 19:43:46 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-27-vim-intro\/","description":"<p>Vim Motions are useful irrespective of whether I choose vim as my text editor or not.<\/p>\n<p>A motion is anything that moves the cursor.<\/p>\n<p><!-- raw HTML omitted --><!-- raw HTML omitted --><!-- raw HTML omitted --><\/p>\n<p>Pasting over a highlighted region with Visual mode is extremely cool and useful for overwriting.<\/p>\n<p>Yank and Delete commands write into the same buffer.<\/p>"},{"title":"You Are How You Act","link":"https:\/\/kxsh.dev\/notes\/2025-11-27-you-are-how-you-act\/","pubDate":"Thu, 27 Nov 2025 12:32:16 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-27-you-are-how-you-act\/","description":"<blockquote>\n<p>The repetition of behavior, not the sincerity of belief, is what shapes character. You become the kind of person who does the things you repeatedly do.<\/p>\n<\/blockquote>\n<p>I can relate with this. Inspiration has not worked for me. I am drawn by the demand for consistent effort.<\/p>\n<blockquote>\n<p>Rousseau invites endless introspection. Franklin invites progress. The first is about how you feel; the second is about what you build. We invoke Rousseau when we need forgiveness: I meant well. We invoke Franklin when we need accountability: Show me what you\u2019ve done.<\/p>\n<\/blockquote>\n<p>Are these were 2 lines of thought necessarily independent?<\/p>\n<blockquote>\n<p>I find the Franklin model far more useful. Not because it\u2019s truer in some cosmic sense, but because it gives you agency. You can\u2019t always change how you feel, but you can always decide what to do next.<\/p>\n<\/blockquote>\n<p>Agency is important as it empowers me to channel my energy into pursuits that fulfill me.<\/p>"},{"title":"Building Data Visualisations in Python in Minutes - GOTO 2025","link":"https:\/\/kxsh.dev\/notes\/2025-11-26-data-viz\/","pubDate":"Wed, 26 Nov 2025 16:57:16 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-26-data-viz\/","description":"<p>Kris recommends not to serve Streamlit apps in high traffic scenarios.\nStreamlit can still be extremely valuable for internal analytics dashboards - without involving a lot of frontend engineering.<\/p>"},{"title":"air with templ","link":"https:\/\/kxsh.dev\/posts\/2025-11-25-air-templ\/","pubDate":"Tue, 25 Nov 2025 18:58:47 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-11-25-air-templ\/","description":"<p>My webdev stack is as follows:<\/p>\n<ul>\n<li>Go for the web server.<\/li>\n<li><code>templ<\/code> for the HTML templates.<\/li>\n<li><code>htmx<\/code> for client-server interaction wherever needed.<\/li>\n<li><code>AlpineJS<\/code> for client-side interactivity.<\/li>\n<\/ul>\n<p>This stack works well for most of the simple CRUD applications I build.<\/p>\n<p>My local dev flow is as follows:<\/p>\n<ul>\n<li>Either change the HTML template,<\/li>\n<li>or change Go server logic,<\/li>\n<li>or both.<\/li>\n<\/ul>\n<p>I expect my setup to incorporate all the changes I made above.\nThat is, I should need to neither regenerate the HTML templates nor rebuild the server binary.\nThe idea to reproduce a DevEx similar to other web frameworks.<\/p>\n<p><code>air<\/code> is my preferred tool for hot reloading Go binaries during local development.\nI even plug the HTML template generation using <code>templ<\/code> into <code>air<\/code>:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-toml\" data-lang=\"toml\"><span style=\"display:flex;\"><span>cmd = <span style=\"color:#40a02b\">&#34;go tool templ generate &amp;&amp; go build -o .\/bin\/server .\/cmd\/server&#34;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>Unfortunately, <code>air<\/code> does not &ldquo;blend&rdquo; with <code>templ<\/code> out of the box.\nIf you give it a try, you might be stuck on a infinite loop between\nthe changes in templ files and the generated Go files.\nI am not sure why though.<\/p>\n<p>Over the past year, I have settled on a recipe to make this work.\nSimply change the default <code>.air.toml<\/code> config to ignore changes to the Go files generated by <code>templ<\/code>.\n<code>templ<\/code> generates <code>*_templ.go<\/code> files by default. We can instruct <code>air<\/code> to not watch these files as follows:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-toml\" data-lang=\"toml\"><span style=\"display:flex;\"><span>exclude_regex = [<span style=\"color:#40a02b\">&#34;_test.go&#34;<\/span>, <span style=\"color:#40a02b\">&#34;_templ.go&#34;<\/span>] <span style=\"color:#9ca0b0;font-style:italic\"># Ignore files generated by templ.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>include_ext = [<span style=\"color:#40a02b\">&#34;go&#34;<\/span>, <span style=\"color:#40a02b\">&#34;tpl&#34;<\/span>, <span style=\"color:#40a02b\">&#34;tmpl&#34;<\/span>, <span style=\"color:#40a02b\">&#34;html&#34;<\/span>, <span style=\"color:#40a02b\">&#34;templ&#34;<\/span>] <span style=\"color:#9ca0b0;font-style:italic\"># Watch for updates to .templ files.<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>This is one of my first steps when bootstrapping a new project with these tools.\nHope this tweak helps improve your DevEx too.<\/p>"},{"title":"Review: Fatherland","link":"https:\/\/kxsh.dev\/posts\/2025-11-24-fatherland\/","pubDate":"Mon, 24 Nov 2025 16:40:27 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-11-24-fatherland\/","description":"<p>A colleague recommended me this historical fiction, crime mystery set in 1960s Berlin.\nSimilar to The Man on the High Castle, the story speculates an alternate timeline\nwhere Nazi Germany prevailed in the WWII.<\/p>\n<p>The plot spins around the following themes:<\/p>\n<ul>\n<li>Patriotic loyalty over personal loyalty to family and friends.<\/li>\n<li>Corruption couples itself with power.<\/li>\n<li>Duty demands an allegiance to the truth; at the cost of disobedience.<\/li>\n<li>Free, independent press plays an important role to hold the powerful accountable.<\/li>\n<\/ul>\n<p>I really enjoyed my time reading this. However, not worth a re-read for me.<\/p>\n<h2 id=\"references\">References<\/h2>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/w\/index.php?title=Fatherland_%28novel%29&amp;oldid=1320650997&amp;useskin=vector\">Fatherland (novel) - Wikipedia<\/a><\/li>\n<\/ul>"},{"title":"you can just do things","link":"https:\/\/kxsh.dev\/posts\/2025-11-24-advent-of-nvim\/","pubDate":"Mon, 24 Nov 2025 13:50:28 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-11-24-advent-of-nvim\/","description":"<p>Finished the <a href=\"https:\/\/youtu.be\/X7HFU786NiQ?si=GQpODtpc3ZMCryeD\">final episode of this series<\/a>.<\/p>\n<p>Thank you so much, TJ!<\/p>\n<p>I resonated with the message to keep learning what interests me, irrespective\nof the AI hype train. Perhaps, AI will render a lot of my esoteric knowledge\nworthless, but the effort to acquire it is worthwhile.<\/p>\n<p>Neovim configs are still a mystery to me.\nHowever, I feel a bit more comfortable using Neovim as my daily driver now.<\/p>\n<p>I intend to maintain my Neovim config in this fork of <a href=\"https:\/\/github.com\/kshitij10496\/kickstart.nvim\">nvim-lua\/kickstarter.nvim<\/a>.<\/p>"},{"title":"Neovim Plugin From Scratch: User Customization (Part 8)","link":"https:\/\/kxsh.dev\/notes\/2025-11-23-nvim\/","pubDate":"Sun, 23 Nov 2025 20:12:30 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-23-nvim\/","description":"<p>We extend on yesterday&rsquo;s session about executing code within the presentation.\nThe idea is to allow users to execute codeblocks in more programming languages,\nsuch as Python, JS.<\/p>\n<p>The higher-order function to capture the output of any program and inject it\ninto our slide is pretty neat.<\/p>"},{"title":"Neovim Plugin From Scratch: Executing Markdown Blocks LIVE (Part 7)","link":"https:\/\/kxsh.dev\/notes\/2025-11-22-nvim\/","pubDate":"Sat, 22 Nov 2025 20:57:48 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-22-nvim\/","description":"<p>In this episode, we add the ability to execute Lua codeblocks from within our slides.\nThe live code executor is pretty cool as it enables us to make our slides dynamic.<\/p>"},{"title":"Neovim Plugin From Scratch: Custom Commands\/Lazy Loading (Part 6)","link":"https:\/\/kxsh.dev\/notes\/2025-11-21-nvim\/","pubDate":"Fri, 21 Nov 2025 14:24:34 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-21-nvim\/","description":"<p>User commands provide a powerful interface between a plugin&rsquo;s core functionality\nand the end user.<\/p>\n<p>While developing a plugin, we should be mindful about affecting the Neovim\nstartup time from the user&rsquo;s perspective - default to <strong>Lazy Loading<\/strong>.<\/p>"},{"title":"Neovim Plugin From Scratch: Testing + CI (Part 5)","link":"https:\/\/kxsh.dev\/notes\/2025-11-20-nvim\/","pubDate":"Thu, 20 Nov 2025 13:02:39 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-20-nvim\/","description":"<p>We use <a href=\"https:\/\/github.com\/nvim-lua\/plenary.nvim\">plenary.nvim<\/a> test harness together with <a href=\"https:\/\/lunarmodules.github.io\/busted\/\">Busted framework<\/a> for testing our plugin code.<\/p>\n<p><code>PlenaryBustedFile %<\/code>: Run tests from a specific file.<\/p>\n<p>The natural next step is to add CI workflows to hook up these tests as part of our project&rsquo;s development lifecycle.<\/p>"},{"title":"Writing an Intepreter: Parsing","link":"https:\/\/kxsh.dev\/posts\/2025-11-19-interpreter\/","pubDate":"Wed, 19 Nov 2025 22:05:31 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-11-19-interpreter\/","description":"<p>A parser turns a stream of tokens into a more accessible data structure that represents the input.\nThis data structure is usually called the <strong>Abstract Syntax Tree<\/strong> or <strong>AST<\/strong>.\nIn short, the AST is an internal representation of the source code.<\/p>\n<p>The parser analyses the input tokens and checks for syntactic correctness of the source code.\nThus, this process is also called <strong>Syntactic Analysis<\/strong>.<\/p>\n<p>For example, if we serialise\/deserialise data to\/from JSON format, we are conceptually parsing tokens - just like our interpreter.\nExcept LISP, we seldom see the internal representation of the parsed source code in most programming languages.<\/p>\n<p>Parsers are well suited for code generation. As a result, we have many <strong>Parser generators<\/strong> (such as <code>yacc<\/code>) that when fed with a formal description of a language, produce parsers as their output.\nThe generated parser is simply code that can be compiled, and fed together with the source code to produce the AST.<\/p>\n<p>However, we will write our own for the sake of it - this is a toy project after all.\nIn particular, we implement the <strong>Pratt Parser<\/strong> which a top-down operator precedence (or recursive descent parser). The main idea is to process the token sequentially while building an in-memory tree.\nWe use recursion to re-arrange the nodes of the trees as need arises (and it does).<\/p>\n<p>I learnt about the difference between a &ldquo;statement&rdquo; and &ldquo;expression&rdquo;.\nExpressions produce a value; statements do not.<\/p>\n<p>Variable bindings (<code>let<\/code>) and function returns (<code>return<\/code>) are statements.\nEverything else in the Monkey programming language is an expression - including <code>if<\/code> statements.<\/p>\n<p>The different types of expressions we need to support are:<\/p>\n<ul>\n<li>Prefix operators: <code>-5<\/code>, <code>!x<\/code><\/li>\n<li>Infix operators: <code>5 + 37<\/code><\/li>\n<li>Comparison operators: <code>answer == 42<\/code><\/li>\n<li>Grouped Expressions: <code>(5 + 1) * 7<\/code><\/li>\n<li>If Expressions: <code>if (x &gt; 0) { true } else { false }<\/code><\/li>\n<li>Function Literals: <code>fn(x, y) { return x + y; }<\/code><\/li>\n<li>Call Expressions: <code>isPositive(-5)<\/code><\/li>\n<\/ul>\n<p>I found this video by <a href=\"https:\/\/youtu.be\/0c8b7YfsBKs?si=7gN8D5lEYwNlOeT1\">Core Dumped about Pratt Parsing<\/a> much more intuitive than the book&rsquo;s explanation.<\/p>\n<p>I had to drag through the implementation as I found it difficult to understand and express the concept of Pratt Parsing. At the moment, I just have a theoretical model of how the algorithm is supposed to work.\nSomething for me to circle back to later.<\/p>\n<p>At the end, the source code is parsed into an AST.\nThe next step is to &ldquo;interpret&rdquo; or &ldquo;evaluate&rdquo; the tree we have built.<\/p>"},{"title":"Neovim Plugin From Scratch: How to Iterate (Part 4)","link":"https:\/\/kxsh.dev\/notes\/2025-11-19-nvim\/","pubDate":"Wed, 19 Nov 2025 15:30:18 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-19-nvim\/","description":"<p>We add a footer window to each slide.<\/p>\n<p>I resonated with the bit about not following best practices as dogma.\nFor toy projects, it might be an overkill.<\/p>\n<p>Macros were handy for refactoring the codebase.\nI need to learn and use macros more often.<\/p>"},{"title":"Shipping Through Chaos","link":"https:\/\/kxsh.dev\/notes\/2025-11-19-shipping-through-chaos\/","pubDate":"Wed, 19 Nov 2025 14:04:21 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-19-shipping-through-chaos\/","description":"<p>This talk made me wonder the importance of soft skills to build healthy working relationship with people across the board in order to pull together a project in big corporations.<\/p>\n<p>Always fun to hear from Kaustubh.\nI only know a handful of people with comparable levels of enthusiasm, and sense of humor.<\/p>\n<p>I would be so frustated if I were in his shoes - with the presentation flickering.<\/p>\n<p>Kudos to him!<\/p>"},{"title":"Neovim Plugin From Scratch: Plugins + Autocmds (Part 3)","link":"https:\/\/kxsh.dev\/notes\/2025-11-18-nvim-autocmd\/","pubDate":"Tue, 18 Nov 2025 11:16:24 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-18-nvim-autocmd\/","description":"<p>Our plugin should be responsive to the viewport resizing events.\nZooming-in (or zooming-out) should not break our plugin&rsquo;s UI.<\/p>\n<p>Neovim provides a mechanism to define &ldquo;event listeners&rdquo; via <em>autocommands<\/em>.\nThe plugin needs to handle relevant events that can be triggered by the user in the editor.<\/p>\n<p>In this case, we care for the <code>VimResized<\/code> event and re-render the current slide after resizing our windows.<\/p>"},{"title":"Neovim Plugin From Scratch: Managing Floating Windows (Part 2)","link":"https:\/\/kxsh.dev\/notes\/2025-11-17-nvim-windows\/","pubDate":"Mon, 17 Nov 2025 20:51:22 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-17-nvim-windows\/","description":"<p>In this episode, we implement a bunch of features.<\/p>\n<ul>\n<li>Set the floating terminal to consume the entire viewport available to the editor.<\/li>\n<li>Remove borders from the floating terminal.<\/li>\n<li>Remove the status line from the bottom.<\/li>\n<li>Split the slide window into multiple windows and arrange them with absolute positioning.<\/li>\n<li>Render the markdown and center the slide title.<\/li>\n<\/ul>\n<p>The Neovim status line at the bottom of the editor can be manipulated by the <code>cmdheight<\/code>option.\nAccording to the docs, this property is defined per Nvim tab. So when we change\nit for a single window, it affects all the windows in the current tab.<\/p>\n<p>The composition of multiple windows to render a single slide feels a bit too complex.\nThe absolute positions of the header window and the body window was cool but not\nfun to work with - similar to absolute CSS postioning. So I think I will go\nalong with the implementation without diving as deep as I could for the time\nbeing. I will make sure to revisit this in a few months when I am more familiar.<\/p>"},{"title":"Writing an Interpreter: Lexer","link":"https:\/\/kxsh.dev\/posts\/2025-11-16-interpreter\/","pubDate":"Sun, 16 Nov 2025 18:31:08 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-11-16-interpreter\/","description":"<p>Lexer is responsible to transform the source code into a collection of tokens.\nWorking with tokens is much more accessible than with raw source code.\nAdditionally, tokenization provides a fairly decent abstraction layer about\nthe underlying programming language.<\/p>\n<p>Few consideration at this step of language design:<\/p>\n<ul>\n<li>Native UTF-8 charset support.<\/li>\n<li>Handling whitespace characters.<\/li>\n<li>Metadata about the tokens (location in the file).<\/li>\n<li>Supported keywords and special characters.<\/li>\n<li>Guidelines for naming variables.<\/li>\n<\/ul>\n<p>Few observations from other languages:<\/p>\n<ul>\n<li>Python uses indentation to define scopes.<\/li>\n<li>Macros in Rust are suffixed with a <code>!<\/code>.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/codeberg.org\/kxsh\/monkey\/src\/tag\/v0.1.0\">Checkout the implementation thus far on codeberg.<\/a><\/p>"},{"title":"Neovim Plugin From Scratch: Markdown Presentation (Part 1)","link":"https:\/\/kxsh.dev\/notes\/2025-11-16-nvim-plugin\/","pubDate":"Sun, 16 Nov 2025 11:42:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-16-nvim-plugin\/","description":"<p>I have developed a good sense of how to navigate around the Neovim ecosystem.\nUse the help docs, define keymaps useful to me, and configure the setup as I wish.<\/p>\n<p>Building a plugin aims to wrap all these concepts together.\nIn particular, we build a markdown presentation tool.<\/p>\n<p>In this episode, we implement the following:<\/p>\n<ul>\n<li>Parse a single markdown file from a buffer into multiple slides (split by H1).<\/li>\n<li>Render the slides in a floating window.<\/li>\n<li>Define keymaps and commands to interact with the slideshow.<\/li>\n<\/ul>"},{"title":"Custom Right-Click Menus in Neovim","link":"https:\/\/kxsh.dev\/notes\/2025-11-15-nvim-click-menu\/","pubDate":"Sat, 15 Nov 2025 08:40:51 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-15-nvim-click-menu\/","description":"<p>Pretty cool to see that we can even configure the context menus for mouse interactions.<\/p>"},{"title":"Needy Programs","link":"https:\/\/kxsh.dev\/notes\/2025-11-14-needy-programs\/","pubDate":"Fri, 14 Nov 2025 15:55:12 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-14-needy-programs\/","description":"<p>Patterns of programs that demand our engagement:<\/p>\n<ul>\n<li>Mandate User Accounts.<\/li>\n<li>Lock out users not on the latest app version.<\/li>\n<li>Abuse Notifications grab attention.<\/li>\n<li>Popups for &ldquo;What&rsquo;s new&rdquo; update preventing functional use.<\/li>\n<\/ul>\n<blockquote>\n<p>Programs that have their own agenda and that are trying to make it yours, too. Programs that want you to think about them. Programs that think they are entitled to a part of your attention. \u201cPick me\u201d programs.<\/p>\n<\/blockquote>\n<p>I find myself gravitating towards tools that work in the simplest way possible.\nBut I still use some of the &ldquo;updates&rdquo; feature instead of building from source.<\/p>\n<p>A text editor with Vim Motions: Neovim, Zed\nA note taking app that editable in Markdown with WSYWIG editor: Obsidian\nA terminal emulator that is configurable, fast, and not ugly looking: Ghostty<\/p>"},{"title":"Floating toggle-able terminal in Neovim","link":"https:\/\/kxsh.dev\/notes\/2025-11-14-neovim-toggle-term\/","pubDate":"Fri, 14 Nov 2025 09:48:11 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-14-neovim-toggle-term\/","description":"<p>A long running shell is useful when we are working a time consuming part of the process.\nIn Rust, it can be the compilation and build step.\nIn Rails, it&rsquo;s usually when we want to run the entire test suite.<\/p>\n<p>Another demand is &ldquo;live&rdquo; rendering - &ldquo;hot reload&rdquo;, &ldquo;liveview&rdquo; - where a longstanding client-server connection provides a rich developer experience.\nThus, we need a terminal and a text editor in parallel.\nI mostly multiplex the terminal emulator in such scenarios.\nHowever, its good to know that Neovim might support this.<\/p>"},{"title":"The easiest neovim autocompletion setup?","link":"https:\/\/kxsh.dev\/notes\/2025-11-13-neovim-autocomp\/","pubDate":"Thu, 13 Nov 2025 09:13:27 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-13-neovim-autocomp\/","description":"<p>We replace the <a href=\"https:\/\/github.com\/hrsh7th\/nvim-cmp\"><code>nvim.cmp<\/code><\/a> with <a href=\"https:\/\/github.com\/saghen\/blink.cmp\"><code>blink.cmp<\/code><\/a> for autocompletion.\nIt integrates well with our LSPs as well.<\/p>"},{"title":"Filetrees are Bad but oil.nvim is Good","link":"https:\/\/kxsh.dev\/notes\/2025-11-12-neovim-filetrees\/","pubDate":"Wed, 12 Nov 2025 15:49:36 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-12-neovim-filetrees\/","description":"<p>With a Telescope keymap, I can understand the appeal of not creating a dedicated File Explorer &ldquo;panel&rdquo;.\nAs long as we know the specific file we want to navigate to, a consistent keymap helps a lot.\nHowever, I still find a filetree handy when working with Rails.<\/p>\n<p><code>oil.nvim<\/code> is helpful as it integrates well with the Neovim file explorer out of the box.\nHowever, I still prefer to use the CLI when manipulating files or directories.<\/p>"},{"title":"Neovim has it's own terminal?!","link":"https:\/\/kxsh.dev\/notes\/2025-11-11-neovim-terminal\/","pubDate":"Tue, 11 Nov 2025 19:38:12 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-11-neovim-terminal\/","description":"<p>Neovim ships with a builtin terminal emulator. Specifically,<\/p>\n<p><em>&ldquo;Nvim embeds a VT220\/xterm terminal emulator based on libvterm&rdquo;<\/em><\/p>\n<p>We can open a terminal buffer with the command <code>:term<\/code>.\nThese terminal buffers behave mostly like regular buffers.\nThis implies we have a fully programmable terminal emulator.<\/p>\n<p>The &ldquo;small terminal&rdquo; keymap from TJ is nice but I still prefer to multiplex my terminals just to keep the editor and terminal separate and independent - same reason I never use Git integrations in any of my editors.<\/p>\n<p><code>\\r\\n<\/code> stands for <del>Carriage Return<\/del> Registered Nurse.<\/p>\n<p>Note: On my Mac machine, Neovim defaults to using the <code>\/bin\/sh<\/code> as the shell in the terminal. I had to force <code>\/bin\/zsh<\/code> as my shell. This is pretty strange considering Zsh is now the default shell on Mac.<\/p>"},{"title":"Quickfix can do so much!","link":"https:\/\/kxsh.dev\/notes\/2025-11-10-neovim-quickfix\/","pubDate":"Mon, 10 Nov 2025 11:11:19 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-10-neovim-quickfix\/","description":"<p>Quickfix List is a special buffer where Neovim stores a list of positions in files.\nIt provides a convenient way to move to specific locations in our repo such as LSP references, diagnostic errors.\nWe can even convert our Telescope fuzzy find results into a quickfix list.<\/p>\n<p>Access documentation with <code>:help quickfix<\/code>.<\/p>\n<p><code>:cdo<\/code> command is powerful tool when we want to operate on every single item in our Quickfix list.<\/p>\n<p>Useful keymaps for navigation in quickfix list:<\/p>\n<ul>\n<li><kbd>Option<\/kbd>\n <kbd>j<\/kbd>\n: Move to the next item in the quickfix list (<code>:cnext<\/code>).<\/li>\n<li><kbd>Option<\/kbd>\n <kbd>k<\/kbd>\n: Move to the previous item in the quickfix list (<code>:cprev<\/code>).<\/li>\n<\/ul>\n<p>Handy tips to populate the Quickfix List:<\/p>\n<ul>\n<li><kbd>g<\/kbd>\n<kbd>r<\/kbd>\n<kbd>r<\/kbd>\n: Puts a symbol&rsquo;s references from the LSP.<\/li>\n<li><kbd>Ctrl<\/kbd>\n <kbd>q<\/kbd>\n: Move current Telescope results to quickfix list.<\/li>\n<li><code>vim.diagnostic.setqflist()<\/code>: Fills the quickfix list with all the diagnostics from the LSP.<\/li>\n<\/ul>"},{"title":"Buffers, Windows, and Tabs!","link":"https:\/\/kxsh.dev\/notes\/2025-11-09-windows\/","pubDate":"Sun, 09 Nov 2025 09:59:52 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-09-windows\/","description":"<p>Vim Reference Manual has a dedicated chapter for the concept of &ldquo;buffers&rdquo;, &ldquo;windows&rdquo;, and &ldquo;tabs&rdquo; - <code>windows.txt<\/code>.\nThe gist of it is as follows:<\/p>\n<ul>\n<li>A buffer is the in-memory text of a file.<\/li>\n<li>A window is a viewport on a buffer.<\/li>\n<li>A tab page is a collection of windows.<\/li>\n<\/ul>\n<p>Here are some of the keybindings I use a lot:<\/p>\n<ul>\n<li><kbd>Ctrl<\/kbd>\n <kbd>w<\/kbd>\n + Motion : Working with Windows.<\/li>\n<li><kbd>Ctrl<\/kbd>\n <kbd>w<\/kbd>\n <kbd>T<\/kbd>\n: Move the current window to its own tab.<\/li>\n<li><kbd>Ctrl<\/kbd>\n <kbd>w<\/kbd>\n <kbd>q<\/kbd>\n: Close currently selected window.<\/li>\n<li><kbd>Ctrl<\/kbd>\n <kbd>w<\/kbd>\n + <kbd>Ctrl<\/kbd>\n <kbd>w<\/kbd>\n: Cycle through windows in the current tab.<\/li>\n<li><kbd>g<\/kbd>\n <kbd>t<\/kbd>\n: Cycle through open tabs.<\/li>\n<li><code>:fclose<\/code>: Close a floating window (say from a plugin or <code>lazy.nvim<\/code>)<\/li>\n<\/ul>"},{"title":"Rendering Markdown in the Terminal","link":"https:\/\/kxsh.dev\/notes\/2025-11-08-termagent\/","pubDate":"Sat, 08 Nov 2025 18:23:17 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-08-termagent\/","description":"<p>Good post to learn about rendering text in the terminal - ANSI color and styling codes, markdown parsing regex.<\/p>"},{"title":"Risk, Ruin, and Reward","link":"https:\/\/kxsh.dev\/posts\/2025-11-08-risk-ruin-reward\/","pubDate":"Sat, 08 Nov 2025 16:07:49 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-11-08-risk-ruin-reward\/","description":"<p>I received a copy of <a href=\"https:\/\/openlibrary.org\/books\/OL7593672M\/The_Misbehavior_of_Markets\">The Misbehaviour of Markets<\/a> this Friday evening.\nThis book has been a part of my Antilibrary for years now.\nThanks to Nassim Taleb who introduced me to the Mendelbrot&rsquo;s contributions\nto finance.<\/p>\n<p>Here are some of my notes from the first chapter titled &ldquo;Risk, Ruin, and Reward&rdquo;.<\/p>\n<ul>\n<li>Implemented a historical index point change tracker. <a href=\"https:\/\/demeanor.kxsh.dev\/\">App<\/a> <a href=\"https:\/\/github.com\/kshitij10496\/demeanor\">Source<\/a><\/li>\n<\/ul>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/2025-11-08-risk-ruin-reward\/part-1.jpeg\" alt=\"first page of the notes\" title=\"Part 1\"><\/p>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/2025-11-08-risk-ruin-reward\/part-2.jpeg\" alt=\"second page of the notes\" title=\"Part 2\"><\/p>"},{"title":"Use the XDG Base Directory Specification!","link":"https:\/\/kxsh.dev\/notes\/2025-11-08-xdg-spec\/","pubDate":"Sat, 08 Nov 2025 16:02:45 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-08-xdg-spec\/","description":"<p>I have around 90 files and dirs in my home directory on my machine.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>ls -la ~ | wc\n<\/span><\/span><\/code><\/pre><\/div><p>XDG config looks neat. Neovim already supports it.<\/p>\n<p>I will remember to support this with my next CLI tool.<\/p>"},{"title":"Setting up Multigrep with telescope.nvim","link":"https:\/\/kxsh.dev\/notes\/2025-11-08-multigrep-telescope\/","pubDate":"Sat, 08 Nov 2025 11:39:28 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-08-multigrep-telescope\/","description":"<p>I am already enjoying the newly configured keybinding to navigate my filetree with Telescope: <kbd>Space<\/kbd>\n <kbd>f<\/kbd>\n <kbd>d<\/kbd>\n.<\/p>\n<p>Today, we setup Multigrep with Telescope using some advanced scripting.\nMultigrep allows us to grep for strings within our files in the current directory.\nWe allow the user to filter filters using glob patterns.\n<code>rg<\/code> (ripgrep) powers this feature under the hood.<\/p>\n<p>TJ walks us through defining our own Picker to power this feature.\nIn Telescope, a Picker is composed of the following:<\/p>\n<ul>\n<li>finder (which finds the options),<\/li>\n<li>sorter (which filters and sorts the options),<\/li>\n<li>previewer (which renders the preview of the selected option),<\/li>\n<\/ul>\n<p>Once we have the script ready, we define the following keybinding to help use this feature:<\/p>\n<p><kbd>Space<\/kbd>\n <kbd>f<\/kbd>\n <kbd>g<\/kbd>\n: Find Grep<\/p>"},{"title":"telescope.nvim Introduction","link":"https:\/\/kxsh.dev\/notes\/2025-11-07-telescope\/","pubDate":"Fri, 07 Nov 2025 18:53:39 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-07-telescope\/","description":"<p>Navigating files is a hassle.\nFuzzy finder can help with this problem.\n<a href=\"https:\/\/github.com\/nvim-telescope\/telescope.nvim\"><code>telescope.nvim<\/code><\/a> is one of the most popular fuzzy finder plugin for Neovim.<\/p>\n<h4 id=\"setup\">Setup<\/h4>\n<p>We create a new plugin file <code>~\/.config\/nvim\/lua\/config\/plugins\/telescope.lua<\/code> with Telescope and it&rsquo;s dependencies:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua\" data-lang=\"lua\"><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">return<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#39;nvim-telescope\/telescope.nvim&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> tag <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;0.1.8&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> dependencies <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#39;nvim-lua\/plenary.nvim&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> { <span style=\"color:#40a02b\">&#39;nvim-telescope\/telescope-fzf-native.nvim&#39;<\/span>, build <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;make&#39;<\/span> }\n<\/span><\/span><span style=\"display:flex;\"><span> },\n<\/span><\/span><span style=\"display:flex;\"><span> config <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span>()\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">end<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><h4 id=\"usage\">Usage<\/h4>\n<p>After installing the plugins, we can explore the filetree with <code>:Telescope<\/code> command in Normal mode.\nHowever, it is much more convenient to define a few keymaps (or keybindings) for common operations:<\/p>\n<ul>\n<li><kbd>Space<\/kbd>\n<kbd>f<\/kbd>\n<kbd>d<\/kbd>\n: Find files in the current directory.<\/li>\n<li><kbd>Space<\/kbd>\n<kbd>f<\/kbd>\n<kbd>h<\/kbd>\n: Find help in documentation.<\/li>\n<li><kbd>Space<\/kbd>\n<kbd>e<\/kbd>\n<kbd>n<\/kbd>\n: Find files in the Neovim config.<\/li>\n<\/ul>\n<p>Playing around with the <code>ivy<\/code> theme was also pretty cool.<\/p>"},{"title":"Zed Meetup","link":"https:\/\/kxsh.dev\/notes\/2025-11-06-zed-meetup\/","pubDate":"Thu, 06 Nov 2025 21:39:53 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-06-zed-meetup\/","description":"<p>Zed hosted their first meetup in Berlin this evening.\nThe theme was AI.<\/p>\n<p>Here are some of my notes from the event:<\/p>\n<h4 id=\"ben-brandt-agent-communication-protocol\">Ben Brandt: Agent Communication Protocol<\/h4>\n<p>A nice, short introduction to the <a href=\"https:\/\/agentclientprotocol.com\/overview\/introduction\">ACP<\/a> developed at Zed.\nIt uses a similar concept to LSP for defining the communication protocol between a text editor and AI Agent.\nAt the surface level, it is a bidirectional JSON RPC.<\/p>\n<p>JetBrains, Neovim and Obsidian plugins already support this protocol.<\/p>\n<p>I still don&rsquo;t understand the need for a special protocol instead of reusing existing LSP support.\nBut I need to investigate this a bit more.<\/p>\n<h4 id=\"hrishikesh-yadav-ai-multimodal-project\">Hrishikesh Yadav: AI Multimodal Project<\/h4>\n<p>Unfortunately, I didn&rsquo;t understand a single thing.<\/p>\n<p>How is video data format processed, and fed into a model for training as well as inference?\nHow does the architecture of a multimodal model compare with an LLM?\nWhat are the current challenges with multimodal models?<\/p>\n<p>I need to checkout TwelveLabs to evaluate their video AI offering.<\/p>\n<h4 id=\"nicolay-gerold-context-engineering-for-agents\">Nicolay Gerold: Context Engineering for Agents<\/h4>\n<p>Excellent presentation from Nicolay about the issues with managing LLM context window.\nHe really tied the story together by sharing [Amp]&rsquo;s approach to context engineering.<\/p>\n<p>I had read about Amp from Hashimoto&rsquo;s blog post before.\nGonna give the free tier a try soon.<\/p>\n<p>Food: Pizzas + Mezzo Mix<\/p>"},{"title":"Code Formatting made easy","link":"https:\/\/kxsh.dev\/notes\/2025-11-06-code-formatting\/","pubDate":"Thu, 06 Nov 2025 10:06:13 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-06-code-formatting\/","description":"<p>Our current Neovim setup allows us to indent our code files with the keybinding\n<kbd>=<\/kbd>\n <kbd>G<\/kbd>\n.\nThis improves the reability of our code but we can do better.\nEnter code formatting.\nAutoformat code on file save can be considered &ldquo;linting&rdquo;.\nWe use our LSP setup to enable this feature.<\/p>\n<p>The following functionalities should be considered:<\/p>\n<p><code>vim.lsp.buf.format()<\/code>\nFormats a buffer using the attached (and optionally filtered) language\nserver clients.<\/p>\n<p><code>LspAttach<\/code>\nAfter an LSP client performs &ldquo;initialize&rdquo; and attaches to a buffer. The\n|autocmd-pattern| is the buffer name. The client ID is passed in the\nLua handler |event-data| argument.<\/p>\n<p><code>BufWrite<\/code> or <code>BufWritePre<\/code>\nBefore writing the whole buffer to a file.<\/p>\n<p>Neovim documentation provides an autoformat recipe by composing the above.<\/p>\n<p>Problem: We need a mechanism to define the shared code formatting guidelines\nbetween our editor, our LSP and code formatting tool.<\/p>\n<p>Enter <code>~\/.config\/nvim\/.editorconfig<\/code><\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-toml\" data-lang=\"toml\"><span style=\"display:flex;\"><span>[<span style=\"color:#d20f39\">*<\/span>.lua]\n<\/span><\/span><span style=\"display:flex;\"><span>indent_style = space\n<\/span><\/span><span style=\"display:flex;\"><span>indent_size = <span style=\"color:#fe640b\">2<\/span>\n<\/span><\/span><\/code><\/pre><\/div>"},{"title":"LSP in Neovim","link":"https:\/\/kxsh.dev\/notes\/2025-11-05-lsp\/","pubDate":"Wed, 05 Nov 2025 18:27:18 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-05-lsp\/","description":"<p>Language Server Protocol (LSP) allows our text editors to communicate with another program using a simple client-server architecture.\nThis protocol allows us to write programs that can operate with and manipulate the state of the editor.\nSuch programs often operate on a specific programming language, and are thus called &ldquo;Language Servers&rdquo;.\nThe text editors are the &ldquo;Clients&rdquo;.<\/p>\n<p>A common usecase is to look up definition of the symbol under our cursor.<\/p>\n<p>Fortunately, Neovim ships with an <a href=\"https:\/\/neovim.io\/doc\/user\/lsp.html\">LSP client<\/a>.\nWe just need to install and configure the Language Servers for the programming languages that we intend to work with.<\/p>\n<p><a href=\"https:\/\/github.com\/neovim\/nvim-lspconfig\"><code>nvim-lspconfig<\/code><\/a> plugin helps us configure our Language Servers with sensible defaults. We scaffold a new plugin under <code>~\/.config\/nvim\/lua\/config\/plugins\/lsp.lua<\/code>:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua\" data-lang=\"lua\"><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">return<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#34;neovim\/nvim-lspconfig&#34;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> config <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span>()\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">end<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>We can use the command <code>:help lspconfig-all<\/code> to discover relevant Language Servers for our programming languages.\nAfter we follow the installation instructions from the specific Language Server, we validate that Neovim LSP client can discover our Language Server with the following helper:<\/p>\n<p><code>:echo executable('&lt;our-ls-server&gt;')<\/code><\/p>\n<p>I have added <code>:help ins-completion<\/code> to my reading list to learn more about completion keybindings.<\/p>\n<p>{{ notice <code>gx<\/code> on a hyperlink under the cursor opens the link in the default browser. }}<\/p>"},{"title":"Compilers","link":"https:\/\/kxsh.dev\/notes\/2025-11-05-compilers\/","pubDate":"Wed, 05 Nov 2025 14:09:51 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-05-compilers\/","description":"<p>Bookmarking this page as a reference for compiler choices.<\/p>"},{"title":"Mr. TIFF","link":"https:\/\/kxsh.dev\/notes\/2025-11-05-tiff\/","pubDate":"Wed, 05 Nov 2025 13:48:58 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-05-tiff\/","description":"<p>Even though web browsers do not render TIFF images natively, I find them easy to operate on for my trivial image manipulation tasks.<\/p>\n<p>Thanks to John Buck for investigating and sharing the history of the TIFF format.\nIt&rsquo;s sad to hear about the passing of Stephen Carlsen - the creator of the TIFF format.<\/p>\n<p>Rest in Peace, Mr. TIFF - Stephen Carlsen.<\/p>"},{"title":"The Conversation Loop | Termagent","link":"https:\/\/kxsh.dev\/notes\/2025-11-04-termagent\/","pubDate":"Tue, 04 Nov 2025 22:26:52 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-04-termagent\/","description":"<p>Really enjoyed part 2 of this series from my colleague.\nIt&rsquo;s never a bad time to read some LISP.<\/p>"},{"title":"Valdrada","link":"https:\/\/kxsh.dev\/posts\/2025-11-04-valdrada\/","pubDate":"Tue, 04 Nov 2025 18:33:03 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-11-04-valdrada\/","description":"<p>Check out <a href=\"https:\/\/valdrada.kxsh.dev\/\">Valdrada<\/a> - a small tool I built while learning Dithering effect.<\/p>"},{"title":"Treesitter Basics and Installation","link":"https:\/\/kxsh.dev\/notes\/2025-11-04-treesitter\/","pubDate":"Tue, 04 Nov 2025 17:38:07 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-04-treesitter\/","description":"<p>tldr: I still do not understand Treesitter but this intro was helpful.<\/p>\n<p>Treesitter powers a powerful set of applications for working with text.\nThis includes syntax highlighting, indentation.<\/p>\n<p>Language parsers and queries power Treesitter.\nThe language parsers are incremental so the editor does not need to parse the\nentire buffer as we edit.\nQueries allow us to query the parsed Abstract Syntax Tree (AST).\nThe queries are declared in Scheme Programming Language.<\/p>\n<p>Neovim provides the engine to run Treesitter - running a parser on the text in\nthe buffer. We need to <code>nvim-treesitter<\/code> plugin to keep up to date with\ncommunity maintained language parsers and queries.<\/p>\n<p>We define the <code>treesitter.lua<\/code> plugin as follows:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua\" data-lang=\"lua\"><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">return<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#34;nvim-treesitter\/nvim-treesitter&#34;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> branch <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;master&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> lazy <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">false<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> build <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#34;:TSUpdate&#34;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> config <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span>()\n<\/span><\/span><span style=\"display:flex;\"><span> require<span style=\"color:#40a02b\">&#39;nvim-treesitter.configs&#39;<\/span>.setup {\n<\/span><\/span><span style=\"display:flex;\"><span>\t<span style=\"color:#9ca0b0;font-style:italic\">-- A list of parser names, or &#34;all&#34; (the listed parsers MUST always be installed)<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\tensure_installed <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> { <span style=\"color:#40a02b\">&#34;c&#34;<\/span>, <span style=\"color:#40a02b\">&#34;lua&#34;<\/span>, <span style=\"color:#40a02b\">&#34;vim&#34;<\/span>, <span style=\"color:#40a02b\">&#34;vimdoc&#34;<\/span>, <span style=\"color:#40a02b\">&#34;query&#34;<\/span>, <span style=\"color:#40a02b\">&#34;markdown&#34;<\/span>, <span style=\"color:#40a02b\">&#34;markdown_inline&#34;<\/span> },\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t<span style=\"color:#9ca0b0;font-style:italic\">-- Install parsers synchronously (only applied to `ensure_installed`)<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\tsync_install <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">false<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>\thighlight <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span>\t enable <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">true<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t <span style=\"color:#9ca0b0;font-style:italic\">-- Disable slow treesitter highlight for large files<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t disable <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span>(lang, buf)\n<\/span><\/span><span style=\"display:flex;\"><span>\t <span style=\"color:#d20f39\">local<\/span> max_filesize <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">100<\/span> <span style=\"color:#04a5e5;font-weight:bold\">*<\/span> <span style=\"color:#fe640b\">1024<\/span> <span style=\"color:#9ca0b0;font-style:italic\">-- 100 KB<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t <span style=\"color:#d20f39\">local<\/span> ok, stats <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))\n<\/span><\/span><span style=\"display:flex;\"><span>\t <span style=\"color:#8839ef\">if<\/span> ok <span style=\"color:#04a5e5;font-weight:bold\">and<\/span> stats <span style=\"color:#04a5e5;font-weight:bold\">and<\/span> stats.size <span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> max_filesize <span style=\"color:#8839ef\">then<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t <span style=\"color:#8839ef\">return<\/span> <span style=\"color:#fe640b\">true<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t <span style=\"color:#8839ef\">end<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t <span style=\"color:#8839ef\">end<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>\t additional_vim_regex_highlighting <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">false<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span>\t},\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">end<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div>"},{"title":"Linkers part 1","link":"https:\/\/kxsh.dev\/notes\/2025-11-04-linker\/","pubDate":"Tue, 04 Nov 2025 09:57:03 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-04-linker\/","description":"<p>A bit about computer programming history.<\/p>\n<p>Software dev pipeline in good ol&rsquo; days:<\/p>\n<ol>\n<li>Human writes code (in C)<\/li>\n<li>Compiles<\/li>\n<li>Human readable assembly code<\/li>\n<li>Assembles<\/li>\n<li>Machine executable code<\/li>\n<\/ol>\n<p>But we need shared libraries to reuse subroutines:<\/p>\n<ol>\n<li>Human writes code (in C)<\/li>\n<li>Compiles<\/li>\n<li>Human readable assembly code<\/li>\n<li>Assembles<\/li>\n<li>Generates an <strong>object file<\/strong>.<\/li>\n<li>Shared Library assembly code<\/li>\n<li>Assembles<\/li>\n<li>Generates another <strong>object file<\/strong>.<\/li>\n<li>Linker<\/li>\n<li>Combines multiple object files together into a single executable.<\/li>\n<\/ol>"},{"title":"A Cartoon Intro to WebAssembly","link":"https:\/\/kxsh.dev\/notes\/2025-11-03-webassembly\/","pubDate":"Mon, 03 Nov 2025 21:20:49 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-03-webassembly\/","description":"<p>Engaging and theorical introduction to WebAssembly.<\/p>\n<p>The content has aged very well, considering GC landed in WebAssembly 3 spec only a couple of months ago.<\/p>"},{"title":"Configuring Neovim's Options","link":"https:\/\/kxsh.dev\/notes\/2025-11-03-neovim-options\/","pubDate":"Mon, 03 Nov 2025 18:56:23 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-03-neovim-options\/","description":"<p>What are Neovim options?<\/p>\n<p>We can define editor configuration options (such as font size, tab width) via\nthe <code>vim.opt<\/code> Lua table.\nWe manipulate it as desired to achieve our desired global editor setup.<\/p>\n<h2 id=\"options-per-language\">Options per language<\/h2>\n<p>Suppose we prefer certain options based on the file.\nIn my Python files, I want to use a 4-character width space indentation.\nWhile my Lua files should be indented with 2-character width.<\/p>\n<p>Neovim has a solution for this - it allows us to specify options that are\nscoped to a particular filetype.<\/p>\n<blockquote>\n<p>Vim can detect the type of file that is edited. This is done by checking the\nfile name and sometimes by inspecting the contents of the file for specific\ntext.<\/p>\n<\/blockquote>\n<p>Read more about the <code>:filetype<\/code> in <a href=\"https:\/\/neovim.io\/doc\/user\/filetype.html#file-type\">the Neovim documentation about Filetype<\/a><\/p>\n<p>The setup is a bit clunky to be honest.<\/p>\n<p>We need to create a specific file in a specific path with our options.\n(This convention-over-configuration pattern reminds me a lot of Ruby on Rails).<\/p>\n<p>For my desired setup above, I need to create a new dir with a couple of files:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># pwd = ~\/.config\/nvim<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>mkdir after\/ftplugin\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Create Python config<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>touch after\/ftplugin\/python.lua\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Create Lua config<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>touch after\/ftplugin\/lua.lua\n<\/span><\/span><\/code><\/pre><\/div><p>We can define the options that are set by Neovim whenever it detects a Python\nfile in the open buffer.\nNote: Just like CSS, the language specific config overrides the global config.<\/p>\n<p><strong>~\/.config\/nvim\/after\/ftplugin\/python.lua<\/strong><\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua\" data-lang=\"lua\"><span style=\"display:flex;\"><span>vim.opt_local.shiftwidth <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">4<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p><strong>~\/.config\/nvim\/after\/ftplugin\/lua.lua<\/strong><\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua\" data-lang=\"lua\"><span style=\"display:flex;\"><span>vim.opt_local.shiftwidth <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">2<\/span>\n<\/span><\/span><\/code><\/pre><\/div>"},{"title":"lazy.nvim explained","link":"https:\/\/kxsh.dev\/notes\/2025-11-02-lazy-nvim\/","pubDate":"Sun, 02 Nov 2025 10:24:09 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-02-lazy-nvim\/","description":"<p><em>Ref: <a href=\"https:\/\/www.youtube.com\/watch?v=_kPg0VBRxJc&amp;list=PLep05UYkc6wTyBe7kPjQFWVXTlhKeQejM&amp;index=4\">lazy.nvim explained - TJ DeVries | YouTube<\/a><\/em><\/p>\n<p>Neovim extends the Vim API to enable developers to tweak the editor to their\nliking. This capability has led to a rich ecosystem of open source plugins to\nsolve simple problems using code written in Lua (or VimScript).\nHowever, it the the dev&rsquo;s responsibility to maintain their own setup.\nJust like any programming language ecosystem, the need for a plugin manager to\nhelp us manage, organize and optimize our local setup emerges.<\/p>\n<p><code>lazy.nvim<\/code> is one such popular plugin manager for Neovim.<\/p>\n<h2 id=\"runtime-paths\">Runtime Paths<\/h2>\n<p>Neovim searches for the editor configurations (plugins, colorschemes, keymaps)\nin user specified list of system paths.\n&ldquo;Runtime Paths&rdquo; (or <code>rtp<\/code> variable) specify such directory paths on our system.\nConsider them analogous to the shell&rsquo;s <code>PATH<\/code> variable for loading executable binaries.<\/p>\n<p>The current runtimepaths can be listed with the following command:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-vim\" data-lang=\"vim\"><span style=\"display:flex;\"><span>:echo &amp;rtp\n<\/span><\/span><\/code><\/pre><\/div><p>Note: We need to update the list of runtime paths with any of our custom configurations.<\/p>\n<p>Specifically for plugins (defined in Lua), Neovim looks for Lua files inside\nthe <code>lua\/<\/code> directory in each of the runtime path.<\/p>\n<p>Ex: <code>require(&quot;config.lazy&quot;)<\/code> resolves to looking up the <code>\/lua\/config\/lazy.lua<\/code> file.<\/p>\n<h2 id=\"installing-lazynvim\">Installing <code>lazy.nvim<\/code><\/h2>\n<p>Here is the <a href=\"https:\/\/lazy.folke.io\/installation\">installation guide<\/a> for <code>lazy.nvim<\/code>.<\/p>\n<p>TJ excellently breaks down how the bootstrapped lazy config that we copy-paste\nfrom the official documentation.<\/p>\n<ul>\n<li>Clone the <code>lazy.nvim<\/code> GitHub repo to the &ldquo;data&rdquo; path.<\/li>\n<li>Add the lazy package manager to our runtime paths - allowing us to load the\ndefault plugins.<\/li>\n<\/ul>\n<h3 id=\"healthcheck\">Healthcheck<\/h3>\n<p>Neovim provides a mechanism to perform health checks across all the plugins\ninstalled on the system.<\/p>\n<p>The health check for <code>lazy.nvim<\/code> - <code>:checkhealth lazy<\/code> command - returns\nthe following warning on my machine related to <code>lua<\/code> versioning and <code>luarocks<\/code>.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-md\" data-lang=\"md\"><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">-<\/span> \u26a0\ufe0f WARNING <span style=\"color:#40a02b\">`lua`<\/span> version <span style=\"color:#40a02b\">`5.1`<\/span> needed, but found `Lua 5.4.8 Copyright (C)\n<\/span><\/span><span style=\"display:flex;\"><span>1994-2025 Lua.org, PUC-Rio<span style=\"color:#40a02b\">`\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#40a02b\">- \u26a0\ufe0f WARNING {lua5.1} or {lua} or {lua-5.1} version `<\/span>5.1` not installed\n<\/span><\/span><\/code><\/pre><\/div><p>I will have a look at\n<a href=\"https:\/\/github.com\/folke\/lazy.nvim\/discussions\/1551\">this related discussion<\/a>\nlater as it is safe to ignore for now.<\/p>\n<p>side note: I need to assume <code>sudo<\/code> role to use Neovim on my machine.<\/p>\n<p>With our Lazy set up, let&rsquo;s start adding plugins.<\/p>\n<h2 id=\"using-catppuccin-as-our-colorscheme\">Using Catppuccin as our <code>colorscheme<\/code><\/h2>\n<p>I would like to maintain consistency across all of my text editors and terminals.\nThis requires me to chose to use the Catppuccin theme for Neovim.\nFortunately, I need to simply use the <a href=\"https:\/\/github.com\/catppuccin\/nvim\"><code>catppuccin.nvim<\/code> plugin<\/a>.<\/p>\n<p>Setting the color scheme is a 2-step process:<\/p>\n<ol>\n<li>Install the plugin.<\/li>\n<li>Activate the colorscheme.<\/li>\n<\/ol>\n<p>Luckily for us, we can do both the operations with a single code block as follows:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua:init.lua\" data-lang=\"lua:init.lua\"><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">-- Setup lazy.nvim<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>require(<span style=\"color:#40a02b\">&#34;lazy&#34;<\/span>).setup({\n<\/span><\/span><span style=\"display:flex;\"><span> spec <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">-- Set Catppuccin as the colorscheme.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#34;catppuccin\/nvim&#34;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> name <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#34;catppuccin&#34;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> priority <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">1000<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> config <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span> ()\n<\/span><\/span><span style=\"display:flex;\"><span> vim.cmd.colorscheme <span style=\"color:#40a02b\">&#34;catppuccin&#34;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">end<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> },\n<\/span><\/span><span style=\"display:flex;\"><span> },\n<\/span><\/span><span style=\"display:flex;\"><span>})\n<\/span><\/span><\/code><\/pre><\/div><h2 id=\"tweak-the-statusline-with-mininvim\">Tweak the <code>statusline<\/code> with <code>mini.nvim<\/code><\/h2>\n<p>Just for variety, we use an import-style spec for setting up the collection of\nplugins from <a href=\"https:\/\/github.com\/nvim-mini\/mini.nvim\"><code>mini.nvim<\/code><\/a>.<\/p>\n<p>Create a <code>mini.lua<\/code> file within a newly created <code>plugins<\/code> dir.\nThe current config directory structure:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>$ tree .\n<\/span><\/span><span style=\"display:flex;\"><span>.\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 init.lua\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 lazy-lock.json\n<\/span><\/span><span style=\"display:flex;\"><span>\u2514\u2500\u2500 lua\n<\/span><\/span><span style=\"display:flex;\"><span> \u2514\u2500\u2500 config\n<\/span><\/span><span style=\"display:flex;\"><span> \u251c\u2500\u2500 lazy.lua\n<\/span><\/span><span style=\"display:flex;\"><span> \u2514\u2500\u2500 plugins\n<\/span><\/span><span style=\"display:flex;\"><span> \u2514\u2500\u2500 mini.lua\n<\/span><\/span><\/code><\/pre><\/div><div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua:lua\/config\/plugins\/mini.lua\" data-lang=\"lua:lua\/config\/plugins\/mini.lua\"><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">return<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#39;nvim-mini\/mini.nvim&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> version <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;*&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> config <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span>()\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">local<\/span> statusline <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> require <span style=\"color:#40a02b\">&#39;mini.statusline&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> statusline.setup { use_icons <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">true<\/span> }\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">end<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>Note: Use <code>enabled = false<\/code> to toggle a specific plugin off.<\/p>\n<hr>"},{"title":"Everything You Need To Start Writing Lua","link":"https:\/\/kxsh.dev\/notes\/2025-11-01-lua-crash-course\/","pubDate":"Sat, 01 Nov 2025 16:11:02 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-11-01-lua-crash-course\/","description":"<p>Today&rsquo;s session was a theoretical introduction to the Lua programming language.\nLua is the primary language used to define Neovim configurations.\nNeovim also supports Vimscript. Thus, it is backwards compatible with Vim plugins.\nHowever, a lot of the popular Neovim plugins are written in Lua.<\/p>\n<p>Lua uses &ldquo;Mechanisms over Policies&rdquo;.\nWe compose implementations using fundamental building blocks.\nFunctions are first-class citizens.\nTables are effectively only data structure that must be used to define lists, and maps.\nModules are just files.<\/p>\n<h3 id=\"highlight-yank-text\">Highlight Yank Text<\/h3>\n<p>We define a few simple configuration as an exercise to explore Lua.<\/p>\n<p>Specifically, a useful suggestion from Bram Moolenaar in his talk was to highlight the text we copy (or yank) while editing. This provides a nice visual feedback to the user with proper demarcation of the text boundaries.<\/p>\n<p><code>:set hlsearch<\/code><\/p>\n<blockquote>\n<p>An autocommand is a command that is executed automatically in response to some event &hellip;<\/p>\n<\/blockquote>\n<p>We create a &ldquo;event listener&rdquo; whenever the user yanks a piece of text in the buffer.\nThe event that we need to handle is <code>TextYankPost<\/code>.\nThe function to highlight text is <code>highlight.on_yank()<\/code>.\nWe just need to define an &ldquo;autocommand&rdquo; and hook up the event handler - similar to how we handle DOM events in JS.<\/p>\n<p>Here is my current <code>init.lua<\/code>:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua\" data-lang=\"lua\"><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">-- Highlight when yanking text<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">-- See `:help vim.highlight.on_yank()`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>vim.api.nvim_create_autocmd(<span style=\"color:#40a02b\">&#39;TextYankPost&#39;<\/span>, {\n<\/span><\/span><span style=\"display:flex;\"><span>\tdesc <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;Highlight when yanking text&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span>\tgroup <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> vim.api.nvim_create_augroup(<span style=\"color:#40a02b\">&#39;kickstart-highlight-yank&#39;<\/span>, { clear <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">true<\/span> }),\n<\/span><\/span><span style=\"display:flex;\"><span>\tcallback <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span>()\n<\/span><\/span><span style=\"display:flex;\"><span>\t\tvim.highlight.on_yank()\n<\/span><\/span><span style=\"display:flex;\"><span>\t<span style=\"color:#8839ef\">end<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span>})\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">-- Dev setup to work with Neovim configs.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>vim.keymap.set(<span style=\"color:#40a02b\">&#34;n&#34;<\/span>, <span style=\"color:#40a02b\">&#34;&lt;space&gt;&lt;space&gt;x&#34;<\/span>, <span style=\"color:#40a02b\">&#34;&lt;cmd&gt;source %&lt;CR&gt;&#34;<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>vim.keymap.set(<span style=\"color:#40a02b\">&#34;n&#34;<\/span>, <span style=\"color:#40a02b\">&#34;&lt;space&gt;x&#34;<\/span>, <span style=\"color:#40a02b\">&#34;:.lua&lt;CR&gt;&#34;<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>vim.keymap.set(<span style=\"color:#40a02b\">&#34;v&#34;<\/span>, <span style=\"color:#40a02b\">&#34;&lt;space&gt;x&#34;<\/span>, <span style=\"color:#40a02b\">&#34;:lua&lt;CR&gt;&#34;<\/span>)\n<\/span><\/span><\/code><\/pre><\/div><p>I learnt a bit about defining keymaps and using Neovim&rsquo;s <code>:help<\/code> command to\nread about new functions like <code>nvim_create_autocmd<\/code>.\nCombined with <kbd>K<\/kbd>\n, <kbd>C-i<\/kbd>\n, and <kbd>C-o<\/kbd>\n for navigating links, I had a lot of fun putting these pieces together. However, I still don&rsquo;t understand the significance of defining the &ldquo;group&rdquo; at the moment.<\/p>"},{"title":"CSS Grid: A helpful mental model and the power of grid lines","link":"https:\/\/kxsh.dev\/notes\/2025-10-31-css-grid\/","pubDate":"Fri, 31 Oct 2025 22:35:56 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-31-css-grid\/","description":"<p>Think of CSS Grid almost as a spreadsheet i.e. define the columns and rows as structure\/template for the content that goes into it. Hence, we define <code>grid-template-columns<\/code> and <code>grid-template-rows<\/code> attributes on the parent container.\nMostly, it makes sense to use proportional values in the context of templates i.e. use <code>fr<\/code> units.<\/p>\n<p>Use <code>grid-auto-rows<\/code> and <code>grid-auto-columns<\/code> to define how the grid handles extra content in the container.<\/p>\n<p>Grids work with the concept of grid lines (indexed from 1).\nWe address &ldquo;cells&rdquo; or children of the grid via a pair of start and end grid lines as <code>x\/y<\/code> (e.g. <code>1\/3<\/code>).\nThis looks strange to me because a pair of coordinate values are usually represented as <code>(x, y)<\/code> in regular mathematics.<\/p>\n<blockquote>\n<p>Grid prioritized explicitly positioned elements over implicitly positioned ones.<\/p>\n<\/blockquote>\n<p>Children cells, if need be, should be positioned with <code>grid-row<\/code> and <code>grid-column<\/code> as desired in the grid system.<\/p>\n<p>Really well written article, except for 1 typo (<code>some<\/code> instead of <code>come<\/code>).<\/p>"},{"title":"Neovim Tutor","link":"https:\/\/kxsh.dev\/notes\/2025-10-31-neovim-tutor\/","pubDate":"Fri, 31 Oct 2025 18:52:01 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-31-neovim-tutor\/","description":"<p>Today, I spent about 30 mins to go over the <code>:Tutor<\/code> Chapter 1.<\/p>\n<p>The only time-tested method for learning hard skills (like editing efficiently\nwith Neovim) is to get our hands dirty through practice.<\/p>\n<p>Vim packs too many commands to memorize. At least that&rsquo;s how I see it.\nWe compose operators, count and motion together to express an idea similar to a language.<\/p>\n<p>We do not learn every word defined in the Oxford dictionary before we composed\nour first essay, do we?\nThis would imply putting the cart before the horse.<\/p>\n<p>Instead of memorizing commands, the approach is to learn just enough to begin\nwith and proactively grow the knowledge base as I think about specific problems.<\/p>\n<ol>\n<li>Be on the outlook for common patterns in the operations I perform.<\/li>\n<li>Research for a simpler set of motions to achieve the same result.<\/li>\n<li>Repeat, and hopefully memorize it through practice.<\/li>\n<\/ol>\n<p>Ex: Instead of moving around in Insert mode (like I would in any other editor),\nI deliberately move around in Normal mode - using Vim motions as much as possible.<\/p>\n<p>This would definitely slow me down to begin with, but thanks to LLM assisted\nprogramming I have a lot more time on my hand. &#x1f609;<\/p>"},{"title":"Advent of Neovim: Why Neovim?","link":"https:\/\/kxsh.dev\/notes\/2025-10-30-advent-of-neovim\/","pubDate":"Thu, 30 Oct 2025 21:09:58 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-30-advent-of-neovim\/","description":"<h4 id=\"installing-neovim\">Installing Neovim<\/h4>\n<p>We can conveniently install Neovim using a system supported package manager\n(like Homebrew on Mac, pacman on Arch).\nBut I followed TJ&rsquo;s suggestion to <a href=\"https:\/\/github.com\/neovim\/neovim\/blob\/master\/BUILD.md#quick-start\">install from source<\/a>\non my machine (14&quot; Macbook with M3 Pro chip).<\/p>\n<p>For posterity, I want to details the steps involved:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Clone the repo<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>git clone https:\/\/github.com\/neovim\/neovim\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Install all dependencies on my system<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>xcode-select --install\n<\/span><\/span><span style=\"display:flex;\"><span>brew install ninja cmake gettext curl git\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Follow the build instructions<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5\">cd<\/span> neovim\n<\/span><\/span><span style=\"display:flex;\"><span>make <span style=\"color:#dc8a78\">CMAKE_BUILD_TYPE<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span>RelWithDebInfo\n<\/span><\/span><span style=\"display:flex;\"><span>sudo make install\n<\/span><\/span><\/code><\/pre><\/div><p>If everything goes well with the above build process, we should be able to\ncheckout the newly built binary<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>$ ls -lah \/usr\/local\/bin\/nvim\n<\/span><\/span><span style=\"display:flex;\"><span>-rwxr-xr-x@ <span style=\"color:#fe640b\">1<\/span> root wheel 7.5M Oct <span style=\"color:#fe640b\">30<\/span> 19:47 \/usr\/local\/bin\/nvim\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Check whether nvim binary is in the PATH or not.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>$ nvim -v\n<\/span><\/span><span style=\"display:flex;\"><span>NVIM v0.12.0-dev-1548+g5ddabbeba4\n<\/span><\/span><span style=\"display:flex;\"><span>Build type: RelWithDebInfo\n<\/span><\/span><span style=\"display:flex;\"><span>LuaJIT 2.1.1761727121\n<\/span><\/span><span style=\"display:flex;\"><span>Run <span style=\"color:#40a02b\">&#34;nvim -V1 -v&#34;<\/span> <span style=\"color:#8839ef\">for<\/span> more info\n<\/span><\/span><\/code><\/pre><\/div><p>The build took less than a minute and takes only 7.5 MB (compared to 5.4 MB for <code>vim<\/code>).\n(Tip: It might not be a bad idea to add <code>\/usr\/local\/bin<\/code> to the shell <code>PATH<\/code>.)<\/p>\n<h4 id=\"first-config-initlua\">First config: <code>init.lua<\/code><\/h4>\n<p>Next step is to write a &ldquo;Hello World&rdquo; equivalent with a configuration file -\nfollowing programming traditions.\nLua is our scripting language of choice instead of Vimscript.\nOur first config file will be called <code>init.lua<\/code>.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Create a Neovim config dir for my user<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>mkdir -p ~\/.config\/nvim\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5\">cd<\/span> ~\/.config\/nvim\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># Create the config file<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>touch init.lua\n<\/span><\/span><\/code><\/pre><\/div><p>The idea is to get familiar with basic editing skills in Neovim.\nNot to mention exiting out of the editor.<\/p>\n<h4 id=\"sourcing\">Sourcing<\/h4>\n<p>We source the current &ldquo;file&rdquo; buffer to execute the code from top to bottom with\nthe command:\n<code>:source %<\/code><\/p>\n<p>We can source a visual selection with the command:\n<code>:lua<\/code><\/p>\n<h4 id=\"conclusion\">Conclusion<\/h4>\n<p>I spent a few minutes to play around with the <code>init.lua<\/code>.\nHere is my current config.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-lua\" data-lang=\"lua\"><span style=\"display:flex;\"><span>wisdom <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#8839ef\">function<\/span>()\n<\/span><\/span><span style=\"display:flex;\"><span> quotes <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#34;Only the autodidacts are free&#34;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span> print(quotes[math.random(<span style=\"color:#04a5e5;font-weight:bold\">#<\/span>quotes)])\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">end<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>email <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#34;hi@kxsh.dev&#34;<\/span>;\n<\/span><\/span><\/code><\/pre><\/div><p>Now, I can get some NNT wisdom inside my Neovim with <code>:lua wisdom()<\/code>!<\/p>\n<p>This was extremely fun and I look forward to tomorrow.<\/p>"},{"title":"My Neovim Story","link":"https:\/\/kxsh.dev\/posts\/2025-10-30-neovim\/","pubDate":"Thu, 30 Oct 2025 20:11:11 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-10-30-neovim\/","description":"<p>I tried out Vim during uni days, before giving it up in favour of Sublime Text.\nVSCode has been my mainstay for the last 5 years.<\/p>\n<p>One day at work, a senior colleague forgot to bring along his mouse. He chose to\nspend the entire day primarily driving from his split keyboard.\nThis made me wonder how difficult would it be to center my workflows around a\nkeyboard instead of the mouse. I mentioned this to him over lunch and he\nsuggested me to check out Neovim.<\/p>\n<p>Over dinner that evening, I installed Neovim and set it up using\n<a href=\"https:\/\/www.youtube.com\/watch?v=m8C0Cq9Uv9o\">TJ DeVries&rsquo; Kickstart.nvim<\/a> configuration.\nI practiced the <code>:Tutor<\/code> daily for a week. The 8th day I uninstalled VSCode from\nmy machine.<\/p>\n<p>Since then, I have extended this config with many plugins, and LSPs to suit a\nvast majority of dev tasks, including writing this post.\nDespite I still need GUI Text Editors for LLM-driven development sometimes.\n(The fallback is to Zed with Vim Motions.)<\/p>\n<p>Now, I intend to understand various concepts involved in configuring Neovim.\nTJ published a YouTube playlist titled <a href=\"https:\/\/www.youtube.com\/playlist?list=PLep05UYkc6wTyBe7kPjQFWVXTlhKeQejM\">Advent of Neovim<\/a>\nthat I intend to follow over the next month.<\/p>"},{"title":"A brief history of random numbers","link":"https:\/\/kxsh.dev\/notes\/2025-10-29-rng\/","pubDate":"Wed, 29 Oct 2025 12:05:31 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-29-rng\/","description":"<p>I have never user a slide rule.\nBut this was a very interesting read about how the process to generate random numbers has evolved.<\/p>\n<p>Software tech is only a tiny piece in the puzzle.<\/p>\n<p>TODO: Study and implement a simple PCG algorithm.<\/p>"},{"title":"The Programmer Identity Crisis","link":"https:\/\/kxsh.dev\/notes\/2025-10-29-programmer\/","pubDate":"Wed, 29 Oct 2025 10:32:45 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-29-programmer\/","description":"<blockquote>\n<p>Creative puzzle-solving is left to the machines, and we become mere operators\ndisassociated from our craft.<\/p>\n<\/blockquote>\n<p>We are trading the craftsmanship of software development with &ldquo;apparent&rdquo; speed\nprovided by LLMs.<\/p>"},{"title":"What's Left for Frontend Engineers?","link":"https:\/\/kxsh.dev\/notes\/2025-10-28-webdev\/","pubDate":"Tue, 28 Oct 2025 13:38:31 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-28-webdev\/","description":"<p>I pulled this talk out of my antilibrary today.<\/p>\n<p>Sending HTML (instead of JSON) as the data exchange format looks unfamiliar at first.\nBut semantically the same data is encoded.\nMoreover, <em>HTML encodes both data and behavior, unlike JSON<\/em>.<\/p>\n<p>Frontend engineering: putting hypermedia to work<\/p>\n<h5 id=\"task-a-build-the-structure-templates-fragments-css\">Task A: Build the structure: templates, fragments, CSS<\/h5>\n<p>Simplify the approach to building web apps from a frontend - backend dichotomy\nto a unified templating powered system.<\/p>\n<h5 id=\"task-b-write-new-html-elements\">Task B: Write new HTML elements<\/h5>\n<p>Use Web Components together with enough JS glue code to provide interactivity.<\/p>\n<p>Aside: A 10x engineer makes their 5 colleagues 2x more effective.<\/p>\n<h5 id=\"task-c-be-the-browser-expert-security-accessibility-interactivity\">Task C: Be the browser expert (security, accessibility, interactivity)<\/h5>\n<blockquote>\n<p>Always ask: could this JS be HTML or CSS?<\/p>\n<\/blockquote>\n<p>Leverage existing, declarative constructs like Grid Layout wherever possible.<\/p>\n<p>Consider perf optimizations:<\/p>\n<ul>\n<li>Cache-control headers<\/li>\n<li>Image resizing<\/li>\n<li>Avoid blocking on slow\/large assets<\/li>\n<\/ul>"},{"title":"Letter from Huxley to Orwell about 1984","link":"https:\/\/kxsh.dev\/notes\/2025-10-28-dystopia\/","pubDate":"Tue, 28 Oct 2025 12:13:52 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-28-dystopia\/","description":"<p>Gentle reminder to self: Re-read &ldquo;Brave New World&rdquo;, &ldquo;Brave New World Revisited&rdquo;,\nand &ldquo;Island&rdquo;.<\/p>"},{"title":"Wat","link":"https:\/\/kxsh.dev\/notes\/2025-10-28-wat\/","pubDate":"Tue, 28 Oct 2025 12:10:49 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-28-wat\/","description":"<p>Rediscovered this classic ~4 mins of pure joy.<\/p>"},{"title":"Understanding the Execution Plan of a Hash Join","link":"https:\/\/kxsh.dev\/notes\/2025-10-28-pg-hash-join\/","pubDate":"Tue, 28 Oct 2025 12:01:18 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-28-pg-hash-join\/","description":"<p>The PostgreSQL query planner can flip the join sides for efficiency.\nSo, what you see is not what you get.<\/p>\n<p>LEFT JOINs can be RIGHT JOINs under the surface.<\/p>\n<p>TODO: Dive a bit deeper into how this works and understand the implications.<\/p>"},{"title":"We're in the Wrong Moment","link":"https:\/\/kxsh.dev\/notes\/2025-10-27-wrong-moment\/","pubDate":"Mon, 27 Oct 2025 11:26:18 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-27-wrong-moment\/","description":"<p>A bit of a gloomy post for Monday morning.\nBut I drift towards the same question:\ngiven the state (and continuous rise) of LLM powered GenAI, are software engineering skills soon going to be a sunk cost?<\/p>\n<blockquote>\n<p>I\u2019m not sure if anyone else feels this way, but with the introduction of generative AI, I don\u2019t find coding fun anymore. It\u2019s hard to motivate myself to code knowing that a model can do it much quicker.<\/p>\n<\/blockquote>\n<p>I related to this.\nMy workaround is to not use LLMs on my personal projects - embrace the &ldquo;inefficiency&rdquo;.\nThis is a personal tradeoff I choose.<\/p>"},{"title":"Out of the way and a little inconvenient","link":"https:\/\/kxsh.dev\/notes\/2025-10-26-bottom\/","pubDate":"Sun, 26 Oct 2025 11:36:54 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-26-bottom\/","description":"<blockquote>\n<p>\u201cYou can pick anyone, and we\u2019re anyone\u201d isn\u2019t going to be helpful going forward.\nBe someone instead.<\/p>\n<\/blockquote>\n<p>A product\/entity needs to standout in the rapidly mediocre global\nspace driven by Generative AI. While the cost of achieving feature parity is dropping,\nthe tax of standardization is increasing.<\/p>\n<p>A product needs to make a compelling argument to standout from the rest.<\/p>"},{"title":"I want to see the claw","link":"https:\/\/kxsh.dev\/notes\/2025-10-26-claw\/","pubDate":"Sun, 26 Oct 2025 11:24:35 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-26-claw\/","description":"<p>What does &ldquo;mastery&rdquo; in software look like in the age of generative code?<\/p>\n<p>Mediocrity would become the norm if we let generative code wild (YOLO mode).<\/p>\n<blockquote>\n<p>It (generative code) is the average of all publicly available software,\nupdated at some cadence and mixed into training data soup and then RLHFed\naccording to some arbitrary metrics, and as such can only offer a ghost of quality.<\/p>\n<\/blockquote>"},{"title":"Code like a Surgeon","link":"https:\/\/kxsh.dev\/notes\/2025-10-25-code-surgeon\/","pubDate":"Sat, 25 Oct 2025 16:20:59 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-25-code-surgeon\/","description":"<blockquote>\n<p>The goal isn\u2019t to delegate your core work, it\u2019s to identify and delegate the\nsecondary grunt work tasks, so you can focus on the main thing that matters.<\/p>\n<\/blockquote>\n<p>This perspective resonates with how I feel about programming software these days.<\/p>"},{"title":"Controlled Feeds of Information","link":"https:\/\/kxsh.dev\/notes\/2025-10-24-rss-feed-org\/","pubDate":"Fri, 24 Oct 2025 21:00:47 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-24-rss-feed-org\/","description":"<blockquote>\n<p>If I\u2019m in the mood for something lighter, I can just look into my \u201cFun\u201d\nfolder to check out new stuff from The Oatmeal or xkcd. If I feel like\nreading something more thoughtful, I\u2019d dive into my \u201cReads\u201d folder for\nThe Marginalian or Sentiers.<\/p>\n<\/blockquote>\n<p>Really neat tip to organize the feeds!\nIn addition to the above, I have\n<a href=\"https:\/\/poorlydrawnlines.com\/\">Poorly Drawn Lines<\/a> in my &ldquo;fun&rdquo; folder.<\/p>"},{"title":"HTML Form Accessibility","link":"https:\/\/kxsh.dev\/notes\/2025-10-24-html-form-a11y\/","pubDate":"Fri, 24 Oct 2025 20:02:07 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-24-html-form-a11y\/","description":"<p>Practical tip on creating a more accessible input field with a label:<\/p>\n<p>Use explicit association with <code>for<\/code> and <code>id<\/code> HTML attributes instead of\nimplicit association when defining a form field.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-html\" data-lang=\"html\"><span style=\"display:flex;\"><span>&lt;<span style=\"color:#8839ef\">label<\/span> <span style=\"color:#1e66f5\">for<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#40a02b\">&#34;email&#34;<\/span>&gt;Email address&lt;\/<span style=\"color:#8839ef\">label<\/span>&gt;\n<\/span><\/span><span style=\"display:flex;\"><span>&lt;<span style=\"color:#8839ef\">input<\/span> <span style=\"color:#1e66f5\">id<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#40a02b\">&#34;email&#34;<\/span> <span style=\"color:#1e66f5\">type<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#40a02b\">&#34;email&#34;<\/span>&gt;\n<\/span><\/span><\/code><\/pre><\/div><p>over<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-html\" data-lang=\"html\"><span style=\"display:flex;\"><span>&lt;<span style=\"color:#8839ef\">label<\/span>&gt;\n<\/span><\/span><span style=\"display:flex;\"><span> Email address\n<\/span><\/span><span style=\"display:flex;\"><span> &lt;<span style=\"color:#8839ef\">input<\/span> <span style=\"color:#1e66f5\">type<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#40a02b\">&#34;email&#34;<\/span>&gt;\n<\/span><\/span><span style=\"display:flex;\"><span>&lt;\/<span style=\"color:#8839ef\">label<\/span>&gt;\n<\/span><\/span><\/code><\/pre><\/div>"},{"title":"TheStandup - Omarchy is Amazing | YouTube - ThePrimeTime","link":"https:\/\/kxsh.dev\/notes\/2025-10-24-thestandup-omarchy\/","pubDate":"Fri, 24 Oct 2025 17:52:52 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-24-thestandup-omarchy\/","description":"<p>Aside from the usual DHH rant, <a href=\"https:\/\/youtu.be\/ljGPvgMPOn8?si=ASRiSWLm-zeHNHrh&amp;t=2111\">this section<\/a> is worth reflecting on:<\/p>\n<blockquote>\n<p>Can I find more of such investments where it hurts for like a couple of days,\nand then maybe its annoying for a week, and then it&rsquo;s kind of incredible for\nthe next decade?<\/p>\n<\/blockquote>\n<p>Outside of the context of computers and tech, I believe this rationale can be\nextended to other areas of life for long term projects.<\/p>"},{"title":"Building multi-step login forms that work well with password managers","link":"https:\/\/kxsh.dev\/notes\/2025-10-13-building-multistep-login-forms\/","pubDate":"Mon, 13 Oct 2025 20:46:35 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-13-building-multistep-login-forms\/","description":"<p>Good reference to keep in mind when building login forms.\nAlso, I strongly dislike multi-step forms - to the point of abandoning the pursuit.<\/p>"},{"title":"Is Software Engineering a Relevant Skill?","link":"https:\/\/kxsh.dev\/posts\/2025-10-12-software-engineering-skill\/","pubDate":"Sun, 12 Oct 2025 19:33:02 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2025-10-12-software-engineering-skill\/","description":"<blockquote>\n<p>Does software engineering hold any value beyond a means to an end?\nIs the software more than a utilitarian tool?<\/p>\n<\/blockquote>\n<p>A perspective on this question affects what I can offer as an engineer.<\/p>\n<p>If we treat software as utilitarian, then autogenerated, YOLO-mode LLM generated\ncode might be good enough. Self-adaptive systems, if ever, might make it possible\nto generate code on-the-fly.<\/p>\n<p>Then again, if we believe software engineering holds an intrinsice value, is it\nstill worth pursuing?<\/p>\n<p>I suppose when you work on the frontier, it&rsquo;s difficult to turn your face away\nfrom this conversation. One can speculate whether the society would reward\nengineering in a few years.<\/p>\n<p>I don&rsquo;t have an answer but a belief. Humans are adaptable species, perhaps to a fault.\nThus, the question boils down to what kind of adaptations does this new\nopportunity demand of me? Is it worth it for me?<\/p>"},{"title":"Vibing a Non-Trivial Ghostty Feature | Mitchell Hashimoto","link":"https:\/\/kxsh.dev\/notes\/2025-10-11-vibing-ghostty-feature\/","pubDate":"Sat, 11 Oct 2025 21:08:49 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-11-vibing-ghostty-feature\/","description":"<p>A pretty balanced and insightful post by Mitchell Hashimoto on LLM augmented\ncode generation.<\/p>\n<blockquote>\n<p>I believe good AI drivers are experts in their domains and utilize\nAI as as assistant, not a replacement.<\/p>\n<\/blockquote>\n<p>Noted.<\/p>\n<p>First came the Big Picture, then the plan.\nDevelop an <em>agreeable enough<\/em> plan with the coding agent before implementing.<\/p>\n<p>&ldquo;oracle&rdquo; is not a bad name for an agent.<\/p>\n<blockquote>\n<p>I find the &ldquo;zero to one&rdquo; stage of creation very difficult and time consuming\nand AI is excellent at being my muse.<\/p>\n<\/blockquote>\n<p>Using LLM for inspiration - disposable, sandbox prototyping.<\/p>\n<blockquote>\n<p>I find agents do much better when they have both natural language descriptions\nas well as the code itself.<\/p>\n<\/blockquote>\n<p>Nice tip. I will try to be more cognizant of adding documentation for the\nLLM generated code blocks.<\/p>\n<blockquote>\n<p>AI is very good at fill-in-the-blank or draw-the-rest-of-the-owl. My pattern\nhere of creating scaffolding with descriptive function names, parameters, todo\ncomments, etc. is a really common one for me and it works very well.<\/p>\n<\/blockquote>\n<p>Very cool. I must try out this approach.<\/p>\n<p>One of the key insights is to consider room for improvements even after the\nfunctional requirements of the task are achieved.<\/p>"},{"title":"Armin Ronacher on the Pragmatic Engineer | YouTube","link":"https:\/\/kxsh.dev\/notes\/2025-10-08-armin-ronacher-on-the-pragmatic-engineer\/","pubDate":"Wed, 08 Oct 2025 22:44:10 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-08-armin-ronacher-on-the-pragmatic-engineer\/","description":"<p>Armin is the creator of a couple of Python frameworks that made programming fun\nfor me - Flask and click, more than a decade ago.\nNaturally, I have a lot of respect for him. So, I dialled in to hear him.\nHere are some of my notes from the converstation with Gergely:<\/p>\n<h3 id=\"python2-python3-migration\">Python2-&gt;Python3 Migration<\/h3>\n<p>Armin wrote an <a href=\"https:\/\/lucumr.pocoo.org\/2014\/5\/12\/everything-about-unicode\/\">insightful article<\/a>\nabout the complexity involved upgrading to Python3 - especially concerning strings.\nI need to refresh my memory about this.<\/p>\n<h3 id=\"split-brain-programming\">Split-brain programming<\/h3>\n<p>It&rsquo;s reassuring to hear Armin share that<\/p>\n<p>The discussion about how to approach picking programming language at a startup\nwas particularly relevant.\nThe importance of ecosystems while choosing a language: Static typing in Rust\nmakes it unsuitable for dynamic environments such as a fast paced startup.<\/p>\n<h3><\/h3>\n<p>&ldquo;The floor is raising; the ceiling not so much.&rdquo;\nThe expectation that everybody has everything is much higher than before.<\/p>\n<h3 id=\"switching-stance-on-llm\">Switching stance on LLM<\/h3>\n<p>Coding agents have become too good to ignore.\nMany projects did not go anywhere because they needed too much tooling\/legwork\nto achieve success. Now, the threshold is much lower.<\/p>"},{"title":"The Runner's Routine | Youtube","link":"https:\/\/kxsh.dev\/notes\/2025-10-06-the-runner-s-routine-youtube\/","pubDate":"Mon, 06 Oct 2025 23:19:42 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-10-06-the-runner-s-routine-youtube\/","description":"<p>Beautiful, motivating video yet again from Tracksmith.<\/p>"},{"title":"The Only Video You Need to Get Started with Neovim","link":"https:\/\/kxsh.dev\/notes\/2025-08-24-neovim-tj-devries\/","pubDate":"Sun, 24 Aug 2025 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-08-24-neovim-tj-devries\/","description":"<p>Every time I watch TJ explain the config, either I learn something new or refine\nexisting knowledge about my Neovim setup - new keymaps, LSP config that I can\nplay with.<\/p>"},{"title":"The ROI of exercise | Herman Martinus","link":"https:\/\/kxsh.dev\/notes\/2025-08-23-roi-of-exercise\/","pubDate":"Sat, 23 Aug 2025 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-08-23-roi-of-exercise\/","description":"<p>The argument to focus on <em>Quality of life-years<\/em> instead of\n<em>Quantity of life-years<\/em> is compelling. A part of me related to the ability of\nfocused hard work translating into sustainable energy into other aspects of our life.<\/p>"},{"title":"Build a Large Language Model (From Scratch)","link":"https:\/\/kxsh.dev\/posts\/bllm\/","pubDate":"Sat, 16 Aug 2025 12:07:44 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/bllm\/","description":"<p>At my current role, I have been building a few Agentic workflows using LLMs.\nWhile the work has mostly revolved around practical applications of GenAI, the\nprocess has made me curious about learning how the LLM model work internally.\nSo I watched a couple of videos to skim the basic ideas involved.\nBut I want to dive deeper - hopefully implement a small toy project.<\/p>\n<p>Thus, I have picked up a book recommended to me by a friend - Build an LLM from\nScratch by Sebastian Raschka<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>.\nThe author recorded a complimentary video series that covers a lot of the\nconcepts from the book.<\/p>\n<p>Though I&rsquo;m not sure about the cadence to progress through the book, I would be\nhappy if I can learn a bit and wrap it up by the end of the year.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/sebastianraschka.com\/books\/\">Sebastian Raschka - Books<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Agentic Engineering | Zed","link":"https:\/\/kxsh.dev\/notes\/2025-07-24-agentic-engineering-zed\/","pubDate":"Thu, 24 Jul 2025 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-07-24-agentic-engineering-zed\/","description":"<p>This series by Zed Industries is worth following.\nI really enjoyed the <a href=\"https:\/\/www.youtube.com\/watch?v=XyQ4ZTS5dGw\">episode with Mitchell Hashimoto<\/a>\nabout his appraoch to using AI Agents while developing software systems.\nKey takeways include:<\/p>\n<ul>\n<li>Thinking more like an architect.<\/li>\n<li>Allow AI Agents to use tools to achieve the desired outcome.<\/li>\n<li>Comment what the code implementation as a way to build redundancy (AI can\nflag discrepancies now)<\/li>\n<\/ul>\n<p>And I look forward to Steve Yegge&rsquo;s episode next.<\/p>"},{"title":"Find Your People - Jessica Livingston","link":"https:\/\/kxsh.dev\/notes\/2025-05-24-find-your-people\/","pubDate":"Sat, 24 May 2025 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-05-24-find-your-people\/","description":"<p>Find what problems people are working on, and filter what aligns with you.\nThis is how you find your people.\nDo not just drift, start steering your life.<\/p>"},{"title":"Why I Maintain a 17 Year Old Thinkpad","link":"https:\/\/kxsh.dev\/notes\/2025-04-03-why-i-maintain-thinkpad\/","pubDate":"Thu, 03 Apr 2025 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-04-03-why-i-maintain-thinkpad\/","description":"<p>In general, I find physical artifacts to be almost always fragile to the effects of time (including plastic). Thus, I don&rsquo;t feel comfortable about discussing the notion of anti-fragility in the context of laptops. However, the argument to differentiate between Thinkpads and Macbooks in terms of longevity, and repairability is appealing. Especially considering that I have never owned a Thinkpad, and recently bought a couple of new Macbooks.<\/p>"},{"title":"Windows Tiling on macOS","link":"https:\/\/kxsh.dev\/posts\/macos-windows-tiling\/","pubDate":"Thu, 27 Mar 2025 18:40:17 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/macos-windows-tiling\/","description":"<p>macOS Sequoia introduced <a href=\"https:\/\/support.apple.com\/en-gb\/guide\/mac-help\/mchlef287e5d\/15.0\/mac\/15.0\">native tiling window support<\/a>. This feature aims to make it easy to arrange open windows into a structured layout - a problem already solved in Linux and Windows world. Until recently, I relied on third-party tools like <a href=\"https:\/\/magnet.crowdcafe.com\/\">Magnet<\/a>, and <a href=\"https:\/\/rectangleapp.com\/\">Rectangle<\/a> to manage windows on my machines.<\/p>\n<p>Currently, I use the native tiling window management (with the built-in keyboard shortcuts) supplemented by Rectangle.<\/p>\n<h3 id=\"almost-maximize\">Almost Maximize<\/h3>\n<p>Rectangle offers a window tile size called &ldquo;Almost Maximize&rdquo;. It allows you to resize the window to 90% of the screen, leaving a small, padded border around the windows<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>. This is particularly handy for applications like web browsers, terminal emulators. Surprisingly, I almost always use the &ldquo;Almost Maximize&rdquo; in favor of both the regular full screen and the &ldquo;Center Window&rdquo;.<\/p>\n<h3 id=\"multiple-window-tiling\">Multiple Window Tiling<\/h3>\n<p>The macOS native tiling window management offers a few window layouts to arrange multiple windows. This feature is particularly useful for applications like IDEs, terminals, and other tools that require multiple windows to be open simultaneously. I use it extensively for my development workflow.<\/p>\n<p>Overall, I find the native tiling window management to be a powerful tool that enhances my personal productivity. But the tooling is a bit cumbersome for the time being.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/github.com\/rxhanson\/Rectangle\/blob\/main\/TerminalCommands.md#almost-maximize\">Rectangle - Terminal Commands<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Sorting Go Slices","link":"https:\/\/kxsh.dev\/notes\/2025-03-25-sorting-go-slices\/","pubDate":"Tue, 25 Mar 2025 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2025-03-25-sorting-go-slices\/","description":"<p>This article makes a strong case for using the &ldquo;generic&rdquo; implementation (provided by the <code>slices<\/code> package) for sorting slices in Go.\nI have used the <code>sort.Interface<\/code> interface as well as the <code>sort.Slice<\/code> function to sort slices. For precisely the same reasons listed in the post, I have never felt comfortable with either of them. The next time I need to sort a slice, I will make sure to give the <code>slices.Sort<\/code> function a try.<\/p>"},{"title":"Setup Ghostty","link":"https:\/\/kxsh.dev\/posts\/setup-ghostty\/","pubDate":"Wed, 08 Jan 2025 20:15:25 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/setup-ghostty\/","description":"<p>I switched my terminal from Warp to Ghostty over the weekend.\nI had been using Warp for almost a couple of years now and it has been great.\nBut I wanted to try something new and Ghostty seemed like a good option.\nI have been using it for a few days now, and I really enjoy the experience so far.<\/p>\n<p>The default configuration of Ghostty is pretty good.\nHowever, I made a few changes to adapt it to my muscle memory.<\/p>\n<ul>\n<li><strong>Font Size<\/strong>: Increased to 16px.<\/li>\n<li><strong>Theme<\/strong>: Changed to <em>Dracula+<\/em>.<\/li>\n<li><strong>Keybindings<\/strong>(macOS specific): Allow CMD + Backspace to delete the current line buffer.<\/li>\n<\/ul>\n<p>Here is the current configuration of Ghostty:<\/p>\n<pre tabindex=\"0\"><code># Increase the default font size.\nfont-size = 18\n\n# Allow CMD + Backspace to delete the current line buffer (like Warp).\nkeybind = cmd+backspace=esc:w\n\n# ZSH Shell\nshell-integration = zsh\n\n# Theme\ntheme = Dracula+\n<\/code><\/pre><p>I will keep using Ghostty for a few more days and see how it goes.<\/p>"},{"title":"Gary Turk: Look Up 2 - Ten Years Later | YouTube","link":"https:\/\/kxsh.dev\/notes\/2024-10-01-look-up-2\/","pubDate":"Tue, 01 Oct 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-10-01-look-up-2\/","description":"<p>Finally Gary Turk got around to making a sequel to his viral video &ldquo;Look Up&rdquo;.\nThe original video was novel and had a profound impact on me.\nI have kept revisiting it over the past few years, as my relationship with technology and gadgets has evolved.\nNow, this sequel is a timely and worthy follow-up.<\/p>"},{"title":"Fooled by Randomness: The Hidden Role of Chance in Life and in the Markets","link":"https:\/\/kxsh.dev\/posts\/fbr\/","pubDate":"Wed, 28 Aug 2024 16:01:35 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/fbr\/","description":"<p>I admire Nassim Nicholas Taleb a lot. His unconventional perspective to dealing with uncertainities intrigues me. The arguments flow naturally, yet against the traditional approach. However, I confess that I do not grasp the depths of all his ideas.<\/p>\n<p>Despite that, his perspectives have shaped a lot of my thinking and approach to life. I am compelled me to take a step back, and look at the world through a different lens - a lens composed of probability, randomness and chance. More often than not, this point of view brings a lot of self-doubt and humility about my assumptions. It is not easy to accept that the world is not as deterministic as I would like it to be. It is not easy to accept that I am not as smart as I think I am. It is not easy to accept that I am not in control of everything. But, it is necessary for me to acknowledge these facts. Even at the cost of some strained personal relationships, or some lost opportunities.<\/p>\n<p>Over the past month, I re-read my paperback copy of his book &ldquo;Fooled by Randomness&rdquo;. Every single time I read any of his works, I&rsquo;m left with more questions than answers to my existing predilictions. At this moment, I am pondering about - &ldquo;How do I know the sun will rise tomorrow?&rdquo;. Given the fact that the topic makes me anxious, and a bit pessimistic, I intend to test his ideas with elimentary empirical expermimentation (nothing &ldquo;scientific&rdquo;) (and invite you to do the same).<\/p>\n<p>Given my background in mathematics and software development, I merely desired to replicate his results as mentioned in the book. You can find a collection of scripts I wrote for this purpose in this <a href=\"https:\/\/github.com\/kshitij10496\/exp\/tree\/0b35f294bcbe63d38f71c368d38d93043f0889ec\/fbr\">GitHub repository<\/a>. This experiment allowed me to spend more time with a specific concept, and a sandbox to play with them. I intend to expand on the scripts, and write about my findings in a series of blog posts. Do check them out if you are interested. I would love to hear your thoughts on them.<\/p>\n\n\n<object\n data=\"notes-fbr.pdf#view=Fit&amp;page=1\" width=\"100%\" height=\"1200px\"type=\"application\/pdf\"\n>\n <p>Unable to display PDF file. <a href=\"notes-fbr.pdf#view=Fit&amp;page=1\">Download<\/a> instead.<\/p>\n<\/object>\n"},{"title":"Nicole Tietz-Sokolskaya - TIL: 8 versions of UUID and when to use them","link":"https:\/\/kxsh.dev\/notes\/2024-08-26-uuid-versions\/","pubDate":"Mon, 26 Aug 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-08-26-uuid-versions\/","description":"<p>Handy reference for when to use the different versions of UUIDs.<\/p>\n<p>For DB primary keys, random strings are inefficient for lookups i.e. UUID v4.\nI will give the v8 with prefix a try for my next project.<\/p>"},{"title":"It's Natural to Be Afraid","link":"https:\/\/kxsh.dev\/posts\/intba\/","pubDate":"Sun, 18 Aug 2024 18:56:29 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/intba\/","description":"<p>This morning I ran about 22 km, for a weekly total of over 65kms across 6 runs.\nLouis joined me for the run. It was overcast and humid. Not ideal conditions\nfor running but not too terrible either.<\/p>\n<p>Today marks twelve weeks into this season\u2019s structured training plan. I was in\nIndia mid-June to attend yet another friend\u2019s marriage - 3rd of the year already.\nThis trip disrupted the training plan for a couple of weeks so I have been\ncatching up for the last month.<\/p>\n<p>Just like the past summers, life centers around running. Almost everyday, I\nwrap up work and head out for an easy jog around the neighborhood. Most\nevenings in Berlin are incredibly beautiful with gentle sunlight falling on me\nas I loop the trails in the park. In a small section of the park, few people\nsetup picnics where they grill, smoke up, and celebrate something or the other.\nSummer is a magical uplifting spirit manifested through all the smiling faces\naround me. Another reminder to run light.<\/p>\n<p>At least a couple of mornings, I workout at the gym. Also, I squeeze in a\nweekly visit to a running track for interval training. Running fast provides a\nnatural release in itself. So does lifting weights. Sunday mornings are reserved\nfor long runs, and Saturday dinner for pasta almost exclusively. Between job\nand household chores, I read my books \u2014 running, physics, computer science,\nscience fiction et. al. Late in the evenings, I write and edit while I eat\ndinner, mostly arranging my notes and thoughts. In short, I deliberately stay\noff the internet as much as possible.<\/p>\n<p>Ideally, this routine repeats itself week after week, every year. The purpose\nof rigorous training is to build a reserve of mental, and emotional depth to\nborrow from during hardships. Any improvements in physical endurance are an\nadd-on. Discomfort provides perspective to stay humble. Humility naturally\nbuilds a nurturing, healthy self-confidence.\nRegardless of my confidence, running a marathon will always stay a challenging,\nscary task for me. Hopefully, the ability to dig deep alleviates the\nundercurrent of fear within me. In a sense, this repetitive process gradually\nrefines parts of my being that I can\u2019t necessarily reason with, metrics that no\nsmartwatch can measure. Anyways, that\u2019s what I choose to believe.<\/p>\n<p>As Haruki Murakami wrote, \u201cI think certain types of processes don\u2019t allow for\nany variation. If you have to be part of that process, all you can do is\ntransform\u2014or perhaps distort\u2014yourself through that persistent repetition, and\nmake that process a part of your own personality.\u201d<\/p>\n<p>Overall, I have not faithfully executed the training plan so far. Not that I\ncan affect the past either way. Better to commit myself to the weeks ahead.<\/p>"},{"title":"Half as Interesting: How the UN Translates Everything in Real-Time by Half as Interesting | YouTube","link":"https:\/\/kxsh.dev\/notes\/2024-07-15-un-translates-everything\/","pubDate":"Mon, 15 Jul 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-07-15-un-translates-everything\/","description":"<p>Most of the books I found meaningful are products of translation.<\/p>\n<p>Real-time translation of diplomatic speeches at such a grand stage as the UN has far more stakes.\nWhile watching speeches in the Indian Houses of Parliaments, I observe similar phenomenon.\nIt makes me wonder how effectively can such powerful people communicate with each other using different tongues.<\/p>\n<p>Distilling a person&rsquo;s ideas from their words into an essence.\nRepackaging that essense using a different set of words, and figures of speech.<\/p>\n<p>The act of translation lacks a layer of agency, at least on the surface.\nAfter all, it&rsquo;s not the translator&rsquo;s original idea that they are communicate, is it?<\/p>\n<p>Interpretation seems to be a unifying skill, to me at least.\nUnfortunately, I have not translated any piece of work yet.\nBut, it could be a potentially valuable exercise.<\/p>"},{"title":"British Council: Cricket (1950) | YouTube","link":"https:\/\/kxsh.dev\/notes\/2024-06-14-cricket-1950\/","pubDate":"Fri, 14 Jun 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-06-14-cricket-1950\/","description":"<p>This video is the most informative introduction to the game of Cricket I have come across. It provides the enough historical context, and delves the right amount into the complexity of the sport.\nI thoroughly enjoyed this film.<\/p>"},{"title":"MKBHD: Talking Tech and AI with Tim Cook! | YouTube","link":"https:\/\/kxsh.dev\/notes\/2024-06-12-mkbhd-tim-cook-interview\/","pubDate":"Wed, 12 Jun 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-06-12-mkbhd-tim-cook-interview\/","description":"<p>A couple of key takeaways for me from this interview:<\/p>\n<ul>\n<li>\n<p>AI can potentially help reduce Screen Time.<\/p>\n<\/li>\n<li>\n<p>&ldquo;Our [Apple] objective is never to be first. Our objecttive is to be the best.&rdquo;<\/p>\n<\/li>\n<\/ul>"},{"title":"Steven Scrawls - Quicksilver and Clay","link":"https:\/\/kxsh.dev\/notes\/2024-04-01-quicksilver-and-clay\/","pubDate":"Mon, 01 Apr 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-04-01-quicksilver-and-clay\/","description":"<p>Identity is composed from a combination of elements built using &ldquo;quicksilver&rdquo; or &ldquo;clay&rdquo;.<\/p>\n<p>Quicksilver represents the beliefs, opinions, and behaviours adopted at a superficial level from others. Clay represents the abilities developed from personal experiences through slow, and laborious work.<\/p>\n<p>While quicksilver offers efficiency and speed, it lacks resilience; clay, on the other hand, withstands the fire of hardships.<\/p>\n<p>A balance between quicksilver and clay is necessary to shape a resilient, and authentic self.<\/p>"},{"title":"vlogbrothers: THE BEST DAY | YouTube","link":"https:\/\/kxsh.dev\/notes\/2024-03-06-vlogbrothers-the-best-day\/","pubDate":"Wed, 06 Mar 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-03-06-vlogbrothers-the-best-day\/","description":"<p>Sports teams can be treated as community assets.\nIn some domains, modern capitalism has reduced sport teams to franchises - business operated from the PoV of profiteering.\nThis is a very fundamental point connected to <em>TATA<\/em> IPL and F1 (<em>Visa Cash App RB F1 Team<\/em>).<\/p>\n<p>I am not trying to judge one against the other.\nPersonal opinions aside, both setups bring value to the table.<\/p>\n<p>Apart from that, as usual, John Green weilds literature with emotion, and grace.<\/p>"},{"title":"David Moldawer - Page Pacing","link":"https:\/\/kxsh.dev\/notes\/2024-02-20-page-pacing\/","pubDate":"Tue, 20 Feb 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-02-20-page-pacing\/","description":"<blockquote>\n<p>The best attribute of a physical book is its width.<\/p>\n<\/blockquote>\n<p>I use the metrics of Reading Time (on Firefox Reader View) or Number of Words on web content as a measure of expected commitment.<\/p>\n<blockquote>\n<p>Thanks to digital screens destroying our brains, none of us run marathons anymore, either. We&rsquo;re sprinters now. When the flow of words bogs down, we set the text aside and move on to another distraction.<\/p>\n<\/blockquote>\n<p>Really interesting. I agree with this. Lately, I forward web pages on my Kindle and read it there.<\/p>\n<blockquote>\n<p>Wherever you write and wherever your writing gets read, pace with pages.<\/p>\n<\/blockquote>\n<p>I would be interested in trying out a page based layout design on this blog.<\/p>"},{"title":"Redowan Delowar - Omitting dev dependencies in Go binaries","link":"https:\/\/kxsh.dev\/notes\/2024-01-25-go-omit-dev-dependencies\/","pubDate":"Thu, 25 Jan 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-01-25-go-omit-dev-dependencies\/","description":"<p>Today I got a chance to finish my 2nd-pass over this article.<\/p>\n<p>Problem: Updating dependencies (Go version -&gt; golangci-lint etc) with least effort.<\/p>\n<p>Essentially, the idea is to add any tooling (such as linters) to the list of dev dependencies in the project.\nIt allows for easier, proactive, frequent updates to the project with <code>dependabot<\/code> integration.\nThis is not a new idea - other language ecosystems well support it.\nThe issue is primarily related to Go.<\/p>\n<p>However, the practice of using a <code>tools.go<\/code> file is used in the Kubernetes project, as well as stated in the Go project&rsquo;s documentation.\nI intend to can give this a try in one of my projects in the future.<\/p>\n<p>This article had been lurking in a background tab over the past couple of days.\nSo it&rsquo;s good to finally get this down into words.<\/p>"},{"title":"Patrick Dubroy: Cold-blooded software","link":"https:\/\/kxsh.dev\/notes\/2024-01-19-cold-blooded-software\/","pubDate":"Fri, 19 Jan 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-01-19-cold-blooded-software\/","description":"<p>The technology choices for a software project should be influenced by it&rsquo;s <strong>expected velocity<\/strong>. For projects that require hibernation and convenience of long-term reliability, the author proposes to use boring technology. I tend to agree with the idea. Moreover, it&rsquo;s helpful to use this criteria as a dimension when approaching new project ideas.<\/p>\n<p>I also enjoyed <a href=\"https:\/\/blog.jim-nielsen.com\/2024\/cold-blooded-software\/\">Jim Nielson&rsquo;s take<\/a> on this topic.<\/p>"},{"title":"Chris Coyier - Exposed RSS","link":"https:\/\/kxsh.dev\/notes\/2024-01-14-chris-coyier-exposed-rss\/","pubDate":"Sun, 14 Jan 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-01-14-chris-coyier-exposed-rss\/","description":"<p>I have always admired the RSS discovery feature from NetNewsWire.<\/p>\n<p>Every time a website asks their viewers to Sign Up for newsletter, I just wish they chose to provide their RSS feed as an alternate.<\/p>"},{"title":"Signing Git Commits","link":"https:\/\/kxsh.dev\/posts\/signing-git-commits\/","pubDate":"Sat, 06 Jan 2024 16:13:12 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/signing-git-commits\/","description":"<p>Whenever I setup a new machine, the following Git commands are a staple:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-shell\" data-lang=\"shell\"><span style=\"display:flex;\"><span>git config user.name <span style=\"color:#40a02b\">&#34;Your Name&#34;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>git config user.email <span style=\"color:#40a02b\">&#34;your.email@domain.ext&#34;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>I have always wondered what&rsquo;s preventing a person from impersonating somebody other than themselves.<\/p>\n<p>This curiousity led me to learning about Signatures, especially how to configure them on Git.\nIn particular, I was interested in setting up my machine to sign via my work and personal identities.<\/p>\n<p>The solution to the generic problem of identification (authentication) is addressed with the concept of &ldquo;digital signature&rdquo;. Usually, we can implement via public key cryptography.<\/p>\n<h2 id=\"ssh-key-signatures\">SSH Key Signatures<\/h2>\n<p>I already use SSH to authenticate with GitHub while working with repositories - cloning repos, fetching and pushing branches. Hence, I would also like to use the same SSH mechanism to sign commits.<\/p>\n<h2 id=\"timeline\">Timeline<\/h2>\n<ul>\n<li>2008 : Launch of GitHub.<\/li>\n<li>2012 : Git supports signing commits via GPG.<\/li>\n<li>2016 : GitHub supports signature verification via GPG.<\/li>\n<li>2019 : OpenSSH supports signing and verification on arbitrary data.<\/li>\n<li>2021 : Git supports signing commits via SSH keys.<\/li>\n<li>2022 : GitHub supports signature verification via SSH keys.<\/li>\n<\/ul>\n<p>It has been a 14 year long journey to reach a point where we can easily sign Git commits with SSH.<\/p>\n<h2 id=\"process\">Process<\/h2>\n<p>The steps to authenticate and sign commits with SSH is well documented for <a href=\"https:\/\/docs.github.com\/en\/authentication\/managing-commit-signature-verification\/about-commit-signature-verification#ssh-commit-signature-verification\">GitHub<\/a> and <a href=\"https:\/\/docs.gitlab.com\/ee\/user\/project\/repository\/signed_commits\/ssh.html\">GitLab<\/a>.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>It&rsquo;s still open for discussion whether to use the same SSH key for both authentication and signing commits or not.\nRegardless, the idea of signing commits in a code repository is an easy, valuable security measure.<\/p>\n<p>I strongly recommend signing commits with SSH wherever possible.<\/p>"},{"title":"Tracksmith: The Year of the Amatuer | YouTube","link":"https:\/\/kxsh.dev\/notes\/2024-01-01-tracksmith-year-of-amateur\/","pubDate":"Mon, 01 Jan 2024 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2024-01-01-tracksmith-year-of-amateur\/","description":"<p>I admire most of the films from Tracksmith on their YouTube channel.\nAnd this one goes right up there.<\/p>\n<blockquote>\n<p>Because the act of devotion reveals a path to fulfillment we can&rsquo;t find anywhere else.<\/p>\n<\/blockquote>\n<p>What a beautiful way to express the potential running holds for some of us.<\/p>\n<blockquote>\n<p>In running, we are all amatuers.<\/p>\n<\/blockquote>"},{"title":"Flamed Fury: Relics of Web","link":"https:\/\/kxsh.dev\/notes\/2023-12-29-relics-of-web\/","pubDate":"Fri, 29 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-29-relics-of-web\/","description":"<p>Linking content on the web is a superpower.\nA superpower that is easy to overlook.<\/p>\n<p>The web is inherently designed for ease of discovery (through links).\nAt the same time, the relevancy is a burden for the individual to resolve.\nWe do not need any centralised service to curate a personalised experience for us.\nYet, in reality the situation is quite different.<\/p>\n<p>This post provides a lot of context around web-native ideas to improve the process of discovery and relevancy.<\/p>\n<p>I&rsquo;m definitely going to curate a blogroll here soon.<\/p>"},{"title":"Donald Knuth: Ancient Babylonian Algorithms","link":"https:\/\/kxsh.dev\/notes\/2023-12-28-ancient-babylonian-algorithms\/","pubDate":"Thu, 28 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-28-ancient-babylonian-algorithms\/","description":"<p>This is such an intriguing paper on the history of computing, hence mathematics.\nI highly recommend reading it yourself.<\/p>\n<p>Few notes from the paper:<\/p>\n<ul>\n<li>Question: How is computer science connected with the human history further beyond the developments in the last century?<\/li>\n<li>Base 60 system instead of Base 10 for mathematics.<\/li>\n<li>Pergamonmusuem in Berlin houses a part of one of the clay tablets from Mesopotamia. I would have liked to see it but the museum is closed for renovations (for 14 years). So I guess I need to wait a bit longer.<\/li>\n<li>Babylonian procedures are genuine algorithms. &ldquo;This is the procedure.&rdquo;<\/li>\n<li>Neither conditionals not iterations were used in the procedures. Almost everything was &ldquo;known&rdquo; - via lookup tables, or some algebra.<\/li>\n<li>Excellent examples that remind me of my middle school algebra. Just to wonder the advancements we have made in terms of technical sophistication.<\/li>\n<li>Inakibit-Anu was the first man in history to solve a computational problem that takes longer than 1 second of time on a modern electronic computer.<\/li>\n<li>Euclid&rsquo;s Algorithm is one of the oldest algorithms. I need to read more about it. However, I remember implementing it as part of <a href=\"https:\/\/github.com\/kshitij10496\/aoc\/blob\/4c1592d3c41dc89f0c78a19800b29ff93cfe6e34\/src\/aoc\/2023\/day08.clj#L79-L82\">Advent of Code 2023 challenges<\/a>.<\/li>\n<\/ul>"},{"title":"Bill Watterson: Some Thoughts On The Real World By One Who Glimpsed It And Fled","link":"https:\/\/kxsh.dev\/notes\/2023-12-24-bill-watterson-real-world\/","pubDate":"Sun, 24 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-24-bill-watterson-real-world\/","description":"<p>Such an excellent read!\nI am more curious to read about Bill Watterson.<\/p>\n<blockquote>\n<p>Despite the futility of the whole episode, my fondest memories of college are times like these, where things were done out of some inexplicable inner imperative, rather than because the work was demanded.<\/p>\n<\/blockquote>\n<blockquote>\n<p>It&rsquo;s surprising how hard we&rsquo;ll work when the work is done just for ourselves.<\/p>\n<\/blockquote>\n<p>The conventional &ldquo;utility&rdquo; of a piece of work is independent of our ability to relish the effort.\nWhile we cannot always decide on the value for the world, we can choose what an experience meant to us personally.<\/p>\n<blockquote>\n<p>We&rsquo;re not really taught how to recreate constructively. We need to do more than find diversions; we need to restore and expand ourselves. Our idea of relaxing is all too often to plop down in front of the television set and let its pandering idiocy liquefy our brains. Shutting off the thought process is not rejuvenating; the mind is like a car battery-it recharges by running.<\/p>\n<\/blockquote>\n<p>In the world of sports, we use the term &ldquo;active recovery&rdquo; for this.\nActive recovery involves low-effort activities to complement a workout.\nFor example, walking and mobility (yoga, stretching) after running.\nReading this passage, I sense the skill\/art of &ldquo;active recovery&rdquo; is more broadly applicable.<\/p>\n<blockquote>\n<p>Letting your mind play is the best way to solve problems. A playful mind is inquisitive, and learning is fun. If you indulge your natural curiosity and retain a sense of fun in new experience, I think you&rsquo;ll find it functions as a sort of shock absorber for the bumpy road ahead.<\/p>\n<\/blockquote>\n<p>&ldquo;Be curious, not judgemental&rdquo;.\nThe endurance demanded for pursuing one&rsquo;s genuine curiousity can be robust.\nRest all will fall apart with time (or entropy).<\/p>\n<blockquote>\n<p>It was a rude shock to see just how empty and robotic life can be when you don&rsquo;t care about what you&rsquo;re doing, and the only reason you&rsquo;re there is to pay the bills.<\/p>\n<\/blockquote>\n<blockquote>\n<p>You will do well to cultivate the resources in yourself that bring you happiness outside of success or failure.<\/p>\n<\/blockquote>\n<p>I see some value in detaching my personal notion of &ldquo;happiness&rdquo; from the metric of &ldquo;success&rdquo; (atleast the society&rsquo;s definition of &ldquo;success&rdquo;).<\/p>\n<blockquote>\n<p>The truth is, most of us discover where we are headed when we arrive. At that time, we turn around and say, yes, this is obviously where I was going all along. It&rsquo;s a good idea to try to enjoy the scenery on the detours, because you&rsquo;ll probably take a few.<\/p>\n<\/blockquote>\n<p>This reminds me a lot of Camino de Santiago trip with my friends. Yes, absolutely agree and try to lead my life this Way.<\/p>\n<blockquote>\n<p>Drawing comic strips for five years without pay drove home the point that the fun of cartooning wasn&rsquo;t in the money; it was in the work.<\/p>\n<\/blockquote>\n<p>Very interesting!<\/p>\n<blockquote>\n<p>We all have different desires and needs, but if we don&rsquo;t discover what we want from ourselves and what we stand for, we will live passively and unfulfilled. Sooner or later, we are all asked to compromise ourselves and the things we care about. We define ourselves by our actions. With each decision, we tell ourselves and the world who we are. Think about what you want out of this life, and recognize that there are many kinds of success.<\/p>\n<\/blockquote>\n<p>This hits home. I have had a strong belief in something similar. It&rsquo;s good to read it written down in words.<\/p>\n<blockquote>\n<p>Your preparation for the real world is not in the answers you&rsquo;ve learned, but in the questions you&rsquo;ve learned how to ask yourself.<\/p>\n<\/blockquote>\n<p>Reminds me of one of Rilke&rsquo;s famous passage:<\/p>\n<p>&ldquo;Be patient toward all that is unsolved in your heart and try to love the questions themselves, like locked rooms and like books that are now written in a very foreign tongue. Do not now seek the answers, which cannot be given you because you would not be able to live them. And the point is, to live everything. Live the questions now. Perhaps you will then gradually, without noticing it, live along some distant day into the answer.&rdquo;<\/p>"},{"title":"Elicit: Build a search engine, not a vector DB","link":"https:\/\/kxsh.dev\/notes\/2023-12-23-elicit-search-engine\/","pubDate":"Sat, 23 Dec 2023 01:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-23-elicit-search-engine\/","description":"<p>Really interesting take on the problem of knowledge discovery.<\/p>\n<p>Full-text search still remains a challenging problem.\nAt the same time, the increasing popularity of vector DBs, in particular, the embeddings data structure, provide another approach to the fundamental problem. A conjugation of both of these technologies can be used to build a valuable solution.<\/p>\n<p>However, questions around the efficiency of such a solution remains to be tested and monitored.<\/p>"},{"title":"Ethan Zuckerman: How Big Is YouTube","link":"https:\/\/kxsh.dev\/notes\/2023-12-23-how-big-is-youtube\/","pubDate":"Sat, 23 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-23-how-big-is-youtube\/","description":"<p>I don&rsquo;t see a lot of talk about the &ldquo;denominator problem&rdquo;.\nThis article does a great job at providing context to the discussion of normalizing data.\nIt&rsquo;s not too difficult to skew most datasets to fit our viewpoint.\nAs a undergrad student, I had shared in this guilty pleasure too.\nAnd I would not be surprised if a similar practice exists in some of the industry.\nNot that it&rsquo;s anybody&rsquo;s fault, I belive it&rsquo;s just part of our nature.<\/p>\n<p>Anyways, I really appreciate Ethan sharing the process here.\nThe linked articles about building URLs for YouTube can be valuable from engineering PoV.\nThanks for Tubestats as well.<\/p>\n<blockquote>\n<p>I believe that high level data like this should be published regularly for all large user-generated media platforms. These platforms are some of the most important parts of our digital public sphere, and we need far more information about what&rsquo;s on them, who creates this content and who it reaches.<\/p>\n<\/blockquote>"},{"title":"Steve Yegge - Math for Programmers","link":"https:\/\/kxsh.dev\/notes\/2023-12-20-math-for-programmers\/","pubDate":"Wed, 20 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-20-math-for-programmers\/","description":"<p>One of the most inspiring articles to study mathematics, especially as a full-time programmer aka Liberal Arts degreee in Mathematics.<\/p>\n<blockquote>\n<p>Math is almost always about formalizing our &ldquo;common sense&rdquo; about some domain, so that we can deduce and\/or prove new things about that domain.<\/p>\n<\/blockquote>\n<p>This is a such a powerful perspective to approach mathematics.\nFor example, Formal Methods are mathematically techniques related to software systems (analysis, verification etc).\nAnother example could be the real-life problems with travelling across cities resulting in the field of Graph Theory. (Travelling salesman problem).<\/p>\n<blockquote>\n<p>the math that you&rsquo;ll find useful is pretty different from the math your school thought would be useful.<\/p>\n<\/blockquote>\n<p>Based on my experience as a Math graduate, I can attest to this.<\/p>\n<p>Think of learning math as a hobby more than anything.<\/p>"},{"title":"Andrew Ng: AI's Instagram Problem","link":"https:\/\/kxsh.dev\/notes\/2023-12-19-andrew-ng-ai-instagram-problem\/","pubDate":"Tue, 19 Dec 2023 02:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-19-andrew-ng-ai-instagram-problem\/","description":"<blockquote>\n<p>Judge your projects according to your own standard, and don&rsquo;t let the shiny objects make you doubt the worth of your work!<\/p>\n<\/blockquote>\n<p>I think of 2 things when I read this article:<\/p>\n<ul>\n<li>FOMO due to the latest fashionable trend is not worth it. I have read and realised it through Taleb&rsquo;s writings as well.<\/li>\n<li>One of the most important characteristics of the 21st century (atleast my generation) is the ability to learn, adapt and relearn new skills; especially my skillsets a tech worker.<\/li>\n<\/ul>"},{"title":"CodeSandbox: How we clone a running VM in 2 seconds","link":"https:\/\/kxsh.dev\/notes\/2023-12-19-codesandbox-clone-vm\/","pubDate":"Tue, 19 Dec 2023 01:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-19-codesandbox-clone-vm\/","description":"<p>Amazing engineering work here!<\/p>\n<p>Two key technologies leveraged here:<\/p>\n<ul>\n<li><a href=\"https:\/\/firecracker-microvm.github.io\/\">Firecracker<\/a>, in particular microVMs.<\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Copy-on-write?useskin=vector\">Copy-on-Write<\/a> resource management technique.<\/li>\n<\/ul>\n<p>The concept of memory snapshotting is elaborately described.\nMore so, I found the deep dive into the engineering work to put the pieces together very inspiring.<\/p>\n<p>I need to study and read up about Firecracker and the concept of KVM.\nLet me know if you have any good resources for this.<\/p>"},{"title":"Cheap Web","link":"https:\/\/kxsh.dev\/notes\/2023-12-19-cheap-web\/","pubDate":"Tue, 19 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-19-cheap-web\/","description":"<p>This piece evoked the following emotions:<\/p>\n<ul>\n<li>Strong alignment in principle around how I envision Web technology (in general, any tech) to work.<\/li>\n<li>Reminded me of the <a href=\"https:\/\/solar.lowtechmagazine.com\/\">Low Tech Magazine<\/a>.<\/li>\n<li>Introduced me to the idea of Solarpunk - as a Cyberpunk derivative.<\/li>\n<\/ul>\n<blockquote>\n<p>A wobbly wooden chair built by a friend beats any designer chair.<\/p>\n<\/blockquote>\n<p>Websites\/web apps built around static web pages (like this blog) are a great example of &ldquo;Cheap Web&rdquo;.<\/p>\n<p>I believe web will be better off if we focus on removing unnecessary bloat (JS libraries, complex architecture etc) from our software; not by adding new features. Less is More!<\/p>"},{"title":"Peter Norvig: Teach Yourself Programming in 10 Years","link":"https:\/\/kxsh.dev\/notes\/2023-12-10-norvig-teach-yourself-programming\/","pubDate":"Sun, 10 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-10-norvig-teach-yourself-programming\/","description":"<p>I remember reading this article way back in my uni days. It reminded me of a popular quote from Richard Feynmann<\/p>\n<p>Now that I have stumbled across it after few years of experience working as a professional software engineer, I related a bit more with the content.<\/p>\n<p>Ways to develop a deep understanding:<\/p>\n<ul>\n<li>Write more significant programs that solve problems.<\/li>\n<li>Work with experienced programmers.<\/li>\n<\/ul>\n<blockquote>\n<p>&ldquo;A language that doesn&rsquo;t affect the way you think about programming, is not worth knowing&rdquo;<\/p>\n<\/blockquote>\n<p>We need deliberate practice to continuously learn and grow.<\/p>"},{"title":"Clojure From the Ground Up: Functions","link":"https:\/\/kxsh.dev\/notes\/2023-12-09-clojure-functions\/","pubDate":"Sat, 09 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-09-clojure-functions\/","description":"<p>Functions are verbs.<\/p>\n<p>We can define symbols to values that will not change (called <code>immutable<\/code>) using <code>let<\/code>.\nThese symbols are only available with an expression (&ldquo;scoped&rdquo;). The symbols can be overriden to point to a different value.<\/p>\n<p><code>def<\/code> allows us to define mutable variables. These are helpful for experimentation.<\/p>\n<p><code>defn<\/code> is a shorthand to define functions.<\/p>\n<p>The chapter builds an extremely powerful intuition behind the relation between <code>let<\/code> and functions.<\/p>\n<p>Also, it&rsquo;s helpful to think about functions as &ldquo;common patterns of computation&rdquo;.\nWhile problem solving, I&rsquo;m starting to adopt this approach as well:<\/p>\n<ul>\n<li>Look for patterns in the problem.<\/li>\n<li>Formulate a function to solve a simple pattern.<\/li>\n<li>Combine multiple patterns to solve the bigger problems. (composition using standard library functions)<\/li>\n<\/ul>\n<blockquote>\n<p>This is core pursuit of software engineering: organizing expressions. Almost every programming language is in search of the right tools to break apart, name, and recombine expressions to solve large problems.<\/p>\n<\/blockquote>\n<p>I find this really insightful. Often, our mental models are constrained by the programming langauge we use.\nThe way a backend engineer approaches a problem is quite different from a frontend engineer.\nI experienced this in a sense when I switched from Python to Go as my preferred language.\nAnd now, learning LISP (Racket, Clojure) has afforded me an even simpler way to approach problems.<\/p>"},{"title":"Clojure From the Ground Up: Basic Types","link":"https:\/\/kxsh.dev\/notes\/2023-12-07-clojure-basic-types\/","pubDate":"Thu, 07 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-07-clojure-basic-types\/","description":"<p>What is a &ldquo;type&rdquo; anyway?<\/p>\n<blockquote>\n<p>A type is a group of values which work in the same way. It&rsquo;s a property that some values share, which allows us to organize the world into sets of similar things.<\/p>\n<\/blockquote>\n<p>I find this to be a very neat and simple way to think about &ldquo;types&rdquo; in general.\nTry to determine the appropriate type for a value based on how well it fits into a particular universe (programming language), and context (problem domain).<\/p>\n<p>The definition of &ldquo;type system&rdquo; is particularly interesting. Also, the 2 dimensions of any type system - strong\/weak, static\/dynamic.<\/p>\n<p>Some of the common programming constructs - symbols, lists, vectors, maps - provide a brief introduction to working with data.<\/p>\n<blockquote>\n<p>As software engineers, we model the world by creating a particular representation of the problem in the program. Having a rich set of values at our disposal allows us to talk about complex problems. In Clojure, we compose data structures to form more complex values; to talk about bigger ideas.<\/p>\n<\/blockquote>\n<p>Sweet! Looks extremely promising.<\/p>"},{"title":"Clojure From the Ground Up: Welcome","link":"https:\/\/kxsh.dev\/notes\/2023-12-06-clojure-from-ground-up-welcome\/","pubDate":"Wed, 06 Dec 2023 01:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-06-clojure-from-ground-up-welcome\/","description":"<p>Really neat article (and series) about program design from first principles.<\/p>\n<p>I loved the emphasis on motivation and simplicity.<\/p>\n<p>Lisp is ridiculously simple to write computation.\nThis post does a great job at developing intuition about programming.\nI found a lot of traces from SICP in the mental model.<\/p>\n<blockquote>\n<p>You could think of this structure as a tree\u2013which is a provocative idea,\nbecause <em>languages<\/em> are like trees too: sentences are comprised\nof clauses, which can be nested, and each clause may have subjects\nmodified by adjectives, and verbs modified by adverbs, and so on.<\/p>\n<\/blockquote>\n<p>Extremely powerful concept.<\/p>"},{"title":"Aphyr - Why is Jepsen Written in Clojure?","link":"https:\/\/kxsh.dev\/notes\/2023-12-06-jepsen-clojure\/","pubDate":"Wed, 06 Dec 2023 00:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/notes\/2023-12-06-jepsen-clojure\/","description":"<p>Just as I am developing an interest in the Lisp family of languages, particularly Clojure, I discovered Kyle&rsquo;s post on my feed.<\/p>\n<p>Few things that stood out from this piece:<\/p>\n<ul>\n<li>Clojure&rsquo;s ability to interop with Java (and JVM primitives) opens up the potential to leverage an existing, mature ecosystem.<\/li>\n<li>Immutable, persistent data structures make it easier to write concurrent programs without static typing.<\/li>\n<li>Most of the times, &ldquo;good enough&rdquo; tech and pragmatism are enough to build useful software tools.<\/li>\n<\/ul>"},{"title":"Testcontainers with Podman","link":"https:\/\/kxsh.dev\/posts\/testcontainers-with-podman\/","pubDate":"Mon, 20 Nov 2023 15:48:41 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/testcontainers-with-podman\/","description":"<p>I use <a href=\"https:\/\/testcontainers.com\/\">Testcontainers<\/a> for writing integration tests for my APIs.<br>\nIn particular, the tests concerning DBs - migrations, SQL queries.<\/p>\n<p>Currently, I replacing <a href=\"https:\/\/www.docker.com\/\">Docker<\/a> with <a href=\"\">Podman<\/a> as the preferred tool for managing <a href=\"https:\/\/developers.redhat.com\/blog\/2018\/02\/22\/container-terminology-practical-introduction#container\">Containers<\/a>.<\/p>\n<p>Eventually, I stumbled upon the problem of configuring Testcontainers with Podman on my local machine.\nHere is what I discovered during the process of migration from Docker to Podman, with respect to Testcontainers:<\/p>\n<h2 id=\"problem\">Problem<\/h2>\n<p>Testcontainers implicitly use Docker as the default container runtime.\nThus, the library acts as a Docker API client.<\/p>\n<h2 id=\"solution\">Solution<\/h2>\n<ol>\n<li>We do not need to make any changes on the application code layer.<\/li>\n<li>We need to set the following 2 envvars in order to seamless switch from Docker to Podmangit:<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># only for rootless Podman.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>$ <span style=\"color:#04a5e5\">export<\/span> <span style=\"color:#dc8a78\">TESTCONTAINERS_RYUK_DISABLED<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#04a5e5\">true<\/span> \n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\"># configure Docker API clients to use Podman for running containers.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>$ <span style=\"color:#04a5e5\">export<\/span> <span style=\"color:#dc8a78\">DOCKER_HOST<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span>unix:\/\/<span style=\"color:#8839ef\">$(<\/span>podman machine inspect --format <span style=\"color:#40a02b\">&#39;{{.ConnectionInfo.PodmanSocket.Path}}&#39;<\/span><span style=\"color:#8839ef\">)<\/span> \n<\/span><\/span><\/code><\/pre><\/div><p>Voila!<\/p>\n<h2 id=\"references\">References<\/h2>\n<ul>\n<li><a href=\"https:\/\/java.testcontainers.org\/supported_docker_environment\/#podman\">Testconatiners - General Container Runtime Requirements<\/a><\/li>\n<li><a href=\"https:\/\/golang.testcontainers.org\/system_requirements\/using_podman\/\">Testcontainers - Using Podman instead of Docker<\/a><\/li>\n<\/ul>"},{"title":"Race Report: Great Berlin 10k 2023","link":"https:\/\/kxsh.dev\/posts\/2023-10-22-race-great-berlin-10k\/","pubDate":"Sun, 22 Oct 2023 14:43:56 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-10-22-race-great-berlin-10k\/","description":"<p>On 15 October 2023, I ran the Great 10k race in Berlin. This is an account of\nhow the race unfolded.<\/p>\n<p>Autumn had settled in the streets of the city. It was quite a chilly morning\nwith gray clouds and strong winds. I felt a bit restless standing in front of\nSchloss Charlottenberg. Partially, due to the fact that I was unprepared for\nthe race. I had been nursing an injury after the Marathon, and the doctor had\nadvised me to rest, even end the season. Regardless, I chose to run. Even\nthough I enjoy running in cool conditions, I instinctively knew that it was\nnot going to be one of those days. This acknowledgement of my current ability\nwas all I thought about as I crossed the starting line.<\/p>\n<p>Around 15 mins into the run, I felt sharp pain in my left knee \u2014 as if the knee\ncould give out any moment. My body was not ready to meet my expectations. The\nwise thing to do would be to listen to my body. At the same time, I was\ndetermined to finish the race. Thus, I adjusted to a steady effort at a\nmanageable level of pain. That\u2019s the best I could do \u2013 not that I had a choice.<\/p>\n<p>I have to admit - I chose to distract myself from the pain during the rest of\nthe race. I recalled a couple of stories from Ernest Hemingway\u2019s short story\ncollection called Men Without Women. In particular, I remembered an Italian\nArmy Major from one of the stories saying something along the lines -\n\u201cI am utterly unable to resign myself\u201d. I reflected a bit on that.<\/p>\n<p>Turning over a few more passages in my head, I almost reached the finish. I\nwas pleasantly surprised to see a friend cheering the runners on. It provided\nme with a lot of boost to push the last kilometer, despite the pain. As soon as\nI crossed the finish line, I felt extremely relieved.<\/p>\n<p>On my way back to the apartment, I realized that even though it was not my race,\nit made for a very important experience in my journey, a feeling I would not\nideally want to experience again. So I will be back stronger!<\/p>"},{"title":"Running: August 2023","link":"https:\/\/kxsh.dev\/posts\/2023-09-10-running-august-23\/","pubDate":"Sun, 10 Sep 2023 14:50:07 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-09-10-running-august-23\/","description":"<figure><img src=\"https:\/\/kxsh.dev\/posts\/2023-09-10-running-august-23\/cover.jpg\"\n alt=\"Neust\u00e4dtische Kirchstra\u00dfe, Berlin\"><figcaption>\n <p>Neust\u00e4dtische Kirchstra\u00dfe, Berlin<\/p>\n <\/figcaption>\n<\/figure>\n\n<p>Mileage: 305k<\/p>\n<p>I ran out of motivation to train in the month of August.<\/p>\n<p>The excitement about starting long-term projects dies out at some point. A more\nprimitive emotion replaces it. This powerful sensation effectively decides the\nimpact of the endeavor - whether the project sustains or fizzles out. Thus, I\nhave to deliberately adapt to this transition. The raw nature of this emotion\nmakes it extremely personal. For me, it\u2019s the void.<\/p>\n<p>Despite my feelings in the moment, I am determined to show up every day, especially\nwhen it is difficult. This grind is necessary to build mental strength as much\nas physical fitness.<\/p>\n<p>With some of these thoughts in my head, I racked up decent mileage under my feet.\nThey should help me towards my goal. And where exactly is that? The streets of\nBerlin, of course, in a couple of weeks.<\/p>"},{"title":"Running: July 2023","link":"https:\/\/kxsh.dev\/posts\/2023-08-04-running-july-23\/","pubDate":"Fri, 04 Aug 2023 15:41:27 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-08-04-running-july-23\/","description":"<p>Mileage: 277.5k<\/p>\n<p>The past month has been chaotic to say the least. Nonetheless, I still managed\nto put in the effort and run.<\/p>\n<p>I try to focus only on things I can control, and let go of the events outside\nmy direct influence. As much as as I would like to have the world work in my\nfavour, most often that\u2019s not going to be the case. What am I going to do about\nheadwinds, and rain on a summer evening! The best I can do is focus on myself,\nand put in my effort. This is something I learnt the hard way through running.<\/p>"},{"title":"Patching Go Modules","link":"https:\/\/kxsh.dev\/posts\/patching-go-modules\/","pubDate":"Wed, 26 Jul 2023 22:24:51 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/patching-go-modules\/","description":"<p>When I was searching for ways to write integation tests in a project, I discovered Test Containers project. I decided to give it a shot and learnt more about the project.\nThanks to the wonderful <code>testcontainers\/testcontainers-go<\/code><sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup> package, it was relatively straightforward to bootstrap the setup into my project - code, tests, and CI. I was pretty happy about the entire experience. Maybe I will share the setup here sometime in the future.<\/p>\n<p>Unfortunately, the CI pipeline broke out of the blue on the morning July 12 2023.\nWhen I checked the logs, it was clear that something funny is going on with test containers.\n<code>http: invalid Host header, host port waiting failed: could not start container: creating reaper failed: failed to create container<\/code><\/p>\n<p>After further investigation, I discovered that the crux of the issue originated from a security patch on the Go project with Go v1.20.6 release. This change cascaded to the <code>docker<\/code> client package, used by <code>testconatiners-go<\/code> pacakge.\nFortunately, the docker\/moby project quickly fixed it and issued a new release.<sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup>\nHowever, I had to wait for the <code>testcontainers-go<\/code> project to update their dependencies.<sup id=\"fnref:3\"><a href=\"#fn:3\" class=\"footnote-ref\" role=\"doc-noteref\">3<\/a><\/sup><\/p>\n<p>Meanwhile, I came to know that we can pin the &ldquo;indirect&rdquo; dependencies in Go Modules.\nThis effectively meant that I could resolve the issue on my project, without needing a fix from <code>testcontainers-go<\/code> project. It was as simple as:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-sh\" data-lang=\"sh\"><span style=\"display:flex;\"><span>go get github.com\/docker\/docker@v24.0.5\n<\/span><\/span><\/code><\/pre><\/div><p>This discovery that we can update indirect dependencies in our modules, independently of the direct dependency. I&rsquo;m not sure whether this clarifies the concept of modules for me or confuses me even further. But it is what it is. If somebody is willing to share why\/how this works, I will be extremely grateful.<\/p>\n<p>Everyday I am amazed by the wonderful OSS community that collaborates, and contributes so much to the wellbeing of the systems we build. It&rsquo;s just a marvellous feat of the anthropocene era.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/github.com\/testcontainers\/testcontainers-go\">https:\/\/github.com\/testcontainers\/testcontainers-go<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/github.com\/moby\/moby\/releases\/tag\/v24.0.5\">https:\/\/github.com\/moby\/moby\/releases\/tag\/v24.0.5<\/a>&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:3\">\n<p><a href=\"https:\/\/github.com\/testcontainers\/testcontainers-go\/pull\/1361\">https:\/\/github.com\/testcontainers\/testcontainers-go\/pull\/1361<\/a>&#160;<a href=\"#fnref:3\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Running Week 05: Guide","link":"https:\/\/kxsh.dev\/posts\/2023-06-25-running-guide\/","pubDate":"Sun, 25 Jun 2023 15:43:46 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/2023-06-25-running-guide\/","description":"<p>Mileage: 49.7k<\/p>\n<p>I took a short break from training this week. For the first time in over 6\nweeks, I went 2 complete days without a run. It\u2019s crazy to think about how\ntraining has changed my lifestyle.<\/p>\n<p>The body felt really strong during the weekend runs. My body needs some time\nto recover from all this intensity. I am more aware of it now.<\/p>\n<p>This week, I was talking to a friend about running with audio guidance - like\nNike Run Club app. Here is what I think about them - they can be extremely\nhelpful but one might want to grow out of them soon. Let me explain. It\u2019s\nfairly usual for my mind to wander into certain areas - access memories, loop\nthought patterns, or spiral downwards. As one might suspect, this can mess up\nwith the training. I try to use cues to gently nudge my mind to focus on the\nessentials. Cues including, but not limited to - feeling my breath in the lungs,\nand keeping my head relatively still. These cues are subjective as they work\nfor me but might not work for you. Perhaps, the audio guide assists with that\nfor you. Do give it a try!<\/p>\n<p>However, I do believe the process to center the mind away from one thing, and\ngently rest it on some other thing is a valuable skill. More than the skill,\nthe experience of finding one\u2019s own system to direct our attention is highly\nrewarding in terms of self-growth. Personally, I have found some cues helpful\neven when I feel anxious or overwhelmed in the daily life.<\/p>\n<h3 id=\"workouts\">Workouts<\/h3>\n<ul>\n<li>Run 1 - 5k Recovery<\/li>\n<li>Run 2 - 5k Tempo<\/li>\n<li>Run 3 - 5.5k Easy<\/li>\n<li>Run 4 - 11k Easy<\/li>\n<li>Run 5 - 23k Long Run<\/li>\n<\/ul>\n<h3 id=\"albums\">Albums<\/h3>\n<ul>\n<li>American Football by American Football<\/li>\n<li>The Velvet Underground and Nico by The Velvet Underground<\/li>\n<\/ul>"},{"title":"PostgreSQL Query Planning","link":"https:\/\/kxsh.dev\/posts\/pg-query-planning\/","pubDate":"Sun, 30 Apr 2023 16:21:26 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/pg-query-planning\/","description":"<p>This past week I triggered an incident on one of the production systems.\nThe issue was a result of a AWS Aurora Postgres major version upgrade (10-&gt;11) gone wrong.\nHere is a brief summary of what I learnt from it.<\/p>\n<p>Every running DBMS has some state associated with the data it stores.\nThis state enables the DBMS to tune it&rsquo;s own performance.<\/p>\n<p>Upgrading the DB is tricky for sure.\nAlways try to create contingency plans (backups, snapshots, redundant DBs) before executing destructive operations.\nMigrating the data from one DB to another is part of the work.\nIt&rsquo;s rather straightforward thanks to Cloud Providers.\nVerifing and validating data correctness post-migration is simple.<\/p>\n<p>However, the difficult part is to understand the DBMS state migration.\nUsually, this state is not migrated by default.\nDBAs need to force it post migration.<\/p>\n<p>The inconsistency between the states pre and post migration resulted in slower queries.\nComparing the query plans can point out missing indexes, inefficient plans.\nThis is how I discovered that PostgreSQL&rsquo;s query planner uses the statistics collected in <code>pg_statistic<\/code> catalog table to determine the most efficient execution plans.<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>\nMorever, PostgreSQL provides a special statement called <code>ANALYZE<\/code> to populate the statistics into this table.<sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup>\nNote: The <code>ANALYZE<\/code> statement is not in the SQL standard.<\/p>\n<p>There are considerations to be made around the <code>ANALYZE<\/code> statement.<\/p>\n<ol>\n<li><code>ANALYZE<\/code> requires only a read lock on the target table. This enables concurrent queries to run in parallel.<\/li>\n<li>In default configuration, <code>AUTOVACCUM<\/code> daemon automates the execution of the <code>ANALYZE<\/code> statement. Check for the <code>AUTOVACCUM<\/code> configuation of your DBs.<\/li>\n<li>A common strategy for read-mostly databases is to run <code>ANALYZE<\/code> once a day during a low-usage time of day.<\/li>\n<\/ol>\n<p>I&rsquo;m still trying to figure out a good strategy to tune <code>ANALYZE<\/code> on the production DBs for individual use cases.\nBut that&rsquo;s a story for another time.<\/p>\n<p>I have learnt this lesson about query planning the hard way.\nNow, there is wisdom, and some scar tissue.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/www.postgresql.org\/docs\/11\/routine-vacuuming.html#VACUUM-FOR-STATISTICS\">PostgreSQL: Documentation: 11: Updating Planner Statistics<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/www.postgresql.org\/docs\/11\/sql-analyze.html\">PostgreSQL: Documentation: 11: ANALYZE<\/a>&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Apple Notes","link":"https:\/\/kxsh.dev\/posts\/apple-notes\/","pubDate":"Mon, 03 Apr 2023 16:37:31 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/apple-notes\/","description":"<p>I use Apple Notes for taking quick notes, and a bin for random ideas that pop up\nin my head. It has one of the best product features I have come across any note\ntaking app.<\/p>\n<p>Feature: <strong>Automatically deleting empty notes<\/strong> or <strong>No empty notes<\/strong>.<\/p>\n<p>My Notion and Google Drive has a few Docs\/Sheets titled &ldquo;Untitled&rdquo;.\nThis adds to the noise. Perhaps the fundamental problem is my failure to name\nthese docs at that moment. But sometimes, it&rsquo;s rather difficult to come up with names.<\/p>\n<p>If I just want to note down a random idea, I do not want to structure it yet.<\/p>\n<p>Apple Notes has by far the most suitable experience for noting unstructured\nthings for me. And I&rsquo;m grateful for the automatic cleanup. I wish more services\nhad an opt-in feature.<\/p>"},{"title":"Tips for working with Terraform as a developer","link":"https:\/\/kxsh.dev\/posts\/tips-terraform\/","pubDate":"Thu, 30 Mar 2023 14:29:46 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/tips-terraform\/","description":"<p>At work lately, I have been working with Terraform for our Infrastructure-as-code.\nMy limited domain expertise lies primarily within the scope of backend systems.\nI had never worked with provisioning infrastructure via code before.\nSo it was a valuable experience to see code turn on machines to execute more code.<\/p>\n<p>Here are a few things I learnt during the process:<\/p>\n<ol>\n<li>Use <code>tfswitch<\/code> for dependency management to install and toggle between the various Terraform versions used across the modules.<\/li>\n<li>Always use <code>terraform init --upgrade<\/code> to never use cached modules. This saves a lot of potential trouble shooting at the cost of few seconds.<\/li>\n<li>Use <code>terraform plan -var='key:value'<\/code> whenever we have to use variables (for example, passwords).<\/li>\n<\/ol>"},{"title":"Zero Copy","link":"https:\/\/kxsh.dev\/posts\/zero-copy\/","pubDate":"Tue, 10 Jan 2023 15:35:37 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/zero-copy\/","description":"<p>Fundamentally, a lot of API development is about gathering, manipulating, and tranferring data across processes.\nThe concept of copying data from one memory area to another memory area is integral to the efficiency of the system.\nMy interest is to better understand how this &ldquo;copy&rdquo; operation works.\nMore so, I want to learn how to make this copy process efficient from a software engineer&rsquo;s POV.<\/p>\n<p>Usually when a user space process (our application binary) has to execute system operations like reading or writing data from\/to a device (disk, network etc.) through their high level software interfaces (language runtime), or like moving data from one device to another, etc., it has to perform one or more system calls that are then executed in kernel space by the operating system.<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>\nMost often these system calls belong to <code>read<\/code><sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup> and <code>write<\/code><sup id=\"fnref:3\"><a href=\"#fn:3\" class=\"footnote-ref\" role=\"doc-noteref\">3<\/a><\/sup> family.\nHowever, these context switches from user space to kernel space are time consuming, thus expensive.<\/p>\n<p>The idea is to reduce the data tranfer operations using efficient system calls that do not perform such context switches.\nThese system calls transfer bytes from one File Descriptor to another within the kernel space.\nExamples of such calls include <code>sendFile<\/code><sup id=\"fnref:4\"><a href=\"#fn:4\" class=\"footnote-ref\" role=\"doc-noteref\">4<\/a><\/sup> and <code>splice<\/code><sup id=\"fnref:5\"><a href=\"#fn:5\" class=\"footnote-ref\" role=\"doc-noteref\">5<\/a><\/sup> among others.<\/p>\n<p>I would defer to an <a href=\"https:\/\/developer.ibm.com\/articles\/j-zerocopy\/?mhsrc=ibmsearch_a&amp;mhq=copy#trad\">article from IBM<\/a> which beautifully explains the intricacies.<\/p>\n<h1 id=\"applications\">Applications<\/h1>\n<ul>\n<li>\n<p>Kafka uses zero-copy data transfer optimizations for high throughput between disk data and network.<sup id=\"fnref:6\"><a href=\"#fn:6\" class=\"footnote-ref\" role=\"doc-noteref\">6<\/a><\/sup><sup id=\"fnref:7\"><a href=\"#fn:7\" class=\"footnote-ref\" role=\"doc-noteref\">7<\/a><\/sup><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pkg.go.dev\/net\/http#FileServer\">Go HTTP FileServer<\/a> from standard library leverages zero-copy techniques <sup id=\"fnref:8\"><a href=\"#fn:8\" class=\"footnote-ref\" role=\"doc-noteref\">8<\/a><\/sup>.<\/p>\n<\/li>\n<\/ul>\n<p>It&rsquo;s pleasantly surprising to discover that the tools I use already implement this concept.\nThis idea of zero copy helps improve my mental model about distributed system design.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Zero-copy\">Wikipedia - Zero-copy<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Read_%28system_call%29\">Wikipedia - read (system call)<\/a>&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:3\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Write_%28system_call%29\">Wikipedia - write (system call)<\/a>&#160;<a href=\"#fnref:3\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:4\">\n<p><a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/sendfile.2.html\">Linux Manual Page - sendfile(2)<\/a>&#160;<a href=\"#fnref:4\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:5\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Splice_%28system_call%29\">Wikipedia - splice (system call)<\/a>&#160;<a href=\"#fnref:5\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:6\">\n<p><a href=\"https:\/\/engineering.linkedin.com\/distributed-systems\/log-what-every-software-engineer-should-know-about-real-time-datas-unifying\">The Log: What every software engineer should know about real-time data&rsquo;s unifying abstraction<\/a>&#160;<a href=\"#fnref:6\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:7\">\n<p><a href=\"https:\/\/youtu.be\/UNUz1-msbOM\">YouTube - System Design: Why is Kafka fast?<\/a>&#160;<a href=\"#fnref:7\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:8\">\n<p><a href=\"https:\/\/www.sobyte.net\/post\/2022-07\/go-zerocopy\/\">SoByte - Building a Zero-Copy File Web Server in Golang<\/a>&#160;<a href=\"#fnref:8\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Review: Let My People Go Surfing","link":"https:\/\/kxsh.dev\/posts\/review-lmpgs\/","pubDate":"Sat, 07 Jan 2023 11:57:56 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/review-lmpgs\/","description":"<p><img src=\"https:\/\/kxsh.dev\/posts\/review-lmpgs\/cover.webp\" alt=\"Cover: Winter swell at Rincon Point, 1973. Photo: Steve Bissell. Book photo: Tim Davis \" title=\"Cover: Winter swell at Rincon Point, 1973. Photo: Steve Bissell. Book photo: Tim Davis\"><\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Patagonia,_Inc.\">Patagonia, Inc.<\/a> is a fascinating brand. Yvon Chouinard, the founder , is an eccentric.<br>\nRecently, Yvon donated the company to a non-profit trust to fight the environmental crisis<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup>.<br>\nThis level of commitment intrigued me. After listening to a couple of Yvon&rsquo;s interviews<sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup>, I picked up this book with the hope of learning more about him.<\/p>\n<p>Along with Yvon&rsquo;s personal story, the book also expands his guiding principles on running a business.\nHe provides a lot of examples on adopting these same philosophies in practice at Patagonia.<\/p>\n<p>In a capitalist economy, companies primarily focus on profits and growth.\nHowever, Yvon is committed to using Patagonia to change the way business is done.\nAlmost always, business owners, stakeholders treat the company as a cash printing <em>product<\/em>.\nAccording to Yvon, a company is a <em>resource<\/em> that should be used for the good - to create value rather than just a tool for minting money.\nThis ideology is starkly in contrast with the tech industry, especially with Web3.\nYvon&rsquo;s depth of thoughts without any formal education in business management fascinates me.<\/p>\n<p>Another idea that stood out for me was Yvon emphasis on a long term vision.\nHe has this 100-year timeframe perspective to taking decisions.\nUsually, stakeholders are under pressure to create short-term gains at the expense of long-term vitality and\u202fresponsibility.\nHowever, Yvon&rsquo;s approach is rather unique in that he prefers slow, organic growth rather than marketing-driven hype around the brand.\nIn addition to this, the brand builds an ecosystem with it&rsquo;s dependents and dependencies to guarantee stability.<\/p>\n<p>Perhaps, this approach comes from Yvon&rsquo;s inherent love for the outdoors, and building tools to improve that experience.\nHe himself admits that he is a craftsman who stumbled into business.\nHis obsession with creating the best product edges him from the rest of the hobbyists.<\/p>\n<p>He raises intriguing questions about being committed to your niche v\/s going mainstream by selling out.\nShould a company compromise quality for scaling in the name of growth?<\/p>\n<p>As expected, I&rsquo;m totally sold on his philosophy about the environment.\nI can only hope the ideas in this book translate them to my daily activities.\nAt least, my relationship with material goods will become a bit more deliberate.\nThe key takeaway here for me is that giving away money for environmental initiates is not philanthrophy.\nIt&rsquo;s about paying dues for our use (aka exploitation) of our planet. So, this money should be cost of doing business or owning a product.<\/p>\n<p>Business is merely a side effect of Yvon&rsquo;s obsession with improving the ecosystem around the activies that interest him.\nThis books sets few conscientiousness expectations from a business towards it&rsquo;s customers, employees, and the environment.\nThere is still a lot for me to absorb from this book, particularly about business management.\nHowever, that information might become more relevant if I ever own a business and\/or manage an organization.\nRegardless, I intend to revisit the new edition of this book<sup id=\"fnref:3\"><a href=\"#fn:3\" class=\"footnote-ref\" role=\"doc-noteref\">3<\/a><\/sup> some time in the future.<\/p>\n<p>The following passage from the book stuck with me:<\/p>\n<blockquote>\n<p>I realize now that what I was trying to do was to instill in my company, at a critical time, lessons that I had already learned as an individual and as a climber, surfer, kayaker, and fly fisherman. I had always tried to live my own life fairly simply, and by 1991, knowing what I knew about the state of the environment, I had begun to eat lower on the food chain and reduce my consumption of material goods. Doing risk sports had taught me another important lesson: Never exceed your limits. You push the envelope, and you live for those moments when you\u2019re right on the edge, but you don\u2019t go over. You have to be true to yourself; you have to know your strengths and limitations and live within your means. The same is true for a business. The sooner a company tries to be what it is not, the sooner it tries to \u201chave it all,\u201d the sooner it will die.<\/p>\n<\/blockquote>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/www.patagonia.com\/ownership\/\">Earth is our only shareholder.<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/www.npr.org\/2017\/07\/13\/504852483\/patagonia-yvon-chouinard\">How I Built This - Patagonia: Yvon Chouinard<\/a>&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:3\">\n<p><a href=\"https:\/\/www.patagonia.com\/stories\/let-my-people-go-surfing\/story-30910.html\">Patagonia - Introducing a New Edition of Yvon Chouinard\u2019s \u201cLet My People Go Surfing\u201d<\/a>&#160;<a href=\"#fnref:3\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Integrating GoatCounter into the blog","link":"https:\/\/kxsh.dev\/posts\/goatcounter\/","pubDate":"Fri, 06 Jan 2023 17:08:57 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/goatcounter\/","description":"<p class=\"notice\">\n This blog is no longer tracked with GoatCounter.\nI keep this post for posterity.\n<\/p>\n\n<hr>\n<p>This blog is tracked with <a href=\"https:\/\/www.goatcounter.com\/\">GoatCounter<\/a>.\nIt&rsquo;s a minimalist, privacy respecting, open source web analytics tool.\nHere is my small adventure into adding the tool into the blog.<\/p>\n<h2 id=\"why-did-i-add-a-tracker\">Why did I add a tracker?<\/h2>\n<p>I discovered GoatCounter on a random HackerNews post earlier this week.\nEventually, I landed on <a href=\"https:\/\/www.goatcounter.com\/design\">GoatCounter&rsquo;s Design<\/a>.\nI appreciate the focus on simplicity, pragmatism, and keeping things boring.\nThis convinced me to try out GoatCounter.<\/p>\n<h2 id=\"how-to-add-the-goatcounter-tracker-to-a-hugo-site\">How to add the GoatCounter tracker to a Hugo site?<\/h2>\n<p>Like most trackers, I needed to add a simple HTML tag to every page on the site.\nThis tag runs some JavaScript code on the visitors&rsquo; browser.<\/p>\n<p>It seems pretty straightforward if this site were built by vanilla HTML.\nHowever, I use Hugo as my static site generator tool with a custom theme.\nAnd, I didn&rsquo;t know how to add custom HTML to either Hugo or to the custom theme.\nSo I started digging.<\/p>\n<p>Hugo uses inheritance for building the final HTML from different HTML templates\n(Hugo template, theme tempalte, custom HTML from user) one top of the other.\nThere is also a specific <a href=\"https:\/\/gohugo.io\/templates\/lookup-order\/\">template lookup order<\/a>\nwith all the information about this process. Essentially, in order to add\ncustom HTML to our site using a Hugo theme, we have to create a new file in our\nproject. The important note here is to create the file at a proper location to leverage\nHugo&rsquo;s inheritance. This part is a bit tricky to debug because we lack\nobservability into why our HTML is not loaded. The template lookup order comes\nin handy in these cases.<\/p>\n<p>For my case, it meant creating the file under <code>layouts\/partials\/head<\/code> directory\nas <code>extensions.html<\/code>.<\/p>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/goatcounter\/coder.png\" alt=\"Coder theme on Hugo\" title=\"Coder theme on Hugo\"><\/p>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/goatcounter\/blog.png\" alt=\"Updated my blog with custom HTML\" title=\"Updated blog with GoatCounter tag\"><\/p>\n<p>You can find the source code on <a href=\"https:\/\/github.com\/kshitij10496\/hugo-blog\/blob\/25d5e4393db48d6432aed970882c6c48bc10b27b\/layouts\/partials\/head\/extensions.html\">github.com\/kshitij10496\/hugo-blog<\/a>.<\/p>\n<p>In retrospect, the integration process was a bit trickier that I first imagined.<\/p>\n<h2 id=\"now\">Now<\/h2>\n<p>I adore the retro, 90s web design of the hosted dashboards.\nThe color palette and fonts are just perfect.\nMore importantly, it gets the job done.\nIt&rsquo;s extremely efficient for 30 mins of setup work.<\/p>\n<p>If you would like not to be tracked on this site, you have a couple of options:<\/p>\n<ol>\n<li>Use a browser extension that blocks trackers. (suggestion: <a href=\"https:\/\/adblockplus.org\/\">Adblock Plus<\/a>)<\/li>\n<li>Reach out to me over social media (or in private) and I will disable the tracker.<\/li>\n<\/ol>"},{"title":"What I Talk About When I Talk About Running: 2022","link":"https:\/\/kxsh.dev\/posts\/witawitar-2022\/","pubDate":"Sun, 01 Jan 2023 10:32:38 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/witawitar-2022\/","description":"<p>This article was originally posted on my <a href=\"https:\/\/runnerblues.substack.com\/\">Running Log Newsletter<\/a> on Substack. You can also read it <a href=\"https:\/\/open.substack.com\/pub\/runnerblues\/p\/what-i-talk-about-when-i-talk-about-15f?r=4vzb5&amp;utm_campaign=post&amp;utm_medium=web\">here<\/a>.<\/p>\n<hr>\n<p><em>As we are trapped between the years, I took some time to reflect on my practice of running. This post is an attempt to better understand myself, and share my learning.<\/em><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/witawitar-2022\/cover.jpg\" alt=\"August in Berlin\" title=\"August in Berlin\"><\/p>\n<p>I\u2019m an average runner at best. There is no doubt about it. However, I start every run with a little curiosity to discover something new about myself. At the very least, I intend to simply observe the subtle differences within me from the previous run. Every time I put on my shoes, I\u2019m ready to be the best average runner I could possibly be. This belief is all that matters to me.<\/p>\n<p>My relationship with running has matured a bit this past year. I feel more comfortable about accepting my limited abilities. Last year, things were a bit too overwhelming. This year was more about drawing a tiny bit of wisdom from all the knowledge I gained from running, and reading. At every starting line, I hoped that somewhere down the road, the pain makes way for some other thing, possibly contentment.<\/p>\n<p>Running has become an integral part of my identity. My habits have adapted significantly to accommodate this aspect into my lifestyle choices. Running affords me a \u201cfidelity\u201d for my fitness - physical, mental, and spiritual. Unfortunately, my general fitness has not improved significantly year-to-date. My goals heading into 2023 need to be different from those that persisted me through 2022. I take this as an important learning for my evolution.<\/p>\n<p><strong>Aside<\/strong>: <em>Watching Eliud Kipchoge at the Berlin Marathon was inspirational. It is one of my most cherished memories from 2022. I wrote down a report for that <a href=\"https:\/\/open.substack.com\/pub\/runnerblues\/p\/berlin-marathon-2022?r=4vzb5&amp;utm_campaign=post&amp;utm_medium=web\">here<\/a>.<\/em><\/p>\n<p>Spring is just around the corner and I\u2019m excited what it holds.<\/p>\n<p>I look forward to many more starting lines in the upcoming year.\nHope some of you will join me.<\/p>\n<p><strong>\u201cPain is inevitable. Suffering is optional.\u201d<\/strong><\/p>"},{"title":"Review: Remembrance of Earth's Past","link":"https:\/\/kxsh.dev\/posts\/review-remembrance-of-earths-past\/","pubDate":"Sun, 24 Jul 2022 18:00:30 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/review-remembrance-of-earths-past\/","description":"<p>I was quite absorbed with this trilogy over the last couple of months.<\/p>\n<p>I distinctly remember reading the first chapter of <a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Three-Body_Problem_%28novel%29\">The Three-Body Problem<\/a>, few years ago at the university. I had stashed it for later. So I eventually decided to pick up the 1st book in the trilogy early May, after returning from India.<\/p>\n<p>After reading the trilogy, I have a lot more questions than I did before.\nQuestions ranging from astrophysics to humanity&rsquo;s collective decision making.\nThere are quite a handful of ideas\/theories that particularly intrigued me in the moment.<\/p>\n<p>It&rsquo;s quite easy to get overwhelmed by reading SciFi, especially when one has slight technical\/scientific background. So I definitely need more time, and probably a re-read to improve my understanding of what the books presented.<\/p>\n<p>I&rsquo;m grateful to the writer and translator for putting together this work.\nThoroughly enjoyed it.<\/p>\n<h1 id=\"references\">References<\/h1>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Three-Body_Problem_%28novel%29\">The Three-Body Problem<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Dark_Forest\">The Dark Forest<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Death%27s_End\">Death&rsquo;s End<\/a><\/li>\n<\/ul>"},{"title":"Review: Project Hail Mary","link":"https:\/\/kxsh.dev\/posts\/review-project-hail-mary\/","pubDate":"Sat, 19 Feb 2022 16:27:50 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/review-project-hail-mary\/","description":"<p><img src=\"https:\/\/upload.wikimedia.org\/wikipedia\/en\/a\/ad\/Project_Hail_Mary%2C_First_Edition_Cover_%282021%29.jpg\" alt=\"Project Hail Mary, 1st Edition Cover\"><\/p>\n<p>Extremely engaging, fun pop &ldquo;scientific&rdquo; fiction.<\/p>\n<h1 id=\"thoughts-provoked\">Thoughts Provoked<\/h1>\n<ul>\n<li>The difference between &ldquo;science&rdquo; and &ldquo;engineering&rdquo;. Without robust engineering skills at hand, scientific knowledge might not become a differentiating factor.<\/li>\n<li>An individual&rsquo;s character is revealed only during an adversity. Most seemingly strong people can be cowards.<\/li>\n<\/ul>\n<p>There is nothing philosophical, in particular, throughout the storyline.\nHowever, a bunch of facts related to basic science are tied into the narrative; no rocket science. Just the regular scientific jargon - &ldquo;relativity&rdquo;, &ldquo;evolution&rdquo;.<\/p>\n<p>The story of the protagonist has a redemption arc but it&rsquo;s a bit rushed towards the end of the story.<\/p>\n<p>All in all, I wouldn&rsquo;t read the book again. To be honest, I would prefer to watch the story as a movie.<\/p>\n<h1 id=\"references\">References<\/h1>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Project_Hail_Mary\">Wikipedia - Project Hail Mary<\/a><\/li>\n<li><a href=\"https:\/\/www.imdb.com\/title\/tt12042730\/\">IMDb - Project Hail Mary<\/a><\/li>\n<\/ul>"},{"title":"Life Long Learning","link":"https:\/\/kxsh.dev\/posts\/life-long-learning\/","pubDate":"Sun, 06 Jun 2021 19:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/life-long-learning\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/junglecoder.com\/blog\/learning-without-burnout\">Learning without Burnout<\/a><\/p>\n<hr>\n<p>I have the deep desire to be a life-long \u201clearner\u201d. Picking up hobbies, projects or fiddling with new activities, at the least. The idea is to not stagnate, and cease the wonderment of experiencing novelty. That is one of the prime reasons I chose to become a programmer professionally.<\/p>\n<p>\u201cKeeping up with the tech\u201d is also one of the pressing expectations in the field of software engineering - need to be on the toes and constantly trying out new concepts\/software. Given the increasing speed of innovation (at least development), there is always some new \u201celixir\u201d launched every week. This intensifies the importance of focusing on the basics and building a strong foundational understanding. At the same time, new tech helps to validate our current concepts and compose new ones.<\/p>\n<p>In the real world, not everyone has time to learn everything so there will always be tradeoffs based on priorities. This also highlights the importance of balancing growth with recovery. In this regard, the crucial skill is to learn to figure out how to fill gaps in one\u2019s knowledge. And the best way to do that is to build something using the tool you want to learn - as opposed to rationalizing and opinionating.<\/p>\n<p>Slow and steady will not lose the race.<\/p>"},{"title":"Quality Time at Tail","link":"https:\/\/kxsh.dev\/posts\/quality-time-at-tail\/","pubDate":"Mon, 31 May 2021 19:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/quality-time-at-tail\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/youtu.be\/JXeJANDKwDc\">When This Number Hits 5200 - You Will be Dead<\/a><\/p>\n<hr>\n<p>Our time on this earth is bounded.<\/p>\n<p>Our time spent with others is limited.<\/p>\n<p>Our time with our loved ones is limited still.<\/p>\n<p>The ongoing pandemic only exacerbates this sense of physical boundedness of human interactions. The next time we meet a person at a bar\/pub\/park\/library could very well be the last opportunity to interact with them.<\/p>\n<p>This concept of <em>doing something for the last time<\/em> feels a bit uncomfortable. Probably because there is a subtle subsconsious association with the inability to carry out that activity. This perspective puts two ideas in stark contrast with one another:<\/p>\n<ol>\n<li>the notion of being young, active, and determined.<\/li>\n<li>being able to do anything you set your mind to.<\/li>\n<\/ol>\n<p>This thought leads to the realization that the time we get to spend with our loved ones is <strong>extremely<\/strong> precious - given that we are the tail end of our interactions with them. Kurzgesagt does a great job at explaining this idea.<\/p>\n<p>Thus, it\u2019s vitally important to spend quality time with our loved ones - in whatever little we get to see them.<\/p>\n<p>The quality of our interpersonal interactions shifts across a spectrum as we cycle through different phases in our lives. As a child, we did not posses the mental faculty to have difficult conversations with our parents. As a teenager\/young adult, the tendencies to withdraw\/grow secluded might emerge. And as we start to become responsible adults, we might begin to notice our parents growing older and learn to treat them with the patience and warmth they need.<\/p>\n<blockquote>\n<p>As long as you live, keep learning how to live. - Seneca<\/p>\n<\/blockquote>"},{"title":"Pareto Principle","link":"https:\/\/kxsh.dev\/posts\/pareto-principle\/","pubDate":"Sun, 23 May 2021 19:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/pareto-principle\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/www.swyx.io\/8020\">80\/20 is the new Half-Ass<\/a><\/p>\n<hr>\n<p>The <strong>Pareto Principle<\/strong> (also known as the <strong>80\/20 rule<\/strong>) is one of the cornerstone characteristics for detecting power laws. It essentially states that a majority (80%) of the outcomes are driven by a minority (20%) of causes. The central idea is that effort and results are not linearly correlated. 80% of your time spent on a project need not translate to 80% of deliverables. For what it\u2019s worth, it could arbitrarily be called the <strong>99\/1<\/strong> rule as there is non-uniformity between the 20% of the effort as well. Thus, such non-linearity should be considered while prioritizing tasks to direct effort effectively.<\/p>\n<p>Moreover, this principle is becoming even more visible in various modern fields - especially software engineering:<\/p>\n<ul>\n<li>20% of the product\u2019s functionality is used in 80% of the user scenarios.<\/li>\n<li>20% of the bugs solve 80% of the customer support issues.<\/li>\n<li>80% of the program\u2019s execution time is spent in 20% of the lines of code.<\/li>\n<\/ul>\n<p>However, using the Pareto principle is not the best strategy for execution. Paying attention to the details creates a differential advantage while executing. It\u2019s easier to abuse this rule as an excuse to be lazy and half-ass at work. Nobody wants to use a product functionality that works only 80% of the time.<\/p>\n<h1 id=\"rules-of-engagement\">Rules of Engagement<\/h1>\n<ul>\n<li>Use Pareto to prioritize among tasks - quick wins, bang for the buck.<\/li>\n<li>Never use Pareto for execution - that\u2019s being lazy and unethical.<\/li>\n<li>Don&rsquo;t spend your time spraying 20% effort all over the place, hoping for 80% results, only to look back and wonder why you never hit 100% on anything.<\/li>\n<\/ul>\n<p><em>Aside: Vilfredo Pareto noticed such non-linearity while studying the power-law distribution of household incomes in Italy, hence the name 80\/20 was adopted.<\/em><\/p>"},{"title":"The Animal","link":"https:\/\/kxsh.dev\/posts\/the-animal\/","pubDate":"Sun, 16 May 2021 19:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/the-animal\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/www.robinhobb.com\/blog\/posts\/38429\">The Animal is Tired<\/a><\/p>\n<hr>\n<p>The Mind-Body Problem is a debate in the Philosophy of Mind concerned with our human mind and its relationship with our bodies. There are two competing schools of thought - <strong>Dualism<\/strong>, and <strong>Monoism<\/strong> - approaching this topic from different perspectives. Dualism proclaims that the human mind and the human body are two independent entities, while Monoism posits that both are imperceptibly indiscernible.<\/p>\n<p>No matter your beliefs, it is important to stay connected with your body - The Animal. It might be useful to check in with the body regularly and listen to its feedback. This thought is more pronounced now more than ever as human society has been tackling another Creation.<\/p>\n<p>We need to put thought into how the body feels every day, possibly during every activity. It is important to balance the desire for growth (or consumption) while not becoming indifferent to The Animal. In order to do so, it is imperative to have expectations matching the demands of the body and its physical limits.<\/p>\n<p>The Animal remembers every bad thing done to it. Whether it is staring continuously at a screen for work, or not moving enough, or running even when the joints complain, it is all going to add up in time. The bill always comes true.<\/p>\n<p>Lately, I have been actively mindful of these three things about my body:<\/p>\n<ul>\n<li>Proper nutrition<\/li>\n<li>Adequate exercise<\/li>\n<li>Time for recovery<\/li>\n<\/ul>\n<p>Don\u2019t be cruel to Animals. Start small.<\/p>"},{"title":"Build, Ship, and Repeat","link":"https:\/\/kxsh.dev\/posts\/build-ship-repeat\/","pubDate":"Sun, 09 May 2021 19:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/build-ship-repeat\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/training.kalzumeus.com\/newsletters\/archive\/do-not-end-the-week-with-nothing\">Don&rsquo;t End The Week With Nothing <\/a><\/p>\n<hr>\n<p>In creative spheres, the habit of <strong>building<\/strong> and <strong>shipping<\/strong> work is a vital feature of high-performing individuals. As a software-focused engineer, I think it\u2019s important to have something to show for at the end of the week. It could be a new product feature at work, reaching a milestone in a personal hobby, or whatever it is you are actively spending your time on.<\/p>\n<p>Shipping something regularly has the indirect benefit of being an intrinsic motivator for breaking into a positive, self-reinforcing loop. A loop of performance and throughput. Just like a muscle that builds up through training consistently. For example, this newsletter is a motivation for me to sit down and clarify my thoughts.<\/p>\n<p>Also, working on bigger projects has taught me the value of milestones as an indicator of gradual progress. Without an indication of progress in your endeavors, it might get difficult to follow through after a certain threshold. Milestones provide feedback and mental checkpoints for course correction.<\/p>\n<p>How exactly should we go about developing this habit of shipping results?\nThe linked post has got a few good pieces of advice for building a career from consistently delivering results.<\/p>\n<p>At the end of the day, it\u2019s the ability of creation that provides a lot of fulfillment, at least to me.<\/p>"},{"title":"Staying Ahead of the Curve","link":"https:\/\/kxsh.dev\/posts\/staying-ahead-of-the-curve\/","pubDate":"Sun, 02 May 2021 19:00:00 +0200","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/staying-ahead-of-the-curve\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/zackkanter.com\/2016\/01\/13\/you-are-not-behind\/\">You Are Not &lsquo;Behind&rsquo;<\/a><\/p>\n<hr>\n<p>Every high-performing individual wants to stay ahead of the curve. At the very least, they do not want to fall \u201cbehind\u201d in the curve. This is a paradox in itself. The interesting aspect of such a \u201ccompetitive\u201d perspective is the emotions that arise.<\/p>\n<p>Three of the most self-destructive emotions are <em>inferiority<\/em>, <em>anxiety<\/em>, and <em>regret<\/em>.\nAn inferiority complex builds up on the back of poor results, especially when compared to your peers. The crippling anxiety soon follows as the inferiority intensifies and recurs. In most cases, anxiety could lead to regrets about missed opportunities and harsher self-criticism. These emotions just act as gateways for many intense thoughts that sap the creative mental energy.<\/p>\n<p>Let us invert the performance criteria - compare only to yourself, specifically the version of you in the last iteration. The only thing that matters is you in this moment. Growth is an extremely individualistic concept. Other\u2019s are irrelevant and we need to let go of them. The only curve that matters is the one where you compare apples to apples.<\/p>\n<p>Nobody is perfect and neither are you. Building this perspective takes time, hard work, and failure. And once you truly internalize, the possibilities of the future are infinite, at the very least.<\/p>"},{"title":"Uncertainty and Gambling","link":"https:\/\/kxsh.dev\/posts\/uncertainly-gambling\/","pubDate":"Sun, 28 Feb 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/uncertainly-gambling\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/gamesofchance.substack.com\/p\/are-you-trading-or-gambling\">Are you trading or gambling?<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/uncertainly-gambling\/cover.webp\" alt=\"Black Swan in Australia\" title=\"Black Swan in Australia\"><\/p>\n<p>We are in a moment in human history, where people are extremely inclined to invest in stock markets. This desire is reflected in the traffic surge on platforms and tools that allow common people to invest their money into financial instruments, such as stock brokerages.<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup> This trend brings in a lot of inquiries about \u201coptimized\u201d ways of dealing with unforeseen events, making bets, and the financial consequences.<\/p>\n<p>It\u2019s extremely intriguing to understand how people deal with the uncertainty in their lives. When making decisions and betting (putting Skin In the Game) on uncertain events, everyone struggles to define that thin line between <strong>gambling<\/strong> and <strong>educated guesses<\/strong>. It is important to acknowledge that such definitions are very subjective - shaped by many cultural, societal, and other opaque elements. Note that it is almost often convenient to characterize decisions that lost as gambles and attribute successes to \u201ceducation and skill\u201d.<\/p>\n<p>This exposure to financial\/personal randomness is not something new that humans face in this day and age. Discussions around chance, luck, and fortune have been omnipresent in our societies in the form of epics and stories - we have the great Mahabharata where the Pandavas bet and lost it all. Then there are ideas of prophecies, destiny, and morality associated with randomness that only increase the difficulty with decision-making.<\/p>\n<p>Combine money, chance, decision making, and \u201cskill\u201d into a game and you have a recipe for hooking people in. When people perceive things in quantifiable amounts, it\u2019s even easier to trick our brains into unreasonable decisions. Also, beware of comparing real-world problems to games - things are a lot more opaque in reality than we would like to believe.<\/p>\n<p>This week\u2019s article talks about 2 important mathematical concepts that we should try to be mindful of when making bets:<\/p>\n<ul>\n<li><strong>Negative Expected Value<\/strong> games lead to <em>Gambler\u2019s Ruin<\/em> in the long run.<sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup><\/li>\n<li>Use <strong>Kelly Criterion<\/strong> for \u201coptimally\u201d sizing your bets.<sup id=\"fnref:3\"><a href=\"#fn:3\" class=\"footnote-ref\" role=\"doc-noteref\">3<\/a><\/sup><\/li>\n<\/ul>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/www.linkedin.com\/posts\/nithin-kamath-81136242_how-big-was-jan-2021-for-the-broking-industry-activity-6768188637533364224-Ypjf\/\">Nithin Kamath\u2019s LinkedIn post about the number of DEMAT accounts in India on a yearly basis.<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Gambler%27s_ruin?useskin=vector\">Gambler\u2019s Ruin<\/a> - Wikipedia&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:3\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Kelly_criterion?useskin=vector\">Kelly Criterion<\/a> - Wikipedia&#160;<a href=\"#fnref:3\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"The Power of Stories","link":"https:\/\/kxsh.dev\/posts\/power-of-stories\/","pubDate":"Sun, 21 Feb 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/power-of-stories\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/collabfund.com\/blog\/story\/\">Best Story Wins<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/power-of-stories\/cover.webp\" alt=\"Pale Blue Dot\" title=\"Pale Blue Dot\"><\/p>\n<p>Stories catch people\u2019s imaginations. Especially, the ones that give the perception of understanding.<\/p>\n<p>We like to simplify complex topics - reduce the dimensions of the underlying information. As Maestro Nassim Taleb writes in Black Swan, \u201cit is impossible for our brain to see anything in raw form without some interpretation. We may not even always be conscious of it.\u201d<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup><\/p>\n<p>Explanations bind facts together, as a cue for memory, among other things. The ability to weave existing information into an easily digestible story is a valuable skill in this modern world. The act of distilling a sequence of events into an explanation can provide a <em>sense of understanding<\/em> in this world full of unknowns. This becomes dangerous when such <em>explanations<\/em> increase our impression of knowledge, severely distorting our mental representation of the world.<\/p>\n<p>As kids, we come across so many fables introducing us to ethics. The story of <strong>\u201cThe Tortoise and The Hare\u201d<\/strong><sup id=\"fnref:2\"><a href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\">2<\/a><\/sup> is just more captivating than reading the pithy proverb - \u201cSlow and steady wins the race\u201d. In addition to fables, there are a lot of popular adult books that weave philosophies of life into their plot and character arcs - to name a few personal favorites - Siddhartha, The Little Prince, and The Alchemist.<\/p>\n<p>Stories can be helpful as a gateway to difficult, and hard-to-grasp topics. For example, I grew so curious about our unending universe after watching Cosmos<sup id=\"fnref:3\"><a href=\"#fn:3\" class=\"footnote-ref\" role=\"doc-noteref\">3<\/a><\/sup>, our magical planet after watching Planet Earth<sup id=\"fnref:4\"><a href=\"#fn:4\" class=\"footnote-ref\" role=\"doc-noteref\">4<\/a><\/sup>, and anthropology after Sapiens<sup id=\"fnref:5\"><a href=\"#fn:5\" class=\"footnote-ref\" role=\"doc-noteref\">5<\/a><\/sup>. Even though a lot of the facts presented in them could be wrong or outdated, they still serve as my North star about the respective topic - I can easily find the specifics if I\u2019m interested in digging deeper.<\/p>\n<p>Maybe that is the point!<\/p>\n<p>Stories may not add inherent value to our existing collective knowledge but they can be powerful enablers. Some stories can pique our curiosity about things that we don\u2019t usually think about or take for granted.<\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p><a href=\"https:\/\/www.goodreads.com\/book\/show\/242472.The_Black_Swan\">The Black Swan: The Impact of the Highly Improbable, Chapter Six<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:2\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Tortoise_and_the_Hare\">The Tortoise and The Hare<\/a>&#160;<a href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:3\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Cosmos:_A_Personal_Voyage\">Cosmos: A Personal Voyage<\/a>&#160;<a href=\"#fnref:3\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:4\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Planet_Earth_%282006_TV_series%29\">Planet Earth<\/a>&#160;<a href=\"#fnref:4\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<li id=\"fn:5\">\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Sapiens:_A_Brief_History_of_Humankind\">Sapiens: A Brief History of Humankind<\/a>&#160;<a href=\"#fnref:5\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"},{"title":"Curing our Epistemic Arrogance","link":"https:\/\/kxsh.dev\/posts\/epsitemic-arrogance\/","pubDate":"Sun, 14 Feb 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/epsitemic-arrogance\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/psyche.co\/ideas\/the-antidote-to-fake-news-is-to-nourish-our-epistemic-wellbeing\">The antidote to fake news is to nourish our epistemic wellbeing<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/epsitemic-arrogance\/cover.webp\" alt=\"Double living root bridge, Meghalaya, India\" title=\"a natural bridge over water stream in Meghalaya, India\"><\/p>\n<blockquote>\n<p>Epist\u0113m\u0113 is a Greek word that refers to knowledge; giving a Greek name to an abstract concept makes it sound important.<\/p>\n<\/blockquote>\n<p>In the book <a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Black_Swan:_The_Impact_of_the_Highly_Improbable?useskin=vector\">The Black Swan<\/a>, maestro Nassim Nicholas Taleb introduces the concept of epistemic arrogance - our overconfidence concerning the limits of our own knowledge; our misevaluation of our own knowledge.<\/p>\n<p>As our knowledge grows, it is threatened by greater increases in our confidence about the underlying information. Thus, the act of retrieving more information in order to grow our knowledge indirectly contributes to an increase in confusion and ignorance. In short, Taleb proclaims that <em>\u201chumans are simply not wise enough to be entrusted with knowledge\u201d<\/em>. Decision making with overconfidence can be as dangerous as (if not more) the decisions made by ignorance, not just for us but also for the people around us - our communities.<\/p>\n<p>As I reflect on this idea, I draw similar conclusions about how my knowledge base grows and the constant struggle to update it as I absorb new information, filtering out the irrelevant (in my personal consideration).<\/p>\n<p>Furthermore, Taleb talks about the self-reinforcing, double-edged effects of our epistemic arrogance:<\/p>\n<ol>\n<li>We overestimate what we know.<\/li>\n<li>We underestimate the uncertainty related to our knowledge.<\/li>\n<\/ol>\n<p>This gap between <em>what people actually know, and how much they think they know<\/em>, is a fault line in our brains that deepens into an ever-widening valley where overconfidence eventually starts to flow if we are not proactive. Personally, I believe our <strong>internal humility<\/strong> and <strong>epistemic wellbeing<\/strong> are few of the bridges connecting these two ends of the valley, and bringing some sanity to this over-the-top world we find ourselves in.<\/p>\n<p>This week\u2019s article focuses on our epistemic wellbeing and breaks down few important questions facing the humankind in the face of abuses of social media and information technology.<\/p>"},{"title":"Managing Stress for Dummies","link":"https:\/\/kxsh.dev\/posts\/managing-stress-for-dummies\/","pubDate":"Sun, 07 Feb 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/managing-stress-for-dummies\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/every.to\/superorganizers\/how-hard-should-i-push-myself\">How hard should I push myself?<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/managing-stress-for-dummies\/cover.webp\" alt=\"To-Do List\" title=\"A selfcare to-do list\"><\/p>\n<p>A lot of us want to give our best at what we do and this desire fuels our work, activities and relationships. Even if you put \u201cgood enough\u201d effort into your activities, you might find this article helpful (even, motivating) about how to manage stress in our daily life.<\/p>\n<h3 id=\"how-hard-should-i-push-myself\">How hard should I push myself?<\/h3>\n<p>I believe that in the process of pushing ourselves, we discover our mental limits, often adapt successfully to the workload. Nonetheless, the value of this question lies in the fact that we might be better off finding our personal balance between realizing our uninhibited ambitions and stretching ourselves too thin.<\/p>\n<p>In the process of answering this question, we need to be absolutely honest with ourselves. It\u2019s far easier to fool yourself with misguided motivators on either end of the spectrum - pushing ourselves too hard as an excuse to fill a deep-seated void, or procrastinating in the name of self-love.<\/p>\n<p>The central premise of the article is that - <strong>pushing yourself creates stress.<\/strong>\nSo the question essentially boils down to: <strong>How much is my appetite for stress?<\/strong><\/p>\n<p>The author dives into the possible mechanisms that manifest themselves as stress. I was very intrigued to note that our stress response could be considered a defense mechanism that is built to get us out of potentially danger. We, humans, have the ability to anticipate danger and a stress signal is the bodily response to such situations. So stress is a totally natural thing to experience in our lives. Thus, the ability to exert stress is not dangerous in and of itself. However, making a habit out of it, results in chronic stress - which is super harmful.<\/p>\n<p>The most useful metaphor for thinking about stress was that of how our physical body muscles develop strength. In particular, the importance of regular workout in keeping our muscles attuned for the environment at the cost of daily physical exertion.<\/p>\n<p>Inspite of how much stress you think you can take, some coping strategies could definitely help you. Here are some that I personally use\/plan to use:<\/p>\n<ol>\n<li>\n<p>Have the <em>optionality<\/em> to control your stressors and dial them down.<\/p>\n<\/li>\n<li>\n<p>Expose yourself to most stressors in a more predictable manner.<\/p>\n<\/li>\n<li>\n<p>Create productive outlets for frustrations - e.g. exercise and journaling.<\/p>\n<\/li>\n<li>\n<p>Social support to put an unmanageable stressor into perspective.<\/p>\n<\/li>\n<\/ol>"},{"title":"Simple Advice for Builders","link":"https:\/\/kxsh.dev\/posts\/advice-for-builders\/","pubDate":"Sun, 31 Jan 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/advice-for-builders\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/www.bti360.com\/what-ive-learned-in-45-years-in-the-software-industry\/\">What I\u2019ve Learned in 45 Years in the Software Industry<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/advice-for-builders\/cover.jpg\" alt=\"Dawn of a Day\" title=\"A dawn breaking over mountains\"><\/p>\n<p>A lot of things to pick up from Joel Goldberg\u2019s article after he retired from the tech industry. The entire post is gold mine for \u201cknowledge workers\u201d, perhaps more so for software engineers who can directly relate to much of what is written. Here are my takeaways from the perspective of a Journeyman, that I would like to implement in my life\/job:<\/p>\n<ol>\n<li><em>Guard against the Curse of Knowledge<\/em><\/li>\n<\/ol>\n<blockquote>\n<p>When you know something it is almost impossible to imagine what it is like not to know that thing.<\/p>\n<\/blockquote>\n<p>As you get more familiar with the internal knowledge of any system, you start developing a jargon within your team\/frequent collaborators. While this can help streamline the process, the cost is the added complexity - a layer of abstraction.<\/p>\n<ol start=\"2\">\n<li>\n<p>Being a <em>dependable team player<\/em> is as much valuable as being the smartest person in the team, if not more.<\/p>\n<\/li>\n<li>\n<p><em>Communicate proactively<\/em> with all the stakeholders of your work.<\/p>\n<\/li>\n<li>\n<p><em>Build simple solutions<\/em> in favor of clever ones.<\/p>\n<\/li>\n<\/ol>\n<p>Having read this article a fair few times throughout the day, there is still a lot of wisdom on offer. It will be a matter of time in my career before I can absorb the values and internalize the principles.<\/p>"},{"title":"Recursive Thinking","link":"https:\/\/kxsh.dev\/posts\/recursive-thinking\/","pubDate":"Sun, 24 Jan 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/recursive-thinking\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/parentheticallyspeaking.org\/articles\/how-not-to-teach-recursion\/\">How Not to Teach Recursion<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/recursive-thinking\/cover.webp\" alt=\"Recursion\" title=\"A curve that is recursive\"><\/p>\n<blockquote>\n<p>There\u2019s a big difference between knowing the name of something and knowing something.<\/p>\n<\/blockquote>\n<p>I think about this statement from Richard Feynman sometimes and often use it as a lens to reflect the depth of concepts I study. Recursion is one such fascinating idea that looks too simple on the surface to grasp.<\/p>\n<p>Recursion was one of the first programming concepts I learnt as a kid - implementing factorials and Fibonacci series. However, as a software engineer I do not consider using recursive solution for potentially suitable problems I face (tail recursion is a separate topic altogether).<\/p>\n<p>This article articulates why our awareness about recursive strategies does not translate to implementations. The author argues that our mental models around recursion are very pedantic, not pragmatic. We are taught to solve niche mathematical problems as examples in classes\/books but mostly use such solutions in isolation. This renders the power of recursion as a problem solving technique rather weak as compared to iteration.<\/p>\n<p>The author also inquires the question whether some problems are inherently recursive. The take on the origins of recursion from <em>self-references in data<\/em> is particularly intriguing. <em>Particularly, the idea that the use of certain data types to solve any given problem inherently affects how the probelm is solved.<\/em> Moreover, it suggests that using self referential data types (e.g. tree) can potentially lead to the development of recursive problem solving approach.<\/p>"},{"title":"Spiral of Primes","link":"https:\/\/kxsh.dev\/posts\/spiral-of-primes\/","pubDate":"Sun, 17 Jan 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/spiral-of-primes\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/www.youtube.com\/watch?v=EK32jo7i5LQ\">Why do prime numbers make these spirals?<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/spiral-of-primes\/cover.png\" alt=\"Primes less than 30000 in polar coordinates\" title=\"Primes less than 30000 in polar coordinates\"><\/p>\n<p>It\u2019s a humid summer day back at the university and I\u2019m sitting in for the semester examination of Modern Algebra in the 3rd year of my Masters in Mathematics. There is a question about Dirichlet\u2019s Theorem and I totally blank on what I had crammed with my friends a day before the examination.<\/p>\n<p>This video brings about an intuition for the relation between geometric representation of numbers with some analytical validations.<\/p>\n<ul>\n<li>\n<p><strong>Residue classes mod n (n.k + m)<\/strong>: everything <em>m<\/em> above multiples of <em>n<\/em>.<\/p>\n<\/li>\n<li>\n<p><strong>Coprimes<\/strong>: relatively prime pair of numbers.<\/p>\n<\/li>\n<li>\n<p><strong>Euler\u2019s Totient Function \u03c6(n)<\/strong> : no of integers from 1 to n which are coprime to n.<\/p>\n<\/li>\n<li>\n<p>Relation between primes and \u03c0.<\/p>\n<\/li>\n<li>\n<p><strong>Dirichlet\u2019s Theorem<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p><em>How pretty but pointless patterns in polar plots of primes prompt pretty important ponderings on properties of those primes.<\/em> Such arbitrary geometric exploration of numbers led me to understand something so beautiful in math.<\/p>\n<p>Cue back to the university examination.<\/p>\n<p>Most of the concepts and theorems I came across in my formal mathematical education I approached them as arbitrary, rigorous definitions that served an immediate purpose rather than learning fundamental constructs in their depth - much like what you would feel if you read the above list and not watch the video. Grant Sanderson\u2019s simple explanations to such complex mathematical concepts definitely help me understand better and build the intuition I was lacking.<\/p>\n<p>I find rediscovering mathematical topics on my own out of genuine curiosity is so much more fulfilling than the obligation to study them for the sake of formal education. Fascinating this!<\/p>"},{"title":"Project Today","link":"https:\/\/kxsh.dev\/posts\/project-today\/","pubDate":"Sun, 10 Jan 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/project-today\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/psyche.co\/films\/one-photo-per-day-for-more-than-a-year-exploring-how-rituals-affect-memory\">Today by Scott Thrift<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/project-today\/cover.jpg\" alt=\"A Wedge of Geese\" title=\"A wedge of geese flying into the setting sun.\"><\/p>\n<p>Jonathan Harris\u2019 project Today is built around the idea of clicking a single photo and posting it online every single day. The concept resonates with me and what I\u2019m trying to achieve with this Substack.<\/p>\n<p>The most interesting aspect of this project was Johnathan\u2019s opinion of human memory and the dichotomy presented by the act of clicking photos - being mindful in the moment, and capturing the moment as well. I fundamentally believe that both are mutually exclusive. Especially given the range of electronic gadgets modernity offers, it is extremely difficult to do both at the same time and easier to mistake one for the other.<\/p>\n<p>Another perspective of the project was to build an extremely personal memory practice and weaving stories around them. There is definitely something to be said about the act of consciously creating memories through such a daily routine. The year long journey felt a lot like an inquiry into artful ways of constructing our own memory methods (memory palaces et al).<\/p>\n<p>As Jonathan himself said, the documentary itself might feel like someone is out hunting with an anticipated finale but it\u2019s actually a relaxing, random walk through the forest. It might even be a metaphor for life - as we plan towards an end goal, perhaps focusing too much on the destination and missing the journey (infinitely many cliches around this thought).<\/p>\n<p>I derived a lot of meta value about art and it\u2019s relation to various aspects of our life from watching this documentary and learning about the project itself. Hope you find something in there as well!<\/p>"},{"title":"Leveraging Emerging Technologies","link":"https:\/\/kxsh.dev\/posts\/leveraging-emerging-technologies\/","pubDate":"Sun, 03 Jan 2021 19:00:00 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/leveraging-emerging-technologies\/","description":"<hr>\n<p>Forwarded: <a href=\"https:\/\/a16zcrypto.com\/posts\/article\/doing-old-things-better-vs-doing-brand-new-things\/\">Doing Old Things Better Vs. Doing Brand New Things - Andreessen Horowitz<\/a><\/p>\n<hr>\n<p><img src=\"https:\/\/kxsh.dev\/posts\/leveraging-emerging-technologies\/cover.webp\" alt=\"Doing Old Things Better v Doing Brand New Things\" title=\"Doing Old Things Better v Doing Brand New Things\"><\/p>\n<p>How can a new technology make the most impact on the world?<\/p>\n<ul>\n<li>Should the focus be on improving existing products\/strategies?<\/li>\n<li>Should the priority instead be to explore new possibilities of working on things that were previously not even conceivable?<\/li>\n<\/ul>\n<p>Usually when a new technological breakthrough happens, it is easier to let the excitement make us focus too much on the minutae - immediate, perceptible gains . However, its is all the more important to take a step back and try to figure out the biggger picture. In the article, Horowitz suggests that non-linear (exponential) payoffs come from imagining and building things around the new \u201cnative\u201d ideas inherently introduced by the technology itself.<\/p>\n<p>For example: Internet in 1990s was primarily used for ecommerce and the solving problems that it was expected to solve. However, the 2000s brought about new products that explored the unknown domains of social media, cryptocurrency, blogging, podcasting and video content as the cost of content distribution decreased substantially.<\/p>\n<p>In the last few years, fields such as virtual reality and cryptocurrencies have caught a lot of imagination and I\u2019m very excited to see what kind of products can be built around this tech even though it might take a decade or more to fully play out and become the new \u201cnormal\u201d.<\/p>\n<p>Another example in this category of technologies would be <strong>Apple M1 chip<\/strong>. I just wonder about the possibilities for the entire Apple Ecosystem with this new processor.<\/p>\n<p>Exciting!<\/p>"},{"title":"Magical Files","link":"https:\/\/kxsh.dev\/posts\/magical-files\/","pubDate":"Sun, 10 Feb 2019 18:55:02 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/magical-files\/","description":"<h1 id=\"context\">Context<\/h1>\n<p>My <code>Downloads<\/code> folder is a mess!<\/p>\n<p>I have got hundreds of files in that directory. Most of them are PDF documents with some images, archives and disk images.<\/p>\n<p>\u201cIs there a way to only list all the PDF files present in a directory?\u201d<\/p>\n<p>Well, filtering based on file extension (<code>.pdf<\/code>) should be able to do this for me. Moreover, I can leverage the power of regular expression: <code>$ ls -lh ~\/Downloads\/*.pdf<\/code><\/p>\n<p>After some experimentation, I discovered that a non-negligible number of files stored in PDF format existed which did not have a <code>.pdf<\/code> extension \ud83d\ude31:<\/p>\n<ol>\n<li>The university\u2019s portal only allows us to download PDFs with a <code>.jsp<\/code> extension. \ud83d\ude13<\/li>\n<li>I had a <code>FileHandler.ashx<\/code> file that also contained data in PDF format.<\/li>\n<\/ol>\n<p>These findings helped me infer that the use of <code>*.pdf<\/code> RegEx is not robust enough to ensure that all PDF documents are selected. Apparently, even the OSX\u2019s Finder fails at detecting the file \u201cKind\u201d for <code>FileHandler.ashx<\/code>.<\/p>\n<p>Finder<\/p>\n<p>Looking for something more sophisticated, eh?<\/p>\n<h1 id=\"detour-magic-numbers-\">Detour: Magic Numbers \u2728<\/h1>\n<p>What is a <strong>magic number<\/strong>?<br>\nAny constant numerical or text value that you find in your code is a magic number, especially the ones you \u201cforget\u201d to comment\/document.<\/p>\n<p>Interestingly enough, many files have such constants that identify the contained data. In addition to this, detecting such constants in files is a simple and effective way of distinguishing between many file formats. \ud83d\ude32 These magic numbers, used to identify or verify the content of a file, are also called \u201cfile signatures\u201d.<\/p>\n<p>Examples:<\/p>\n<ol>\n<li>PDF documents begin with <code>%PDF<\/code> text - the corresponding magic number for this format.<\/li>\n<li>Shebang (<code>!\/usr\/bin\/sh<\/code>) line in script files is a human readable file signature.<\/li>\n<li><code>&lt;!DOCTYPE HTML&gt;<\/code> indicate HTML documents.<\/li>\n<\/ol>\n<p><strong>caution \u26a0\ufe0f:<\/strong><\/p>\n<p>The magic number approach offers better guarantees that the format will be identified correctly, and can often determine more precise information about the file.<\/p>\n<ol>\n<li>Since reasonably reliable \u201cmagic number\u201d tests can be fairly complex, and each file must effectively be tested against every possibility in the magic database, this approach is relatively inefficient, especially for displaying large lists of files.<\/li>\n<li>Also, data must be read from the file itself, increasing latency as opposed to metadata stored in the directory.<\/li>\n<li>Where file types don\u2019t lend themselves to recognition in this way, the system must fall back to metadata.<\/li>\n<\/ol>\n<p><strong>green light \u2705:<\/strong><\/p>\n<p>Failing a well-designed magic number test is a pretty sure sign that the file is either <strong>corrupt<\/strong> or of the <strong>wrong type<\/strong>. On the other hand, a valid magic number does not guarantee that the file is not corrupt or is of a correct type.<\/p>\n<h1 id=\"preliminary-research\">Preliminary Research<\/h1>\n<p>I have previously used the Unix <code>file<\/code> command for determining the file type by performing some \u201ctests\u201d via system calls. One of them is the <strong>magic test<\/strong> which checks the file header for the existence of these magic numbers using the <code>libmagic<\/code> library written in C.<\/p>\n<p>The next question confronting me: \u201cIs there a way to use the libmagic library from Go?\u201d<\/p>\n<p>That\u2019s when I found the <a href=\"https:\/\/github.com\/rakyll\/magicmime\">rakyll\/magicmime<\/a> package from the inimitable JBD. \ud83c\udf89\nIt provides Go bindings for the <code>libmagic<\/code> library - exactly what I was looking for! \ud83d\ude01<\/p>\n<h1 id=\"solution\">Solution<\/h1>\n<p>This week I will be developing a CLI using <a href=\"https:\/\/github.com\/spf13\/cobra\">spf13\/cobra<\/a> which can help the users filter files based on it\u2019s format. My intention is to make a simple, decoupled and UNIX pipe compatible tool that plays well with other utilities. With my university exams starting in 10 days, this week would be the optimal period for me to work on the project.<\/p>\n<p>In case there are any existing solutions for solving this, do let me know!<br>\nIf you currently experience this problem, I would love to hear your thoughts. \ud83d\ude03<\/p>\n<h1 id=\"references\">References<\/h1>\n<ol>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Magic_number_%28programming%29\">Magic number<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/File_%28command%29\">file command<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/File_format\">File format<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_file_signatures\">List of file signatures<\/a><\/li>\n<\/ol>"},{"title":"Weekend with Flutter","link":"https:\/\/kxsh.dev\/posts\/weekend-with-flutter\/","pubDate":"Sun, 03 Feb 2019 19:14:09 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/weekend-with-flutter\/","description":"<p>I built my first-ever mobile application as a weekend project.<br>\nThis post describes my experience, thoughts and emotions over the past few days.<\/p>\n<hr>\n<h1 id=\"motivation\">Motivation<\/h1>\n<p>Last week, my friends introduced me to a cards game called \u201c350\u201d. It involved bidding points, calling trumps, playing hands - so much fun! Now the only issue was that there was no simple way to store our points table. We found ourselves repeatedly checking the scores and wasting a lot of time talking about game information. I used Google Excel\u2019s Android app as an ad-hoc way to track individual scores so as to reduce some friction. Excel sheet worked fine but it still could not display game related information in a consumable format.<\/p>\n<p>The next morning I started to think there <strong>must be a better way<\/strong> to do this. After some online research, I discovered that no existing application\/software for book-keeping specifically for this game. Thus, my decision to dedicate the weekend on developing a simple mobile app for this.<\/p>\n<p>I was pretty excited about the project as this would be my first attempt at app development in around 4 years writing software. At the same time, it was a bit scary as I had no idea about the timeline and whether developing a MVP is even a practical expectation. However, being the optimist that I am, I decided to give it a go.<\/p>\n<p>Breathe!<\/p>\n<h1 id=\"laying-the-groundwork\">Laying the Groundwork<\/h1>\n<h2 id=\"desgining-layouts\">Desgining layouts<\/h2>\n<p>Kicking off the project, I started drawing basic layouts for the app screens on a piece of paper. My primary focus during this stage was to developing the bare minimum functionalities. With no idea of how to implement these layouts, I relied solely on my determination of getting them to work - after all it\u2019s just UI!<\/p>\n<p><img src=\"https:\/\/kxsh.dev\/images\/posts\/play350-layout.jpg\" alt=\"layouts\"><\/p>\n<h2 id=\"choosing-flutter\">Choosing Flutter<\/h2>\n<p>After building the screen layouts, I started looking for frameworks and tools which help build the actual app. I read about <a href=\"https:\/\/developer.android.com\/studio\/\">Android Studio Code<\/a>, <a href=\"https:\/\/facebook.github.io\/react-native\/\">React Native<\/a> and <a href=\"https:\/\/flutter.dev\/\">Flutter<\/a>. With my focus on rapid development, flexible UI and personal productivity, I choose Flutter. In addition to sparing me from writing Java-XML and Javascript, Flutter provided me with the added benefit of building cross-platform native applications.<\/p>\n<h1 id=\"flutter-101\">Flutter 101<\/h1>\n<p>The major issue with Flutter was that the application code must be written in Dart. With a clock on my back, the last thing I wanted to do was spend time learning a new programming language. So, I decided to dive head first into building the app itself and learning Dart syntax on the go.<\/p>\n<p>After setting my dev env, I completed the Google Codelabs to get a brief idea of how things worked in Flutter. I would highly recommend working out the Udacity Course on building Flutter apps as well. These resources taught me the following central concepts for building apps in Flutter:<\/p>\n<ol>\n<li><strong>Stateless Widgets<\/strong> : equivalent to static web pages like this blog post<\/li>\n<li><strong>Stateful Widgets<\/strong> : dynamic pages where contents change with user interactions<\/li>\n<li><strong>State Management<\/strong> : managing the data for Stateful Widgets<\/li>\n<li><strong>Routes<\/strong> : analogous to the URL for an application screen<\/li>\n<li><strong>Navigation<\/strong> : moving around the application screen via respective routes<\/li>\n<\/ol>\n<p>My major takeaway from the exercises was: <strong>\u201cEverything in Flutter is a widget\u201d<\/strong>.<\/p>\n<p>It took me around 6 hours to complete both the labs along with their quizzes.<br>\nThe decision to complete the sample project along in the codelabs paid rich dividends as I started developing my own app.<\/p>\n<h1 id=\"building-screens\">Building screens<\/h1>\n<p>With my initial focus on emulating the layouts I had built into the app, I started off by implementing every screen as a Stateless Widget and fixing on the display layout with the help of <em>Hot Reload<\/em>.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-dart\" data-lang=\"dart\"><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ The Welcome Screen is the 1st page of the application.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ It is a StatelessWidget as the only possible option for the user is to tap a button \n<\/span><\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#9ca0b0;font-style:italic\">\/\/ and navigate to a new screen.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">class<\/span> <span style=\"color:#df8e1d\">WelcomeScreen<\/span> <span style=\"color:#d20f39\">extends<\/span> StatelessWidget {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">@<\/span>override\n<\/span><\/span><span style=\"display:flex;\"><span> Widget build(BuildContext context) {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">return<\/span> Scaffold(\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">body:<\/span> buildBody(context),\n<\/span><\/span><span style=\"display:flex;\"><span> );\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ Implement methods for building the screen body layout\n<\/span><\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>When I was fairly satisfied with the screen, I refactored the code to a <em>Stateful Widget<\/em> along with the relevant <em>State<\/em> data. Note: Each <em>Stateful Screen<\/em> is related to its corresponding <em>ScreenState class<\/em> which stores the state and screen layout instructions.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-dart\" data-lang=\"dart\"><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">class<\/span> <span style=\"color:#df8e1d\">GameBidderScreen<\/span> <span style=\"color:#d20f39\">extends<\/span> StatefulWidget {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ Data which is not modified for this particular screen\n<\/span><\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">final<\/span> <span style=\"color:#d20f39\">String<\/span> boardID;\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">final<\/span> <span style=\"color:#d20f39\">int<\/span> gameID;\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">final<\/span> List<span style=\"color:#04a5e5;font-weight:bold\">&lt;<\/span><span style=\"color:#d20f39\">String<\/span><span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> players;\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">final<\/span> List<span style=\"color:#04a5e5;font-weight:bold\">&lt;<\/span>List<span style=\"color:#04a5e5;font-weight:bold\">&lt;<\/span><span style=\"color:#d20f39\">int<\/span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;<\/span> scoreboard;\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">const<\/span> GameBidderScreen(\n<\/span><\/span><span style=\"display:flex;\"><span> {<span style=\"color:#8839ef\">this<\/span>.boardID, <span style=\"color:#8839ef\">this<\/span>.gameID, <span style=\"color:#8839ef\">this<\/span>.players, <span style=\"color:#8839ef\">this<\/span>.scoreboard});\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">@<\/span>override\n<\/span><\/span><span style=\"display:flex;\"><span> State<span style=\"color:#04a5e5;font-weight:bold\">&lt;<\/span>GameBidderScreen<span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> createState() <span style=\"color:#04a5e5;font-weight:bold\">=&gt;<\/span> _GameBidderScreenState();\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">class<\/span> <span style=\"color:#df8e1d\">_GameBidderScreenState<\/span> <span style=\"color:#d20f39\">extends<\/span> State<span style=\"color:#04a5e5;font-weight:bold\">&lt;<\/span>GameBidderScreen<span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ Data which populates the body and is modifiable.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">String<\/span> bidder;\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">int<\/span> bid <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">0<\/span>;\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">String<\/span> trump;\n<\/span><\/span><span style=\"display:flex;\"><span> List<span style=\"color:#04a5e5;font-weight:bold\">&lt;<\/span>DropdownMenuItem<span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> _playersItems;\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#d20f39\">@<\/span>override\n<\/span><\/span><span style=\"display:flex;\"><span> Widget build(BuildContext context) {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#8839ef\">return<\/span> Scaffold(\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">appBar:<\/span> buildAppBar(context),\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">body:<\/span> buildBody(context),\n<\/span><\/span><span style=\"display:flex;\"><span> );\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ Implement the layout builders\n<\/span><\/span><\/span><\/code><\/pre><\/div><p>This process of continuous refactoring turned out to be rather simple and involved all of 10 LoC.<\/p>\n<ul>\n<li>\n<p>How to decide whether a screen should be a <em>Stateless Widget<\/em> or a <em>Stateful Widget<\/em>?<\/p>\n<ul>\n<li>If any user interactions (tap, long press, drag) change <strong>this<\/strong> screen\u2019s content, use, then the screen can be a Stateless Widget.<\/li>\n<li>Note this conditional holds, even if some actions prompt navigation to another new screen entirely.<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>What data should be stored as the screen state?<\/p>\n<ul>\n<li>Anything that the screen should not be able to change (e.g. user\u2019s name, email) should not be a state variable; it should rather be a <em>final<\/em> instance variable in the Screen widget. Most likely, the value for such variables will be passed in from previous screens in the application flow.<\/li>\n<li>Anything that the screen needs to modify upon user interactions (e.g. like\/unlike, retweet\/share, text input) should be stored as instance variable in the respective ScreenState class.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img src=\"https:\/\/kxsh.dev\/images\/posts\/play350-welcome.png\" alt=\"welcome screen\">\n<img src=\"https:\/\/kxsh.dev\/images\/posts\/play350-gameplay.png\" alt=\"gameplay screen\">\n<img src=\"https:\/\/kxsh.dev\/images\/posts\/play350-gameresult.png\" alt=\"gameresult screen\"><\/p>\n<h1 id=\"navigation\">Navigation<\/h1>\n<p>Now that we have built our screen layouts, its about time to connect all of them and build the user flow. Flutter uses a <strong>stack based navigation<\/strong> system for moving around screens. Basically, this means that you <strong>push<\/strong> a new screen on top of the current screen if you want to switch. Moreover, you have to <strong>pop<\/strong> screens in order to reduce the amount of RAM consumed by your application.<\/p>\n<p>In my case, I decided to pop screens before pushing in new ones whenever the user decided to start a <em>New Game<\/em>.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-dart\" data-lang=\"dart\"><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ When the user presses the &#34;New Game&#34; button on the result screen.\n<\/span><\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">onPressed:<\/span> () {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ Ensure that the scoreboard is updated\n<\/span><\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ Pop the result screen itself\n<\/span><\/span><\/span><span style=\"display:flex;\"><span> Navigator.pop(context);\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#9ca0b0;font-style:italic\">\/\/ Push a new game screen with the incremented game counter\n<\/span><\/span><\/span><span style=\"display:flex;\"><span> Navigator.push(\n<\/span><\/span><span style=\"display:flex;\"><span> context,\n<\/span><\/span><span style=\"display:flex;\"><span> MaterialPageRoute(\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">builder:<\/span> (context) <span style=\"color:#04a5e5;font-weight:bold\">=&gt;<\/span> GameBidderScreen(\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">boardID:<\/span> widget.boardID,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">gameID:<\/span> widget.gameID <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> <span style=\"color:#fe640b\">1<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">players:<\/span> widget.players,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">scoreboard:<\/span> _updatedScoreboard,\n<\/span><\/span><span style=\"display:flex;\"><span> ),\n<\/span><\/span><span style=\"display:flex;\"><span> ),\n<\/span><\/span><span style=\"display:flex;\"><span> );\n<\/span><\/span><span style=\"display:flex;\"><span> },\n<\/span><\/span><\/code><\/pre><\/div><h1 id=\"whats-next\">What\u2019s Next?<\/h1>\n<p>In the future, I plan to complete the following tasks as well:<\/p>\n<ul>\n<li>Firebase integration<\/li>\n<li>Use Firestore database<\/li>\n<li>Google Sign-In<\/li>\n<li>Explore \u201cAnimations\u201d<\/li>\n<li>Make scoreboard interactive.<\/li>\n<li>Add synchronisation between players.<\/li>\n<\/ul>\n<h1 id=\"parting-thoughts\">Parting Thoughts<\/h1>\n<p>I am super satisfied and proud of myself for completing the MVP I had set out at the start of the weekend. It was all down to the ease with which I was able to get things done in Flutter even though I did not learn Dart. Even though this would not be the best code architecture, I am fairly happy to get it working.<\/p>\n<p>Do give the app a try if you like to play 350.<br>\nHappy to incorporate feedback into the app! \ud83d\ude01<\/p>\n<p>Hopefully, this post motivates you to try Flutter for building your next disruptive mobile application!<\/p>\n<h1 id=\"references\">References<\/h1>\n<p>[1]: Source on GitHub: <a href=\"https:\/\/github.com\/kshitij10496\/play350\">kshitij10496\/play350<\/a><br>\n[2]: Google Codelabs: <a href=\"https:\/\/codelabs.developers.google.com\/codelabs\/first-flutter-app-pt1\/index.html?index=..%2F..index#0\">Write Your First Flutter App<\/a><br>\n[3]: Udacity: <a href=\"https:\/\/classroom.udacity.com\/courses\/ud905\">Build Native Mobile Apps with Flutter<\/a><\/p>"},{"title":"Postgres with Docker","link":"https:\/\/kxsh.dev\/posts\/postgres-with-docker\/","pubDate":"Sun, 13 Jan 2019 20:47:59 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/postgres-with-docker\/","description":"<p>Lately, I have been experimenting with running PostgreSQL in a Docker container and communicating with it - from an application. This article documents my experience, learnings and methodology.<\/p>\n<h1 id=\"problem\">Problem<\/h1>\n<p>I have got a lot of small personal projects which use separate databases.<br>\nEach DB is associated with a unique configuration (combination of user, password, name) which as exported as environment variables in the relevant applications.<\/p>\n<p>Now, this soon got messy as my machine was polluted with lots of DBs and their configurations. Thus, I started exploring the possibility of using containers for the task of running the DBs.<\/p>\n<h1 id=\"getting-started\">Getting Started<\/h1>\n<p>Before starting diving into reading endless documentation, articles and tutorials, I wrote down some basic questions which I wanted to be answered first. My prime concern was getting up to speed with performing fundamental DB operations as quickly as possible with the new container layer.<\/p>\n<ol>\n<li>How can I initialise the DB with some schema as soon as it starts up?<\/li>\n<li>Can I access the DB via command-line and perform SQL commands using <code>psql<\/code>?<\/li>\n<li>How do I connect to the DB via a running application?<\/li>\n<li>What is the way to persist data once the running DB container is stopped?<\/li>\n<\/ol>\n<p>Based on my prior experience with Docker, I already knew that as soon as a container is stopped all the data stored in it gets deleted. Thus, persisting data changes would be a major challenge otherwise the whole point of using containers is <em>moo<\/em>. \ud83d\udc2e<\/p>\n<h3 id=\"prerequisites\">Prerequisites<\/h3>\n<ul>\n<li><a href=\"https:\/\/docs.docker.com\/install\/#supported-platforms\">Install <code>docker<\/code><\/a><\/li>\n<li><a href=\"https:\/\/docs.docker.com\/compose\/install\/\">Install <code>docker-compose<\/code><\/a><\/li>\n<\/ul>\n<h1 id=\"project\">Project<\/h1>\n<p>We will a PostgreSQL DB for all the members of the infamous <strong>League of Shadows<\/strong> \ud83d\udc79.<br>\nThis database is mission-critical to the Gotham PD for protecting the city from future acts of terrorisms.<\/p>\n<h2 id=\"basic\">Basic<\/h2>\n<h3 id=\"1-design-the-db-schema\">1. Design the DB schema<\/h3>\n<p>We will keep it simple for now as we are more concerned with learning how to use Postgres from a running container rather than focusing on the database schema design.<\/p>\n<p>We will use a single table called <code>members<\/code> as follows:<\/p>\n<hr>\n<table>\n <thead>\n <tr>\n <th>id<\/th>\n <th>name<\/th>\n <th>bio<\/th>\n <\/tr>\n <\/thead>\n <tbody>\n <tr>\n <td>1<\/td>\n <td>Ra\u2019s al Ghul<\/td>\n <td>He is the founder of The League of Shadows.<\/td>\n <\/tr>\n <tr>\n <td>2<\/td>\n <td>Bruce Wayne<\/td>\n <td>Batman\u2019s secret identity is Bruce Wayne, an American billionaire, playboy, philanthropist, and owner of Wayne Enterprises.<\/td>\n <\/tr>\n <tr>\n <td>3<\/td>\n <td>Talia al Ghul<\/td>\n <td>She is the daughter of Ra\u2019s al Ghul.<\/td>\n <\/tr>\n <tr>\n <td>4<\/td>\n <td>Bane<\/td>\n <td>Bane was once a member of The League until he was excommunicated by Ra\u2019s al Ghul.<\/td>\n <\/tr>\n <\/tbody>\n<\/table>\n<h3 id=\"2-create-and-run-the-postgresdb-container\">2. Create and run the PostgresDB container<\/h3>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"display:flex;\"><span>$ docker run --detach <span style=\"color:#1e66f5\">\\ <\/span><span style=\"color:#9ca0b0;font-style:italic\"># run the container in background<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> --name <span style=\"color:#40a02b\">&#34;shadowsDB&#34;<\/span> <span style=\"color:#9ca0b0;font-style:italic\"># name the container<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> -e <span style=\"color:#dc8a78\">POSTGRES_USER<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#40a02b\">&#34;batman&#34;<\/span> <span style=\"color:#1e66f5\">\\ <\/span><span style=\"color:#9ca0b0;font-style:italic\"># configuration specific to our database<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> -e <span style=\"color:#dc8a78\">POSTGRES_PASSWORD<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#40a02b\">&#34;blueflower&#34;<\/span> <span style=\"color:#1e66f5\">\\\n<\/span><\/span><\/span><span style=\"display:flex;\"><span> -e <span style=\"color:#dc8a78\">POSTGRES_DB<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#40a02b\">&#34;league_of_shadows&#34;<\/span> <span style=\"color:#1e66f5\">\\ <\/span> \n<\/span><\/span><span style=\"display:flex;\"><span> postgres:11.1-alpine \n<\/span><\/span><\/code><\/pre><\/div><ul>\n<li>This command will run a container with a DB named \u201cleague_of_shadows\u201d for the user \u201cbatman\u201d.<\/li>\n<li>We are using <code>--detach<\/code> primarily because we do not want to pollute our terminal with logs from PostgreSQL.<\/li>\n<li>We use the Alpine image for experimentation purpose only. (<code>bash<\/code>)<\/li>\n<\/ul>\n<h3 id=\"3-using-docker-compose-instead-for-a-simpler-interface\">3. Using <code>docker-compose<\/code> instead for a simpler interface.<\/h3>\n<p>As you can see, the multi-line command looks a bit clunky and is prone to mistakes.\nLet\u2019s rewrite the same command in a <code>docker-compose.yml<\/code> file instead.<\/p>\n<p>Create the following <code>docker-compose.yml<\/code> file inside the project directory <code>shadows<\/code>:\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/0fd513ea8c8ece1d4c9dba03bd988489.js?file=docker-compose.yml\"><\/script>\n<\/p>\n<p>Now we can run the container from within the <code>shadows<\/code> directory with:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"display:flex;\"><span>$ docker-compose up\n<\/span><\/span><\/code><\/pre><\/div><h3 id=\"4-access-the-db-running-within-the-container\">4. Access the DB running within the container<\/h3>\n<p>Now that the container is running, open a new terminal.<\/p>\n<p>Exercise: Check whether the DB has any tables or data?<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"display:flex;\"><span>$ docker <span style=\"color:#04a5e5\">exec<\/span> -it shadowsDB bash <span style=\"color:#9ca0b0;font-style:italic\"># opens up a Bash session inside the DB container<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>$ psql league_of_shadows -U batman <span style=\"color:#9ca0b0;font-style:italic\"># connect to the DB<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#dc8a78\">league_of_shadows<\/span><span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#1e66f5\">\\d<\/span>t <span style=\"color:#9ca0b0;font-style:italic\"># list tables in the DB<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>Did not find any relations.\n<\/span><\/span><\/code><\/pre><\/div><p>It\u2019s empty! \ud83d\ude22<\/p>\n<ul>\n<li>Thanks to naming our container and using the Alpine image, we can easily use bash here.<\/li>\n<li>Password is not required when you are connecting to the DB from inside the container.<\/li>\n<\/ul>\n<p><em>I encourage you to play around inside the container.<\/em><\/p>\n<h3 id=\"5-loading-data-into-the-db\">5. Loading data into the DB<\/h3>\n<p>(pwd: <code>shadows<\/code>)<\/p>\n<p>Let\u2019s add our all important data to the empty DB.<\/p>\n<ol>\n<li>(optional) If you are still inside the container, exit it by closing the bash session.<\/li>\n<li>Create <code>1.sql<\/code> and <code>2.sql<\/code> files inside a postgres directory within the project.<br>\nThe SQL files hold the SQL instructions required for creating the DB table and populating it respectively.<\/li>\n<\/ol>\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/4eb85645164a454b7db72a9bb5c2ba48.js?file=1.sql\"><\/script>\n\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/aada57ee13fecb9ae8a8f9f4264339b4.js?file=2.sql\"><\/script>\n\n<ol>\n<li>Add the files to the container as volume by modifying the docker-compose.yml<\/li>\n<\/ol>\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/88474f0a63643f59337574774a00f52a.js?file=docker-compose.yml\"><\/script>\n\n<ol start=\"4\">\n<li>Rebuild and run the container<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"display:flex;\"><span>$ docker-compose down <span style=\"color:#9ca0b0;font-style:italic\"># Stop the running container<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>Stopping shadowsDB ... <span style=\"color:#8839ef\">done<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>Removing shadowsDB ... <span style=\"color:#8839ef\">done<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>Removing network shadows_default\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>$ docker-compose up\n<\/span><\/span><\/code><\/pre><\/div><ol start=\"5\">\n<li>Access the container using Step#4 from above.<\/li>\n<li>Verify that the DB is populated with the data.<\/li>\n<\/ol>\n<p><strong>Notes<\/strong><\/p>\n<ul>\n<li>The SQL files inside the <code>postgres<\/code> directory are executed in alphabetic order. i.e. <code>1.sql<\/code> -&gt; <code>2.sql<\/code>.<\/li>\n<li>You can access the <code>.\/docker-entrypoint-initdb.d<\/code> folder from within the container to locate the SQL files.<\/li>\n<\/ul>\n<h3 id=\"6-the-dark-knight\">6. The Dark Knight<\/h3>\n<p>Now that Gotham PD has created the DB, Gordon reveals that Mr. Wayne is infact Batman and not a member of the League. Thus, we should remove <code>Bruce Wayne<\/code> from the table.<\/p>\n<ol>\n<li>Connect to the DB within the continer using Step#4.<\/li>\n<li>Delete the row with <code>Bruce Wayne<\/code>: <code>DELETE FROM members WHERE id=2;<\/code><\/li>\n<li>Close the connection.<\/li>\n<li>Exit the container.<\/li>\n<li>Stop the container with <code>$ docker-compose down<\/code><\/li>\n<li>Restart the container: <code>$ docker-compose up<\/code><\/li>\n<li>Is <code>Bruce Wayne<\/code> removed from our DB?<\/li>\n<\/ol>\n<p>Sadly, <strong>no<\/strong>! The reason being we are not persisting the changes made in the previous container to the current container.<\/p>\n<h3 id=\"7-data-persistence\">7. Data Persistence<\/h3>\n<p>We simply need to define a new volume for the container where we can store a dump of the database. This could any empty directory on your machine which will reflect the <code>\/var\/lib\/postgresql\/data<\/code> directory present inside the DB container.<\/p>\n<ol>\n<li>Modify <code>docker-compose.yml<\/code> by adding the new volume.\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/2e203ce2651671cd8b5d10ff23c1c319.js?file=docker-compose.yml\"><\/script>\n<\/li>\n<li>Repeat Step#7<\/li>\n<li>Verify that <code>Bruce Wayne<\/code> is successfully removed from the DB.<\/li>\n<\/ol>\n<p>Gotham is now more resilient than ever! Kudos \ud83c\udf89<\/p>\n<h1 id=\"summary\">Summary<\/h1>\n<p>After spending an entire afternoon exploring Docker and Postgres, I\u2019m convinced that using containers for running the DB and application provides me a lot of peace of mind worth the initial burden of writing the <code>Dockerfile<\/code> and <code>docker-compose.yml<\/code> files. From now onwards, I will definitely use Docker containers for running my databases.\nHopefully, you will consider the same when starting a new project! \ud83d\ude01<\/p>\n<h1 id=\"references\">References<\/h1>\n<ul>\n<li><a href=\"https:\/\/www.postgresql.org\/\">PostgreSQL<\/a><\/li>\n<li><a href=\"https:\/\/hub.docker.com\/_\/postgres\/\">PostgreSQL Docker Image<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/League_of_Assassins#Members\">League of Assassins Members Wikipedia<\/a><\/li>\n<\/ul>"},{"title":"Review: Fahrenheit 451","link":"https:\/\/kxsh.dev\/posts\/fahrenheit-451\/","pubDate":"Sat, 05 Jan 2019 21:26:33 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/fahrenheit-451\/","description":"<p><a href=\"https:\/\/www.goodreads.com\/book\/show\/13079982-fahrenheit-451\">Fahrenheit 451<\/a> by Ray Bradbury<\/p>\n<p>451F: Temperature at which book-paper catches fire and burns.<\/p>\n<p>Enter a dystopia where firemen are responsible for burning books rather than preventing houses from fires - in both cases, the firemen are the custodians of peace, saving people from potential \u201cdangers\u201d.<\/p>\n<p><strong>Recommended for<\/strong>: Anyone who doesn\u2019t read regularly.<\/p>\n<p><strong>Characters<\/strong>:<\/p>\n<ul>\n<li>Guy Montag<\/li>\n<li>Clarrise McClellan<\/li>\n<li>Mildred<\/li>\n<li>Captain Beatty<\/li>\n<li>Faber<\/li>\n<\/ul>\n<p>This is a story of Montag, a fireman, awakening to the reality of world he is living in (similar to that of Winston in 1984). Through his conversations with little Clarrise, Montag is faced with some deep, poignant questions about the life he is leading.<\/p>\n<p>What if everyone of us was happy independently?<br>\nShould that be the ideal we all aim to achieve as a human society?<br>\nMoreover, what role should technology play in the sphere of human life?<\/p>\n<p>We are so absorbed with our artificial\/custom, \u201cmodern\u201d surroundings that we become ignorant of the beauty of the natural world around us. We even turn a blind eye to the sufferings of our fellow human beings. Netflix and chill?<\/p>\n<p>Living in a world full of empty possessions, talking to empty people with blank minds. People don\u2019t talk about anything of importance. They name a lot of materialistic things which they possess or dream of possessing. But they all say the same things and nobody says anything different from anyone else.<\/p>\n<p>While the world wants to become deterministic, cold, calculated and \u201cpractical\u201d in our dealings, maybe we are trading our conscience for this.<\/p>\n<p>For the past couple of months, I have come to realise the importance of reading and the lure of digital media services such as Youtube, Netflix, Instagram which did more harm to me than good. I am hopeful that others too will come to confront the nature of their reality in the process of reading this book.<\/p>\n<p><strong>Adivce<\/strong>:<\/p>\n<ul>\n<li>Ask questions<\/li>\n<li>Be curious<\/li>\n<li>Stop and reflect<\/li>\n<\/ul>\n<p>These are probably the few humane things left to do.<\/p>"},{"title":"Asymmetry","link":"https:\/\/kxsh.dev\/posts\/on-asymmetry\/","pubDate":"Thu, 03 Jan 2019 21:33:32 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/on-asymmetry\/","description":"<p><em>cross-posting from 200 Words A Day<\/em><\/p>\n<p>Let\u2019s talk about the asymmetries in our lives today.<\/p>\n<p>After reading <strong>Fooled By Randomness<\/strong> and <strong>The Black Swan<\/strong> from <em>Nassim Nicholas Taleb<\/em>, I am convinced by the presence and importance of asymmetries in all walks of our lives. Moreover, these asymmetries are almost always associated with a \u201crare\u201d(low probability), \u201cunforeseeable\u201d, highly consequential event (called a <em>Black Swan<\/em>).<\/p>\n<p>Turning a blind eye to them can result in a massive blowup \u2013 the much fraught unbecoming. Thus, we all should be aware of these asymmetries and take the necessary steps to guard our interests against them, at the bare minimum; possibly, <em>try to gain from them<\/em>.<\/p>\n<p>In order to shore up our defences against the brewing storm of the asymmetry, the first step is to <strong>notice<\/strong> them around us.<\/p>\n<p>A fundamental problem with these asymmetries is that all of them are too plain to be noticed by us in our day-to-day lives. This is why we do not acknowledge them, let alone guard against them.<\/p>\n<p>For example, look at how you input the plus sign(+) and the minus sign(-) from your computer\u2019s keyboard. Notice it yet?\nThe <em>Shift<\/em> key looks mighty important now, doesn\u2019t it?<\/p>\n<p>We might think that such asymmetries are probably inconsequential to us and we would rather do well to not bother with them - they just complicate our world even further. However, it\u2019s all smooth sailing for us \u2013 until the <em>Black Swan<\/em> hits us on our head and we are left to resent our ignorance\/casual attitude.<\/p>\n<p>Look around you! There are Black Swans waiting to be discovered by you.\nLet me know what you find in the comments below.<\/p>"},{"title":"Education","link":"https:\/\/kxsh.dev\/posts\/on-education\/","pubDate":"Wed, 02 Jan 2019 21:37:59 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/on-education\/","description":"<p><em>cross-posting from 200 Words A Day<\/em><\/p>\n<p>Let\u2019s talk about education today.<\/p>\n<p>There are 2 complementary aspects of getting an education:<\/p>\n<ol>\n<li>the <strong>scholarly education<\/strong> obtained from rigorously studying academic texts obtained from schooling.<\/li>\n<li>the <strong>practical education<\/strong> learned from life experiences dealing in the real world.<\/li>\n<\/ol>\n<p>I\u2019m sure that most of us would agree that they fall somewhere on this spectrum of <strong>the wise and academic<\/strong> to <strong>the streetwise and practical<\/strong>.<\/p>\n<p>Too much theory results in losing <em>Skin in The Game<\/em> while too much of hacking renders the bigger picture of your life a blur. Thus, a balance between the two is essential for personal growth, realising our potential and having a sense of direction in life.<\/p>\n<blockquote>\n<p>&ldquo;If people cannot write well, they cannot think well,\nand if they cannot think well, others will do their thinking for them.&rdquo;\n- George Orwell<\/p>\n<\/blockquote>\n<p>I think an important way to strike this balance is to write regularly and share it with others. This is the reason why I have decided to write posts more consistently in 2019.<\/p>\n<p><strong>Inspiration<\/strong>: <a href=\"https:\/\/www.goodreads.com\/book\/show\/1221559.Letters_from_a_Self_Made_Merchant_to_His_Son\">Letters from a Self-Made Merchant To His Son<\/a><\/p>"},{"title":"Case for Non-violence","link":"https:\/\/kxsh.dev\/posts\/on-non-violence\/","pubDate":"Wed, 28 Nov 2018 20:14:30 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/on-non-violence\/","description":"<p>It was not about being the &ldquo;bigger man&rdquo;.\nEssentially it was about becoming a principled, disciplined person.\nI think it&rsquo;s totally normal for us to feel angry at some point.\nIt&rsquo;s not about teleology - estiology: answer what could this experience mean?\nFrom now onwards, whenever I find myself getting frustrated at a person\/thing,\nI delude myself to think of a happy memory associated with it.\nIt&rsquo;s a pretty hack I&rsquo;ve been using lately.\nForemostly, I need to be mindful of all the moments I share with others, not that many to be honest.\nI try my best to register the emotions I feel as I proceed with the conversation\/activity.<\/p>\n<p>The next step for me would be to acknowledge it then and there and appreciate the beauty of the person.<\/p>\n<p>So whenever my heart feel anything &ldquo;bad&rdquo; about that person, I go to my happy place.\nI remember the specific memory which I share with that person, laughing, playing, eating, talking, working.<\/p>\n<p>All we can do is improve ourselves from within.\nI don&rsquo;t think there are right choices or wrong decisions.\nIt&rsquo;s only our subjective perspective that characterise them as such.\nFor me personally, I think it&rsquo;s rather important to take decisions that I can live with.<\/p>\n<p>For example,\nIn the current hiring season, I chose to opt out of the campus placements aka mass recruitments.\nGiven the attraction of jobs in &ldquo;giant&rdquo; companies, compensation package, its only reasonable for a lot of my colleagues to question it.\nTo me, there were a lot of factors which I would not bore you with.\nI just want you to know that I took a conscious decision which I&rsquo;m happy till date.\nI&rsquo;m grateful for my ever supportive family who trusted me with the decision rather than enforcing their expectation on me.<\/p>"},{"title":"Why I Write Go","link":"https:\/\/kxsh.dev\/posts\/on-go\/","pubDate":"Sun, 11 Nov 2018 09:06:32 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/on-go\/","description":"<p><strong>tl;dr<\/strong>: This is not a rant about how Go is &ldquo;superior&rdquo; to other languages. It&rsquo;s all apples and oranges and I like them both, not at the same time, ofcourse! \ud83c\udf4e\/\ud83c\udf4a<\/p>\n<hr>\n<p><strong>off-topic<\/strong>: When I was a little boy \ud83d\udc66, I used to play all day long with my legos - constructing buildings, trucks, everything that I could imagine. Chaining dominoes with my parent&rsquo;s music collection cassettes, solving jigsaw puzzles and playing scrabble with my cousins. Good ol&rsquo; days!<\/p>\n<hr>\n<h1 id=\"inspiration\">Inspiration<\/h1>\n<p>Reading Rob Pike&rsquo;s post titled &ldquo;<a href=\"https:\/\/commandcenter.blogspot.com\/2012\/06\/less-is-exponentially-more.html\">Less is exponentially more<\/a>&rdquo;, I found myself introspecting about the way I write software. The article evoked some joy in me, stimulated that deep-seated feel-good core - the part of my being that enjoys programming. And I want to share it with everyone!<\/p>\n<h1 id=\"why-go\">Why Go?<\/h1>\n<p>During my GSoC, I used to struggle with grasping the idea of classes implementing behaviours and how would it be useful for subclasses - inheritance.<\/p>\n<p>For example, let&rsquo;s consider a <code>Point<\/code> class representing a point in the Cartesian Space.<\/p>\n<ol>\n<li>Should <code>distance<\/code> be a method on this class?<\/li>\n<li>Does <code>distance<\/code> define the &ldquo;behaviour&rdquo; of a <code>Point<\/code>?<\/li>\n<\/ol>\n<p>*Not necessarily! *<\/p>\n<p>(After reading some mathematics on Measure Theory, I came to know that &ldquo;distance&rdquo; is a quantity defined by a &ldquo;metric function&rdquo; - property of the space rather than any entity.)<br>\nIn our case, the <code>distance<\/code> should be a method on the <code>CartesianSpace<\/code> rather than <code>Point<\/code>.<\/p>\n<ul>\n<li>The question that arises then is how can I assure that I can always compute distance between given pair of <code>Point<\/code> values, or any geometrical entity for that matter?<\/li>\n<li>Should I just override the <code>distance<\/code> method in each geometrical class?<\/li>\n<li>If so, what purpose does the base <code>distance<\/code> method in <code>CartesianSpace<\/code> serve now?<\/li>\n<\/ul>\n<p>I would agree that these questions are subjective and I respect your solution to the problem.<\/p>\n<p>However, then I came to know about <a href=\"https:\/\/kshitij10496.github.io\/posts\/duck-typing-in-python\/\">Duck Typing in Python<\/a> and it&rsquo;s approach to the problem. However, I was not satisfied with the Python implementation. It almost felt kind of a convenience pattern which was incompatible with Pythonic code.<\/p>\n<p>Eventually, I found about Go <code>interfaces<\/code>.(Plus, CSP! \u2764\ufe0f)<\/p>\n<h1 id=\"things-i-like-about-go\">Things I like about Go<\/h1>\n<p>Coming back to the question - <em>&ldquo;Why I Write Go?&rdquo;<\/em>, here are some of my favourite reasons:<\/p>\n<ul>\n<li>emphasis on separation between state and behaviour<\/li>\n<li>composition over inheritance; think <em>legos<\/em> \ud83e\udde9<\/li>\n<li>simplicity in design; <strong>less is more<\/strong>, indeed<\/li>\n<\/ul>\n<p>More importantly, I rediscovered the joy of putting tiny pieces togerther and building something greater than the sum of the individual parts (read off-topic).\nIn addition to writing \u201ccleaner and more readable\u201d code, I find a lot more clarity when it comes to solving problems and coherence in my thinking while implementing the solution. I guess that is the underappreciated USP of Go, for me, ofcourse! \ud83d\ude01<\/p>\n<p>So what is your favourite programming language and why? \ud83d\ude03<\/p>"},{"title":"Make Blog Great Again","link":"https:\/\/kxsh.dev\/posts\/blogging\/","pubDate":"Sun, 04 Nov 2018 00:21:02 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/blogging\/","description":"<p><em>tl;dr: post about posting more posts<\/em><\/p>\n<p>I have forgotten to write blog posts for over a year or have I?<\/p>\n<h2 id=\"blogging-101\">Blogging 101<\/h2>\n<p>I started this blog after I was selected as a <a href=\"https:\/\/summerofcode.withgoogle.com\/archive\/2016\/projects\/6056916694335488\/\">GSoC 2016 student<\/a> under <a href=\"http:\/\/www.sympy.org\/en\/index.html\">SymPy<\/a> so as to log my progress. Few weeks working into the program, it seemed that I had developed the habit of writing weekly articles. Back then, I intended to continue maintaining my blog. However soon after completing the project, I became <strong>lazy<\/strong> and <strong>procrastinated<\/strong>. \ud83d\ude41<\/p>\n<h2 id=\"why-did-i-stop-posting\">Why Did I Stop Posting?<\/h2>\n<p>Whenever I felt like posting an article, I used to persuade my <em>&ldquo;conscious self&rdquo;<\/em> to defer because of the following reasons primarily:<\/p>\n<ul>\n<li>\n<p><strong>Non-existent readership: <em>Who am I writing the post for?<\/em><\/strong><br>\nHardly anyone will read my posts(apart from my friends \ufe0f\ud83d\ude4b\u200d\u2642\ufe0f, of course) so why bother posting them!<\/p>\n<\/li>\n<li>\n<p><strong>Lack of expertise as well as experience: <em>Will my posts be helpful to anyone?<\/em><\/strong><br>\nEven if someone mistakenly did read my post, they would pass it by as some novice&rsquo;s opinions on the topics that he does not even entirely understand; not that I rant too often. Personally, I believe that each article should have a purpose if it is to be deemed useful. And I was unsure about it.<\/p>\n<\/li>\n<\/ul>\n<p>During the GSoC period, I had some readership in the form of my mentors and colleagues as well as some expertise in what I was writing about. After the completion of the project, I had no temptation for updating my blog as I had no justifiable response to the 2 driving questions. Hence, I stopped posting! \ud83d\ude1e<\/p>\n<h2 id=\"motivation\">Motivation<\/h2>\n<p>In addition to the psychological and spiritual benefits that blogging about my learnings with the world provides, a blog also provides a professional incentive, especially to a programmer. I always acknowledged these merits of maintaining a decent blog. However, I was unwilling to post until I found an honest answer to the above-mentioned two questions.<\/p>\n<p>After some introspection, I believe I have found them and they are as follows:<\/p>\n<p>Q1. <strong>Who am I writing the post for?<\/strong><br>\nA: <strong>Myself, in particular; a relentless learner, in general.<\/strong><\/p>\n<p>From now on, I will be writing all the posts for myself - or those who like to learn new things, make mistakes and correct themselves quickly. \ud83e\udd13<\/p>\n<p>Q2. <strong>Will my posts be helpful to anyone?<\/strong><br>\nA: <strong>They will if I make it simple enough and develop competence.<\/strong><\/p>\n<p>I will write with the sole intention of sharing my current preoccupations and what excites me. They shall help me gain some clarity and reflect upon everything I do or happen to me. Thus, they would be useful for me at the very least. \ud83d\ude0c<\/p>\n<p>Q: <strong>What will I write about?<\/strong><br>\nA: <strong>Everything and anything<\/strong><\/p>\n<p>I intend to write about everything that currently occupies me, excites me and motivates me. This includes, but not restricted to, sharing:<\/p>\n<ul>\n<li>a concept I recently studied straight from my moleskine<\/li>\n<li>a new project I&rsquo;m working on or contributing to<\/li>\n<li>book reviews; lots of them<\/li>\n<li>reflections on everything stupid, important and in-between<\/li>\n<\/ul>\n<p>The primary motivations for me to publish new articles are:<\/p>\n<ol>\n<li>challenge myself to review my understanding and presenting them effectively \ud83d\ude00<\/li>\n<li>open up a channel of discourse with people of more diverse background \ud83d\ude4a<\/li>\n<li>spread the joy of learning! &#x1f389;<\/li>\n<\/ol>\n<h2 id=\"modus-operandi\">Modus Operandi<\/h2>\n<p><strong>I pledge myself to publish a new article every Sunday for the rest of 2018.<\/strong><\/p>\n<p>It will be challenging to post every week but I can assure that I will put my honest and dedicated effort into writing from now on.<\/p>\n<p>So, see you all next Sunday for the beginning. &#x1f601;<\/p>"},{"title":"Hugo Blog On GitHub Pages","link":"https:\/\/kxsh.dev\/posts\/hugo-blog-setup\/","pubDate":"Sun, 09 Sep 2018 19:03:31 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/hugo-blog-setup\/","description":"<p>Update: I have published an updated <a href=\"https:\/\/kshitij10496.github.io\/posts\/blog-setup\/\">blogging setup in 2024<\/a>. Thus, the content of this post is not entirely accurate anymore.<\/p>\n<p><strong>Looking to create your personal blog using Hugo and hosting it on GitHub Pages?<\/strong><\/p>\n<p>To be honest, it can sound a bit intimidating and challenging at first.<br>\nI, too, felt the same while I setup <em>this<\/em> blog using Hugo and the Coder theme.<br>\nIn this post, I share my experience during the process - from the specific commands to the lessons learnt.<br>\nIn addition to this, I also share my workflow for publishing posts using a shell script.<\/p>\n<h3 id=\"requirements\">Requirements<\/h3>\n<ul>\n<li>OS: macOS, Ubuntu - the steps can easily extend to other Unix-based OS i.e. No <em>Windows<\/em> (sorry, not sorry)<\/li>\n<li>Terminal + Shell - for executing all the commands<\/li>\n<li>Hugo (Read: <a href=\"https:\/\/gohugo.io\/getting-started\/installing\/\">Installation<\/a>)<\/li>\n<li>Git (Read: <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/install-git\">Installation<\/a>)<\/li>\n<li>Text Editor - to write blog content (I prefer <a href=\"https:\/\/code.visualstudio.com\/download\">Visual Studio Code<\/a>)<\/li>\n<li>Web Browser - for accessing GitHub and selecting themes<\/li>\n<\/ul>\n<p>By the end of the post, you should have a blog, with at least one post, up and running on GitHub Pages.<br>\nLet&rsquo;s dive in!<\/p>\n<h2 id=\"hugo\">Hugo<\/h2>\n<h4 id=\"step-1-create-a-basic-hugo-site\">Step 1: Create a basic Hugo site<\/h4>\n<ol>\n<li>Open up the terminal.<\/li>\n<li>Navigate to the directory where you want to store the blog locally.<\/li>\n<li>Create a new hugo site: <code>$ hugo new site blog<\/code><\/li>\n<li>Change to the newly created <code>blog<\/code> directory: <code>$ cd blog<\/code><\/li>\n<\/ol>\n<h4 id=\"step-2-setup-github-and-git-locally\">Step 2: Setup GitHub and Git locally<\/h4>\n<p><em>(Working directory: <code>blog<\/code>)<\/em><\/p>\n<h5 id=\"github\">GitHub<\/h5>\n<ol>\n<li>Create a new repository on GitHub naming it as <code>&lt;your-github-username&gt;.github.io<\/code>\n(<code>kshitij10496.github.io<\/code>, in my case).<\/li>\n<\/ol>\n<h5 id=\"git\">Git<\/h5>\n<ol>\n<li>Initialise the <code>blog<\/code> directory with Git: <code>$ git init<\/code><\/li>\n<li>Add the <code>$ git submodule add https:\/\/github.com\/&lt;username&gt;\/&lt;username&gt;.github.io public<\/code><\/li>\n<li>A new <code>public<\/code> folder should be created within the <code>blog<\/code> directory.<\/li>\n<li>Choose a Hugo Theme for your blog from <a href=\"https:\/\/themes.gohugo.io\/\">here<\/a><\/li>\n<li>Add the theme as another Git submodule: <code>$ git submodule add &lt;theme-git-url&gt; themes\/&lt;themeName&gt;<\/code><br>\nEx: For the <code>coder<\/code> theme, use: <code>$ git submodule add https:\/\/github.com\/luiz\/coder themes\/coder<\/code><\/li>\n<\/ol>\n<p><strong>LESSON:<\/strong> Using <code>git submodules<\/code> empowers us to specify theme version for our blog and reduce the code duplication and maintenance.<\/p>\n<p><strong>NOTE:<\/strong> This is one of the most important <em>hence<\/em> confusing, step of the entire process. <br>\n<em>We have to deal with atleast <strong>2<\/strong> separate Git repositories in the same directory.<\/em><\/p>\n<p>We will track the final statically generated website in the <code>public<\/code> sub-directory and host it on GitHub.\nIdeally, this would contain the final HTML and CSS files. The <code>blog<\/code> directory should contain the Markdown content,\nstatic images and configuration files relevant to Hugo.<\/p>\n<p><strong>BONUS:<\/strong> It&rsquo;s your choice whether you want to publish this repo to GitHub or not. Personally, I pushed mine to <a href=\"https:\/\/github.com\/kshitij10496\/hugo-blog\"><code>hugo-blog<\/code><\/a>.<\/p>\n<h4 id=\"step-3-creating-content\">Step 3: Creating Content<\/h4>\n<p><em>(Working directory: <code>blog<\/code>)<\/em><\/p>\n<ol>\n<li>Customise the <code>config.toml<\/code> file according to your needs. Refer: <a href=\"https:\/\/gist.github.com\/kshitij10496\/1f6801be9c2e1d2e1ea9855b18b0bd82#file-config-toml\">Sample<\/a><\/li>\n<li>Create a new content file: <code>$ hugo new posts\/hello-world.md<\/code><\/li>\n<li>A new markdown file named <code>hello-world.md<\/code> is created in <code>content\/posts<\/code> directory with some metadata.<\/li>\n<li>Write your heart out! :love:<\/li>\n<li>Preview the website with the newly created draft <code>$ hugo serve -D<\/code><\/li>\n<li>Navigate to your new site at <code>http:\/\/localhost:1313\/<\/code> (most probably).<\/li>\n<li>When you are happy with your post, set the <code>draft<\/code> header in the file to <code>false<\/code>.<\/li>\n<li>Generate the final static website: <code>$ hugo<\/code><\/li>\n<li>Move to <code>public<\/code> directory and you will notice many newly created HTML\/CSS files aka &ldquo;Your Blog&rdquo;.<\/li>\n<\/ol>\n<p>The blog is all ready to be the next viral thing on the internet! &#x1f60e;<br>\nIn the next step, we commit the changes and push the <code>public<\/code> folder to GitHub.<\/p>\n<h4 id=\"step-4-workflow-for-publishing-content\">Step 4: Workflow for Publishing Content<\/h4>\n<p><em>(Working directory: <code>blog\/public<\/code>)<\/em><\/p>\n<ol>\n<li>Staging the changes made: <code>$ git add .<\/code><\/li>\n<li>Commiting the changes: <code>$ git commit -m &quot;&lt;your-commit-message&gt;&quot;<\/code><\/li>\n<li>Pushing to GitHub repo: <code>$ git push origin master<\/code><\/li>\n<li>Enter your GitHub credentials when\/if prompted.<\/li>\n<li>Your blog should be up and running on <code>https:\/\/&lt;your-github-username&gt;.github.io<\/code> within a couple of minutes.<\/li>\n<li>Congratulations! You made it. &#x1f44f;<\/li>\n<\/ol>\n<p><strong>BONUS:<\/strong> I have created a <a href=\"https:\/\/gist.github.com\/kshitij10496\/7f1130979cae450ed0812cbd9d8dd7f4#file-deploy-sh\">deploy.sh<\/a> shell script which abstracts the above commands. You can download it and place it in the <code>blog<\/code> directory.<\/p>\n<p><strong>NOTE:<\/strong> In general, commiting directly to <code>master<\/code> is not a recommended Git practice. Git branches are the way to go.\nHowever, I&rsquo;m suggesting direct manipulation of the <code>master<\/code> branch primarily because this is a personal blog.\nBe careful with this!<\/p>\n<h1 id=\"creating-new-content\">Creating new content<\/h1>\n<p>Now that you have setup your blog, creating new posts is a breeze!<br>\nYou simply need to follow the method mentioned in <strong>Step 3<\/strong> and <strong>Step 4<\/strong> from above.<br>\nPretty clean, isn&rsquo;t it?<\/p>\n<h1 id=\"final-thoughts\">Final Thoughts<\/h1>\n<p>I hope this post will help you get started with adopting Hugo for your static site needs and hosting it on GitHub should now be easy.\nThere are a lot of customisations which I&rsquo;m still exploring and discovering everytime I publish something.\nYou can take a look at my <a href=\"https:\/\/github.com\/kshitij10496\/hugo-blog\/blob\/master\/config.toml\">config.toml<\/a> file for this blog as a reference.<\/p>\n<p>In case you have any queries\/face issues with the above-mentioned process, don&rsquo;t be afraid to ask in the comments section below.<\/p>\n<p>Cheers! &#x1f37a;<\/p>"},{"title":"For some Context","link":"https:\/\/kxsh.dev\/posts\/for-some-context\/","pubDate":"Sun, 17 Dec 2017 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/for-some-context\/","description":"<p>There are a lot of good resources about using <code>context<\/code> packages in software based on your programming language. However, I found that most of these do not address the basic questions of motivation behind the need of context:<\/p>\n<ul>\n<li>How does the use of context help us in programming?<\/li>\n<li>When should a programmer use context?<\/li>\n<\/ul>\n<p>In this blog post, I will share what I understand about <code>context<\/code>.<\/p>\n<h2 id=\"motivation\">Motivation<\/h2>\n<p>Consider you are an event manager of a restaurant. A customer wants to throw a party for 50 people on New Year Eve and you are tasked with organizing the event. Given the magnitude of the event, you start planning and assign jobs to your suboridinates:<\/p>\n<ul>\n<li>waiters are instructed to look their best,\n\u2013 chefs must prepare the grocery list,<\/li>\n<li>errand boys to fetch the grocery.<\/li>\n<li>playlist for the &ldquo;DJ&rdquo;,<\/li>\n<li>someone for decoration<\/li>\n<\/ul>\n<p>The preparations are going smoothly on your end and you expect a picturesque celebration under your leadership. However, a couple of days later the same customer profusely apologizes for cancelling the event due to some reason.\nEven though you are disappointed by this request, you accept the apology.<\/p>\n<p>There are two alternates for you to choose from:<\/p>\n<ol>\n<li>Immediately cancel all the arrangements<\/li>\n<li>Wait till the New Year Eve for some other miraculous booking<\/li>\n<\/ol>\n<p>Being a rational manager, you immeditately start off to cancel all arrangements rather than waiting till the New Year&rsquo;s eve because you do not want to waste resources(time and money).<\/p>\n<p>This is exactly what &ldquo;context&rdquo; is used for in programming:<\/p>\n<ul>\n<li>Cancellation progropagation<\/li>\n<li>Scoping values (passing grocery list around, organizing the playlist)\nThe use of context can make programs efficient with respect to use of computer resources as well as graceful fallback mechanism.<\/li>\n<\/ul>\n<p>Let us understand how we can use <code>context<\/code> with a simple example.<\/p>\n<pre tabindex=\"0\"><code>\/\/ Some time consuming process like:\n\/\/ - API calls\n\/\/ - Cruching data from database\n\/\/\nfunc someFunc() {\n fmt.Println(&#34;Starting computation&#34;)\n time.Sleep(10*time.Second)\n fmt.Println(&#34;Completed computing&#34;)\n<\/code><\/pre><p>Now, the caller of this function is expected to wait for a while (10s in this case) until the processing is complete. However, if the user somehow decides to cancel this process before it completes, he is at a loss. The only way the user can exit is by <code>CTRL<\/code> + <code>C<\/code> i.e by sending an interuption signal to the running process; this maynot even be possible all the time. However, the use of <code>context<\/code> provides him a way to set time deadlines or logical cancellations. Maybe the user wants to wait for atmost 5 seconds before cancelling; the context gives him this power.<\/p>\n<h1 id=\"resources\">Resources<\/h1>\n<ul>\n<li><a href=\"https:\/\/youtu.be\/LSzR0VEraWw\">justforfunc#9: The Context Package in Go<\/a><\/li>\n<li><a href=\"https:\/\/blog.golang.org\/context\">Go Concurrency Patterns: Context<\/a><\/li>\n<\/ul>"},{"title":"Typing in Python, Go and JavaScript","link":"https:\/\/kxsh.dev\/posts\/typing\/","pubDate":"Sun, 10 Dec 2017 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/typing\/","description":"<blockquote>\n<p>Disclaimer: This post has been written from the point-of-view of a software developer rather than a theoretical computer science. So I <a href=\"https:\/\/stackoverflow.com\/questions\/11360858\/what-is-the-eafp-principle-in-python\">&ldquo;ask for forgiveness&rdquo;<\/a> if the post seems too colloquial and pragmatic.<\/p>\n<\/blockquote>\n<p>Reading through the articles on programming languages, you are bound to stumble upon statements similar to the following:<\/p>\n<ol>\n<li>&ldquo;Python is a strongly typed, dynamic language.&rdquo;<\/li>\n<li>&ldquo;Go is a statically typed, strong language.&rdquo;<\/li>\n<li>&ldquo;JavaScript is a dynamic language which is weakly typed.&rdquo;<\/li>\n<\/ol>\n<p>(Aside: Wikipedia pages of inidividual languages themselves have a bullet titled &ldquo;Typing Discipline&rdquo; in the sidebox).<\/p>\n<p>Depending upon your programming background and experience, the above statements might either look deceptively simple to read or seem downright counter-intuitive, yet they are the source of some very famous warts in the respective languages.\nA good understanding of the fundamentals behind such statements can help programmers develop more reasonable expectations from the code they write.<\/p>\n<p>We begin by defining 4 terms central to the discussion, namely:<\/p>\n<ul>\n<li>Static Typing | Dynamic Typing<\/li>\n<li>Strong Typing | Weak Typing<\/li>\n<\/ul>\n<p>The terms grouped together are sematically antonyms to each other.\nEach group defines important characteristics of a programming language independent of the other group.<\/p>\n<h2 id=\"static-typing-dynamic-typing\">Static Typing, Dynamic Typing<\/h2>\n<p>Whether a language is statically typed or dynamically typed depends on how the compiler\/interpreter handles variables and at what point during the execution of the program.<\/p>\n<h3 id=\"static-typing\">Static Typing<\/h3>\n<p>In a statically typed language, the variable itself has a type; if you have a variable that&rsquo;s an integer, you won&rsquo;t be able to assign any other type of value to it later. Some statically typed languages require you to write out the types of all your variables, while others will deduce many of them for you automatically.<\/p>\n<p>Moreover, the compiler can tell which the <em>type<\/em> of a variable, without executing the program.<\/p>\n<h3 id=\"dynamic-typing\">Dynamic Typing<\/h3>\n<p>In a dynamically typed language, a variable is simply a value bound to a name; the value(or object) has a type &ndash; like &ldquo;integer&rdquo; or &ldquo;string&rdquo; or &ldquo;list&rdquo; &ndash; but the variable itself doesn&rsquo;t. We can have a variable which, right now, holds a number, and later assign a string to it.<\/p>\n<p>The programmer is free to bind names to different objects with a different type. So long as you only perform operations valid for the type the interpreter doesn&rsquo;t care what type they actually are.<\/p>\n<hr>\n<h3 id=\"python\">Python<\/h3>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> age <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">21<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> age <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;21&#39;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p><strong>Conclusion:<\/strong> The type of name <code>age<\/code> is the type of the object it refers to at that particular instant. Moreover, no further restriction is laid on it with regards to what values it can\/cannot hold in the future.<\/p>\n<h3 id=\"go\">Go<\/h3>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span>age <span style=\"color:#04a5e5;font-weight:bold\">:=<\/span> <span style=\"color:#fe640b\">21<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>age = <span style=\"color:#40a02b\">&#34;21&#34;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p><strong>Conclusion:<\/strong> A compile time assignment error is raised. Once a type is associated with a variable, the variable cannot hold a value of other data types.<\/p>\n<h3 id=\"javascript\">JavaScript<\/h3>\n<pre tabindex=\"0\"><code>age = 21\nage = &#34;21&#34;\n<\/code><\/pre><p><strong>Conclusion:<\/strong> Same as Python<\/p>\n<hr>\n<h2 id=\"strong-typing-weak-typing\">Strong Typing, Weak Typing<\/h2>\n<p>The distinction between such typing comes to the fore when we write programming statements which involves performing an operation on values of different <em>types<\/em>.<\/p>\n<h4 id=\"expected-behaviors\">Expected Behaviors<\/h4>\n<ul>\n<li><strong>Strongly typed language:<\/strong> more likely to generate an error (either at runtime or compile time depending on whether the language is interpreted or compiled).<\/li>\n<li><strong>Weakly typed language:<\/strong> either produces unpredictable results or perform implicit type conversions to make sense of the expression.<\/li>\n<\/ul>\n<p>In order to resolve the error raised in a strongly typed language, the programmer needs to explicitly convert the type of values to the desired type.<\/p>\n<p>The terms &ldquo;strong&rdquo; and &ldquo;weak&rdquo; are themselves relative by nature. Thus, a person calls some programming language &ldquo;X&rdquo; as strongly(or weakly) typed is totally subjective. From the First Principles perspective, what the person wants to claim is that language &ldquo;X&rdquo; enforces type checks before performing any operations. Every developer will have a different measure of how rigorous these checks are.<\/p>\n<p>Rule of Thumb: the more type coercions (implicit conversions) for built-in operators the language offers, the weaker the typing. (This could also be viewed as more built-in overloading of built-in operators.)\ni.e a strongly typed language is restrictive of type intermingling.<\/p>\n<p>Let us understand this distinction with 2 operations which every programmer must have comes across:<\/p>\n<ol>\n<li>Adding a number to a string<\/li>\n<li>Adding an integer to a floating point number<\/li>\n<\/ol>\n<hr>\n<h3 id=\"python-1\">Python<\/h3>\n<ol>\n<li>Adding a number to a string<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> a, b <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">10<\/span>, <span style=\"color:#40a02b\">&#39;K&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> a <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> b <span style=\"color:#9ca0b0;font-style:italic\"># Binary operation on different types<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">...<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#fe640b\">TypeError<\/span>: unsupported operand <span style=\"color:#04a5e5\">type<\/span>(s) <span style=\"color:#8839ef\">for<\/span> <span style=\"color:#04a5e5;font-weight:bold\">+<\/span>: <span style=\"color:#40a02b\">&#39;int&#39;<\/span> <span style=\"color:#04a5e5;font-weight:bold\">and<\/span> <span style=\"color:#40a02b\">&#39;str&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> a <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> <span style=\"color:#04a5e5\">ord<\/span>(b) <span style=\"color:#9ca0b0;font-style:italic\"># Explicit type conversion of string to integer<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#fe640b\">85<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#04a5e5\">str<\/span>(a) <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> b <span style=\"color:#9ca0b0;font-style:italic\"># Explicit type conversion of integer to string<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#40a02b\">&#39;10K&#39;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><ol start=\"2\">\n<li>Adding an integer to a floating point number<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> a, b <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">1<\/span>, <span style=\"color:#fe640b\">2.5<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> a <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> b <span style=\"color:#9ca0b0;font-style:italic\"># No error<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#fe640b\">3.5<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p><strong>Conclusion:<\/strong> Raises errors when sense cannot be made. Also, the interpreter is not restrictive enough to spoil the fun in programming.<\/p>\n<h3 id=\"go-1\">Go<\/h3>\n<ol>\n<li>Adding a number to a string<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">func<\/span> <span style=\"color:#1e66f5\">AddNumStr<\/span>() {\n<\/span><\/span><span style=\"display:flex;\"><span> a, b <span style=\"color:#04a5e5;font-weight:bold\">:=<\/span> <span style=\"color:#fe640b\">10<\/span>, <span style=\"color:#40a02b\">&#34;K&#34;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> fmt.<span style=\"color:#1e66f5\">Println<\/span>(a <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> b)\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><ol start=\"2\">\n<li>Adding an integer to a floating point number<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">func<\/span> <span style=\"color:#1e66f5\">AddNumFloat<\/span>() {\n<\/span><\/span><span style=\"display:flex;\"><span> a, b <span style=\"color:#04a5e5;font-weight:bold\">:=<\/span> <span style=\"color:#fe640b\">1<\/span>, <span style=\"color:#fe640b\">2.5<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> fmt.<span style=\"color:#1e66f5\">Println<\/span>(a <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> b)\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p><strong>Conclusion:<\/strong> In both the cases, an &ldquo;invalid operation&rdquo; compile-time error is raised.<\/p>\n<h3 id=\"javascript-1\">JavaScript<\/h3>\n<ol>\n<li>Adding a number to a string<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-js\" data-lang=\"js\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> a <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">10<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> b <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#34;K&#34;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> a <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> b\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#40a02b\">&#39;10K&#39;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><ol start=\"2\">\n<li>Adding an integer to a floating point number<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-js\" data-lang=\"js\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> a <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">1<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> b <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#fe640b\">2.5<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> a <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> b\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#fe640b\">3.5<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p><strong>Conclusion:<\/strong> The compiler <em>implicitly<\/em> converts the type of values to make sense of the operation rather than raising errors.<\/p>\n<hr>\n<p>I hope that after reading this article, you are able to justify the statements regarding the type systems used in different languages. In this post, I explored these principles across Python, Go and JS just to cover a variety of examples. I encourage you to perform the same on the languages you know and share your results in the comments below.<\/p>"},{"title":"Duck Typing in Python","link":"https:\/\/kxsh.dev\/posts\/duck-typing-in-python\/","pubDate":"Sun, 03 Dec 2017 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/duck-typing-in-python\/","description":"<h2 id=\"what-is-duck-typing\">What is Duck Typing?<\/h2>\n<p>Python is a dynamic language which is strongly typed.\nDynamic binding is the capability to use an instance without regard for its type. It is handled entirely through a simple attribute lookup process. Whenever an attribute is accessed as <code>object.attribute<\/code>:<\/p>\n<ol>\n<li><code>attribute<\/code> is located by searching within the instance itself. This yields a positive result when the <code>attribute<\/code> being searched for is an instance variable or method.<\/li>\n<li>If the instance does not have the required <code>attribute<\/code>, the instance&rsquo;s class definition is searched. All the class variables, class methods and static methods fall into this category.<\/li>\n<li>If both these lookups do not return any result, the interpreter then proceeds to the base classes of the <code>object<\/code>(resolved by <a href=\"https:\/\/youtu.be\/cuonAMJjHow\">MRO<\/a>). The first match found is returned.<\/li>\n<\/ol>\n<p>The critical aspect of this binding process is it&rsquo;s <em>independence of the <strong>type<\/strong> of <code>object<\/code><\/em>. Thus, if you try a lookup such as <code>object.name<\/code>, it will work on any <code>object<\/code> that happens to have a <code>name<\/code> attribute independent of the class of the <code>object<\/code>. This behavior is colloquially referred to as <em><strong>duck typing<\/strong><\/em> in reference to the adage <em>\u201cif it looks like, quacks like, and walks like a duck, then it is a duck.\u201d<\/em><\/p>\n<blockquote>\n<p>The idea is that you don&rsquo;t need a type in order to invoke an existing method on an object - if a method is defined on it, you can invoke it.<\/p>\n<\/blockquote>\n<h2 id=\"where-should-i-use-it-in-my-code\">Where should I use it in my code?<\/h2>\n<p>More often than not we write programs, either deliberately or unwittingly that rely on duck typing.<\/p>\n<p>While defining classes, the <em>magic<\/em> methods(or <em>dunder<\/em> methods) implement some sort of protocol supported by language. For example,<\/p>\n<ul>\n<li><code>__iter__<\/code> and <code>__next__<\/code> methods are used to implement the Iterator protocol. The instances of the class can now be used in <code>for<\/code> loops.<\/li>\n<li>if we declare the <code>__len__<\/code> and <code>__getitem__<\/code> methods inside a class, it&rsquo;s instances are called <code>sequences<\/code>. All the objects of this class are now subscriptable by index (similar to <code>list<\/code>) as well as can be iterated over.<\/li>\n<\/ul>\n<h2 id=\"the-problem-of-tabulation\">The Problem of Tabulation<\/h2>\n<p>Suppose we are asked to display a dictionary of country names and it&rsquo;s captial in a tabular format. Let us try to write a generic utility function which displays a given input mapping in a tabular form:<\/p>\n<p><strong>Attempt 01<\/strong><\/p>\n<pre tabindex=\"0\"><code>def tabulate_mapping(mapping, headers):\n &#39;&#39;&#39;Tabulates the input mapping as columns with given headers.\n \n &gt;&gt;&gt; mapping = {&#39;India&#39;: &#39;New Delhi&#39;,\n ... &#39;USA&#39;: &#39;Washington&#39;,\n ... &#39;England&#39;: &#39;London&#39;}\n &gt;&gt;&gt; headers = (&#39;Country&#39;, &#39;Captial&#39;)\n &gt;&gt;&gt; tabulate_mapping_01(mapping, headers)\n Country | Capital |\n ----------------------------------\n England | London |\n India | New Delhi |\n USA | Washington |\n &#39;&#39;&#39;\n heading = &#39;&#39;\n for header in headers: ##### NOTE 1\n heading += &#39;{:&gt;15}&#39;.format(header) + &#39; |&#39;\n print(heading)\n print(&#39;-&#39;*len(heading))\n\n for k, v in mapping.items(): ##### NOTE 2\n print(&#39;{:&gt;15} |{:&gt;15} |&#39;.format(k, v))\n<\/code><\/pre><p>The code should look pretty straighforward to any programmer who has written even a few lines of Python. However, there are two salient features about the code which do not strike us at the first sight. After some experimenting, you will figure out the following:<\/p>\n<ol>\n<li>Any iterable can be passed as <code>headers<\/code> i.e. <code>list<\/code>, <code>tuple<\/code>, user-defined sequences. Even unordered collections such as <code>dict<\/code>, <code>set<\/code> would also work.<\/li>\n<li>Any object which implements an <code>items<\/code> method can be printed using <code>tabulate_mapping<\/code> function.<\/li>\n<\/ol>\n<p><strong>Duck Typing At Work!<\/strong><\/p>\n<p>Let us create a class which extends the Python built-in <code>list<\/code> and implements a <code>items<\/code> method.<\/p>\n<pre tabindex=\"0\"><code>class MyList(list):\n &#39;&#39;&#39; A user-defined collection data type which extends the built-in list.\n \n &gt;&gt;&gt; alphabet = MyList(*&#39;ABC&#39;)\n &gt;&gt;&gt; print(alphabet)\n [&#39;A&#39;, &#39;B&#39;, &#39;C&#39;]\n &gt;&gt;&gt; alphabet[1]\n &#39;B&#39;\n &gt;&gt;&gt; for i, item in alphabet.items():\n ... print(i, item)\n 1 A\n 2 B\n 3 C\n &#39;&#39;&#39;\n def __init__(self, *args):\n super().__init__(args)\n \n def items(self):\n &#39;&#39;&#39;Alternate utility to `enumerate` on the instance&#39;&#39;&#39;\n for i, item in enumerate(self, start=1):\n yield i, item\n<\/code><\/pre><p>Now, by the grace of Duck Typing, we can use the <code>tabulate_mapping<\/code> function with instances of <code>MyList<\/code> class. However, what if we do not want malicious objects use our code this way. We all know about SQL Injection. It&rsquo;s about time we become aware of our privacy.<\/p>\n<h2 id=\"the-curious-case-of-input-validation\">The Curious Case of Input Validation<\/h2>\n<p>In the function <code>tabulate_mapping<\/code>, observe that we have not written any code for validating the inputs. With Duck Typing in the fray, it is important to understand the need of a guideline on validating inputs.<\/p>\n<p>Programmers coming from a background of a statically typed background would be inclined to perform <em>static<\/em> type checks on the object. As we have seen, strict type check can be severely restrictive to the point where the developers miss out on the cool features Python has to offer.\ni.e <strong>Too much of <code>isinstance<\/code> and <code>hasattr<\/code> works but it is neither fun nor Pythonic!<\/strong><\/p>\n<p>We will perform different kinds of input validation for the <code>tabulate_mapping<\/code> function based on the requirements:<\/p>\n<ol>\n<li>If we want the <code>tabulate_mapping<\/code> to be generic utility which can work on any <code>mapping<\/code> object with <code>items<\/code> and iterable <code>headers<\/code>.<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-def\" data-lang=\"def\"><span style=\"display:flex;\"><span> \n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5;font-weight:bold\">#<\/span> Validate headers\n<\/span><\/span><span style=\"display:flex;\"><span> try:\n<\/span><\/span><span style=\"display:flex;\"><span> headers_iter <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> iter(headers)\n<\/span><\/span><span style=\"display:flex;\"><span> except TypeError as e:\n<\/span><\/span><span style=\"display:flex;\"><span> raise ValueError(<span style=\"color:#40a02b\">&#39;headers needs to be an iterable.&#39;<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5;font-weight:bold\">#<\/span> Validate mapping\n<\/span><\/span><span style=\"display:flex;\"><span> try:\n<\/span><\/span><span style=\"display:flex;\"><span> mapping_items <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> mapping.items()\n<\/span><\/span><span style=\"display:flex;\"><span> except AttributeError as e:\n<\/span><\/span><span style=\"display:flex;\"><span> raise ValueError(<span style=\"color:#40a02b\">&#39;mapping should have an items method.&#39;<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> heading <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> \n<\/span><\/span><span style=\"display:flex;\"><span> for header in headers_iter:\n<\/span><\/span><span style=\"display:flex;\"><span> heading <span style=\"color:#04a5e5;font-weight:bold\">+=<\/span> <span style=\"color:#40a02b\">&#39;{:&gt;15}&#39;<\/span>.format(header) <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> <span style=\"color:#40a02b\">&#39; |&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> print(heading)\n<\/span><\/span><span style=\"display:flex;\"><span> print(<span style=\"color:#40a02b\">&#39;-&#39;<\/span><span style=\"color:#04a5e5;font-weight:bold\">*<\/span>len(heading))\n<\/span><\/span><span style=\"display:flex;\"><span> \n<\/span><\/span><span style=\"display:flex;\"><span> for k, v in mapping_items:\n<\/span><\/span><span style=\"display:flex;\"><span> print(<span style=\"color:#40a02b\">&#39;{:&gt;15} |{:&gt;15} |&#39;<\/span>.format(k, v))\n<\/span><\/span><\/code><\/pre><\/div><ol start=\"2\">\n<li>If we want to restrict the <code>mapping<\/code> object to an instance of a subclass of the built-in <code>dict<\/code> and the <code>headers<\/code> are specified to be a <code>list<\/code> object:<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-def\" data-lang=\"def\"><span style=\"display:flex;\"><span> \n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5;font-weight:bold\">#<\/span> Validate headers\n<\/span><\/span><span style=\"display:flex;\"><span> if not isinstance(headers, list)\n<\/span><\/span><span style=\"display:flex;\"><span> raise ValueError(<span style=\"color:#40a02b\">&#39;headers needs to be a list object.&#39;<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5;font-weight:bold\">#<\/span> Validate mapping\n<\/span><\/span><span style=\"display:flex;\"><span> if not isinstance(mapping, dict):\n<\/span><\/span><span style=\"display:flex;\"><span> raise ValueError(<span style=\"color:#40a02b\">&#39;mapping needs to be a dict object.&#39;<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span> \n<\/span><\/span><span style=\"display:flex;\"><span> heading <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#40a02b\">&#39;&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> \n<\/span><\/span><span style=\"display:flex;\"><span> for header in headers_iter:\n<\/span><\/span><span style=\"display:flex;\"><span> heading <span style=\"color:#04a5e5;font-weight:bold\">+=<\/span> <span style=\"color:#40a02b\">&#39;{:&gt;15}&#39;<\/span>.format(header) <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> <span style=\"color:#40a02b\">&#39; |&#39;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> print(heading)\n<\/span><\/span><span style=\"display:flex;\"><span> print(<span style=\"color:#40a02b\">&#39;-&#39;<\/span><span style=\"color:#04a5e5;font-weight:bold\">*<\/span>len(heading))\n<\/span><\/span><span style=\"display:flex;\"><span> \n<\/span><\/span><span style=\"display:flex;\"><span> for k, v in mapping_items:\n<\/span><\/span><span style=\"display:flex;\"><span> print(<span style=\"color:#40a02b\">&#39;{:&gt;15} |{:&gt;15} |&#39;<\/span>.format(k, v))\n<\/span><\/span><\/code><\/pre><\/div><h1 id=\"conclusion\">Conclusion<\/h1>\n<blockquote>\n<p>Whenever writing Python, we need to clearly define the allowed interfaces that can be used in place of an object rather than on the basis of classes the object.<\/p>\n<\/blockquote>\n<p>There is no distinction between the <em>right<\/em> way and the <em>wrong<\/em> way when it comes to dealing with objects in Python. The most Pythonic code at a given situation depends entirely on the requirements of the user and the practicality of the use cases. The consideration of Python&rsquo;s Data Model and duck typing can help one write clearer, readable and Pythonic code.<\/p>"},{"title":"Encoding the Python Source Code File","link":"https:\/\/kxsh.dev\/posts\/encoding-python-source-file\/","pubDate":"Sat, 02 Sep 2017 14:42:53 +0100","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/encoding-python-source-file\/","description":"<p>There are about 15 million lines of Python code starting with a variant of the form: <code># -*- coding:&lt;some encoding&gt; -*-<\/code> hosted on GitHub. To any person learning Python, this might seem as another single-line \u201ccomment\u201d. It sure did look that way to me when I started out programming in Python. However, I soon realized that there is something mysterious and esoteric about it. It was some kind of <em>special comment<\/em> which was being used by every Python developer across codebases. In this article, I will try to break down the concepts behind this line of code.<\/p>\n<h1 id=\"our-toolkit\">Our Toolkit<\/h1>\n<p><strong>ASCII<\/strong>: A character set to represent every good old unaccented English letter in memory using a number between 32 and 127. The letter \u201cA\u201d is represented by 65 while 32 represents a \u201cSpace\u201d.<\/p>\n<p><strong>Unicode<\/strong>: Unicode was a brave effort to create a single character set that included every reasonable writing system on the planet and some make-believe ones like Klingon, too. In Unicode, a letter maps to something called a <em>code point<\/em>, which is still just a theoretical concept.<\/p>\n<p><strong>UTF-8<\/strong>: It is an encoding which deals with the problem of storing the characters in memory. In UTF-8, every code point from 0\u2013127 is stored in a single byte. Only code points 128 and above are stored using 2, 3, in fact, up to 6 bytes. This has the neat side effect that English text looks exactly the same in UTF-8 as it did in ASCII.<\/p>\n<blockquote>\n<p>It does not make sense to have a string without knowing what encoding it uses. \u2014 Joel Spolsky<\/p>\n<\/blockquote>\n<p><strong>tl;dr<\/strong> \u2014 If you have a string, in memory or in a file, you have to know what encoding it is in or you cannot interpret it or display it to users correctly.<\/p>\n<h1 id=\"source-code-file-encodings\">Source Code File Encodings<\/h1>\n<p>Whenever you need to type any non-ASCII character while defining literals, that is, a character which cannot be represented through an ASCII code\n(e.g. accented English alphabet, Greek symbols), the Python interpreter does not know the encoding to use in order to represent this character. Thus, defining an encoding enhances the interpretation of Unicode literals in the source code and makes it possible to write Unicode literals using e.g. UTF-8 directly in an Unicode aware editor. This is where our <em>special comment<\/em> comes into picture!<\/p>\n<blockquote>\n<p>If a comment in the first or second line of the Python script matches the regular expression <code>coding[=:]\\s*([-\\w.]+)<\/code>, this comment is processed as an <strong>encoding declaration<\/strong>; the first group of this expression names the encoding of the source code file. The encoding declaration must appear on a line of its own. If it is the second line, the first line must also be a comment-only line.<\/p>\n<\/blockquote>\n<p>Thus, all the variations of the encoding statement are valid as long as the regular expression matches. Refer <a href=\"https:\/\/peps.python.org\/pep-0263\/\">PEP 263<\/a> for examples.<\/p>\n<p><strong>NOTE<\/strong>: From Python 3.0, if no encoding declaration is found, the default encoding is UTF-8.<\/p>\n<h1 id=\"enough-talk-show-me-code\">Enough Talk, Show Me Code<\/h1>\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/e6ce35c04533b340658004399953199b.js\"><\/script>\n\n<p>We will use some variations of the code in the above file to understand the importance of the encoding in files. So, I would suggest you copy and save this Python file somewhere. Perform the following experiments, and try to reason your observations.<\/p>\n<ol>\n<li>Run this file using Python2 interpreter.<\/li>\n<li>Run this file using Python3 interpreter.<\/li>\n<li>Remove L01(read Line 1). Run the updated file using Python2 interpreter.<\/li>\n<li>Remove L01(read Line 1). Run the updated file using Python3 interpreter.<\/li>\n<\/ol>\n<h2 id=\"observations\">Observations<\/h2>\n<ol>\n<li>Experiment 01: The <em>code point<\/em> for the non-ASCII characters in the \u201crepresentation\u201d of the unicode strings.<\/li>\n<li>Experiment 02: <a href=\"https:\/\/stackoverflow.com\/questions\/26125141\/str-object-has-no-attribute-decode-in-python-3\/26125214#26125214\">Reason<\/a> for the <code>AttributeError<\/code>.\nBonus: Modify L03 using <code>encode<\/code> instead of <code>decode<\/code> and execute the file.<\/li>\n<li>Experiment 03: Seems reasonable, doesn\u2019t it?<\/li>\n<li>Experiment 04: Aren\u2019t all the observations identical to those from Experiment 02?<\/li>\n<\/ol>\n<p>If you still are facing trouble understanding the observations or I may have skipped any significant observation, let me know in the comments.<\/p>\n<h1 id=\"lessons-learnt\">Lessons Learnt<\/h1>\n<ul>\n<li>If you intend to write only Python3 specific code using the UTF-8 encoding, you need not use this line.<\/li>\n<li>In all other cases, it is recommended to mention an encoding at the top of your Python files. This has two advantages:\n<ol>\n<li>Being explicit in your code<\/li>\n<li>Compatibility across Python2 and Python3<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h1 id=\"references\">References<\/h1>\n<ul>\n<li><a href=\"https:\/\/peps.python.org\/pep-0263\/\">PEP 263<\/a><\/li>\n<li><a href=\"https:\/\/peps.python.org\/pep-3120\/\">PEP 3120<\/a><\/li>\n<li><a href=\"https:\/\/www.joelonsoftware.com\/2003\/10\/08\/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses\/\">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets(No Excuses!)<\/a><\/li>\n<\/ul>"},{"title":"How Iterables Actually Work in Python","link":"https:\/\/kxsh.dev\/posts\/how-iterables-actually-work-in-python\/","pubDate":"Mon, 28 Aug 2017 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/how-iterables-actually-work-in-python\/","description":"<p>This past week I read about Python&rsquo;s iterator protocol and how the philosophy of iteration is deeply embedded into the language design. Many features that I love about Python such as list comprehensions, tuple unpacking leverage the power of iterator protocol. I wrote an <a href=\"https:\/\/hackernoon.com\/how-iterables-actually-work-in-python-65c36ff91c1e\">article<\/a> on Medium explaining how developers can implement it and use these features much more efficiently in their day-to-day life.<\/p>\n<hr>\n<p>One of the more impressive features of Python language is the use of \u201cfor-each\u201d looping construct that has awed me ever since I started out with Python. For the uninitiated, here is a simple <em>for<\/em> loop which prints the first 10 natural numbers:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-py\" data-lang=\"py\"><span style=\"display:flex;\"><span><span style=\"color:#8839ef\">for<\/span> num <span style=\"color:#04a5e5;font-weight:bold\">in<\/span> <span style=\"color:#04a5e5\">range<\/span>(<span style=\"color:#fe640b\">1<\/span>, <span style=\"color:#fe640b\">11<\/span>):\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">print<\/span>(num)\n<\/span><\/span><\/code><\/pre><\/div><p>We can also loop over the primitive types such as <em>list<\/em>, <em>tuples<\/em>, <em>dictionaries<\/em> and <em>strings<\/em> in similar ways:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-py\" data-lang=\"py\"><span style=\"display:flex;\"><span>numbers <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> [<span style=\"color:#fe640b\">1<\/span>, <span style=\"color:#fe640b\">2<\/span>, <span style=\"color:#fe640b\">3<\/span>, <span style=\"color:#fe640b\">4<\/span>, <span style=\"color:#fe640b\">5<\/span>]\n<\/span><\/span><span style=\"display:flex;\"><span>record <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> (<span style=\"color:#40a02b\">&#39;Kshitij&#39;<\/span>, <span style=\"color:#fe640b\">21<\/span>, <span style=\"color:#40a02b\">&#39;Loves Python&#39;<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>details <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#39;name&#39;<\/span>: <span style=\"color:#40a02b\">&#39;Kshitij&#39;<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#40a02b\">&#39;age&#39;<\/span>: <span style=\"color:#fe640b\">21<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> }<span style=\"color:#8839ef\">for<\/span> num <span style=\"color:#04a5e5;font-weight:bold\">in<\/span> numbers:\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">print<\/span>(num) <span style=\"color:#9ca0b0;font-style:italic\"># 1 2 3 4 5for data in record:<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">print<\/span>(data) <span style=\"color:#9ca0b0;font-style:italic\"># Kshitij 21 Loves Pythonfor key, value in details.items():<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#04a5e5\">print<\/span>(key, value) <span style=\"color:#9ca0b0;font-style:italic\"># age 21 name Kshitij<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>As one implements few data structures in Python using <code>class<\/code>, he feels the desire to loop over the data stored in it\u2019s instances. This is where the Iterator Protocol comes into picture.<\/p>\n<h2 id=\"sample-implementation\">Sample Implementation<\/h2>\n<p>Let us suppose we are tasked with implementing a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Standard_52-card_deck\">standard deck of playing cards<\/a>. A sample implementation might look something like this:<\/p>\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/05dd4ff26257da28e5494b502359508d.js\"><\/script>\n\n<p>This works fine with regards to creating new instances of <code>Deck<\/code> and representing it. However, a major pain point in this implementation is the lack of ability to iterate over the <code>Deck<\/code> object.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-py\" data-lang=\"py\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#179299\">from<\/span> <span style=\"color:#fe640b\">cards<\/span> <span style=\"color:#179299\">import<\/span> Deck\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> new_deck <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> Deck() <span style=\"color:#9ca0b0;font-style:italic\"># New deck instantiated<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#04a5e5\">print<\/span>(new_deck)\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">...<\/span> <span style=\"color:#9ca0b0;font-style:italic\"># Works great<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#8839ef\">for<\/span> card <span style=\"color:#04a5e5;font-weight:bold\">in<\/span> new_deck:\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">...<\/span> <span style=\"color:#04a5e5\">print<\/span>(card)<span style=\"color:#fe640b\">TypeError<\/span>: <span style=\"color:#40a02b\">&#39;Deck&#39;<\/span> <span style=\"color:#04a5e5\">object<\/span> <span style=\"color:#04a5e5;font-weight:bold\">is<\/span> <span style=\"color:#04a5e5;font-weight:bold\">not<\/span> iterable\n<\/span><\/span><\/code><\/pre><\/div><p>One can be smart enough to explore the instance <code>new_deck<\/code> and conclude that the <code>cards<\/code> attributes holds the data required for iterations and it, in fact is a <code>list<\/code> . With this knowledge, he can hack the above loop as follows:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-py\" data-lang=\"py\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#8839ef\">for<\/span> card <span style=\"color:#04a5e5;font-weight:bold\">in<\/span> new_deck<span style=\"color:#04a5e5;font-weight:bold\">.<\/span>cards:\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">...<\/span> <span style=\"color:#04a5e5\">print<\/span>(card)\n<\/span><\/span><span style=\"display:flex;\"><span>Card(<span style=\"color:#04a5e5;font-weight:bold\">...<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">..<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">..<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>This code works great. However, the end user must attain the internal information about the implementation to perform the iteration. This makes our code lose the advantages of data abstraction and leads much to be desired of the implementation.<\/p>\n<blockquote>\n<p>There must be a better way!<\/p>\n<\/blockquote>\n<p>Urged by the enthusiasm from Raymond Hettinger, I searched for ways to improve my implementation to couple with the Python\u2019s <code>for<\/code> loop.<\/p>\n<p>And soon I found the answer \u2014 <strong>The Iterator Protocol<\/strong>.<\/p>\n<h2 id=\"the-iterator-protocol\">The Iterator Protocol<\/h2>\n<p>In order to learn what the Protocol is and how to implement it in Python, we need to understand some basic terms.<\/p>\n<h3 id=\"iterable\">Iterable<\/h3>\n<ul>\n<li>It is any object that <em>you can loop over with a for loop<\/em>.<\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/glossary.html#term-iterable\">Iterables<\/a> are not always indexable, they don\u2019t always have lengths, and they\u2019re not always finite.<\/li>\n<li>An iterable can be passed to <code>iter()<\/code> built-in function to get an iterator for them.<\/li>\n<\/ul>\n<h3 id=\"iterator\">Iterator<\/h3>\n<ul>\n<li>Iterators have exactly one job: return the \u201cnext\u201d item in our iterable.<\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/glossary.html#term-iterator\">Iterators<\/a> can be passed to the built-in <code>next<\/code> function to get the next item from them and if there is no next item (because we reached the end), a <code>StopIteration<\/code> exception will be raised.<\/li>\n<li>Iterators return themselves when passed to the <code>iter()<\/code> built-in.<\/li>\n<\/ul>\n<h2 id=\"the-protocol\">The Protocol<\/h2>\n<h3 id=\"step-01-how-the-iter-built-in-works\">Step 01: How the <code>iter()<\/code> built-in works?<\/h3>\n<p>Whenever the interpreter needs to iterate over an object <code>x<\/code>, it automatically calls <code>iter(x)<\/code>. The <code>iter<\/code> built-in function:<\/p>\n<ol>\n<li>Checks whether the object implements, <code>__iter__<\/code> method and calls that to obtain an <code>iterator<\/code>.<\/li>\n<li>If <code>__iter__<\/code> method is not implemented, but <code>__getitem__<\/code> method is implemented, Python creates an <em>iterator<\/em> that attempts to fetch items in order, starting from index <code>0<\/code>.<\/li>\n<li>If that fails, Python raises <code>TypeError<\/code> exception saying <code>&lt;classname&gt; object is not iterable<\/code>.<\/li>\n<\/ol>\n<h3 id=\"step-02-how-to-implement-the-protocol\">Step 02: How to implement the Protocol?<\/h3>\n<p>I will present two approaches to implementing the Iterator Protocol:<\/p>\n<h4 id=\"approach-1-traditional-way\">Approach 1: Traditional Way<\/h4>\n<ol>\n<li>\n<p>Create a new class representing the <em>iterator<\/em>(say <strong>DeckIterator<\/strong>).<\/p>\n<\/li>\n<li>\n<p>Implement the following two methods in <strong>DeckIterator<\/strong>:<\/p>\n<p><code>__next__<\/code> : returns the next item in the iterable.\n<code>__iter__<\/code> : returns itself i.e <code>self<\/code>.<\/p>\n<\/li>\n<li>\n<p>Define an <code>__iter__<\/code> method in the class over whose instances you want to iterate i.e. class <code>Deck<\/code>. The method should return an instance of <strong>DeckIterator<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<h4 id=\"approach-2-the-pragmatic-way\">Approach 2: The Pragmatic Way<\/h4>\n<ol>\n<li>Implement the <code>__iter__<\/code> method in the <strong>Deck<\/strong> class as a <em>generator function<\/em>.<\/li>\n<\/ol>\n<script src=\"https:\/\/gist.github.com\/kshitij10496\/1aa0fed94b1aaba6165a73220f5fe77a.js\"><\/script>\n\n<p><strong>Features<\/strong><\/p>\n<p>This is the list of all the features that our object magically seem to support as soon as we implement the protocol.<\/p>\n<ol>\n<li>Iteration via <code>for<\/code> loop<\/li>\n<li>Unpacking similar to tuples<\/li>\n<li>Can be used in list comprehensions<\/li>\n<li>Can be used with built-in functions (such as <code>min<\/code>, <code>max<\/code>) which consume an iterable.<\/li>\n<\/ol>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-py\" data-lang=\"py\"><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> new_deck <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> Deck()<span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#9ca0b0;font-style:italic\"># 1. Looping through a for loop<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#8839ef\">for<\/span> card <span style=\"color:#04a5e5;font-weight:bold\">in<\/span> new_deck:\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">...<\/span> <span style=\"color:#04a5e5\">print<\/span>(card) <span style=\"color:#9ca0b0;font-style:italic\"># Works great!&gt;&gt;&gt; # 2. Unpacking similarly to tuples<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> first_card, <span style=\"color:#04a5e5;font-weight:bold\">*<\/span>rest, last_card <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> new_deck<span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#9ca0b0;font-style:italic\"># 3. List Comprehensions<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> spades <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> [card <span style=\"color:#8839ef\">for<\/span> card <span style=\"color:#04a5e5;font-weight:bold\">in<\/span> new_deck <span style=\"color:#8839ef\">if<\/span> card<span style=\"color:#04a5e5;font-weight:bold\">.<\/span>suit <span style=\"color:#04a5e5;font-weight:bold\">==<\/span> <span style=\"color:#40a02b\">&#39;Spades&#39;<\/span>]<span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> <span style=\"color:#9ca0b0;font-style:italic\"># 4. Built-in functions<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#04a5e5;font-weight:bold\">&gt;&gt;&gt;<\/span> max_card, min_card <span style=\"color:#04a5e5;font-weight:bold\">=<\/span> <span style=\"color:#04a5e5\">max<\/span>(new_deck), <span style=\"color:#04a5e5\">min<\/span>(new_deck)\n<\/span><\/span><\/code><\/pre><\/div><h1 id=\"lessons-learnt\">Lessons Learnt<\/h1>\n<ol>\n<li>Iterators in Python aren\u2019t a matter of type but of the protocol i.e. any class that implements this protocol can be iterated over.<\/li>\n<li>Python <em>groks<\/em> iteration.<\/li>\n<\/ol>\n<p>I hope that the knowledge of the Iterator Protocol will help you out when writing Python. In order to raise awareness about this seemingly under appreciated feature of Python, I have proposed a <a href=\"https:\/\/in.pycon.org\/cfp\/2017\/proposals\/iterators-generators-and-you~e9OYb\/\">talk at PyCon India 2017<\/a> on this topic.<\/p>"},{"title":"GSoC Week 10 & 11 - The One with `solvify`","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-10-11\/","pubDate":"Sun, 07 Aug 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-10-11\/","description":"<pre><code> FiniteSet | list\n\n ImageSet, | list (if `f` is periodic)\n Union |\n\n EmptySet | empty list\n\n Others | None\n<\/code><\/pre>\n<ol>\n<li>\n<p>Adding <code>domain<\/code> support.<\/p>\n<p>I added a <code>domain<\/code> argument to <code>isolve<\/code> whose default value is the real domain (<code>domain=S.Reals<\/code>).\nA few limitation to the conditions of <code>S.Infinity<\/code> and <code>S.NegativeInfinity<\/code> followed.<\/p>\n<p>Another noticable point, from the point of implementation, was to deal with singularities and discontinuities of the given inequality.\nFor this, I used the <code>continuous_domain<\/code> method to find the continuous domains of the expression within the specified domain.<\/p>\n<p>This was a minimalistic addition with considerable returns (especially for solving periodic inequalties).<\/p>\n<\/li>\n<li>\n<p>Solving trigonometric inequalities.<\/p>\n<p>Since most of the trigonometric inequalities are periodic in nature and have infinite solutions,\nsolving the expression in the entire real domain is a repetitive task and computationally expensive.<\/p>\n<p>In order to simplify the problem, I intend to solve all the inequalities in a positive periodic interval (say <code>[0, 2*pi)<\/code> for <code>sin(x)<\/code>).\nWe already have a function to compute the real period of a function : <code>periodicity<\/code>.<br>\nIn case of a non-finite <code>domain<\/code> argument, I intend to use this to restrict the solutions of the problem to a periodic interval.<\/p>\n<p>This might not seem the perfect approach but it seems reasonable to handle infinite interval sets for now.\nWe need a new <code>Set<\/code> object : <code>BigUnion<\/code> to represent infinite number of interval objects.<\/p>\n<\/li>\n<\/ol>\n<h3 id=\"new-implementation\"><em>New Implementation<\/em><\/h3>\n<p>I have opened <a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11458\">PR#11458<\/a> for the same with all the implementation details.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span>In []: isolve(cos(x) <span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> S(<span style=\"color:#fe640b\">0<\/span>), x, relational<span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#fe640b\">False<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>Out[]: [<span style=\"color:#fe640b\">0<\/span>, pi<span style=\"color:#04a5e5;font-weight:bold\">\/<\/span><span style=\"color:#fe640b\">2<\/span>) U (<span style=\"color:#fe640b\">3<\/span><span style=\"color:#04a5e5;font-weight:bold\">*<\/span>pi<span style=\"color:#04a5e5;font-weight:bold\">\/<\/span><span style=\"color:#fe640b\">2<\/span>, <span style=\"color:#fe640b\">2<\/span><span style=\"color:#04a5e5;font-weight:bold\">*<\/span>pi)\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>In []: isolve(tan(x) <span style=\"color:#04a5e5;font-weight:bold\">&gt;<\/span> S(<span style=\"color:#fe640b\">0<\/span>), x, relational<span style=\"color:#04a5e5;font-weight:bold\">=<\/span><span style=\"color:#fe640b\">False<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>Out[]: (<span style=\"color:#fe640b\">0<\/span>, pi<span style=\"color:#04a5e5;font-weight:bold\">\/<\/span><span style=\"color:#fe640b\">2<\/span>)\n<\/span><\/span><\/code><\/pre><\/div><h3 id=\"after-thoughts\"><em>After thoughts<\/em><\/h3>\n<p>For the past couple of weeks, I haven&rsquo;t been able to give much time to the project due to my college schedule.\nI try to make up for the lost time during the weekend and meet the 40 hour weekly deadline.<\/p>\n<p>With the endsem evaluation soon approaching, I expect this PR to get merged and count as a part of my project.<\/p>"},{"title":"GSoC Week 09 - The One with Inequalities","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-09\/","pubDate":"Sun, 24 Jul 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-09\/","description":"<p>This week I worked on solving trigonometric inequalities.<\/p>\n<h3 id=\"trigonometric-inequalities\"><strong>Trigonometric inequalities<\/strong><\/h3>\n<p>The primary univariate inequality solver - <code>solve_univariate_inequality<\/code>,<br>\ndepends upon the results of <code>solve<\/code> in order to solve the given inequality.\nTaking a cue from <a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/10022\">PR#10022<\/a> on incorporating <code>solveset<\/code> for inequalities, I worked on developing an approach for replacing the use of <code>solve<\/code>\nwith <code>solveset<\/code> in solving inequalities.<\/p>\n<p><strong>Idea<\/strong><\/p>\n<blockquote>\n<p>Convert <code>Set<\/code>-type output from <code>solveset<\/code> to <code>list<\/code> objects similar to that returned by <code>solve<\/code>.<\/p>\n<\/blockquote>\n<p>The most striking difference between both the APIs is the uniform <code>Set<\/code> output returned by <code>solveset<\/code>.\nHence, the prime concern while transitioning from <code>solve<\/code> to <code>solveset<\/code> should be handling the various type of solutions.<\/p>\n<p>Here are a few implementation ideas on the same:<\/p>\n<ul>\n<li>\n<p><strong>FiniteSet<\/strong> : finite number of solutions<br>\nUsing the <code>list<\/code> constructor on these type of objects works extremely well.<\/p>\n<\/li>\n<li>\n<p><strong>ImageSet<\/strong> : infinite number of solutions<br>\nThis is generally the case with trigonometric functions as most of them are periodic in nature.\nWe need to limit the number of solutions to be finite.<br>\nFor this, I intend to use the a periodic interval: <code>[0, period]<\/code> as the basis for filtering the solution set.\nThis returns a simplified <code>FiniteSet<\/code> of solutions which can be used to solve inequalities in a restricted interval.\nFollowing which we can generalise the output over the entire domain of the function.<\/p>\n<p>A major issue here is the representation of the final solution set.<br>\nFor example:<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span>In []: solveset(cos(x)<span style=\"color:#04a5e5;font-weight:bold\">&lt;<\/span><span style=\"color:#fe640b\">0<\/span>, x, domain<span style=\"color:#04a5e5;font-weight:bold\">=<\/span>S<span style=\"color:#04a5e5;font-weight:bold\">.<\/span>Reals)\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">\u23a1<\/span> \u03c0 <span style=\"color:#fe640b\">3<\/span><span style=\"color:#d20f39\">\u22c5<\/span>\u03c0 <span style=\"color:#d20f39\">\u23a4<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">\u23a2<\/span><span style=\"color:#fe640b\">2<\/span><span style=\"color:#04a5e5;font-weight:bold\">*<\/span>n<span style=\"color:#04a5e5;font-weight:bold\">*<\/span>pi <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> <span style=\"color:#d20f39\">\u2500<\/span>, <span style=\"color:#fe640b\">2<\/span><span style=\"color:#04a5e5;font-weight:bold\">*<\/span>n<span style=\"color:#04a5e5;font-weight:bold\">*<\/span>pi <span style=\"color:#04a5e5;font-weight:bold\">+<\/span> <span style=\"color:#d20f39\">\u2500\u2500\u2500<\/span> <span style=\"color:#04a5e5;font-weight:bold\">|<\/span> n <span style=\"color:#d20f39\">\u220a<\/span> \u2124<span style=\"color:#d20f39\">\u23a5<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#d20f39\">\u23a3<\/span> <span style=\"color:#fe640b\">2<\/span> <span style=\"color:#fe640b\">2<\/span> <span style=\"color:#d20f39\">\u23a6<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>Currently, we do not have a <code>Set<\/code> object for representing this.<br>\nFor this, we need to implement an <em>Indexed Union<\/em> : <code>Union(X(a) for a in I)<\/code><\/p>\n<p>We can symbolically represent the above solution as <code>BigUnion(Interval(2*n*pi + pi\/2, 2*n*pi + 3*pi\/2), n, S.Intgers)<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p><strong>After thoughts<\/strong><\/p>\n<p>Also, this week my <a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11277\">PR#11277<\/a> on periodicity got merged finally.\nI have updated the corresponding <a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11141\">PR#11141<\/a> which has been stalled for some time now.\nHopefully, it will get merged soon.<\/p>\n<p>The next week I will devote my time to the implementation part of solving inequalities.<\/p>"},{"title":"GSoC Week 07 - The One With Generalised Periodicity","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-07\/","pubDate":"Thu, 07 Jul 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-07\/","description":"<p>This week I updated my <a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11277\">PR#11277<\/a> to find the period of a <strong>general function<\/strong>.<\/p>\n<h3 id=\"periodicity\"><em><strong>Periodicity<\/strong><\/em><\/h3>\n<p>In the past few weeks, I dedicated a lot of my time reading about the property of periodicity of a function.\nEarlier, I had implemented a trivial(and restricted) functionality for this task.\nThis motivated me to study this topic as I planned to generalise the function.<\/p>\n<p>Here are my notes on periodicity which were the literature reference for the development of the method:<\/p>\n<ul>\n<li>\n<p>Note that <code>2\u03c0<\/code> is a period of <code>sin(x)<\/code>.\nBut <code>sin(x)<\/code> has many other periods, such as <code>4\u03c0<\/code>, <code>6\u03c0<\/code>, and so on.\nHowever, <code>sin(x)<\/code> has no (positive) period shorter than <code>2\u03c0<\/code>.<\/p>\n<\/li>\n<li>\n<blockquote>\n<p>If <code>p<\/code> is a period of <code>f(x)<\/code>, and <code>H<\/code> is any function, then <code>p<\/code> is a period of <code>H(f(x))<\/code>.<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<blockquote>\n<p>For sums and products, the general situation is complicated.<\/p>\n<\/blockquote>\n<p>Let <code>p<\/code> be a period of <code>f(x)<\/code> and let <code>q<\/code> be a period of <code>g(x)<\/code>.\nSuppose that there are positive integers <code>a<\/code> and <code>b<\/code> such that <code>ap=bq=r<\/code>.<br>\nThen <code>r<\/code> is a period of <code>f(x)+g(x)<\/code>, and also of <code>f(x)g(x)<\/code>.<br>\nHowever, the point to note here is that <code>r<\/code> need not be the shortest period of <code>f(x)+g(x)<\/code> or <code>f(x)g(x)<\/code>.<\/p>\n<p>For example:\nThe shortest period of <code>sin(x)<\/code> is <code>2\u03c0<\/code>, while the shortest period of <code>(sinx)**2<\/code> is <code>\u03c0<\/code>.<\/p>\n<p>Another example: Let <code>f(x)=sin(x)<\/code>, and <code>g(x)=\u2212sin(x)<\/code>.\nEach function has smallest period <code>2\u03c0<\/code>. But their sum is the <code>0<\/code>-function, which has every positive number <code>p<\/code> as a period!<\/p>\n<\/li>\n<li>\n<blockquote>\n<p>If <code>p<\/code> and <code>q<\/code> are periods of <code>f(x)<\/code> and <code>g(x)<\/code> respectively, then any common multiple of <code>p<\/code> and <code>q<\/code> is a period of <code>H(f(x),g(x))<\/code>\nfor any function <code>H(u,v)<\/code>, in particular when <code>H<\/code> is addition, multiplication or division. However, it need not be the smallest period.<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<blockquote>\n<p>The sum of two periodic functions need not be periodic.<\/p>\n<\/blockquote>\n<p>For example: Let <code>f(x)=sin(x)+cos(2\u03c0x)<\/code>.\nThe function is not periodic.<br>\nThe problem is that <code>1<\/code> and <code>2\u03c0<\/code> are incommensurable. There do not exist positive integers <code>a<\/code> and <code>b<\/code>\nsuch that <code>(a)(1)=(b)(2\u03c0)<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"issues\"><em><strong>Issues<\/strong><\/em><\/h3>\n<p>I am abstracting the details of implementation so as not to make the post even further boring.<\/p>\n<p>During the period of development, I faced few issues and had a lot of queries to make.<\/p>\n<ol>\n<li>\n<p>The new implementation returns a value which might not be the <strong>fundamental period<\/strong> of the given function.\nThe previous implementation, though limited, returned the fundamental period of the given function.<\/p>\n<\/li>\n<li>\n<p>The ability to find the LCM of irrationals.\nWe will be dealing with the iconic <code>\u03c0<\/code>(and its multiples) in many of our cases(as is evident from the example above).\nCurrently, we donot have the functionality to find the LCM of\nirrational numbers. A method needs to be developed to handle this issue.<\/p>\n<\/li>\n<li>\n<p>Issue with automatic simplification while verifying the result.<\/p>\n<\/li>\n<\/ol>\n<p><strong>After Thoughts<\/strong><\/p>\n<p>I am looking forward to addressing all these issues in tonight&rsquo;s meeting.\nApart from that, implementing this was a lot of fun.\nI got to learn about inheritance and abstraction while implementing instance methods for periodic functions.<\/p>\n<p>Hopefully, all my effort doesn&rsquo;t go in vain.<\/p>\n<p>Till next time !<\/p>"},{"title":"GSoC Week 06 - The One with Singularities","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-06\/","pubDate":"Fri, 01 Jul 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-06\/","description":"<p>This week I worked on the topic of <em>singularities<\/em>.<\/p>\n<h3 id=\"singularities\"><em><strong>Singularities<\/strong><\/em><\/h3>\n<blockquote>\n<p>A singularity is in general a point at which a given mathematical object is not defined.<\/p>\n<\/blockquote>\n<p>Examples:<\/p>\n<ul>\n<li><code>1\/x<\/code> has a singularity at <code>x = 0<\/code> as it seems to reach infinity.<\/li>\n<li><code>|x| (Absolute)<\/code> has a singularity at <code>x = 0<\/code> since it is not differentiable at that point.<\/li>\n<li><code>\u221ax (Square root)<\/code> has a singularity at <code>x = 0<\/code> since it doesnot admit a tangent there.<\/li>\n<\/ul>\n<p>In real analysis, singularities are either discontinuities or discontinuities of\nthe derivative (sometimes also discontinuities of higher order derivatives).<\/p>\n<p>A <strong>removable singularity<\/strong> of a function is a point at which the function is undefined,\nbut it is possible to redefine the function at that point in such a way that the resulting\nfunction is regular in a neighbourhood of that point.<\/p>\n<p>For instance,<\/p>\n<p><code>f(z) = sin(z)\/z<\/code> has a removable singularity at <code>z = 0<\/code>.<br>\nThis singularity can be removed by defining <code>f(0) := 1<\/code>, which is the limit of <code>f<\/code> as <code>z<\/code> tends to <code>0<\/code>.<\/p>\n<p>In SymPy, we try to automatically simplify some of the expressions before passing it for\nfurther processing.<\/p>\n<p>For example,<\/p>\n<ul>\n<li><code>x\/x<\/code> simplifies to <code>1<\/code>.<\/li>\n<li><code>(x-1)^2\/(x-1)<\/code> simplifies to <code>x-1<\/code>.<\/li>\n<\/ul>\n<p>At times, this can lead to incorrect behaviour.\nSuppose, we are interested to find the singularities ( and\/or domain ) of the function <code>f(x) = x\/x<\/code>.<\/p>\n<pre tabindex=\"0\"><code>In []: f = x\/x\nIn []: singularities(f, x)\nOut[]: S.EmptySet # no singularities\nIn []: continuous_domain(f, x, S.Reals) # finding the valid domain of f on the real line\nOut[]: S.Reals # should be (-oo, 0) U (0, oo)\n<\/code><\/pre><p>After some discussion about this issue of automatic simplification, we came to the\nconclusion that removable singularities should be treated as part of the domain of the function.\nThis will help in justifying the behaviour of expressions which are automatically simplified.<\/p>\n<p>So, I studied about how to classify a singularity as a removable one.\nFor this, we use the <strong>Reimann&rsquo;s theorem<\/strong>:<\/p>\n<blockquote>\n<p>Let <code>f<\/code> a function defined on the set <code>D \\{a}<\/code>.\nThe point <code>a<\/code> is a removable discontinuity if there exists a neighborhood of <code>a<\/code> on which <code>f<\/code> is bounded.<\/p>\n<\/blockquote>\n<p>Mathematically,<\/p>\n<p><code>lim (z -a)*f(z)<\/code><br>\n<code>z-&gt;a+<\/code><\/p>\n<p>I have implemented this theorem in the form of a function but I face certain issues with\nthe values returned by <code>solveset<\/code> due to <code>check_domain<\/code> function (which checks the bound of a\nfunction at a particular value). This remains to be discussed in the meeting.<\/p>\n<p><strong>After Thoughts<\/strong><\/p>\n<p>I have lots to discuss with my mentors on these issues.<br>\nAfter merging the PR#11277, I think <code>solve_decomposition<\/code> method will be good to go.<\/p>"},{"title":"GSoC Weeks 04 & 05 - The One with Periodicity","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-04-05\/","pubDate":"Fri, 24 Jun 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-04-05\/","description":"<p>Hi folks !<\/p>\n<p>The past couple of weeks were spent of developing heuristics for determining the\nfundamental period of a given trigonometric function.<\/p>\n<p>In our higher school, we all must have come across <code>Trigonometric Functions<\/code>.\nOne of the most striking properties of these functions is their periodicty.<br>\nThe ability of a function to repeat its values in regular intervals has always\ncaught my imagination.<\/p>\n<h2 id=\"motivation\"><strong>Motivation<\/strong><\/h2>\n<p>Well, SymPy ought to have a functionality to determine the period of a function.\nThe instigated me to implement this function now was the build failure in my\nPR#11141 on <code>solve_decomposition<\/code>.<\/p>\n<h3 id=\"issue\"><strong>Issue<\/strong><\/h3>\n<p><code>function_range(sin(x), x, domain=S.Reals)<\/code> causes the build to time-out as the\nnumber of critical points of <code>sin(x)<\/code> in the entire real domain is infinite.\nThe same goes for other trigonometric functions as well.<\/p>\n<p>However, if we can set the <code>domain<\/code> argument to be a finite interval which\nencompasses the entire behaviour of <code>sin(x)<\/code> over the entire real domain, our\nissue can be solved.<\/p>\n<p>This led me to the idea of using the periodicity of the function as its domain.<\/p>\n<h2 id=\"design\"><strong>Design<\/strong><\/h2>\n<p><code>f = sin(x) + sin(2*x) + cos(3*x)<\/code><\/p>\n<p>We know that the period of <code>f<\/code> is <code>2\u22c5\u03c0<\/code>\ni.e. the LCM of the periods of individual function.<\/p>\n<p><em>It is known !<\/em><\/p>\n<p>Hence, in order to find the period of <code>f<\/code>, we need the functionality to determine\nthe period simpler trigonometric functions such as <code>sin(x)<\/code>, <code>sin(2*x)<\/code> and <code>cos(3*x)<\/code><\/p>\n<h3 id=\"property\"><strong>Property<\/strong><\/h3>\n<blockquote>\n<p>If the period of <code>g(x)<\/code> is <code>T<\/code>, then the period of <code>g(a*x)<\/code> is <code>T\/a<\/code>.<\/p>\n<\/blockquote>\n<p>Using this property, we can easily compute the periods of <code>sin(2*x)<\/code> and <code>cos(3*x)<\/code>\nwith our knowledge of the periodicity of the fundamental trigonometric functions.<\/p>"},{"title":"GSoC Week 03 - The One With Function Range (Part II)","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-03\/","pubDate":"Fri, 10 Jun 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-03\/","description":"<p>Hey !<\/p>\n<p>This week I worked on implementing a method for finding the range of a function in a given domain.\nFollowing from last weeek&rsquo;s research on the same, I tried to develop these utility functions.<\/p>\n<h3 id=\"implementation\"><strong>Implementation<\/strong><\/h3>\n<p>Here, I have defined the two functions along with some of their implementation details:<\/p>\n<p><strong><code>continuous_in(f, x, interval)<\/code><\/strong><\/p>\n<p>The function returns the sub-domains as an <code>Union<\/code> of <code>Interval<\/code> in case a discontinuity exists in the <code>interval<\/code>. If the function is continuous in the entire domain, the <code>interval<\/code> itself is returned.<\/p>\n<p>For this we need to consider 2 primary conditions:<\/p>\n<ul>\n<li>\n<p><strong>Domain constraints for real functions<\/strong>\nI have also added some code for domain constraints in <code>sqrt<\/code> and <code>log<\/code> functions.\nUsing the <code>solve_univariate_inequality<\/code> method (as the name suggests, it solves univariate inequalities),\nwe calculate these constraints.<br>\nGiven <code>f(x) = sqrt(g(x))<\/code>, we determine the range of values of <code>x<\/code> for which the function <code>g(x) &gt;= 0<\/code>.<br>\nSimilarly, for <code>f(x) = log(g(x))<\/code>, the interval of <code>x<\/code> in which <code>g(x) &gt; 0<\/code> is the constrained interval.<\/p>\n<\/li>\n<li>\n<p><strong>Singularities<\/strong>\nFor determining the discontinuities, I tried to solve the reciprocal of the given function using <code>solveset<\/code>:<code> solveset(1\/f, x, interval)<\/code>. The <code>singularities<\/code> function can also be used here but its implementation is\nrestricted to rational functions only. There are possibilities of improving this function to create a universal\nfunction which returns all the possible singularities of the function in a given domain.<\/p>\n<\/li>\n<\/ul>\n<p><strong><code>function_range(f, x, domain)<\/code><\/strong><\/p>\n<p>Like the name suggests, this method returns the range of a univariate function in a given domain. This function is primarily designed for the purpose of <code>solve_decomposition<\/code>.<\/p>\n<p>This function calls the above implemented <code>continuous_in<\/code> method for finding the actual domain of <code>f<\/code>. Following this, we iterate over each <code>Interval<\/code> object returned by <code>continuous_in<\/code>.<\/p>\n<p>By using the boundaries of the interval and first derivate test, we determine the crtical points in the interval\nand their corresponding critical values.<\/p>\n<p>For determining the values of the function at the singularities, we determine its limit at that point.\nFor this, I use the <code>limit<\/code> function of SymPy.<\/p>\n<p>After calculating the local extremas, I calculate the global minima and maxima using the <code>inf<\/code>(infimum) and <code>sup<\/code>(supremum) of the <code>FiniteSet<\/code> of all critical values. The range, which is the <code>Interval<\/code> of these extremasm, is returned.<\/p>\n<h3 id=\"-git-log\"><strong>$ git log<\/strong><\/h3>\n<p><a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11141\">PR#11141<\/a>: Method for solving equations using Decomposition and Rewriting\n<em>Opened this week<\/em><br>\n<a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11224\">PR#11224<\/a>: Methods for finding the range of a function in a given domain<\/p>\n<p><strong>Final Thoughts<\/strong><\/p>\n<p>That was all for this week.<br>\nMy task for the upcoming days would be to update my <code>solve_decomposition<\/code> method to accomodate these methods.\nI aim to get all these PR merged before the midterm evaluation.<\/p>"},{"title":"GSoC Week 02 - The One With Function Range (Part I)","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-02\/","pubDate":"Sat, 04 Jun 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-02\/","description":"<p>This week I worked on developing methods for computing the range of an univariate function.\nFor this pupose, I spent most of my time in research; reading previous discussions on mailing lists, pull requests and wikis.<\/p>\n<h3 id=\"progress\"><strong>Progress<\/strong><\/h3>\n<p>Suppose, we want to solve the following equation in the variable <code>x<\/code>:<\/p>\n<p><code>sin(x) = \u03c0 \/ 2<\/code><\/p>\n<p>We can straight away state that this equations has <em>no solutions<\/em> as the range of the function <code>sin<\/code> is -1 to 1<br>\ni.e <code>sin(x) \u2208 [-1, 1]<\/code>.<\/p>\n<p>Thus, we find that the range of the function can also be used to leverage the solutions of an equation. The implementation of a function to determine the range of a function in a given domain is particularly interesting for checking whether an equation is at all solvable.<\/p>\n<p>In the last meeting, Amit had suggested me to read the conversation on<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/2723\">PR#2723<\/a> : Fixed imageset for Interval<\/li>\n<li><a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/2925\">PR#2925<\/a> : find singularities for any expression.<\/li>\n<\/ul>\n<p>Along with this, I read the following mailing lists discussions:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/groups.google.com\/forum\/#!searchin\/sympy\/minimize\/sympy\/Na_p5pm1I7M\/V6uv4ZAkp2oJ\">Find minimum value of a function symbolically<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/groups.google.com\/forum\/#!topic\/sympy\/8TM8cnuzkG8\">Best way to find extrema of function over interval<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/groups.google.com\/forum\/#!searchin\/sympy\/singularity\/sympy\/ijhl7rkHEbk\/lsWTuJ2Nb8wJ\">GSoC 2013 Idea - Find Domain \/ Range \/ Continuity \/ Singularity of a Function<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/groups.google.com\/forum\/#!searchin\/sympy\/singularity\/sympy\/c_fpCu9QiII\/n2KaXN-z3rwJ\">On a general representation for singularities and infinities<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/groups.google.com\/forum\/#!searchin\/sympy\/singularity\/sympy\/mJlCxuZ5uZw\/peWogHzbKekJ\">Functions: Singularity and Continuity<\/a><\/p>\n<\/li>\n<\/ol>\n<p>All this research helped me appreciate the difficulty of the problem at hand. Also, my approach to solving this issue is heavily inspired from these discussions.<\/p>\n<h3 id=\"design\"><strong>Design<\/strong><\/h3>\n<p>The methodology of determining the range of a function:<\/p>\n<ol>\n<li>Determine the points of discontinuities in the concerned domain.<\/li>\n<li>Divide the entire domain into sub-domains about the above-determined singularities.<\/li>\n<li>Use the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Derivative_test#Second_derivative_test\">Derivative Test<\/a> to locate the critical points of the function within each sub-domain.<\/li>\n<li>Calcuate the corresponding values of the function at the critical points and the boundary values of the sub-domains.<\/li>\n<li>The extremas of the function in the entire domain are the maximum and minimum values in all the smaller domains combined.<\/li>\n<\/ol>\n<p>For now, I have thought of designing 2 functions to solve this issue:<\/p>\n<ol>\n<li>Function to divide the domain into sub-domains.<\/li>\n<li>Function to calculate the extremum values.<\/li>\n<\/ol>\n<h3 id=\"-git-log\"><strong>$ git log<\/strong><\/h3>\n<p><a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11141\">PR#11141<\/a> : Method for solving equations using Decomposition and Rewriting\n<a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11164\">PR#11164<\/a> : Intersection of certain ImageSets with Intervals<\/p>\n<h3 id=\"thoughts\"><strong>Thoughts<\/strong><\/h3>\n<p>After tommorrow&rsquo;s meeting, I will iron out a more concrete design.\nMy goal for next week would be to implement the above-said functions.<\/p>\n<p>Looking forward to another exciting week !<\/p>"},{"title":"GSoC Week 01 - The One with Intersections","link":"https:\/\/kxsh.dev\/posts\/gsoc-week-01\/","pubDate":"Sun, 29 May 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/gsoc-week-01\/","description":"<h3 id=\"-git-log\"><strong>$ git log<\/strong><\/h3>\n<p><a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11149\">PR #11149<\/a> : Intersection of null Range and an Interval returns EmptySet\n<a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11164\">PR #11164<\/a> : Intersection of certain ImageSets with Intervals<\/p>\n<p>In the next week, I will try to design a method to determine the range of a function in the given domain.\nThis will require some digging up and a bit of research.<\/p>\n<p>Looking forward to it !<\/p>"},{"title":"Solving equations via Decomposition and Rewriting","link":"https:\/\/kxsh.dev\/posts\/solving-equations-via-decomposition-and-rewriting\/","pubDate":"Sun, 22 May 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/solving-equations-via-decomposition-and-rewriting\/","description":"<p>A robust framework for solving equations is a salient feature of any Computer Algebra System. An important idea in this regard is <strong>&ldquo;Rewriting and Decomposition&rdquo;<\/strong>. By using this techniques, we try to reduce the given equation to a set of simpler equations which can be solved with relative ease.<\/p>\n<p>An example here would be the best way to establish the significance of the above idea.<\/p>\n<p>If we have to solve for <code>x<\/code> in the equation <code>f(x) = 0<\/code>, where<br>\n<code>f(x) = ln(x)**2 - 3*ln(x) + 2<\/code><\/p>\n<p>This problem can be approached with the idea of &ldquo;Decomposition and Rewriting&rdquo;.\nHere is the procedure:<\/p>\n<ol>\n<li>\n<p><strong>Decomposition<\/strong>\nThe step involves a decomposition of the given function into smaller, constituent functions.\nIn the above case, we decompose f(x) as:\n<code>f(x) = g(x)*2- 3*g(x) + 2<\/code> , where <code>g(x) = ln(x)<\/code><\/p>\n<\/li>\n<li>\n<p><strong>Rewriting<\/strong>\nSubstituting <code>g(x)<\/code> with a dummy variable <code>t<\/code> in <code>f(x)<\/code>, we get a polynomial in <code>t<\/code>:<br>\n<code>h(t) = (t -1)*(t-2)<\/code> , where <code>t = ln(x)<\/code><\/p>\n<\/li>\n<li>\n<p>We determine the values which satisfy the equation <code>h(t) = 0<\/code>.<br>\nFor our example: <code>t = 1<\/code> or <code>t = 2<\/code><\/p>\n<\/li>\n<li>\n<p>Back-substituting the value of <code>t<\/code> into these solutions, we get 2 independent equations in <code>x<\/code>:<br>\n<code>ln(x)= 1<\/code> or <code>ln(x) = 2<\/code><\/p>\n<\/li>\n<li>\n<p>Solving these equations individually, we get the desired solutions of the inital equation <code>f(x) = 0<\/code> i.e.<br>\n<code>x = exp(1)<\/code> or <code>x = exp(2)<\/code><\/p>\n<\/li>\n<\/ol>\n<p>Thus, we get two possible solutions of the given complex transcendental equation through the methods of Rewriting and Decomposition. An important observation can be made with respect to the relative ease of calculating the solutions of the intermediate equations compared to that of the original equation. This motivates the development of a simpler and modular system for solving equations rather than a vast and case-specific one.<\/p>\n<p>A well-designed implementation of the above technique can be of high value to the <code>solveset<\/code> system. This will be my task for the 1st week of GSoC. I created a Pull Request <a href=\"https:\/\/github.com\/sympy\/sympy\/pull\/11141\">PR#11141<\/a> with a primitive design.\nReviews and suggestions are welcomed !\nThats pretty much it for now. In the next blog post, I will be writing in detail about the implementation process.<\/p>"},{"title":"Auditing SymPy's Transcendental solver","link":"https:\/\/kxsh.dev\/posts\/auditing-sympys-transcendental-solver\/","pubDate":"Sun, 15 May 2016 00:00:00 +0530","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/posts\/auditing-sympys-transcendental-solver\/","description":"<p>Having considered the current codebase of <code>_tsolve<\/code> function, I find the following few points considered while implementing the new solver:<\/p>\n<ul>\n<li>modularise the code for various classes of equations(LambertW, <code>bivariate<\/code> equation type, logarithmic, exponential).<\/li>\n<li>using SymPy <code>Set<\/code> objects internally, instead of using the built-in Python <code>lists<\/code>.<\/li>\n<li>use of <code>decompogen<\/code> function to check for possible decomposition of the given expression into simpler functions.<\/li>\n<li>handle the case where the given equation has no closed-form solution and infinite recursion occurs.<\/li>\n<\/ul>\n<p>These are just a handful of strategies that I intend to use. However, the whole process of development is going to a lot more complex and might need some more considerations from my side.<\/p>\n<h3 id=\"task--implement-transolve-function\">Task : Implement <code>transolve<\/code> function.<\/h3>\n<p>My plan is to do a <em>test-driven development<\/em> for this solver.\nFor this, I will start by porting the relevant tests present in <code>test_solvers.py<\/code> module to the <code>test_solveset.py<\/code>.\nFollowing this, I will start the developement process of the <code>transolve<\/code> solver.<\/p>\n<p>I aim to accomplish a major portion of this task by the end of this week.<\/p>\n<p>Thats all for now.\nAnd the coding begins !<\/p>"},{"title":"About","link":"https:\/\/kxsh.dev\/about\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/about\/","description":"<p>Hi! \ud83d\udc4b<\/p>\n<p>My name is Kshitij. I am currently based in Berlin where I work as a professional\nsoftware engineer, focusing on backend systems.<\/p>\n<p>This blog is the place where I think in public.\nThe posts are my attempt to share my ideas, opinions, experiments, and reflect\non experiences.<\/p>\n<p>The following are a few links to know a bit more about me:<\/p>\n<ul>\n<li><a href=\"https:\/\/kxsh.dev\/now\/\">Now<\/a> documents about my current interests.<\/li>\n<li><a href=\"https:\/\/kxsh.dev\/tags\/review\/\">Weekly Reviews<\/a> is a weekly review<\/li>\n<li><a href=\"https:\/\/kxsh.dev\/tags\/running\/\">Running<\/a> is a log on my relationship with long-distance running.<\/li>\n<\/ul>\n<h3 id=\"feeds\">Feeds<\/h3>\n<ul>\n<li><a href=\"https:\/\/kxsh.dev\/notes\/index.xml\">Notes<\/a><\/li>\n<li><a href=\"https:\/\/kxsh.dev\/posts\/index.xml\">Posts<\/a><\/li>\n<li><a href=\"https:\/\/kxsh.dev\/index.xml\">All content<\/a><\/li>\n<\/ul>\n<p>In case you would like to discuss anything, please reach out to me on the social\nmedia accounts linked on the <a href=\"https:\/\/kxsh.dev\/\">Home page<\/a>. Alternately, via <a href=\"mailto:hi@kxsh.dev\">email<\/a>.<\/p>\n<p>Cheers! \ud83c\udf7a<\/p>"},{"title":"Now","link":"https:\/\/kxsh.dev\/now\/","pubDate":"Mon, 01 Jan 0001 00:00:00 +0000","author":"hi@kxsh.dev (Kshitij Saraogi)","guid":"https:\/\/kxsh.dev\/now\/","description":"<p>This page hosts regular updates about what I have been up to lately. Inspired by Derek Siver&rsquo;s Now Page.<sup id=\"fnref:1\"><a href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\">1<\/a><\/sup><\/p>\n<p><strong>Reading<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Steppenwolf_%28novel%29?useskin=vector\">Steppenwolf<\/a> by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hermann_Hesse?useskin=vector\">Hermann Hesse<\/a>.<\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/A_Wild_Sheep_Chase?useskin=vector\">A Wild Sheep Chase<\/a> by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Haruki_Murakami?useskin=vector\">Haruki Murakami<\/a>.<\/li>\n<li><a href=\"https:\/\/pages.cs.wisc.edu\/~remzi\/OSTEP\/\">Operating Systems: Three Easy Pieces<\/a><\/li>\n<\/ul>\n<p><strong>Projects<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/codeberg.org\/kxsh\/kjsh\">Building a UNIX Shell <code>kjsh<\/code><\/a>.<\/li>\n<li>German on Duolingo.<\/li>\n<\/ul>\n<p><strong>Physical Fitness<\/strong><\/p>\n<ul>\n<li>Recovering after <a href=\"https:\/\/www.bmw-berlin-marathon.com\/en\/\">Berlin Marathon 2026<\/a>.<\/li>\n<li>Strength Training: <a href=\"https:\/\/stronglifts.com\/stronglifts-5x5\/workout-program\/\">Stronglifts 5x5<\/a>, 3x per week<\/li>\n<\/ul>\n<p><em>Updated: 6th October 2026<\/em><\/p>\n<div class=\"footnotes\" role=\"doc-endnotes\">\n<hr>\n<ol>\n<li id=\"fn:1\">\n<p>Derek Siver&rsquo;s movement for <a href=\"https:\/\/nownownow.com\/about\">creating a <strong>&ldquo;now&rdquo;<\/strong> page<\/a>&#160;<a href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\">&#x21a9;&#xfe0e;<\/a><\/p>\n<\/li>\n<\/ol>\n<\/div>"}]}}