<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Monte&#39;s Snippets</title>
    <link>https://montepy.in/</link>
    <description>Recent content on Monte&#39;s Snippets</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 23 Oct 2026 14:36:43 +0530</lastBuildDate>
    <atom:link href="https://montepy.in/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Tokenisation</title>
      <link>https://montepy.in/posts/tokenisation/</link>
      <pubDate>Fri, 23 Oct 2026 14:36:43 +0530</pubDate>
      <guid>https://montepy.in/posts/tokenisation/</guid>
      <description>&lt;p&gt;As we all know, neural networks understand one and only one thing i.e. numbers, so how are they able to work with text data like &lt;code&gt;&amp;quot;what&#39;s your name?&amp;quot;&lt;/code&gt;? If that&amp;rsquo;s the case, then how do we convert text into numbers, what&amp;rsquo;s the best way to do it, and is one way better than another and why? We need a way to convert text into numbers and numbers back to text.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Hotfix 1: Redirect or Rewrite</title>
      <link>https://montepy.in/posts/hotfix-1/</link>
      <pubDate>Sun, 27 Sep 2026 12:26:23 +0530</pubDate>
      <guid>https://montepy.in/posts/hotfix-1/</guid>
      <description>&lt;p&gt;&lt;em&gt;This is the first edition of the &lt;a href=&#34;https://montepy.in/tags/hotfix/&#34;&gt;Hotfix&lt;/a&gt; series, in which I document an issue I encountered in production and how I fixed it.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;We were in the midst of cleanup activities aimed at removing technical debt. Part of this effort focused on removing APIs that were no longer in use. It was silly of us not to properly define &lt;strong&gt;&amp;ldquo;no longer in use.&amp;rdquo;&lt;/strong&gt; A proper definition should account for backward compatibility, especially when dealing with mobile apps rather than websites. Websites always fetch the latest version, so backward compatibility is not an issue, but there is no such guarantee with mobile apps because it depends on when users update the app.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Gemini Tool Call</title>
      <link>https://montepy.in/posts/gemini-tool-call/</link>
      <pubDate>Tue, 15 Sep 2026 21:09:49 +0530</pubDate>
      <guid>https://montepy.in/posts/gemini-tool-call/</guid>
      <description>&lt;p&gt;Working with &lt;code&gt;gemini-live-2.5-flash-native-audio&lt;/code&gt; (of course, naming things is not Google&amp;rsquo;s strongest suit—remember Bard?) has its own ups and downs. No doubt, the liveliness, expressiveness, and language capabilities are really good, but tool (function) calling had me thinking otherwise.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Reducing unintentional tool calls is especially important for our use case, as it involves taking images via voice commands. A photo taken unintentionally makes it look like the device is taking photos by itself.&lt;/p&gt;
&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>Websocket</title>
      <link>https://montepy.in/posts/websocket/</link>
      <pubDate>Sat, 27 Jun 2026 19:00:29 +0530</pubDate>
      <guid>https://montepy.in/posts/websocket/</guid>
      <description>&lt;p&gt;If you go through &lt;a href=&#34;https://websocket.org&#34;&gt;weboscket.org&lt;/a&gt;, you will see the essential events are &lt;code&gt;onopen&lt;/code&gt;, &lt;code&gt;onmessage&lt;/code&gt;, &lt;code&gt;onerror&lt;/code&gt;, &lt;code&gt;onclose&lt;/code&gt;. Naively I assumed that authentication should happen in &lt;code&gt;onopen&lt;/code&gt; event. But this resulted in an unanticipated security breach.&lt;/p&gt;
&lt;p&gt;But first the normal web requests. In a normal requests, I can send custom headers like &lt;code&gt;Authorization: Bearer token&lt;/code&gt;. This works, because the browser makes the preflight request, asking the server &lt;code&gt;&amp;quot;I am about to make this request with this header and this method, do you allow it?&amp;quot;&lt;/code&gt;. At this stage the server can reject this request, if either the method or the header doesn&amp;rsquo;t exist.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Cognitive Load</title>
      <link>https://montepy.in/posts/cognitive-load/</link>
      <pubDate>Sun, 22 Feb 2026 21:24:25 +0530</pubDate>
      <guid>https://montepy.in/posts/cognitive-load/</guid>
      <description>&lt;p&gt;With the recent update of &lt;code&gt;claude&lt;/code&gt; (which is a significant improvement), like many, my programming style has also changed. Unlike the old days (it&amp;rsquo;s just been a few weeks, and it&amp;rsquo;s already old), I don&amp;rsquo;t write code &lt;strong&gt;&amp;ldquo;manually&amp;rdquo;&lt;/strong&gt;, like laboriously typing &lt;code&gt;def&lt;/code&gt; before every function — I simply ask &lt;code&gt;claude&lt;/code&gt; to do it. Even for the smallest of tasks, I would much rather type &lt;code&gt;&amp;quot;please commit the recent changes and push to remote&amp;quot;&lt;/code&gt; instead of &lt;code&gt;git add . &amp;amp;&amp;amp; git commit -m &amp;quot;(wip)&amp;quot; &amp;amp;&amp;amp; git push&lt;/code&gt;. In other words, I have completely shifted to &lt;strong&gt;&amp;ldquo;Agentic Coding&amp;rdquo;&lt;/strong&gt;. The advantages are clear: I am certainly writing more code and shipping faster, plus while &lt;code&gt;claude&lt;/code&gt; is thinking and writing the code, I get mini breaks to scroll through Instagram slop.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to set up a JavaScript/TypeScript project</title>
      <link>https://montepy.in/posts/how-to-setup-jsts-project/</link>
      <pubDate>Thu, 14 Nov 2024 17:27:43 +0530</pubDate>
      <guid>https://montepy.in/posts/how-to-setup-jsts-project/</guid>
      <description>&lt;h2 id=&#34;running-a-javascript-file&#34;&gt;Running a Javascript file&lt;/h2&gt;
