<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Suyash Raj on Medium]]></title>
        <description><![CDATA[Stories by Suyash Raj on Medium]]></description>
        <link>https://medium.com/@suyash10581108?source=rss-95a2ee4e6c61------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JIHcbGYNQjTxqzLVST63pw.jpeg</url>
            <title>Stories by Suyash Raj on Medium</title>
            <link>https://medium.com/@suyash10581108?source=rss-95a2ee4e6c61------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:14:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suyash10581108/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Three Tiny Vim Tricks I Use Almost Every Day (That Replace Scripts and Online Tools)]]></title>
            <link>https://medium.com/@suyash10581108/three-tiny-vim-tricks-i-use-almost-every-day-that-replace-scripts-and-online-tools-71d4c9a2dbdb?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/71d4c9a2dbdb</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[vim]]></category>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 09:09:26 GMT</pubDate>
            <atom:updated>2026-01-28T09:09:26.509Z</atom:updated>
            <content:encoded><![CDATA[<h4>JSON cleanup, PEM fixes, and unescaping strings — without leaving your editor</h4><p>Every few days, I run into the same small but annoying developer tasks:</p><p>I need to <strong>pretty-print or compact some JSON</strong></p><ul><li>I need to <strong>turn a PEM certificate string back into a real file</strong></li><li>I need to <strong>clean up stringified JSON full of escaped quotes</strong></li></ul><p>Most people solve these by:</p><ul><li>writing a quick script,</li><li>opening an online formatter,</li><li>or pasting things into random tools (sometimes even ChatGPT).</li></ul><p>I don’t. I just stay in <strong>Vim</strong>.</p><p>Because Vim is a <em>text editor</em>, and these are <em>text problems</em>.</p><p>Here are <strong>three things I do almost daily in Vim</strong> that save time, avoid context switching, and work everywhere — locally, over SSH, or on production logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmprhWf9D8dZPuH_o8hs5A.png" /></figure><h3>Expand or Compact JSON <em>in Place</em> Using jq</h3><p>JSON formatting is probably the most common one. I guess you do it as follows:</p><ul><li>paste JSON into an online formatter,</li><li>copy it back,</li><li>then come back again if you need to edit something.</li></ul><p>That’s slow — especially if you want to <em>edit the JSON before or after formatting</em>.</p><h4>What I do</h4><ol><li>Open Vim</li><li>Paste the JSON</li><li>Enter Visual Line mode: Shift+V</li><li>Select the JSON (use G if you want to select to last line)</li><li><strong>To expand </strong>:&#39;&lt;&#39;&gt;!jq</li><li><strong>To compact </strong>:&#39;&lt;&#39;&gt;jq -c</li></ol><blockquote>The &#39;&lt;&#39;&gt; is automatically inserted by vim, when you press : in Vim from Visual mode. It represents the selected text block.</blockquote><h3>Turn PEM Strings Back Into Real Certificates</h3><p>If you work with APIs, Kubernetes, terraform, environment variables, or JSON/YAML configs, then you’ve probably seen PEM files encoded like this:</p><pre>&quot;-----BEGIN CERTIFICATE-----\nMIID...\n-----END CERTIFICATE-----&quot;</pre><p>The painful part is replacing \n with <strong>actual newlines</strong> before putting it into a file.</p><h4>What I do</h4><ol><li>Copy the PEM string</li><li>Open Vim and paste the string.</li><li>Run :%s/\\n/\r/g</li></ol><h3>Convert Stringified JSON Back to Real JSON</h3><p>This one shows up all the time in logs, configs, test files, API responses, or code where JSON is stored as a string. Example:</p><pre>&quot;{\&quot;name\&quot;:\&quot;service\&quot;,\&quot;port\&quot;:8080}&quot;</pre><p>Before you can do anything useful with it, you need to remove the escaped quotes.</p><h4>What I do</h4><ol><li>Copy the JSON <strong>without the outer quotes</strong></li><li>Open Vim and paste the string.</li><li>Run: :%s/\\&quot;/&quot;/g</li></ol><p>And that’s it. No temp files. No browser tabs. No scripts.</p><h3>Why I Prefer Doing This in Vim</h3><p>These aren’t “advanced Vim tricks”.</p><p>They’re just <strong>small, boring text operations</strong> — and that’s exactly why Vim is perfect for them.</p><ul><li>No context switching</li><li>No external tools (save jq)</li><li>No security risk from pasting secrets online</li><li>Works everywhere Vim works</li><li>Composes nicely with other edits</li></ul><p>For everyday developer tasks, Vim quietly replaces scripts, websites, and one-off utilities.</p><h3>Final thought</h3><p>If you already use Vim, you probably do some version of this already. If you don’t — this might be a good reason to start.</p><p>Because sometimes the fastest tool isn’t a script, a website, or an AI.</p><p>It’s just a good text editor.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71d4c9a2dbdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Bucket Theory]]></title>
            <link>https://medium.com/@suyash10581108/the-bucket-theory-ba883e595bd4?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba883e595bd4</guid>
            <category><![CDATA[mindfulness]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[brain]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[procrastination]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 08:06:59 GMT</pubDate>
            <atom:updated>2026-01-16T05:49:00.214Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Wasn’t Lazy. My Task System Was Leaking</h3><h4>The “Bucket Theory” that changed how I work, think, and rest.</h4><p>For a long time, I thought procrastination was a discipline problem.</p><p>That if I were more focused, more motivated, or simply better at managing my time, I’d finally reach my potential. I’m a software engineer. I’m doing relatively okay in life. From the outside, things look fine.</p><p>But internally, I always felt behind.</p><p>Not dramatically. Just enough to notice.</p><p>I had things I cared about. Goals I genuinely wanted to work on. Small responsibilities I kept postponing. And yet, most days ended with the same feeling: busy, tired, and strangely unsatisfied.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*QkjlRO8BDSDw3M2Ws443NQ.png" /></figure><h4>The kind of procrastination that’s hard to notice</h4><p>I’m not talking about doing nothing.</p><p>I’m talking about the kind where you <em>intend</em> to do things but never quite get to them.</p><p>Practice competitive coding.<br>Reply to that message.<br>Book an appointment.<br>Work on an idea you care about.</p><p>Each one is small. Together, they create mental noise.</p><p>And I noticed something while writing things down in my diary:</p><blockquote>What drains you isn’t the work.<br> It’s carrying unfinished promises in your head.</blockquote><h4>What’s really going on in the brain</h4><p>The brain is terrible at holding open loops.</p><p>Every “I should” stays active in the background:</p><ul><li>I need to do this</li><li>Don’t forget that</li><li>I’ll get to it later</li></ul><p>Individually harmless. Collectively exhausting.</p><p>So when you finally get free time, instead of acting, you freeze. Too many options. Too much emotional weight. You scroll. You distract yourself. You postpone.</p><p>Not because you’re lazy. Because your mind is overloaded.</p><h4>The change that actually helped me</h4><p>I didn’t fix this by becoming more disciplined.</p><p>I fixed it by <strong>changing where my promises and responsibilities live</strong>.</p><p>Instead of carrying everything in my head, I started putting all of it in one place. My diary stopped being a planner. It became a container.</p><p>That idea is what I now think of as:</p><h3>The Bucket</h3><h4>What the Bucket is (and isn’t)</h4><p>The Bucket isn’t a to-do list.</p><p>It’s where anything that creates mental tension goes:</p><ul><li>Something I need to do someday</li><li>Something I don’t want to forget</li><li>A goal that feels too big to start</li></ul><p>If it’s taking up space in my head, it goes in the Bucket.</p><blockquote>No deadlines. No pressure. Just capture.</blockquote><h4>Why this works</h4><p>The moment a responsibility leaves your brain and enters a trusted place, something changes.</p><p>The anxiety drops.<br> The mental noise quiets.</p><p>Your brain stops shouting “Don’t forget this” and starts asking a better question:</p><blockquote><em>What feels doable right now?</em></blockquote><p>That question is the difference between action and avoidance.</p><h4>Optionality beats motivation</h4><p>Most systems fail because they force urgency.</p><p>The Bucket doesn’t.</p><p>Some days I pick something small.<br>Some days I pick something meaningful.<br>Some days I pick nothing at all.</p><p>And somehow, progress still happens.</p><p>Big goals stop being intimidating when they sit next to small, ordinary things. They lose their weight. And that’s why they finally move.</p><h4>Where I am now</h4><p>I still get distracted. I still procrastinate sometimes.</p><p>But now:</p><ul><li>Responsibilities don’t haunt me</li><li>Free time doesn’t paralyze me</li><li>Progress happens quietly, without force</li></ul><p>I’m not at my full potential yet. But for the first time, I feel like I’m moving toward it — without constantly feeling behind.</p><h3>One thought to leave you with</h3><p>You don’t need more discipline.</p><p>You need somewhere safe for your responsibilities to rest.</p><p>For me, that started with a diary.<br> For you, it could be anything.</p><blockquote>Take it out of your head. Contain it. Choose when you’re ready.</blockquote><p>That’s the Bucket Theory.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba883e595bd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When AI Writes Your Code, It Also Writes Your Résumé]]></title>
            <link>https://medium.com/@suyash10581108/when-ai-writes-your-code-it-also-writes-your-r%C3%A9sum%C3%A9-18bd834b10d8?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/18bd834b10d8</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 21:52:19 GMT</pubDate>
            <atom:updated>2025-08-24T20:05:28.089Z</atom:updated>
            <content:encoded><![CDATA[<h4>Garbage In, Garbage Out: AI Edition</h4><p>There’s a funny thing about using AI to write code: it doesn’t just show whether you can get the syntax right. It shows how you think about designing systems. If you know what you’re doing, AI becomes a partner that accelerates clean abstractions, composable functions, and maintainable architecture. If you don’t – well, the result can be… enlightening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*OMhgu6G3Ur4WrldgKcmEaQ@2x.jpeg" /></figure><p>Recently, I stumbled across a piece of automation code written by a very senior engineer. And when I say “senior,” I mean by title, not by demonstration. We were running into failures fetching data from our primary database and therefore he decided to implement a call to a fallbackDB with alternating retries between the two. Here’s what it was supposed to do</p><ul><li>Take a given operation (a function).</li><li>Run it on the main database.</li><li>If it fails, retry on the fallback database.</li><li>Alternate between the two databases for a configured number of retries.</li></ul><p>Sounds straightforward enough, right? Except the final implementation was the kind of thing that makes you question how this person has ever emerged from a code review alive.</p><h3>Exhibit A: Function Names Out of a Hat</h3><p>The functions didn’t describe what they actually did. They didn’t even come close. You’d expect things like executeWithFallback or retryOperation . Instead, it looked more like someone mashed the keyboard and called it done. Single words, vague verbs, completely stripped of context. Nothing reveals engineering sloppiness faster than a refusal to name things clearly. If you can’t express intent in words, you almost certainly haven’t thought through the problem.</p><h3>Exhibit B: Nested Ifs That Go On Forever</h3><p>The automation flow was littered with conditional branches that could only be described as pathological. Every argument check was stuffed into the “main” executor function, stacked one on top of the other. The code didn’t read top-to-bottom – it read like trying to follow a hedge maze designed by someone who doesn’t believe in exits.</p><p>(And yes, in 2025 we do have AI-powered Copilot with refactoring tools that would untangle this mess in minutes. The fact that this was written by the same Copilot – says a lot.)</p><h3>Exhibit C: Hiding Logic Where It Doesn’t Belong</h3><p>The retry behavior, instead of being clearly expressed as its own component, was buried inside a general-purpose execute function. And this precious little gem took both the main DB and the fallback DB as arguments but hid the retry semantics inside. In other words, the call that looks simple on the surface is secretly performing control flow gymnastics you’d only discover by wading through the function body.</p><p>This isn’t clever abstraction. This is opaque indirection pretending to be design.</p><h3>What the AI Mirror shows You</h3><p>The beauty (and danger) of using AI in your workflow is that it tends to reflect your discipline back at you. If you know how to structure a problem, you’ll guide the tool toward producing predictable, elegant chunks of logic. If you don’t, the AI will gladly generate exactly what you asked for: spaghetti, indirection, cryptic names, and nested if-statements.</p><p>AI will not save you from bad engineering judgment. It will just make your bad engineering judgment arrive faster.</p><h3>The Takeaway</h3><p>Watching a “senior” engineer misuse both Go and AI in a single automation flow is a sobering reminder: experience isn’t measured in years, it’s measured in clarity. If your variable names are meaningless, your retries are hidden like Easter eggs, and your if-statements require a wall diagram to decipher… maybe just write code the normal way. Try to learn to do things in your own. And then use AI as a tool and not a crutch.</p><p>Because at the end of the day, using AI to code doesn’t hide how smart you are. It reveals it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18bd834b10d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Github copilot with NeoVim]]></title>
            <link>https://medium.com/@suyash10581108/setting-up-github-copilot-with-neovim-214edfa843bf?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/214edfa843bf</guid>
            <category><![CDATA[vim]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[neovim]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 21:40:48 GMT</pubDate>
            <atom:updated>2025-08-21T21:40:48.698Z</atom:updated>
            <content:encoded><![CDATA[<h4>Having an AI companion doing so much in your Stone Age reliable code editor.</h4><p>I have been using NeoVim as my daily driver IDE for Golang development for over an year now. And in that time I’ve learnt some things. But there was a new cool trend at my workplace that I was really lagging behind at. Everyone and their moms with VSCode had GitHub copilot integrated into their development environment and used it to quickly go through code and write code without switching windows. I, on the other hand, was the guy from the stone age. And I don’t care what you say, this looks pretty cool:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q12pnuz1VEH2Y4JbmBCt-A@2x.jpeg" /></figure><p>While I don’t mind not having some of the resources of other IDEs like integrated build system, and a DB viewer within the same screen. Instead it gives me pleasure when I see a colleague watch with his mouth hanging open as I navigate the code, making changes with Vim-speed. And personally I’m not a big fan of an LLM writing the code in the same space. But my seniors were looking in on my workflow and kept bugging me. Because apparently it takes me one hour to push a small feature instead of 5 min that it takes for the AI. I decided that i can’t sacrifice my workflow that I have set up so let us set up copilot with chat in NeoVim.</p><h3>Part I : Github Copilot Autocomplete</h3><p>If you like an AI coding alongside you giving helpful suggestions and generating entire functions just from the name, <a href="https://github.com/github/copilot.vim">copilot.vim</a> is the first plugin you need.</p><p>You can install it, either using vim-plug :</p><pre>github/copilot.vim</pre><p>Or manually, as I did for my Neovim on MacOS:</p><pre>git clone --depth=1 https://github.com/github/copilot.vim.git \<br>  ~/.config/nvim/pack/github/start/copilot.vim</pre><p>And then afterwards, to setup yourcopilot, just run the following command in your Neovim</p><pre>:Copilot setup</pre><p>Great!!! Now you’re all setup to have an AI companion that gives inline suggestions for your code and can be accepted with &lt;Tab&gt;.</p><p>But we don’t stop here.</p><h3>Part II : Copilot Chat</h3><p>So we brought copilot into our programming setup. But if we’ve done this much we might as well go all the way. I wanted to replicate the side-by-side code and chat experience that is present in IDEs like VSCode and IntelliJ. And guess what, I found an easy-to-use plugin. <a href="https://github.com/CopilotC-Nvim/CopilotChat.nvim">CopilotChat.nvim</a></p><p>You can install it using vim-plug as well:</p><pre>call plug#begin()<br>    Plug ‘nvim-lua/plenary.nvim’<br>    Plug ‘CopilotC-Nvim/CopilotChat.nvim’<br>call plug#end()<br><br>lua &lt;&lt; EOF<br>require(“CopilotChat”).setup()<br>EOF</pre><p>This can also use some optional plugins to support more functionality such as faster search and ui pickup.</p><p>In the meantime you can use <em>:CopilotChat </em>to start using Copilot chat side by side as you program. You can also use <em>#file:&lt;filename&gt;</em> to add a code file to the context. It comes with a bunch of pre-defined prompts.</p><p>And just say q to quit the chat windows.</p><p>I plan to customise my configuration even further and share those here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=214edfa843bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Real Dystopia Isn’t the Future — It’s Our Interpretation of It]]></title>
            <link>https://medium.com/@suyash10581108/brave-new-world-ee338d039263?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee338d039263</guid>
            <category><![CDATA[utopia]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[humanity]]></category>
            <category><![CDATA[happiness]]></category>
            <category><![CDATA[society]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Wed, 07 May 2025 03:46:52 GMT</pubDate>
            <atom:updated>2026-01-16T05:50:37.996Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why we see <em>Brave New World</em> as science fiction… and miss the warning.</h4><p>I just finished reading Aldous Huxley’s <strong>Brave New World </strong>and I have to say, after all the hype which lead me to this book, I felt disappointed in man’s absolute failure to predict what future holds for our species. Or maybe, the failure lies not in Huxley’s imagination or writing, but in our interpretation of what we read. I recall this line from an Emma Stone movie:</p><blockquote>The books you read in class always seem to have a strong connection with whatever angsty adolescent drama is being recounted.</blockquote><p>And I believe that humans have a deeper love for stories than we can understand ourselves. When we like a story, we use it as a frame through which our own life can be evaluated. There’s been an age old tradition to pass on the deepest of human values through stories, and for a good reason. Through the <em>margin of error </em>the story keeps on changing but the deep message always remains relevant to the current situation. What an invention stories are!</p><h3>A future of <em>soma</em></h3><p>Imagine the perfect drug. No bad hangover. No harmful effects on your body. And accidental overdose is almost entirely impossible. What more, no post usage guilt, no withdrawal symptoms, and no social consequences of using the drug. That is one of the cornerstones of Huxley’s new world.</p><p>Even though we do not know a detailed history of the world, we know that humans got tired of wars, strife and overall dissatisfaction, and thus, everything in this brave new existence is set up in a way so as to ensure perfect stability. I do not know how people felt about this existence when the book was originally published. But some aspects of such a content human life do not disgust or terrify now.</p><p>People are conditioned to strive for pleasure, through hypnosis. The society is setup in a way so as to discourage isolation and not allow discomfort to seep in. All physical maladies seem to have been solved. People are genetically engineered and conditioned instead of allowing to be born naturally. Sex is a social activity and ‘<em>Everyone belongs to Everyone’. </em>There’s no violence, assaults or terrorism, because those thoughts have been conditioned out of civilised human beings. Youth is maintained through treatments until it’s your time to die, and even death is not something to be afraid of because you have been conditioned since childhood to accept it as a fact and nothing more.</p><p>A taste of twisted socialism is found in this society where no individual is very important. Murder is less severe a crime than free thinking because while the former only harms one person, the latter threatens the stability of the society.</p><p>And finally if you have bad thoughts, grief, or anything that makes you feel different from what you’re conditioned to, just take half a gram of soma and go on a ride. And remember, there are no social consequences to doing so.</p><h3>A Utopian Hierarchy</h3><p>People are birthed (through well-engineered factory processes) into predestined categories. Ranging from Alpha to Epsilon. Everyone has a function and they have been trained to do that job only and conditioned to find pleasure in doing it. At first glance, this may seem like an oppressive class-system but other than having a pre-defined place in society and some level of deference to the higher classes, we do not see any measures of severe oppression or direct harm done by higher classes upon lower masses.</p><p>Everyone has a function and everyone’s job is important. Of course, those at higher levels enjoy more pleasures, more money and a certain degree of freedom in some choices but most of those choices are immaterial in that society.</p><p>The reason why I do not find it so repulsive because in our free world, no matter how we say that we’re all equal and we don’t impose any pre-destined class systems, hierarchies still exist. There are people who rule, and masses who are ruled. Rich enjoy a certain degree of freedom that poor cannot barter for even with their lives. And the oppression and harm done by the upper classes is much more real in our world.</p><h3>The Reservations</h3><p>Of course, not the entire world is civilised in this way. And those who could not be civilised in the brave new world, were enclosed in reservations and left to their own devices. We do not know if these people were somehow repressed or harmed, but they seemed to have lost even basic technologies which exist (or might have existed in the last century).</p><p>This is where my problems start. On one side is the new civilised society and on the other hand we have <strong>The Savage</strong> reservations. These people are more like tribes cut off from the real world and any human inventions after fire and language. It’s acceptable to consider that there’s parts of human species who would not accept to be a part of this world but these people seem to never have been given a choice. And at the same time, the way these people are so behind and resort to violence seems to be a separation of civilisation and uncultured within the author’s mind.</p><p>You can either be a part of fully civilised and stable human society, or you will be a savage living in huts, hunting big animals to prove your love and calling a woman who does not conform to your standards of modesty, a whore and whipping her.</p><p>At any rate, the author seems to paint this world in blacks and whites and neither of the groups seems to have any measure of free thinking allowed within their societies. UNREALISTIC</p><h3>The Thinkers</h3><p>Another dissatisfaction I had while reading this was the lack of free thinking on anyone’s part. We could see the hypnopaedic conditioning being triggered when thoughts of discontent creeped in but the incidents seem sparsed and seem far detached from our own observation of the human condition. In this setup, hypnosis and genetic engineering are mostly enough to get rid of anti-social elements and thoughts and when they’re not enough, a gram of soma keeps the doctor away.</p><p>But if you’re still a thinker, a free soul, and you can’t contain this anti-social behaviour, you will be sent to camps to recide with people like you. Or in the rare case, if you have all the right stars lined up, you’ll be asked to rule this world and maintain the very state of stability and unhappiness that your soul rebels against.</p><h3>Conclusion</h3><p>There are interesting thoughts and extrapolations posed by Huxley about the ultimate destination of the human condition. And small parts of it ring true to what we know and feel about our species. But I advise caution against trying to fit it too much to our current situation. Social media addiction in the youth is not soma. Our societal hierarchy of the free world is not an operational decision and our free thinkers are not a rare phenomena who are thrown out of the civilised world.</p><p>Unlike Mr Savage, we do not need to demand <em>the right to be unhappy</em>. It has been conferred to us by our birth, our society, and our gods.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee338d039263" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Go Deliberately Doesn’t Have Exceptions — And What I Learned From It]]></title>
            <link>https://medium.com/@suyash10581108/i-wish-we-had-exceptions-in-go-but-should-we-3b6b4eacf866?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b6b4eacf866</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[error]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Tue, 18 Feb 2025 21:20:18 GMT</pubDate>
            <atom:updated>2026-01-16T05:55:16.851Z</atom:updated>
            <content:encoded><![CDATA[<h4>More control, less magic — a perspective shift for serious programmers.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*WF-lXC2IpHL7uYKHy6JGjw.png" /></figure><p>Look at the following code from Journey — a blogging engine, and think on what you see:</p><pre>func UpdatePost(id int64, title []byte, markdown []byte, published bool) error {<br><br>  currentPost, err := RetrievePostById(id)<br>  if err != nil {<br>    return err<br>  }<br><br>  status := &quot;draft&quot;<br>  if published {<br>    status = &quot;published&quot;<br>  }<br><br>  writeDB, err := readDB.Begin()<br>  if err != nil {<br>    writeDB.Rollback()<br>    return err<br>  }<br><br>  // If the updated post is published for the first time, add publication date and user<br>  if published &amp;&amp; !currentPost.IsPublished {<br>    _, err = writeDB.Exec(stmtUpdatePostPublished, title, markdown, status, id)<br>  } else {<br>    _, err = writeDB.Exec(stmtUpdatePost, title, markdown, status, id)<br>  }<br>  if err != nil {<br>    writeDB.Rollback()<br>    return err<br>  }<br><br>  return writeDB.Commit()<br>}</pre><p>After writing every useful line of code that actually gets something done, we put in a line handling the error. As a traditionally Java developer, this annoyed me to no end. If this was Java, I would just allow the method to throw the exception and let the caller handle it as needed.</p><p>One of the great advantages of the way Java does exceptions is that they can be handled at the appropriate place in the code where they should be (as decided by the programmer) and the programmer doesn’t need to write extra code to make sure the exceptions reach the handling code. But if you want to handle an error in go, you have to write an if block to ensure that your handling code is executed in case something goes wrong. Isn’t that just moving backwards???</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FVYyjTkQfZdwI3r54la%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FVYyjTkQfZdwI3r54la%2Fgiphy.gif%3Fcid%3D790b7611bgic2x5p0c4ddwn0etcrlnfauex3lnp4gkpowvl5%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExeWtyeTM0Y2c4aXVicTRhM2N4bzBucThuamlzczE1MjMwYnhjend0byZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FVYyjTkQfZdwI3r54la%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/f000dd5af4fefeafc74dedeee39987ca/href">https://medium.com/media/f000dd5af4fefeafc74dedeee39987ca/href</a></iframe><h3>And then it hit me…</h3><p>There can be more than just one way to achieve a goal. You can do something entirely different and still reach the same end result. The world is just weird like that.</p><p>And what Go is trying to say is…</p><p><em>Dear Programmer, when you write a piece of code, or a function, a lot of things may happen and do happen when that code is run. In fact, among all the situations that may arise, more of those are unexpected ones. Remember, there’s only one good execution path and so many more edge cases, unexpected errors, misconfigurations, unplanned usage, and so on. So I’ll provide you as many number of ways to handle those unexpected things (which happened through no fault of yours).</em></p><p>But wait, all Go provides is one error type. If anything, it contains less information than the main return value. But maybe if we renamed it to <strong>status</strong>. This new status type lets you know all the information you need to know about what happened when you called a function. And if this status is OK (err == nil), then all is good, and you can read the expected result from other returned values.</p><h3>Types of errors</h3><p>Let’s look at a broad typology of errors that can help you handle and create your own errors with more confidence.</p><h4>Typeless / Valueless errors</h4><p>These are the type of errors which are more generic and are predefined in the system. They don’t need any extra structured information to tell the user what happened. Or maybe the user just doesn’t need to know. Think of the following:</p><pre>return fmt.Errorf(&quot;Your file seems to be corrupted: %s&quot;, filename)</pre><p>These are best used when you know that there’s a situation which your code cannot handle by itself and therefore, there’s no point of providing too much information to the calling function. This is a case where you don’t want to crash the program, but you know that there might not be a good way for the code to automatically recover. So this allows the program to fail and prompts manual intervention for closer investigation. This is also useful when there’s an obvious underlying reason that can be easily fixed by human intervention.</p><h4>Sentinel Values as errors</h4><p>These are not real errors in the sense that these are not unexpected. These are control values that can be used to terminate a loop or a sequence of operations. Recall the null character appended to the end of string in C, well that’s what these are, essentially.</p><pre>for() {<br>  n, err := file.Read(data)<br>  if err == io.EOF {<br>    break<br>  }<br>}</pre><p>Nothing went wrong, you just reached the end of file. Which has to be expected. It’s more of a signal that something significant has happened and must be handled appropriately. <strong>io.EOF</strong> is a very good example of where errors are not actually a bad thing. In fact they’re just an overarching signalling tool with an unfortunate name.</p><h4>Structured Errors</h4><p>Remember that error type is an interface in Go, and users are highly encouraged to implement their own types using structs. This is the real purpose of go errors, passing more information about what happened during the code execution. For instance,</p><pre>type AppError struct {<br>  Code    int    `json:&quot;code&quot;`    // Error code<br>  Message string `json:&quot;message&quot;` // User-friendly error message<br>  Details string `json:&quot;details,omitempty&quot;` // Optional for debugging<br>}<br><br>// Implement the error interface for AppError<br>func (e *AppError) Error() string {<br>        return fmt.Sprintf(&quot;AppError: %d - %s&quot;, e.Code, e.Message)<br>}</pre><p>Well now you can signal so much more inforamtion to the caller function (and to the rest of the code) about what went on with the code execution — good or bad or worse :)</p><p>I wanna talk more about these but not right now.</p><h4>Wrapped errors</h4><p>If you’ve used Java exceptions, you must be familiar with embedding the cause in the main exception. If the user wants more debugging information or if the code can maybe solve some of those causes automatically, maybe it’s useful to embed that cause error within the main error.</p><pre>type FileError struct {<br>    Op  string<br>    Path string<br>    Err error // The cause <br>}<br><br>func (e *FileError) Error() string {<br>    return fmt.Sprintf(&quot;%s %s: %v&quot;, e.Op, e.Path, e.Err)<br>}</pre><p>The code is actually a good example. There are so many things that can go wrong while reading a file. You want your higher level code to know that it was the file-reading step that went wrong. But maybe there are some underlying causes which your code can handle, e.g., maybe it’s capable of triggering another process which can put the file there and it can retry the read.</p><h3>Footnote — Back to C</h3><p>If you spend some time with go, you’d notice how there are underlying similarities with C (except for the more overt ones). Remember the following system call:</p><pre>int create(char *filename, mode_t mode);</pre><p>This would create an empty file, returning a file descriptor. But if something went wrong, it would just return -1. And that’s all the information one would have.</p><p>Now think of Go errors as more elaborate, and more structured way of doing the same thing. And you don’t need to pass pointers in to gain more information out of the function.</p><h3><strong>References</strong></h3><ul><li><a href="https://github.com/kabukky/journey/blob/master/database/update.go">https://github.com/kabukky/journey/blob/master/database/update.go</a></li><li><a href="https://go.dev/blog/error-handling-and-go">https://go.dev/blog/error-handling-and-go</a></li><li><a href="https://www.geeksforgeeks.org/input-output-system-calls-c-create-open-close-read-write/">https://www.geeksforgeeks.org/input-output-system-calls-c-create-open-close-read-write/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b6b4eacf866" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What If Numbers Don’t Exist — But We Act Like They Do?]]></title>
            <link>https://medium.com/@suyash10581108/lets-think-about-numbers-387e8c9f931a?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/387e8c9f931a</guid>
            <category><![CDATA[zero]]></category>
            <category><![CDATA[questions]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[numbers]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Tue, 18 Feb 2025 06:03:09 GMT</pubDate>
            <atom:updated>2026-01-16T05:53:30.220Z</atom:updated>
            <content:encoded><![CDATA[<h4>Zero, imaginary quantities, and the hidden assumptions in how we count reality.</h4><p>Earlier this evening, I was watching an episode of Young Sheldon where our eponymous protagonist and two of his senior colleagues were beating themselves up saying “<strong>Zero Doesn’t Exist</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*N6VSZHLmZDuq1W4cjeOsoA.png" /></figure><p>So, are they right? I mean, of course zero is a number like no other. But does that mean that it’s nothing. I’m sure you have either thought of these questions yourselves, or have heard kids ask them. And as is the norm, all adults have ignored these questions. But maybe it’s time to think about numbers.</p><h3>So, what are numbers?</h3><p>Let me say this right out before we start. None of the numbers are real, at least not in any tangible sense. You cannot hold a number in hand, you cannot perceive it with any of your five senses. All of mathematics is created to serve a fundamental need to understand our world and make predictions about it. And numbers are one of the first tools that we learn to use in this noble quest to understand nature. However, most of us never stop and think about this and therefore, when someone says, zero is nothing, we stop and think <em>Hmmmm.</em></p><p>And that is why we have people in our world who come up with ideas like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xRNsS23C1Yo7Tf55-ihAHA.png" /></figure><p>And in our attention economy, you know that even this guy can turn heads. But I think it’s the responsibility of all the reasonable adults out there to make sure that our kids get actual answers to their questions, so we don’t see more of these. With that, let’s let our thought ponder the realm of numbers.</p><h3>Natural Numbers</h3><p>These are the numbers we all start with, when we start to count. 1 sheep, 2 sheep, 3 sheep… These are the numbers we believe even the ancienct civilizations understood. And they were helpful in their day to day lives. To them, and to us, these numbers are just a way to represent a count of things around us, and operations such as addition and subtraction help us represent day-to-day give and take of those items. Note, that this is the reason why roman numerals start from <strong><em>I</em></strong> (one) and all they have are natural numbers. And for them that was enough.</p><p>These numbers are an easy way to tell our fellow caveman, how many animals we hunted today, or how many people are there in our tribe, or how many were killed in the last bear attack (<em>subtraction would tell you how many survived</em>). OK, that’s all well and good. But that sounds like natural numbers should be enough. Why aren’t they???</p><h3>Whole Numbers</h3><p>So, we can represent the count of oranges I have using our numbers (also called natural numbers). And if I give my oranges to someone or get more oranges, my numbers should be able to count that as well. Well, what if I gave away all my oranges. How many oranges do I have left???</p><p>Damn!!! It seems like we don’t know how to represent this count. But this seems like a very unique situation. Certainly not like other times when I actually had oranges. So maybe we can assign a new number to represent my situation. Let’s call it <a href="https://www.scientificamerican.com/article/what-is-the-origin-of-zer/"><strong>zero</strong></a>. But hey, that seems weird, if I have no oranges, then how can there be a number representing my oranges.</p><p>And that is why zero is unique. It’s nothing like the (natural) numbers we previously encountered. But it works well with them as far as our day to day transactions are concerned (using <em>plus</em> and <em>minus</em>). Well it doesn’ work so well with multiplication and division, but let’s not think of that just yet.</p><p>First let’s address another issue. What happens if I cut an orange and give you a few slices!!!</p><h3>Fractions and Decimals</h3><p>So if you give a kid something called a whole number, the first thing their mischeivous mind would come up with — why is it whole? I agree, let’s cut up that pizza into slices. Say you &amp; I bought a small pizza, cut it into four. Now we wanna eat equally, so we each get two slices. But how many pizza did each of us get? The numbers we have been discussing till now are not gonna be helpful to represent this count.</p><p>So how about this? Each of us got two out of fourth of a pizza. Let’s somehow use that information to represent how much pizza we ate. Let’s just put together those two numbers and voila — <strong>2/4</strong>. This is a fraction. What if we had divided our pizza into six slices and each had three. Well then I would have eaten <strong>3/6</strong> of the pizza. Or what if I just divided into two and had one — <strong>1/2 </strong>of the pizza. In each of these cases even though the numbers themselves look different, actually I ate the same amount of pizza. So you would say, that means that all of these fractions, <strong>2/4</strong>, <strong>3/6</strong> and <strong>1/2 </strong>should be equal. And you’re absolutely right. They’re exactly the same number, but we can represent it in different ways.</p><p>Another way of represent the same number is using decimals. Put a dot (<strong>.</strong>) and whatever number you put after it actually means… well let me just show it to you with examples. If you put <strong>.5 </strong>it means <strong>5/10</strong>. If you put 79 after the dot, i.e., <strong>.79</strong>, that is the same as <strong>79/100</strong> and if you put <strong>.00001, </strong>that’s just 00001/100000, or 1/100000. You got it right?</p><p>Another note —</p><p>What if after eating that <strong>2/4 </strong>of the pizza, I was still hungry, I ordered another pizza and ate that <strong>whole </strong>pizza by myself. Now how would I represent that using numbers. I just put the <strong>whole </strong>number as it is followed by the fraction or the decimal representing the rest of the pizza I ate. This is <strong>1 </strong>followed by <strong>2/4. </strong>This is the same as 1 1/2 or 1 5/10. This is also the same as <strong>1.5</strong></p><h3>Conclusion</h3><p>No conclusion yet. We’ll talk about negative numbers and so much more in the next part.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=387e8c9f931a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AsyncTask V2 — Doing asynchronous work in Android / Java with Executor Service]]></title>
            <link>https://medium.com/@suyash10581108/asynctask-v2-doing-asynchronous-work-in-android-java-with-executor-service-497145bc4e82?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/497145bc4e82</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Wed, 02 Oct 2024 06:19:09 GMT</pubDate>
            <atom:updated>2024-10-02T06:19:09.071Z</atom:updated>
            <content:encoded><![CDATA[<h3>AsyncTask V2 — Doing asynchronous work in Android / Java with Executor Service</h3><h4>AsyncTask is deprecated! Here’s an easy-to-use simple alternative abstraction.</h4><p>I learnt Android application development ages ago. Back in the days when AsyncTask was a great abstraction to take my headache away when it came to executing long-running tasks like network calls or database writes. All I had to do was extend the class and do what I needed to do in a background thread while ensuring that progress updates, pre-job tasks and post-execution work can be executed on the main thread (letting the user know about the status or failure).</p><p>It made for a clean way to handle long-running tasks while making sure your UI is responsive, both to the user’s input as well as the job in the background thread. But then they unalived <a href="https://developer.android.com/reference/android/os/AsyncTask">AsyncTask</a>!!!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FnrNqeGB1sxlZe%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FnrNqeGB1sxlZe%2Fgiphy.gif%3Fcid%3D790b7611r69tebezf07iwxr3v0z6xofmbf6ktythglw90l5a%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExY2MzMTljeWQ0ZHk1am12ejB3amM4ZDlud2d3ZzRuMTRiNTF1cTlkciZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FnrNqeGB1sxlZe%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddc21c362a4324e1b302bf955eb37e06/href">https://medium.com/media/ddc21c362a4324e1b302bf955eb37e06/href</a></iframe><p>So, what now!!!</p><h3>What’s the alternative?</h3><p>Well, as per the official documentation:</p><blockquote><strong>This class was deprecated in API level 30.</strong><br>Use the standard <strong>java.util.concurrent</strong> or <a href="https://developer.android.com/topic/libraries/architecture/coroutines">Kotlin concurrency utilities</a> instead.</blockquote><p>But, I didn’t want to use Kotlin just yet.</p><p>I know! I know! It’s the better alternative. But it’s one that I can’t find the time to learn. I already know Java and I know how to build Android apps in that. And I don’t have the time to switch. So, I guess I’ll be using the <strong>concurrent </strong>package.</p><h3>The problem</h3><p>Well I don’t know anything about using the <strong>concurrent </strong>package. And for all my internet searches, I never came upon anything that can be a simple plug and play.</p><p>Moving from a simple to use tool to something exponentially more complex with no guidebook is kind of hard to do. Specially if you don’t have the time to figure out everything.</p><h3>The solution</h3><p>Not much to explain. Here’s an abstract class that you can copy and paste into your codebase as-is. Create a new file <em>AsyncExecTask.java</em></p><pre>import android.os.Handler;<br>import android.os.Looper;<br>import android.util.Log;<br><br>import androidx.annotation.AnyThread;<br>import androidx.annotation.MainThread;<br>import androidx.annotation.Nullable;<br>import androidx.annotation.WorkerThread;<br><br>import java.util.concurrent.Callable;<br>import java.util.concurrent.ExecutionException;<br>import java.util.concurrent.ExecutorService;<br>import java.util.concurrent.Executors;<br>import java.util.concurrent.Future;<br>import java.util.concurrent.atomic.AtomicBoolean;<br><br>public abstract class AsyncExecTask&lt;Params, Progress, Result&gt;{<br><br>    public enum Status {<br>        PENDING,<br>        RUNNING,<br>        FINISHED<br>    }<br><br>    private final String TAG = &quot;AsyncExecTask&quot;;<br><br>    private final Handler mainHandler = new Handler(Looper.getMainLooper());<br>    private final AtomicBoolean cancelled = new AtomicBoolean(false);<br><br>    private Result result;<br>    private Future&lt;Result&gt; future;<br>    private ExecutorService executorService;<br>    private Status status = Status.PENDING;<br><br>    private void setStatus(Status status) {<br>        this.status = status;<br>    }<br><br>    private void initializeExecutor() {<br>        executorService = Executors.newSingleThreadExecutor();<br>    }<br><br>    protected abstract Result doInBackground(Params params);<br><br>    protected void onPreExecute() {}<br><br>    protected void onPostExecute(Result result) {}<br><br>    protected void onProgressUpdate(Progress progress) {}<br><br>    protected void onCancelled() {}<br><br>    protected void onCancelled(Result result) {<br>        this.onCancelled();<br>    }<br><br>    protected boolean isShutdown() {<br>        return this.executorService.isShutdown();<br>    }<br><br>    @MainThread<br>    public final Future&lt;Result&gt; execute(@Nullable Params params) {<br><br>        setStatus(Status.RUNNING);<br><br>        this.initializeExecutor();<br><br>        // run the pre-execute stuff<br>        onPreExecute();<br><br>        try {<br>            Callable&lt;Result&gt; backgroundCallable = () -&gt; doInBackground(params);<br>            this.future = executorService.submit(backgroundCallable);<br><br>            // pass the getResult function to return the result after completion<br>            executorService.submit(this.getResult());<br>            return future;<br>        } finally {<br>            if (executorService != null) {<br>                executorService.shutdown();<br>            }<br>        }<br>    }<br><br>    @WorkerThread<br>    public final void publishProgress(Progress progress) {<br>        if (!isCancelled()) {<br>            mainHandler.post(() -&gt; onProgressUpdate(progress));<br>        }<br>    }<br><br>    @MainThread<br>    public final void cancel(boolean interruptRunning) {<br>        cancelled.set(true);<br>        if (future != null) {<br>            future.cancel(interruptRunning);<br>        }<br>    }<br><br>    @AnyThread<br>    public final boolean isCancelled() {<br>        return this.cancelled.get();<br>    }<br><br>    @AnyThread<br>    public final Status getStatus() {<br>        return this.status;<br>    }<br><br>    private Runnable getResult() {<br>        return () -&gt; {<br>            try {<br>                if (!isCancelled()) {<br>                    result = future.get();<br>                    mainHandler.post(() -&gt; onPostExecute(result));<br>                } else {<br>                    mainHandler.post(this::onCancelled);<br>                }<br><br>                // update the task status as finished<br>                setStatus(Status.FINISHED);<br><br>            } catch (InterruptedException | ExecutionException e) {<br>                Log.e(TAG, &quot;Exception occurred while trying to get result&quot;, e);<br>            }<br>        };<br>    }<br>}</pre><h3>Usage</h3><p>Now that, you have created a new class, all you have to do is extend it, with appropriate types for input, progress parameters and the output. The only method that you <em>have to</em> override for this class is doInBackground() . This contains the code for the long-running work you have to do.</p><p>Optionally you can choose to override one or more of onPreExecute() , onPostExecute() , onProgressUpdate() , onCancelled() and onCancelled(Result) . You can use these functions to do something in the UI thread.</p><p>Here’s an example implementation. Make sure to go through it.</p><p>Believe me, it’s much faster than the alternative</p><pre>AsyncExecTask&lt;Integer, Double, Pair&lt;Integer, Double&gt;&gt; testTask = new AsyncExecTask&lt;Integer, Double, Pair&lt;Integer, Double&gt;&gt;() {<br><br>    @Override<br>    protected void onPreExecute() {<br>        Toast.makeText(getContext(), &quot;Before executing task&quot;, Toast.LENGTH_SHORT).show();<br>        super.onPreExecute();<br>    }<br><br>    @Override<br>    protected void onPostExecute(Pair&lt;Integer, Double&gt; integerDoublePair) {<br>        Toast.makeText(getContext(), &quot;After executing task&quot;, Toast.LENGTH_SHORT).show();<br>        super.onPostExecute(integerDoublePair);<br>    }<br><br>    @Override<br>    protected void onProgressUpdate(Double progress) {<br>        Toast.makeText(getContext(), &quot;Task progress: &quot; + progress + &quot;%&quot;, Toast.LENGTH_SHORT).show();<br>        super.onProgressUpdate(progress);<br>    }<br><br>    @Override<br>    protected void onCancelled() {<br>        Toast.makeText(getContext(), &quot;The task was cancelled&quot;, Toast.LENGTH_SHORT).show();<br>        super.onCancelled();<br>    }<br><br>    @Override<br>    protected Pair&lt;Integer, Double&gt; doInBackground(Integer i) {<br>        Pair&lt;Integer, Double&gt; result = new Pair&lt;&gt;(3, 100.0);<br>        try {<br>            Thread.sleep(4000);<br>            publishProgress(25.0);<br>            Thread.sleep(5000);<br>            publishProgress(60.0);<br>            Thread.sleep(7500);<br>            publishProgress(100.0);<br>        } catch (InterruptedException e) {<br>            Log.e(&quot;TestActivity&quot;, &quot;There was an error executing the background task&quot;, e);<br>        }<br><br>        return result;<br>    }<br>};<br>testTask.execute(0);</pre><h3>References</h3><ol><li><a href="https://developer.android.com/reference/android/os/AsyncTask"><em>https://developer.android.com/reference/android/os/AsyncTask</em></a></li><li><a href="https://www.baeldung.com/java-executor-service-tutorial"><em>https://www.baeldung.com/java-executor-service-tutorial</em></a></li><li><a href="https://stackoverflow.com/questions/76284612/how-to-set-progress-of-progressbar-in-executorservice-dont-want-to-use-asyncta"><em>https://stackoverflow.com/questions/76284612/how-to-set-progress-of-progressbar-in-executorservice-dont-want-to-use-asyncta</em></a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=497145bc4e82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go(lang) debugging simplified in Neovim – with Delve and DAP]]></title>
            <link>https://medium.com/@suyash10581108/go-lang-debugging-simplified-in-neovim-with-delve-and-dap-760bb950305d?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/760bb950305d</guid>
            <category><![CDATA[minimalism]]></category>
            <category><![CDATA[vim]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[neovim]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Fri, 14 Jun 2024 03:22:46 GMT</pubDate>
            <atom:updated>2024-10-01T06:49:34.207Z</atom:updated>
            <content:encoded><![CDATA[<h4>Debug Go(lang) within Neovim like a pro. IDE experience combined with Vim minimalism</h4><p>In my journey of using vim(or nvim) as my code editor of choice, both at home and at work, the biggest problem I’ve come across is lack of a good debugging integration(plugin). And mind you, I say code editor, and not IDE only so that I don’t offend anyone. Because while I do admit that modern IDEs are just so pumped with features that they do make dev experience that much more comfortable for most everyone. At the same time, I believe that vim can do almost all of those features with potential to do even more. The only reason it’s not doing better than everything else out there is because there’s not enough money in it. But</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*1Bl74L1kf1EmeQnDQUap9w.gif" /></figure><h3>The Problem</h3><p>With Go being one of the fastest growing programming languages, it’s one of the most supported ones out there. And I love Vim, so I’ve created my own little setup [<a href="https://medium.com/@suyash10581108/my-neovim-go-lang-setup-as-good-as-intellj-goland-ide-d48dd765f6de">Link here</a>]. I’ve been using this at work too. Now for the most part, I make do without a debugger(I know, I am not the best programmer). But sometimes, going the roundabout way is just that much more expensive. So I gave <a href="https://github.com/go-delve/delve">Delve</a> a try.</p><p>And I was so surprised by just how fast I was breezing through bugs. If you’ve read my previous post <a href="https://medium.com/@suyash10581108/my-neovim-go-lang-setup-as-good-as-intellj-goland-ide-d48dd765f6de">(Link here)</a> then you might know that I have been using vim-go that is supposed to have debug support using delve. And sometimes it works, for small codebases maybe. But no matter what I did, I could not get it working for a large codebase, on latest versions of everything. Vim kept getting stuck where I just had to force quit everything.</p><h3>The Solution</h3><p>While searching for a solution, I came across DAP — <a href="https://microsoft.github.io/debug-adapter-protocol/">Debug Adapter Protocol</a> by Microsoft. This allows client-server communication where the client can be an IDE/editor and the server is your debugger. Delve supports this, and from there it was just a matter of finding an appropriate client in neovim and a set of good configurations. Best case, I’d also like to add some kind of minimalistic UI within Neovim.</p><p>So let’s see now how we can do this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*v8YeVZdr3A3n9-X-qMPhVw.gif" /></figure><h3>Install a Debugger — Delve</h3><p>The first step, of course, is to install a Go debugger on your system. We’re choosing to go with <a href="https://github.com/go-delve/delve">Delve</a>. It’s easy to get started with, fast and surprisingly easy to connect with DAP. Plus, even if you’re not using Vim (or Neovim), it integrates with other IDEs and can be used conveniently from just your terminal.</p><p>For most OS, it’s recommended to follow the general installation guide <a href="https://github.com/go-delve/delve/tree/master/Documentation/installation">here</a>. But I’ll add the steps here anyways (with special considerations for MAC):</p><h4>MacOS</h4><p>If you haven’t enabled developer mode, or don’t know what this is, then follow these steps:</p><pre>xcode-select --install</pre><pre>sudo /usr/sbin/DevToolsSecurity -enable</pre><pre>sudo dscl . append /Groups/_developer GroupMembership $(whoami)</pre><p>Finally just use <a href="https://brew.sh/">brew</a>.</p><pre>brew install delve</pre><h4>For all other OSes(Windows &amp; Linux)</h4><p>Either build from source</p><pre>git clone https://github.com/go-delve/delve<br>cd delve<br>go install github.com/go-delve/delve/cmd/dlv</pre><p>Or install with <strong>go install</strong></p><pre># Install the latest release:<br>go install github.com/go-delve/delve/cmd/dlv@latest<br><br># Install at tree head:<br>go install github.com/go-delve/delve/cmd/dlv@master<br><br># Install at a specific version or pseudo-version:<br>go install github.com/go-delve/delve/cmd/dlv@v1.7.3<br>go install github.com/go-delve/delve/cmd/dlv@v1.7.4-0.20211208103735-<br>2f13672765fe</pre><blockquote>If you face any issues with the installation, please refer to the general installation guide. <a href="https://github.com/go-delve/delve/tree/master/Documentation/installation">Link</a></blockquote><blockquote>Also, you’ll need to have go installed before you install delve. Duh!</blockquote><h3>Neovim DAP client</h3><p>Delve comes with its own DAP server built in. Now we need to connect our nvim to that using a DAP client plugin. That is going to be <a href="https://github.com/mfussenegger/nvim-dap">Nvim DAP</a>. Add the following to your vim-plug section.</p><pre>Plug &#39;mfussenegger/nvim-dap&#39;</pre><h3>Neovim DAP configuration</h3><p>We need to configure our nvim-dap to work for our go code and dlv server. But instead of doing it manually, there’s a much easier way to do it: we’ll use the <a href="https://github.com/leoluz/nvim-dap-go">nvim-dap-go</a> plugin. Just install it and go.</p><p>Inside your vim-plug section, add:</p><pre>Plug &#39;leoluz/nvim-dap-go&#39;</pre><p>and then:</p><pre>lua require(&#39;dap-go&#39;).setup()</pre><h3>Making it look good</h3><p>So, that’s all there is to running a bare-bones Go debugging setup that lets you run your tests and debug them from within your favorite code editor. But the sugar on the icing, we want to make it look amazing, giving you the promised IDE Experience. To start with this, include the following in your vim-plug section:</p><pre>Plug &#39;nvim-neotest/nvim-nio&#39;<br>Plug &#39;rcarriga/nvim-dap-ui&#39;</pre><h4>Some more configuration</h4><p>Let’s create a new Lua file —<em> myconfig.lua</em> and add it in the same directory as your <em>init.vim</em> under a <em>lua </em>directory.</p><pre>local dap, dapui = require(&#39;dap&#39;), require(&#39;dapui&#39;)<br>local dapgo = require(&#39;dap-go&#39;)<br>dapui.setup()<br>dapgo.setup()<br>dap.listeners.before.attach.dapui_config = function()<br> dapui.open()<br>end<br>dap.listeners.before.launch.dapui_config = function()<br> dapui.open()<br>end<br><br><br>-- Include the next few lines until the comment only if you feel you need it<br>dap.listeners.before.event_terminated.dapui_config = function()<br> dapui.close()<br>end<br>dap.listeners.before.event_exited.dapui_config = function()<br> dapui.close()<br>end<br>-- Include everything after this<br><br><br>vim.keymap.set(&#39;n&#39;, &#39;&lt;F5&gt;&#39;, function() require(&#39;dap&#39;).continue() end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;F10&gt;&#39;, function() require(&#39;dap&#39;).step_over() end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;F11&gt;&#39;, function() require(&#39;dap&#39;).step_into() end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;F12&gt;&#39;, function() require(&#39;dap&#39;).step_out() end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;Leader&gt;q&#39;, function()<br>require(&#39;dap&#39;).toggle_breakpoint() end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;Leader&gt;Q&#39;, function() require(&#39;dap&#39;).set_breakpoint()<br>end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;Leader&gt;lp&#39;, function()<br>require(&#39;dap&#39;).set_breakpoint(nil, nil, vim.fn.input(&#39;Log point message: &#39;))<br>end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;Leader&gt;dr&#39;, function() require(&#39;dap&#39;).repl.open() end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;Leader&gt;dl&#39;, function() require(&#39;dap&#39;).run_last() end)<br><br>vim.keymap.set(&#39;n&#39;, &#39;&lt;Leader&gt;w&#39;, function() dapui.open() end)<br>vim.keymap.set(&#39;n&#39;, &#39;&lt;Leader&gt;W&#39;, function() dapui.close() end)</pre><p>Now we can require this file in our <em>init.vim</em> by adding the following line:</p><pre>lua require(&#39;myconfig&#39;)</pre><p>And that’s it folks, we’re done.</p><blockquote>You can refer to the above Lua file to understand some good debugging shortcut keys.</blockquote><h3>Final thoughts</h3><p>DAP is a powerful tool that can go beyond what I’ve shown above. For example, it provides you a REPL console to freely interact with your debugger, which gives you the freedom to execute and evaluate on the go. Not only that, it allows you to define custom mappings as per your convenience. An example of such mappings is given below. You can create this as a Lua file using the method previously described.</p><pre>local repl = require &#39;dap.repl&#39;<br>repl.commands = vim.tbl_extend(&#39;force&#39;, repl.commands, {<br> <br>  -- Add a new alias for existing commands<br>  exit = {&#39;exit&#39;, &#39;.exit&#39;},<br>  <br>  -- Add new commands<br>  custom_commands = {<br>    [&#39;.print&#39;] = function(v)<br>      repl.execute(v)<br>    end,<br>  },<br>})</pre><p>For more details, I highly recommend that you refer to the <a href="https://github.com/mfussenegger/nvim-dap/blob/master/doc/dap.txt">Documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=760bb950305d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amnesia Test — The Turing Test of existence of Free Will]]></title>
            <link>https://medium.com/@suyash10581108/amnesia-test-the-turing-test-of-existence-of-free-will-d9fee36e1459?source=rss-95a2ee4e6c61------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9fee36e1459</guid>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[supernatural]]></category>
            <category><![CDATA[choices]]></category>
            <category><![CDATA[free-will]]></category>
            <category><![CDATA[free-will-choice]]></category>
            <dc:creator><![CDATA[Suyash Raj]]></dc:creator>
            <pubDate>Wed, 05 Jun 2024 06:36:48 GMT</pubDate>
            <atom:updated>2026-01-16T05:59:25.260Z</atom:updated>
            <content:encoded><![CDATA[<h3>What If Free Will Fails the Turing-Style Test?</h3><h4>A mental experiment that reframes age-old philosophical debate into a single question</h4><p>I love Supernatural! I keep watching it on repeat in the background while I do other tasks. That is, when I’m not actually just watching the show. Recently, during one of those times, I was going through this episode called “Regarding Dean” where our favorite supernatural cowboy is caught in a spell and starts losing more and more of his memories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*q0cPlWSPm3r5eba88qDoEQ.gif" /></figure><p>At one point, Sam and he walk into the office of a missing guy and start to look around. Dean finds a box of cigars, takes one and proclaims it as ‘Douche Tax’. Sam responds by saying that he did the exact same thing yesterday.</p><p>Now, this makes me think. Did Dean have a choice to not pick up that cigar in the first place? If you were to erase the memory &amp; experience of a man making a decision, and then put him in similar circumstances as the original choice, can he make a different one?</p><h3>Free Will through the ages</h3><p>Countless philosophers, scientists and thinkers through the ages have tried to come up with an answer to this question: ‘Does true free will exist in human world’. But before we go more into the history, let’s define free will more formally. To paraphrase <em>The Stanford Encyclopedia of Philosophy:</em></p><p><em>Free will is a philosophical term for the capacity of rational agents to choose a course of action from among various alternatives.</em></p><p>The definition itself, seems simple enough. Not only that, we humans have evolved to understand the world around us with reason. Our instincts tell us that every effect comes from a cause and therefore, no action or decision can have arbitrary choice leading to it, in addition to other deterministic causes. So far, the natural laws of the universe, understood through mathematics and physics, seem to agree with this basic instinct. Then why has this debate not already been settled. What is it that drives the opponents of <strong>causal determinism </strong>to argue against so much seemingly consistent evidence?</p><h3>The moral responsibility of free will</h3><p>I choose to believe that proponents of free will (which, to some extent, is each and every one of us) want to place blame on others for bad things <em>that happen</em> and earn praise for the good things <em>that</em> <em>we do. </em>In addition to this personal bias, free will is also very useful as a social concept. We punish criminals because we say that they can be held responsible for their actions. Similarly, our society tends to reward moral actions with praise and awards.</p><p>This has important consequences; by associating people’s actions and treating them as free agents, our societal structure encourages actions which contribute to the betterment of the individual, the family, the society and the human race, while deterring actions which can cause us harm. At an individual level, these emotions of receiving blame or praise, dispose us to act in a variety of ways.</p><h3>The Problem</h3><p>Let’s do a thought experiment. Think of the last time you had to make a big decision or a choice. Something that makes you feel, “What if I chose the other option?” Really focus on the choice, and then answer this question — ‘Could you have chosen differently given those exact circumstances, you being the exact person you were back then!’</p><p>Humans can be the agents of free will only if they can choose differently. That is, given the circumstances of the world around and within them at any moment, they have an equal opportunity to make a free choice. Sadly, we have not been able to prove the existence or absence of this choice. You can never know the answer to that question, because it’s impossible to recreate those exact circumstances. Or maybe there is! At least as a thought.</p><h3>The Solution</h3><p>So, can we come up with a simple setup and a question, that when answered, will tell us with absolute certainty if free will exists. And note that here, free will simply means the freedom to make a choice given a set of precisely defined circumstances.</p><p><em>Let’s try to be just a tad more formal!</em></p><p>Given, a person has a made a decision in a given set of precisely defined external and internal circumstances. If that person loses all memories of everything that happened after the decision, and we put them back in a situation that is similar enough to the original one such as not to affect the eventual decision, what is the probability (chances) that the person makes the same choice.</p><p>If the probability is 1,i.e., there’s no chance that the person can make any other decision, then we have effectively proven that free will doesn’t exist. If however, the odds are anything but perfect, then folks, congratulations!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*dqvo9KftQvNvyWVd_LgNSA.png" /><figcaption>The choice of free will</figcaption></figure><h3>Conclusion</h3><p>All that needs to be said, has been said. I’ll leave the rest to your thinking and imagination.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9fee36e1459" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>