&lt;p&gt;Suppose you have a javascript file that you want to run from the command line.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;node&lt;/code&gt; or &lt;code&gt;deno&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Run the file with &lt;code&gt;node &amp;lt;filepath.js&amp;gt;&lt;/code&gt; or &lt;code&gt;deno &amp;lt;filepath.js&amp;gt;&lt;/code&gt; or &lt;code&gt;deno run &amp;lt;filepath.js&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;running-a-typescript-file&#34;&gt;Running a TypeScript file&lt;/h2&gt;
&lt;p&gt;Suppose you have a typescript file that you want to run from the command line.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;node&lt;/code&gt;. &lt;code&gt;npm&lt;/code&gt; comes bundled with &lt;code&gt;node&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Install the typescript compiler with &lt;code&gt;npm install -g typescript&lt;/code&gt;. Note that this will install the latest version of typescript compiler globally.&lt;/li&gt;
&lt;li&gt;Compile the file with &lt;code&gt;tsc &amp;lt;filepath.ts&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Run the file with &lt;code&gt;node &amp;lt;comiled-filepath.js&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Alternatively, you can install the &lt;code&gt;ts-node&lt;/code&gt; package with &lt;code&gt;npm install -g ts-node&lt;/code&gt;. This will install the latest version of &lt;code&gt;ts-node&lt;/code&gt; globally. &lt;code&gt;ts-node&lt;/code&gt; compiles the file on the file and executes it. &lt;code&gt;ts-node &amp;lt;filepath.ts&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;running-a-javascript-project&#34;&gt;Running a Javascript project&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;The project directory must have a &lt;code&gt;package.json&lt;/code&gt; file. This file is used by &lt;code&gt;npm&lt;/code&gt; and can also be used to define additional information if you plan to publish the module to &lt;code&gt;npm&lt;/code&gt; registry.&lt;/li&gt;
&lt;li&gt;Install the dependencies mentioned in the &lt;code&gt;package.json&lt;/code&gt; file with &lt;code&gt;npm install&lt;/code&gt;, &lt;a href=&#34;https://docs.npmjs.com/cli/v10/configuring-npm/package-json&#34;&gt;more details about &lt;code&gt;package.json&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;package.json&lt;/code&gt; file have a &lt;code&gt;scripts&lt;/code&gt; section, this defines the commands that can be run with &lt;code&gt;npm run &amp;lt;command&amp;gt;&lt;/code&gt;. In this section, you can define commands like &lt;code&gt;start: node index.js; test: jest .&lt;/code&gt;, then if you run &lt;code&gt;npm run test&lt;/code&gt; it will run the tests.&lt;/li&gt;
&lt;li&gt;Note, &lt;code&gt;npm&lt;/code&gt; defines three commands which can be run without using the &lt;code&gt;run&lt;/code&gt; command, &lt;code&gt;npm start&lt;/code&gt;, &lt;code&gt;npm test&lt;/code&gt; and &lt;code&gt;npm stop&lt;/code&gt;. The &lt;code&gt;start&lt;/code&gt; command defaults to using &lt;code&gt;index.js&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;package.json&lt;/code&gt; file has a &lt;code&gt;main&lt;/code&gt; field, this is the file that is executed when you import the package in another file.&lt;/li&gt;
&lt;li&gt;By default, &lt;code&gt;npm&lt;/code&gt; treats the imports as CommonJS modules, if you are using ES modules, you need to add the &lt;code&gt;type&lt;/code&gt; key in your &lt;code&gt;package.json&lt;/code&gt; with value &lt;code&gt;module&lt;/code&gt;. Then all files must use &lt;code&gt;import/export&lt;/code&gt; syntax.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-json5&#34; data-lang=&#34;json5&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;err&#34;&gt;name:&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;&amp;#34;my-package&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;err&#34;&gt;version:&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;&amp;#34;1.0.0&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;err&#34;&gt;main:&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;&amp;#34;index.js&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;err&#34;&gt;scripts:&lt;/span&gt; &lt;span class=&#34;err&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;err&#34;&gt;start:&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;&amp;#34;node index.js&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;err&#34;&gt;test:&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;&amp;#34;jest .&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;err&#34;&gt;type:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;module&amp;#34;&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;err&#34;&gt;dependencies:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;err&#34;&gt;jest:&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;&amp;#34;^27.5.1&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;running-a-typescript-project&#34;&gt;Running a TypeScript project&lt;/h2&gt;
&lt;h3 id=&#34;using-ts-node&#34;&gt;Using &lt;code&gt;ts-node&lt;/code&gt;&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;[!NOTE]
You can avoid using &lt;code&gt;ts-node&lt;/code&gt; and use &lt;code&gt;tsx&lt;/code&gt; which supports TypeScript out of the box. No need to add additional support for esm modules&lt;/p&gt;
&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>All the ways to `git add`</title>
      <link>https://montepy.in/posts/git-add/</link>
      <pubDate>Thu, 24 Oct 2024 20:26:20 +0530</pubDate>
      <guid>https://montepy.in/posts/git-add/</guid>
      <description>&lt;p&gt;I always get confused with, should I run &lt;code&gt;git add .&lt;/code&gt;, or should I run &lt;code&gt;git add --all&lt;/code&gt;, or should I run &lt;code&gt;git add -A&lt;/code&gt;? Given all these commands, do a similar thing, confusion is bound to happen. Thankfully, it&amp;rsquo;s not just &lt;a href=&#34;https://stackoverflow.com/questions/23003118/any-difference-between-git-add-and-git-add-all#:~:text=git%20add%20%2D%2Dall%20will,git%20add%20.&#34;&gt;me&lt;/a&gt;. So I decided to take a deep dive into &lt;code&gt;add&lt;/code&gt; command of &lt;code&gt;git&lt;/code&gt;, to end this confusion once and for all.&lt;/p&gt;
&lt;h2 id=&#34;what-does-add-even-do&#34;&gt;What does &lt;code&gt;add&lt;/code&gt; even do?&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;add&lt;/code&gt; command adds your changes to staging area. Staging area is a buffer zone where you place your files before committing them. This buffer zone allows you to be selective with your commits, there are some files that you want to commit now and some files that you want to commit later. Staging area is also known as &lt;code&gt;index&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to parse json in terminal using jq</title>
      <link>https://montepy.in/posts/jq/</link>
      <pubDate>Mon, 01 Apr 2024 22:43:39 +0530</pubDate>
      <guid>https://montepy.in/posts/jq/</guid>
      <description>&lt;h2 id=&#34;a-practical-tutorial-on-jq&#34;&gt;A practical tutorial on &lt;code&gt;jq&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;So here&amp;rsquo;s the problem statement: &lt;em&gt;&lt;strong&gt;Find the repository on github in which you have made most number of commits? And you need to do this on terminal (no python)&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Ofcourse, one can use python to find the answer, and it might be probably easy for you, if you have been using python for last many years. But let&amp;rsquo;s see if I can do this in terminal with &lt;code&gt;jq&lt;/code&gt; and while doing so, let&amp;rsquo;s learn about it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to `find` files in terminal?</title>
      <link>https://montepy.in/posts/find/</link>
      <pubDate>Wed, 21 Feb 2024 20:26:20 +0530</pubDate>
      <guid>https://montepy.in/posts/find/</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;Manager&lt;/strong&gt;&lt;/em&gt;: Hey, I need your help, I have couple of images that are taking a lot of space on my PC, I want to delete them. How can I do that?&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Developer&lt;/strong&gt;&lt;/em&gt;: Well that should be simple. Here, you go. This looks for all files with &lt;code&gt;.png&lt;/code&gt; extension in the current directory and its subdirectories (using &lt;code&gt;-R&lt;/code&gt; flag), then pipes those file names to &lt;code&gt;rm&lt;/code&gt; command to delete them.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ls -R &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; grep &lt;span class=&#34;s2&#34;&gt;&amp;#34;.png&lt;/span&gt;$&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; xargs rm
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Manager&lt;/strong&gt;&lt;/em&gt;: Nice, but wait. This will delete all the &lt;code&gt;png&lt;/code&gt; files in the current directory and its subdirectories. I only want to delete in specific directories.&lt;/p&gt;</description>
    </item>
    <item>
      <title>First Post</title>
      <link>https://montepy.in/posts/first-post/</link>
      <pubDate>Fri, 02 Feb 2024 23:39:06 +0530</pubDate>
      <guid>https://montepy.in/posts/first-post/</guid>
      <description>&lt;h1 id=&#34;first-post&#34;&gt;First Post&lt;/h1&gt;
&lt;p&gt;This is an example post to test the website. It just contains some rough snippets.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;hello_world&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;():&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;Hello, World!&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
