<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/rss/styles.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Chaitanya Varu</title><description>Chaitanya Varu&apos;s Blog site</description><link>https://chaitanyavaru.com</link><item><title>Add devise to rails app</title><link>https://chaitanyavaru.com/blogs/add-devise-to-rails-app</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/add-devise-to-rails-app</guid><description>Add devise to rails app</description><pubDate>Fri, 25 Aug 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Devise is a very useful gem in the rails ecosystem. It provides powerful out-of-the-box solutions for authentication functionalities to add to your rails application.&lt;/p&gt;
&lt;p&gt;In this guide, we will look at the basic steps one needs to integrate devise.&lt;/p&gt;
&lt;h2 id=&quot;install-devise&quot;&gt;Install devise&lt;/h2&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:17ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bundle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;devise&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;bundle add devise&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;This will add install the gem and add it to the gemfile&lt;/p&gt;
&lt;h2 id=&quot;generate-initial-configuration-files&quot;&gt;Generate initial configuration files&lt;/h2&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:29ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;rails&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;generate&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;devise:install&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;rails generate devise:install&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;In config/environment/dev add &lt;code&gt;config.action_mailer.default_url_options = { host: &apos;localhost&apos;, port: 3000 }&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;This ensures that Devise-generated emails contain the correct URL.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Set a root path in routes.rb, if not already.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;generate-the-view-files&quot;&gt;Generate the view files&lt;/h2&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:27ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;rails&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;generate&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;devise:views&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;rails generate devise:views&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Use it to modify the default view of signup, login and other authentication-related pages.&lt;/p&gt;
&lt;h2 id=&quot;generate-user-model&quot;&gt;Generate user model&lt;/h2&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:26ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;rails&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;generate&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;devise&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;User&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;rails generate devise User&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;after generating the model, perform a database migration to add the User model to your database.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:16ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;rails&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;db:migrate&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;rails db:migrate&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Now you could explore other features like confirming while signup, forgot password, lock attempts etc.&lt;/p&gt;</content:encoded></item><item><title>Git for beginners</title><link>https://chaitanyavaru.com/blogs/basic-git-commands</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/basic-git-commands</guid><description>List of common git commands useful in day to day operations</description><pubDate>Sun, 30 Apr 2023 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;github-repo-to-local-system&quot;&gt;Github Repo to Local System&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;copy SSH link of repo&lt;/li&gt;
&lt;li&gt;go to folder in pc where you want the project, then&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git clone &amp;#x3C;link&gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;configure-git-for-a-project-and-push-files&quot;&gt;Configure Git for a project and Push files&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git init&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;initializes project&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git add .&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;adds files to staging area&lt;/li&gt;
&lt;li&gt;. means all files. for specific files, give their names&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git commit -m “message”&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;“-m” is for message&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git remote add origin &amp;#x3C;link&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;copy SSH link from repo&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git push origin &amp;#x3C;branch_name&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;push command updates the remote repository with local commits&lt;/li&gt;
&lt;li&gt;origin represents a remote name where the user wants to push the changes&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;branches&quot;&gt;Branches&lt;/h2&gt;
&lt;p&gt;Basics&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git branch &amp;#x3C;branch_name&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;create new branch&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git checkout &amp;#x3C;branch_name&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to go to another branch&lt;/li&gt;
&lt;li&gt;add -b to create &amp;#x26; go to new branch&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git branch&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;check current branch&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git branch -a&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to see list of all branches&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Merging branches&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;go to branch where you want to merge&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git merge &amp;#x3C;branch_name&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&amp;#x3C;branch_name&gt; is the branch you want to merge into current branch&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Renaming branch&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git branch -m &amp;#x3C;oldname&gt; &amp;#x3C;newname&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git branch -m &amp;#x3C;newname&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;if you want to rename current branch&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Deleting branch&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git branch -d &amp;#x3C;local_branch_name&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;-d deletes only those branches which are merged and pushed to remote branch&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git push origin --delete &amp;#x3C;remote_branch_name&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to delete remote branch&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Cloud Resume Challenge</title><link>https://chaitanyavaru.com/blogs/cloud-resume-challenge</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/cloud-resume-challenge</guid><description>jMy ourney of cloud resume challenge, azure path</description><pubDate>Wed, 02 Aug 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I wanted to explore cloud so I took the &lt;a href=&quot;https://cloudresumechallenge.dev/docs/the-challenge&quot;&gt;Cloud Resume Challenge&lt;/a&gt;. It is a great way to get hands on learning experience on cloud. Here’s my journey through it.&lt;/p&gt;
&lt;p&gt;One can take it using any cloud platform like AWS, Azure or GPC. I selected the Azure path.&lt;/p&gt;
&lt;h2 id=&quot;adding-the-basic-structure&quot;&gt;Adding the basic structure&lt;/h2&gt;
&lt;p&gt;First, I setup the basic HTML, CSS, JS structure. The page had few social links and a counter. I kept it very minimal since focus is on learning cloud not HTML, CSS.&lt;/p&gt;
&lt;h2 id=&quot;hosting-static-website&quot;&gt;Hosting Static website&lt;/h2&gt;
&lt;p&gt;I created &lt;code&gt;Static Web App&lt;/code&gt; from the azure portal and hosted the app. This took no time.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1690988090/blog/azure_static.png&quot; alt=&quot;creating a static web app&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;configuring-a-custom-domain&quot;&gt;Configuring a Custom Domain&lt;/h2&gt;
&lt;p&gt;From the hosted static app, I went to &lt;code&gt;custom domain on other DNS&lt;/code&gt;. Created CNAME record from DNS management from my DNS provider with value as azure hosted url.&lt;/p&gt;
&lt;h2 id=&quot;working-with-azure-cosmos-db&quot;&gt;Working with Azure Cosmos DB&lt;/h2&gt;
&lt;p&gt;Created an &lt;code&gt;Azure Cosmos DB&lt;/code&gt; account. Make sure to select (consumption) serverless option.
&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1690988090/blog/azure_cosmos_db.png&quot; alt=&quot;creating a cosmos db&quot;&gt;&lt;/p&gt;
&lt;p&gt;Then created a new container from data explorer and added an item to it.
&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1690987171/blog/cosmos_db_container.png&quot; alt=&quot;cosmos db container&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;implementing-azure-functions&quot;&gt;Implementing Azure Functions&lt;/h2&gt;
&lt;p&gt;This was the most challenging part. I created an &lt;code&gt;Function app&lt;/code&gt; from the portal.
&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1690988090/blog/azure_function.png&quot; alt=&quot;creating a function app&quot;&gt;
Once function app is created, create the function with http Trigger.&lt;/p&gt;
&lt;p&gt;Now select &lt;code&gt;Integrate&lt;/code&gt; and add input &amp;#x26; output bindings. Set binding type as cosmos DB since we have stored the count there and select the database we created earlier. Database name will be database-id and collection name will be container-id.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1690988090/blog/azure_function_testing.png&quot; alt=&quot;testing azure function&quot;&gt;&lt;/p&gt;
&lt;p&gt;This is the required function. The &lt;code&gt;data&lt;/code&gt; parameter receives data from the &lt;code&gt;Input binding&lt;/code&gt;. Then we assign the required value from it to &lt;code&gt;Output binding&lt;/code&gt; so that it could be used after function execution. The data is returned in the body. The count value is incremented in output binding and after function execution, it is stored in the database.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:54ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;exports&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (context, req, data) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bindings&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;outputDocument&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;];&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bindings&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;outputDocument&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;visitorCount&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;context&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;res&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;body: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;visitorCount: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;visitorCount&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;};&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;};&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;module.exports = async function (context, req, data) {    context.bindings.outputDocument = data[0];    context.bindings.outputDocument.visitorCount += 1;    context.res = {        body: {            visitorCount: data[0].visitorCount,        },    };};&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;🚨 Mistake I did was that I kept partition key and the key storing count value same. It was creating a new record instead of updating it. This took up a lot of time.&lt;/p&gt;
&lt;p&gt;For this step, articles by &lt;a href=&quot;https://dev.to/therealbolaji/creating-a-serverless-resume-with-visitor-counter-in-azure-3f78&quot;&gt;Akande Bolaji&lt;/a&gt;, &lt;a href=&quot;https://craigtwall.com/azure-cloud-resume-challenge&quot;&gt;Craig Wall&lt;/a&gt; and &lt;a href=&quot;https://jeffbrown.tech/azure-cloud-resume-challenge-part-1&quot;&gt;Jeff Brown&lt;/a&gt; helped a lot.&lt;/p&gt;
&lt;p&gt;Also enable CORS after function is ready.&lt;/p&gt;
&lt;h2 id=&quot;using-cdn&quot;&gt;Using CDN&lt;/h2&gt;
&lt;p&gt;For CDN I used &lt;code&gt;Front Door and CDN profile&lt;/code&gt; from azure portal. Added the static web app’s url as endpoint.
&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1690987170/blog/azure_cdn.png&quot; alt=&quot;adding cdn&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The resume is deployed in azure static web app and is live at &lt;del&gt;chaitanyavaru.tech&lt;/del&gt;. It is storing the visitor count value in azure cosmos DB whose value is updated by azure function whenever the page is visited. And its using custom domain.&lt;/p&gt;
&lt;p&gt;I learned a lot from this challenge. It was a great experience. I will be exploring more of azure in future.&lt;/p&gt;</content:encoded></item><item><title>Deploy in Railway</title><link>https://chaitanyavaru.com/blogs/deploy-in-railway</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/deploy-in-railway</guid><description>steps to follow to deploy in railway.app</description><pubDate>Tue, 25 Apr 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;To share our app with others, we need to deploy it. There are many ways to deploy our app, but one of the easiest services I have found is &lt;a href=&quot;https://railway.app/&quot;&gt;Railway&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;here-is-a-quick-guide-to-deploy-your-app-in-railway&quot;&gt;Here is a quick guide to deploy your app in Railway.&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Go to dashboard&lt;/li&gt;
&lt;li&gt;Select deploy from github&lt;/li&gt;
&lt;li&gt;Add variables, if any&lt;/li&gt;
&lt;li&gt;Then go to settings tab
&lt;ul&gt;
&lt;li&gt;Select root directory&lt;/li&gt;
&lt;li&gt;Add build command&lt;/li&gt;
&lt;li&gt;Add sisdfsdftart command&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now deploy&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thats it! Now you can share the app using the domain from the settings tab.&lt;/p&gt;</content:encoded></item><item><title>Getting Started with Cloudflare Workers</title><link>https://chaitanyavaru.com/blogs/getting-started-with-cloudflare-workers</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/getting-started-with-cloudflare-workers</guid><description>Getting started with Cloudflare Workers</description><pubDate>Thu, 10 Aug 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Serverless can be confusing if you’re new to it. Despite the name “serverless,” it does involve servers in the background. Basically in &lt;em&gt;serverless&lt;/em&gt; we write functions and deploy and the platform where functions are deployed takes care of rest of the things.&lt;/p&gt;
&lt;p&gt;Cloudflare workers is a simple way to get started with the serverless architecture.
Its better to have hands-on learning than just theories. So we will build a serverless resume to understand cloudflare workers.&lt;/p&gt;
&lt;h2 id=&quot;wrangler&quot;&gt;Wrangler&lt;/h2&gt;
&lt;p&gt;Cloudflare workers can be managed through the web interface or by its command line tool &lt;code&gt;wrangler&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;installation&quot;&gt;Installation&lt;/h3&gt;
&lt;p&gt;To install Wrangler, use the following command:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:31ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;npm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;install&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;wrangler&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;--save-dev&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;npm install wrangler --save-dev&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h3 id=&quot;generating-project&quot;&gt;Generating project&lt;/h3&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:30ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;wrangler&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;generate&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;project_name&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;wrangler generate project_name&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;This wil generate starter files for cloud flare workers.&lt;/p&gt;
&lt;h2 id=&quot;code&quot;&gt;Code&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Create a new file and add your resume contents in it.&lt;/li&gt;
&lt;li&gt;Now in index.js we will import resume and send as response.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:67ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;resumeData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;./resume&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;corsHeaders&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;Access-Control-Allow-Origin&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;*&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;Access-Control-Allow-Methods&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;GET, OPTIONS&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;Access-Control-Allow-Headers&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;Content-Type&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;};&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(request, env, ctx) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;formatedResume&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;JSON&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;stringify&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;resumeData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;Response&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;formatedResume&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;headers: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:16ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;Content-Type&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;application/json&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:16ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;corsHeaders&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;};&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;import resumeData from &amp;#x27;./resume&amp;#x27;;const corsHeaders = {    &amp;#x27;Access-Control-Allow-Origin&amp;#x27;: &amp;#x27;*&amp;#x27;,    &amp;#x27;Access-Control-Allow-Methods&amp;#x27;: &amp;#x27;GET, OPTIONS&amp;#x27;,    &amp;#x27;Access-Control-Allow-Headers&amp;#x27;: &amp;#x27;Content-Type&amp;#x27;,};export default {    async fetch(request, env, ctx) {        const formatedResume = JSON.stringify(resumeData, null, 2);        return new Response(formatedResume, {            headers: {                &amp;#x27;Content-Type&amp;#x27;: &amp;#x27;application/json&amp;#x27;,                ...corsHeaders,            },        });    },};&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;To enable cross-origin resource sharing (CORS) ie add its headers.&lt;/p&gt;
&lt;p&gt;To make the resume display in a more readable way, we are using JSON.stringify() function. It takes 3 arguments. Original data, a replacer callback function which is null here and space argument which is 2 which means that means that each level of nesting within the JSON structure will be indented by two spaces.&lt;/p&gt;
&lt;h2 id=&quot;deploy&quot;&gt;Deploy&lt;/h2&gt;
&lt;p&gt;In wrangler.toml file, configure project details like name and entry point.&lt;/p&gt;
&lt;p&gt;To deploy it use the command:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:15ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;wrangler&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;deploy&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;wrangler deploy&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;automating-with-github-actions&quot;&gt;Automating with Github Actions&lt;/h2&gt;
&lt;p&gt;To automate the deployment process we are using github actions. This workflow deploys updated code whenever changes are pushed to the repository.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create ‘.github/workflows’ directory&lt;/li&gt;
&lt;li&gt;Inside it add a YAML file&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here’s the content of the YAML file&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;yaml&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:63ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;Deploy to Cloudflare Workers&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;on&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;push&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;branches&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;master&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;jobs&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;deploy&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;runs-on&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;ubuntu-latest&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;Deploy&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;steps&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;uses&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;actions/checkout@v2&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;Publish&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:14ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;              &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;uses&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;cloudflare/wrangler-action@2.0.0&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:14ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;              &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:18ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;                  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;apiToken&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;${{ secrets.CLOUDFLARE_API_TOKEN }}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;name: Deploy to Cloudflare Workerson:    push:        branches:            - masterjobs:    deploy:        runs-on: ubuntu-latest        name: Deploy        steps:            - uses: actions/checkout@v2            - name: Publish              uses: cloudflare/wrangler-action@2.0.0              with:                  apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;To access our Cloudflare account, we are using API token. Generate the token from cloudflare dashboard. Then add it to github secrets of the repository.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Thats it. We built a simple cloudflare workers project to server resume data.&lt;/p&gt;
&lt;p&gt;Now when anyone enters the URL associated with the project, they would receive the resume data in response.&lt;/p&gt;</content:encoded></item><item><title>How to integrate google APIs to your application</title><link>https://chaitanyavaru.com/blogs/google-api-integration</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/google-api-integration</guid><description>How to integrate Google API with your application</description><pubDate>Wed, 07 Jun 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;API is a way to use features of other applications in our application. Google has several APIs that could be used in our applications.&lt;/p&gt;
&lt;p&gt;In this article, we will see how to integrate Google API with our application.&lt;/p&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Account in Google Cloud Platform&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;steps&quot;&gt;Steps&lt;/h2&gt;
&lt;h3 id=&quot;1-create-google-cloud-project&quot;&gt;1. Create Google Cloud Project&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1691494960/blog/gcp_create_project.png&quot; alt=&quot;Create Project&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;From the sidebar, go to APIs &amp;#x26; Services &gt; Library.&lt;/li&gt;
&lt;li&gt;Search for the API to enable, here we are enabling google sheets API.&lt;/li&gt;
&lt;li&gt;Click on Enable.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;2-create-credentials&quot;&gt;2. Create Credentials&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/dmtacem5p/image/upload/v1691494960/blog/gcp_create_credentials.png&quot; alt=&quot;Create Credentials&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Now create credentials for the API. For this, there are 3 ways
&lt;ul&gt;
&lt;li&gt;OAuth 2.0: to access user data on their behalf.&lt;/li&gt;
&lt;li&gt;API Key: to access public data.&lt;/li&gt;
&lt;li&gt;Service Account: to access our data on behalf of our application.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;here we are using a service account.&lt;/li&gt;
&lt;li&gt;Add a service account name and click on create.&lt;/li&gt;
&lt;li&gt;Fill the required details&lt;/li&gt;
&lt;li&gt;Click on Done and download the JSON file which contains the credentials.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;3-integrate-api-using-the-credentials&quot;&gt;3. Integrate API using the credentials&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Create an &lt;code&gt;.env&lt;/code&gt; file and add &lt;code&gt;GOOGLE_SHEET_CLIENT_EMAIL&lt;/code&gt;, &lt;code&gt;GOOGLE_SHEET_PRIVATE_KEY&lt;/code&gt; and &lt;code&gt;GOOGLE_SHEET_ID&lt;/code&gt; from the downloaded JSON file.&lt;/li&gt;
&lt;li&gt;For the private key, include everything from “-----BEGIN PRIVATE KEY-----” to “-----END PRIVATE KEY-----”&lt;/li&gt;
&lt;li&gt;Install &lt;code&gt;googleapis&lt;/code&gt; package using your package manager.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:93ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;google&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; } &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;googleapis&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getSheetData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;() {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// create auth client&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;auth&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;google&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;auth&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;GoogleAuth&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;({&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;credentials: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;client_email: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;process&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;env&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;GOOGLE_SHEET_CLIENT_EMAIL&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;private_key: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;process&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;env&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;GOOGLE_SHEET_PRIVATE_KEY&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;scopes: [&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;https://www.googleapis.com/auth/spreadsheets&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// to read and write spreadsheets&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;https://www.googleapis.com/auth/drive&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// to create a new spreadsheet&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;],&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// create client instance&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;auth&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getClient&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// create google sheet instance&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;sheetInstance&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;google&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;sheets&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;({ version: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;v4&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, auth: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; });&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// get all data in range&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; } &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;sheetInstance&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;spreadsheets&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;values&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;({&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;spreadsheetId: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;process&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;env&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;GOOGLE_SHEET_ID&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;range: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;sheet1&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// this is sheet name&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;values&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;import { google } from &amp;#x27;googleapis&amp;#x27;;export default async function getSheetData() {    // create auth client    const auth = new google.auth.GoogleAuth({        credentials: {            client_email: process.env.GOOGLE_SHEET_CLIENT_EMAIL,            private_key: process.env.GOOGLE_SHEET_PRIVATE_KEY,        },        scopes: [            &amp;#x27;https://www.googleapis.com/auth/spreadsheets&amp;#x27;, // to read and write spreadsheets            &amp;#x27;https://www.googleapis.com/auth/drive&amp;#x27;, // to create a new spreadsheet        ],    });    // create client instance    const client = await auth.getClient();    // create google sheet instance    const sheetInstance = google.sheets({ version: &amp;#x27;v4&amp;#x27;, auth: client });    // get all data in range    const { data } = await sheetInstance.spreadsheets.values.get({        spreadsheetId: process.env.GOOGLE_SHEET_ID,        range: &amp;#x27;sheet1&amp;#x27;, // this is sheet name    });    return data.values;}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;</content:encoded></item><item><title>My journey of learning Vim Motions</title><link>https://chaitanyavaru.com/blogs/journey-of-learning-vim-motions</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/journey-of-learning-vim-motions</guid><description>My journey of learning vim motions</description><pubDate>Sun, 10 Dec 2023 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;why-vim-motions&quot;&gt;Why vim motions ?&lt;/h2&gt;
&lt;p&gt;Couple of months back I started having little bit pain around my wrists. So I started doing some basic wrist stretches. There was temporary relief but for a long term solution, I looked around for other solutions as well.&lt;/p&gt;
&lt;p&gt;I found that ergonomically it was bad for wrists to move from letter keys to arrow keys &amp;#x26; moves frequently. Shifting from letter keys to arrow keys every time when I had to navigate seemed slow. For this I landed upon vim. With vim’s mode based editing, there would be less wrist movement and most of navigation could be done from the home row of keyboard.&lt;/p&gt;
&lt;p&gt;However, shifting entirely to terminal based editor(vim) from VS Code felt overwhelming and unnecessary for now. So I decided to focus only on vim motions.&lt;/p&gt;
&lt;p&gt;I am using ‘amVim’ extension in VS Code with which we can get some vim features in vscode.&lt;/p&gt;
&lt;h2 id=&quot;what-are-vim-motions&quot;&gt;What are vim motions?&lt;/h2&gt;
&lt;p&gt;Vim motions are ways with which we can edit text efficiently. Most basic example is that instead of arrow keys to navigate, we use &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, &lt;code&gt;k&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, so no need to lift hand from home row of keyboard.&lt;/p&gt;
&lt;p&gt;Another example would be selecting some text inside parenthesis. For that we could use mouse and drag, or in keyboard we could press &lt;code&gt;ctrl + shift &lt;/code&gt; + arrow key until we select all text. But with vim motions, we just press three characters. Stay inside parenthesis and press &lt;code&gt;vi(&lt;/code&gt; thats it.&lt;/p&gt;
&lt;p&gt;More examples would be navigating each word with &lt;code&gt;w&lt;/code&gt;, deleting word with &lt;code&gt;dw&lt;/code&gt;, toggle upper/lower case of characters with &lt;code&gt;~&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;And these are just on single word or line. By adding numbers in front of commands we can perform them in multiple lines. For example, &lt;code&gt;10j&lt;/code&gt; will move cursor 5 lines below, &lt;code&gt;5dw&lt;/code&gt; will delete next 5 words.&lt;/p&gt;
&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;
&lt;p&gt;Most of the learning was from &lt;a href=&quot;https://www.barbarianmeetscoding.com/boost-your-coding-fu-with-vscode-and-vim/table-of-contents&quot;&gt;Jaime Gonzalez Garcia’s guide&lt;/a&gt; on Vim in VS Code. This is a fantastic guide for anyone looking for vim motions. The site &lt;a href=&quot;https://vim-adventures.com&quot;&gt;vim adventures&lt;/a&gt; and ThePrimagen’s &lt;a href=&quot;https://youtube.com/playlist?list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R&amp;#x26;si=daQyEc2SkKnhYy2Y&quot;&gt;youtube playlist&lt;/a&gt; are also good for introduction.
After this, it was just google searches for what I needed.&lt;/p&gt;
&lt;h2 id=&quot;learning-journey&quot;&gt;Learning journey&lt;/h2&gt;
&lt;p&gt;To increase the chances of using vim motions, I enabled them in both VS Code and &lt;a href=&quot;https://obsidian.md&quot;&gt;Obsidian&lt;/a&gt; (tool I use for note taking).&lt;/p&gt;
&lt;p&gt;For the first few weeks, I enabled vim mode only during weekends, so I don’t get slowed down in my day work. One I got comfortable with vim motions, I started using vim mode full time on both apps.&lt;/p&gt;
&lt;p&gt;I already used lot of keybindings instead of using mouse in my vscode so adding new commands to memory was not a challenge. Though getting habituated to using those commands instead of arrow keys took some time.
Also remapping caps lock key to escape key was helpful.&lt;/p&gt;
&lt;h2 id=&quot;two-weeks-into-vim-motions&quot;&gt;Two weeks into vim motions&lt;/h2&gt;
&lt;p&gt;Now that I am using it for two weeks for full time, editing text has become simpler and fast. The ease of navigation, selecting and modifying text is amazing.&lt;/p&gt;
&lt;p&gt;Stil, more practice is required to develop the muscle memory. And I might also change the extension to ‘Vim’ instead of ‘amVim’ so that I could add my own key bindings.&lt;/p&gt;
&lt;p&gt;Update: I did moved to ‘Vim’ extension. And because of all the custom settings, I am finding it much better.&lt;/p&gt;
&lt;h3 id=&quot;more-readings&quot;&gt;More readings&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.viemu.com/a-why-vi-vim.html&quot;&gt;http://www.viemu.com/a-why-vi-vim.html&lt;/a&gt; (a very interesting read. I am using vim motions since past 6 months, but still found some new ones here or the logic behind why a key is mapped with a particular motion)&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>My VS Code configurations</title><link>https://chaitanyavaru.com/blogs/my-vscode-configurations-2023</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/my-vscode-configurations-2023</guid><description>VS Code configurations that I am using in 2023</description><pubDate>Sun, 24 Dec 2023 00:00:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;The better we know our tools, the better we can use them. - By Someone&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For programmers, text editor is one of their most important tool. Its useful to know your editor’s functionalities. It helps to customize it based on your preferences, which can enhance our workflow and productivity.&lt;/p&gt;
&lt;p&gt;In this post, I will go through the configurations I use in VS Code.&lt;/p&gt;
&lt;h2 id=&quot;theme&quot;&gt;Theme&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=liviuschera.noctis&quot;&gt;Noctis&lt;/a&gt; - It is a collection of themes, out of which I use Noctis Obscuro. I find noctis themes very easy for the eyes.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme&quot;&gt;Material Icon Theme&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.jetbrains.com/lp/mono&quot;&gt;JetBrains Mono&lt;/a&gt; - JetBrains Mono focuses on readability a lot. It’s increased letter height and easily distinguishable characters reduces eye strain.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;extensions&quot;&gt;Extensions&lt;/h2&gt;
&lt;p&gt;Most of these extensions are language agnostic and there are few others which I add/remove depending on the language I am working on.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=dkundel.vscode-new-file&quot;&gt;Advanced-new-file&lt;/a&gt; - This extension helps to create new files in specific directories right from the command pallete, without using the file tree.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=auiworks.amvim&quot;&gt;amVim&lt;/a&gt; - Provides vim features inside VS Code.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=sleistner.vscode-fileutils&quot;&gt;File Utils&lt;/a&gt; - This extension gives features like rename, copy etc right from the command palette. I use this for renaming a lot.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow&quot;&gt;Indent Rainbow&lt;/a&gt; - Highlights the indentation.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer&quot;&gt;Live Server&lt;/a&gt; - To view simple html files.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh&quot;&gt;Remote SSH&lt;/a&gt; - This extension lets us open any folder on remote machine inside VS Code.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;settings&quot;&gt;Settings&lt;/h2&gt;
&lt;p&gt;I tend to use the built-in settings whereever possible and use less extensions, and keep the screen minimal.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;json&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:85ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.suggestSelection&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;first&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.fontSize&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;19&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.fontFamily&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;&apos;JetBrains Mono&apos;&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.fontLigatures&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;breadcrumbs.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// Scroll&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.fastScrollSensitivity&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.list.fastScrollSensitivity&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;terminal.integrated.fastScrollSensitivity&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.mouseWheelScrollSensitivity&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.accessibilitySupport&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;off&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.cursorBlinking&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;smooth&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.cursorSmoothCaretAnimation&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;on&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// Terminal&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;terminal.integrated.profiles.windows&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;Git Bash&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: { &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;path&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;C:&lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;Program Files&lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;Git&lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;bin&lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;bash.exe&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; }&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;terminal.integrated.defaultProfile.windows&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;Git Bash&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;terminal.integrated.fontSize&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;terminal.integrated.scrollback&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;10000&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// lenght of how much we can scroll back&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;terminal.integrated.defaultLocation&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;editor&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;explorer.confirmDelete&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;explorer.confirmDragAndDrop&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;explorer.compactFolders&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;explorer.openEditors.visible&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.wordWrap&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;on&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.formatOnSave&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.formatOnType&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.tabSize&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.indentSize&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.wrappingIndent&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;indent&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.inlineSuggest.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.bracketPairColorization.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.codeActionsOnSave&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;source.organizeImports&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;explicit&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// indent guide (the vertical lines)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.guides.bracketPairs&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.guides.highlightActiveIndentation&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.guides.bracketPairsHorizontal&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;active&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// minimap&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.minimap.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.minimap.autohide&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.minimap.renderCharacters&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.minimap.maxColumn&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.cursorSurroundingLines&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.glyphMargin&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;//  the breakpoint column&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.linkedEditing&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// auto rename tags&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editor.stickyScroll.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.tree.enableStickyScroll&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.tree.stickyScrollMaxItemCount&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.sideBar.location&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;right&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.activityBar.location&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;hidden&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.layoutControl.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.editor.pinnedTabSizing&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;shrink&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.editor.enablePreview&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.startupEditor&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.colorTheme&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;Noctis Obscuro&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.iconTheme&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;material-icon-theme&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.tree.indent&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.tree.renderIndentGuides&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;always&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;workbench.colorCustomizations&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;tab.activeBorderTop&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#d5971a&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;[Noctis Obscuro]&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;tab.activeBorderTop&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#d5971a&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// editor indent guide colors&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.background1&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#2a2a2a&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.background2&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#2a2a2a&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.background3&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#2a2a2a&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.background4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#2a2a2a&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.background5&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#2a2a2a&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.background6&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#2a2a2a&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.activeBackground1&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#e4e4e4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.activeBackground2&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#e4e4e4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.activeBackground3&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#e4e4e4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.activeBackground4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#e4e4e4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.activeBackground5&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#e4e4e4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorBracketPairGuide.activeBackground6&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#e4e4e4&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;tree.indentGuidesStroke&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#0f707e&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// file explorer indent guides&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;files.autoSave&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;afterDelay&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;files.autoSaveDelay&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;files.insertFinalNewline&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;files.trimTrailingWhitespace&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;window.commandCenter&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// the mdiddle box in title bar&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;window.title&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;window.menuBarVisibility&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;compact&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;diffEditor.renderSideBySide&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;diffEditor.hideUnchangedRegions.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;gitlens.menus&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;editorGroup&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;scmItemInline&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:12ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;stash&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;gitlens.statusBar.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;gitlens.codeLens.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;remote.SSH.connectTimeout&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// aVim&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;amVim.useSystemClipboard&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;amVim.smartRelativeLineNumbers&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;//auto close tags&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;html.autoClosingTags&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;javascript.autoClosingTags&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;typescript.autoClosingTags&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// auto imports&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;javascript.suggest.autoImports&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;typescript.suggest.autoImports&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;javascript.updateImportsOnFileMove.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;always&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;typescript.updateImportsOnFileMove.enabled&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;always&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;javascript.preferences.quoteStyle&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;single&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;typescript.preferences.quoteStyle&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;single&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;html.completion.attributeDefaultValue&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;singlequotes&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;css.lint.unknownAtRules&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;ignore&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&quot;liveServer.settings.donotShowInfoMsg&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;{    &amp;#x22;editor.suggestSelection&amp;#x22;: &amp;#x22;first&amp;#x22;,    &amp;#x22;editor.fontSize&amp;#x22;: 19,    &amp;#x22;editor.fontFamily&amp;#x22;: &amp;#x22;&amp;#x27;JetBrains Mono&amp;#x27;&amp;#x22;,    &amp;#x22;editor.fontLigatures&amp;#x22;: true,    &amp;#x22;breadcrumbs.enabled&amp;#x22;: false,    // Scroll    &amp;#x22;editor.fastScrollSensitivity&amp;#x22;: 1,    &amp;#x22;workbench.list.fastScrollSensitivity&amp;#x22;: 1,    &amp;#x22;terminal.integrated.fastScrollSensitivity&amp;#x22;: 1,    &amp;#x22;editor.mouseWheelScrollSensitivity&amp;#x22;: 1,    &amp;#x22;editor.accessibilitySupport&amp;#x22;: &amp;#x22;off&amp;#x22;,    &amp;#x22;editor.cursorBlinking&amp;#x22;: &amp;#x22;smooth&amp;#x22;,    &amp;#x22;editor.cursorSmoothCaretAnimation&amp;#x22;: &amp;#x22;on&amp;#x22;,    // Terminal    &amp;#x22;terminal.integrated.profiles.windows&amp;#x22;: {        &amp;#x22;Git Bash&amp;#x22;: { &amp;#x22;path&amp;#x22;: &amp;#x22;C:\\Program Files\\Git\\bin\\bash.exe&amp;#x22; }    },    &amp;#x22;terminal.integrated.defaultProfile.windows&amp;#x22;: &amp;#x22;Git Bash&amp;#x22;,    &amp;#x22;terminal.integrated.fontSize&amp;#x22;: 16,    &amp;#x22;terminal.integrated.scrollback&amp;#x22;: 10000, // lenght of how much we can scroll back    &amp;#x22;terminal.integrated.defaultLocation&amp;#x22;: &amp;#x22;editor&amp;#x22;,    &amp;#x22;explorer.confirmDelete&amp;#x22;: false,    &amp;#x22;explorer.confirmDragAndDrop&amp;#x22;: false,    &amp;#x22;explorer.compactFolders&amp;#x22;: false,    &amp;#x22;explorer.openEditors.visible&amp;#x22;: 1,    &amp;#x22;editor.wordWrap&amp;#x22;: &amp;#x22;on&amp;#x22;,    &amp;#x22;editor.formatOnSave&amp;#x22;: true,    &amp;#x22;editor.formatOnType&amp;#x22;: true,    &amp;#x22;editor.tabSize&amp;#x22;: 2,    &amp;#x22;editor.indentSize&amp;#x22;: 4,    &amp;#x22;editor.wrappingIndent&amp;#x22;: &amp;#x22;indent&amp;#x22;,    &amp;#x22;editor.inlineSuggest.enabled&amp;#x22;: true,    &amp;#x22;editor.bracketPairColorization.enabled&amp;#x22;: true,    &amp;#x22;editor.codeActionsOnSave&amp;#x22;: {        &amp;#x22;source.organizeImports&amp;#x22;: &amp;#x22;explicit&amp;#x22;    },    // indent guide (the vertical lines)    &amp;#x22;editor.guides.bracketPairs&amp;#x22;: true,    &amp;#x22;editor.guides.highlightActiveIndentation&amp;#x22;: true,    &amp;#x22;editor.guides.bracketPairsHorizontal&amp;#x22;: &amp;#x22;active&amp;#x22;,    // minimap    &amp;#x22;editor.minimap.enabled&amp;#x22;: true,    &amp;#x22;editor.minimap.autohide&amp;#x22;: true,    &amp;#x22;editor.minimap.renderCharacters&amp;#x22;: false,    &amp;#x22;editor.minimap.maxColumn&amp;#x22;: 100,    &amp;#x22;editor.cursorSurroundingLines&amp;#x22;: 10,    &amp;#x22;editor.glyphMargin&amp;#x22;: false, //  the breakpoint column    &amp;#x22;editor.linkedEditing&amp;#x22;: true, // auto rename tags    &amp;#x22;editor.stickyScroll.enabled&amp;#x22;: true,    &amp;#x22;workbench.tree.enableStickyScroll&amp;#x22;: true,    &amp;#x22;workbench.tree.stickyScrollMaxItemCount&amp;#x22;: 6,    &amp;#x22;workbench.sideBar.location&amp;#x22;: &amp;#x22;right&amp;#x22;,    &amp;#x22;workbench.activityBar.location&amp;#x22;: &amp;#x22;hidden&amp;#x22;,    &amp;#x22;workbench.layoutControl.enabled&amp;#x22;: false,    &amp;#x22;workbench.editor.pinnedTabSizing&amp;#x22;: &amp;#x22;shrink&amp;#x22;,    &amp;#x22;workbench.editor.enablePreview&amp;#x22;: false,    &amp;#x22;workbench.startupEditor&amp;#x22;: &amp;#x22;none&amp;#x22;,    &amp;#x22;workbench.colorTheme&amp;#x22;: &amp;#x22;Noctis Obscuro&amp;#x22;,    &amp;#x22;workbench.iconTheme&amp;#x22;: &amp;#x22;material-icon-theme&amp;#x22;,    &amp;#x22;workbench.tree.indent&amp;#x22;: 18,    &amp;#x22;workbench.tree.renderIndentGuides&amp;#x22;: &amp;#x22;always&amp;#x22;,    &amp;#x22;workbench.colorCustomizations&amp;#x22;: {        &amp;#x22;tab.activeBorderTop&amp;#x22;: &amp;#x22;#d5971a&amp;#x22;,        &amp;#x22;[Noctis Obscuro]&amp;#x22;: {            &amp;#x22;tab.activeBorderTop&amp;#x22;: &amp;#x22;#d5971a&amp;#x22;        },        // editor indent guide colors        &amp;#x22;editorBracketPairGuide.background1&amp;#x22;: &amp;#x22;#2a2a2a&amp;#x22;,        &amp;#x22;editorBracketPairGuide.background2&amp;#x22;: &amp;#x22;#2a2a2a&amp;#x22;,        &amp;#x22;editorBracketPairGuide.background3&amp;#x22;: &amp;#x22;#2a2a2a&amp;#x22;,        &amp;#x22;editorBracketPairGuide.background4&amp;#x22;: &amp;#x22;#2a2a2a&amp;#x22;,        &amp;#x22;editorBracketPairGuide.background5&amp;#x22;: &amp;#x22;#2a2a2a&amp;#x22;,        &amp;#x22;editorBracketPairGuide.background6&amp;#x22;: &amp;#x22;#2a2a2a&amp;#x22;,        &amp;#x22;editorBracketPairGuide.activeBackground1&amp;#x22;: &amp;#x22;#e4e4e4&amp;#x22;,        &amp;#x22;editorBracketPairGuide.activeBackground2&amp;#x22;: &amp;#x22;#e4e4e4&amp;#x22;,        &amp;#x22;editorBracketPairGuide.activeBackground3&amp;#x22;: &amp;#x22;#e4e4e4&amp;#x22;,        &amp;#x22;editorBracketPairGuide.activeBackground4&amp;#x22;: &amp;#x22;#e4e4e4&amp;#x22;,        &amp;#x22;editorBracketPairGuide.activeBackground5&amp;#x22;: &amp;#x22;#e4e4e4&amp;#x22;,        &amp;#x22;editorBracketPairGuide.activeBackground6&amp;#x22;: &amp;#x22;#e4e4e4&amp;#x22;,        &amp;#x22;tree.indentGuidesStroke&amp;#x22;: &amp;#x22;#0f707e&amp;#x22; // file explorer indent guides    },    &amp;#x22;files.autoSave&amp;#x22;: &amp;#x22;afterDelay&amp;#x22;,    &amp;#x22;files.autoSaveDelay&amp;#x22;: 100,    &amp;#x22;files.insertFinalNewline&amp;#x22;: true,    &amp;#x22;files.trimTrailingWhitespace&amp;#x22;: true,    &amp;#x22;window.commandCenter&amp;#x22;: false, // the mdiddle box in title bar    &amp;#x22;window.title&amp;#x22;: &amp;#x22; &amp;#x22;,    &amp;#x22;window.menuBarVisibility&amp;#x22;: &amp;#x22;compact&amp;#x22;,    &amp;#x22;diffEditor.renderSideBySide&amp;#x22;: false,    &amp;#x22;diffEditor.hideUnchangedRegions.enabled&amp;#x22;: true,    &amp;#x22;gitlens.menus&amp;#x22;: {        &amp;#x22;editorGroup&amp;#x22;: false,        &amp;#x22;scmItemInline&amp;#x22;: {            &amp;#x22;stash&amp;#x22;: false        }    },    &amp;#x22;gitlens.statusBar.enabled&amp;#x22;: false,    &amp;#x22;gitlens.codeLens.enabled&amp;#x22;: false,    &amp;#x22;remote.SSH.connectTimeout&amp;#x22;: 100,    // aVim    &amp;#x22;amVim.useSystemClipboard&amp;#x22;: true,    &amp;#x22;amVim.smartRelativeLineNumbers&amp;#x22;: true,    //auto close tags    &amp;#x22;html.autoClosingTags&amp;#x22;: true,    &amp;#x22;javascript.autoClosingTags&amp;#x22;: true,    &amp;#x22;typescript.autoClosingTags&amp;#x22;: true,    // auto imports    &amp;#x22;javascript.suggest.autoImports&amp;#x22;: true,    &amp;#x22;typescript.suggest.autoImports&amp;#x22;: true,    &amp;#x22;javascript.updateImportsOnFileMove.enabled&amp;#x22;: &amp;#x22;always&amp;#x22;,    &amp;#x22;typescript.updateImportsOnFileMove.enabled&amp;#x22;: &amp;#x22;always&amp;#x22;,    &amp;#x22;javascript.preferences.quoteStyle&amp;#x22;: &amp;#x22;single&amp;#x22;,    &amp;#x22;typescript.preferences.quoteStyle&amp;#x22;: &amp;#x22;single&amp;#x22;,    &amp;#x22;html.completion.attributeDefaultValue&amp;#x22;: &amp;#x22;singlequotes&amp;#x22;,    &amp;#x22;css.lint.unknownAtRules&amp;#x22;: &amp;#x22;ignore&amp;#x22;,    &amp;#x22;liveServer.settings.donotShowInfoMsg&amp;#x22;: true,}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;</content:encoded></item><item><title>PWA Basics</title><link>https://chaitanyavaru.com/blogs/progressive-web-app-basics</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/progressive-web-app-basics</guid><description>Basics of making progressive web apps</description><pubDate>Sat, 06 May 2023 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;what-is-a-pwa&quot;&gt;What is a PWA?&lt;/h2&gt;
&lt;p&gt;Progressive Web Apps (PWA) is a way by which we can run our websites outside of the browser like native apps. They can be accessed from a user’s home screen or app drawer, just like native apps.&lt;/p&gt;
&lt;h2 id=&quot;why-pwa&quot;&gt;Why PWA?&lt;/h2&gt;
&lt;p&gt;PWAs have fast load times, work offline, and can be accessed from anywhere without the need for a specific app store&lt;/p&gt;
&lt;h2 id=&quot;some-examples-of-pwa&quot;&gt;Some examples of PWA&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://squoosh.app&quot;&gt;Squoosh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.pinterest.com&quot;&gt;Pinterest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://open.spotify.com&quot;&gt;Spotify&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;main-parts-of-a-pwa&quot;&gt;Main parts of a PWA&lt;/h2&gt;
&lt;p&gt;There are 3 main parts of a PWA:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Web App&lt;/li&gt;
&lt;li&gt;Manifest File&lt;/li&gt;
&lt;li&gt;Service Worker&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;web-app&quot;&gt;Web App&lt;/h2&gt;
&lt;p&gt;It is the regular website part that we usually write.&lt;/p&gt;
&lt;p&gt;In the HTML file, add following tags in the head section&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;html&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:92ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;viewport&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;width=device-width, initial-scale=1.0, viewport-fit=cover&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;&amp;#x3C;!-- we can change this theme color using JS, but not the one in manifest file  --&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;theme-color&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;#ed6606&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;manifest&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;./app.webmanifest&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;apple-touch-icon&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;./assets/icons/icon_512.png&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;./sw-registerer.js&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;&lt;meta name=&amp;#x22;viewport&amp;#x22; content=&amp;#x22;width=device-width, initial-scale=1.0, viewport-fit=cover&amp;#x22; /&gt;&lt;!-- we can change this theme color using JS, but not the one in manifest file  --&gt;&lt;meta name=&amp;#x22;theme-color&amp;#x22; content=&amp;#x22;#ed6606&amp;#x22; /&gt;&lt;link rel=&amp;#x22;manifest&amp;#x22; href=&amp;#x22;./app.webmanifest&amp;#x22; /&gt;&lt;link rel=&amp;#x22;apple-touch-icon&amp;#x22; href=&amp;#x22;./assets/icons/icon_512.png&amp;#x22; /&gt;&lt;script src=&amp;#x22;./sw-registerer.js&amp;#x22;&gt;&lt;/script&gt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;manifest-file&quot;&gt;Manifest File&lt;/h2&gt;
&lt;p&gt;It is a JSON file which acts as the metadata of our app. By convention it is named as manifest.json or app.webmanifest. It is used to provide the browser with information about how the PWA should be installed and displayed to the user.
Some of the important fields are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt;: this is the full name of our PWA&lt;/li&gt;
&lt;li&gt;&lt;code&gt;short_name&lt;/code&gt;: this is the name that will be displayed as the app name on the home screen&lt;/li&gt;
&lt;li&gt;&lt;code&gt;icons&lt;/code&gt;: it is an array which contains all the icons that will be used for our app. Each icon should have these 3 fields &lt;code&gt;src&lt;/code&gt;, &lt;code&gt;sizes&lt;/code&gt;, &lt;code&gt;type&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;One icon should have the purpose as &lt;code&gt;any&lt;/code&gt; which will be used as the icon for the splash screen&lt;/li&gt;
&lt;li&gt;One icon should have the purpose as &lt;code&gt;maskable&lt;/code&gt; which will be used as the icon for the splash screen&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;start_url&lt;/code&gt;: the url from where our app will start&lt;/li&gt;
&lt;li&gt;&lt;code&gt;display&lt;/code&gt;: it is the display mode of our app. Usually kept as &lt;code&gt;standalone&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;theme_color&lt;/code&gt;: it is the color of the status bar when the app runs outside of the browser&lt;/li&gt;
&lt;li&gt;&lt;code&gt;background_color&lt;/code&gt;: it is the color of the splash screen&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scope&lt;/code&gt;: scope determines where the service worker will be active&lt;/li&gt;
&lt;li&gt;&lt;code&gt;orientation&lt;/code&gt;: it is the orientation of the app. Usually kept as &lt;code&gt;portrait&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;description&lt;/code&gt;: description will be desplayd when the user installs the app&lt;/li&gt;
&lt;li&gt;&lt;code&gt;screenshots&lt;/code&gt;: screenshots will be desplayd when the user installs the app. Structure is similar to the icons array&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;service-worker&quot;&gt;Service Worker&lt;/h2&gt;
&lt;p&gt;Service Worker is just a javascript file running in its own thread that will act as a middleware offering a local installed web server or web proxy for your PWA.
Basically it is is like a web server installed in client side.&lt;/p&gt;
&lt;p&gt;In native app, we download all resources together as a package, and it works offline. In web apps, we download HTML, then browser downloads resources on demand, and it doesn’t work offline since it doesn’t have all the required resources.&lt;/p&gt;
&lt;p&gt;In PWA, we download HTML. HTML then registers a service worker. service worker installs some resources &amp;#x26; browser installs other resources on demand. Now this works offline since service worker has installed the required resources to run app.&lt;/p&gt;
&lt;p&gt;Service worker caches the required resources which can be used to serve even when there is no internet connection.&lt;/p&gt;
&lt;p&gt;It is installed by the web page and doesn’t require user permission to be installed.&lt;/p&gt;
&lt;h3 id=&quot;registering-a-service-worker&quot;&gt;Registering a service worker&lt;/h3&gt;
&lt;p&gt;In the head section of the HTML file, add &lt;code&gt;&amp;#x3C;script src=&quot;./sw-registerer.js&quot;&gt;&amp;#x3C;/script&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;We are using a serviceworker registerer file because if we directly add the serviceworker to the HTML file then it wil be in the same thread and not a separate thread.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:57ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;serviceWorker&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;navigator&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;navigator&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;serviceWorker&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;register&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;./serviceworker.js&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;if (&amp;#x22;serviceWorker&amp;#x22; in navigator) {  navigator.serviceWorker.register(&amp;#x22;./serviceworker.js&amp;#x22;);}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;useful-resources-for-making-pwa&quot;&gt;Useful resources for making PWA&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://maskable.app&quot;&gt;Maskable Icon Maker&lt;/a&gt;: it helps to check if our icon is maskable or not, and also helps to make the icon maskable&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/learn/pwa/&quot;&gt;PWA tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Promise in Javascript</title><link>https://chaitanyavaru.com/blogs/promise-in-js</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/promise-in-js</guid><description>explanation of promise in javascript in simple easy to understand words</description><pubDate>Thu, 02 Mar 2023 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;what-is-promise&quot;&gt;What is promise?&lt;/h2&gt;
&lt;p&gt;Promise is a special object that represents a future value of an asynchronous operation, the value could be a success or failure.&lt;/p&gt;
&lt;p&gt;Now to handle promise, 2 most common methods are either using callbacks or async/await&lt;/p&gt;
&lt;h2 id=&quot;callback&quot;&gt;&lt;strong&gt;Callback&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;We use &lt;code&gt;.then()&lt;/code&gt; after the promise to tell javascript what needs to be done after the has resolved/rejected. It takes 2 callbacks &lt;code&gt;onResolve&lt;/code&gt; and &lt;code&gt;onReject&lt;/code&gt; (usually omitted)&lt;/p&gt;
&lt;p&gt;eg&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:76ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;fetch&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;https://dummyjson.com/carts?limit=5&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;then&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(data &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;})&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(err &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;err&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;})&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;hum first, hum first &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// this will appear first in console&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;fetch(&amp;#x22;https://dummyjson.com/carts?limit=5&amp;#x22;)    .then(data =&gt; {        console.log(data)    })    .catch(err =&gt; {        console.log(err);    })console.log(&amp;#x22;hum first, hum first \n&amp;#x22;); // this will appear first in console&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;asyncawait&quot;&gt;&lt;strong&gt;Async/Await&lt;/strong&gt;&lt;/h2&gt;
&lt;h3 id=&quot;async&quot;&gt;Async&lt;/h3&gt;
&lt;p&gt;It tells javascript that this is an asynchronous function. An async function always returns a promise.&lt;/p&gt;
&lt;h3 id=&quot;await&quot;&gt;Await&lt;/h3&gt;
&lt;p&gt;It tells javascript to wait for an asynchronous action to finish before continuing the function. With this we can write asynchronous code in a synchronous manner. It is used instead of &lt;code&gt;.then()&lt;/code&gt;. It works only inside async function.&lt;/p&gt;
&lt;p&gt;eg&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:105ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getCurrentTabData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; () &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tabs&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;chrome&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tabs&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;({ active: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, currentWindow: &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; });&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;requiredData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; { title: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tabs&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, url: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tabs&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; };&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;requiredData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;};&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;someFunction&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(){&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getCurrentTabData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;//❌ we won&apos;t get the expected value&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data2&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getCurrentTabData&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(); &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;//✔ as we wait for promise to resolve, we get expected value&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;const getCurrentTabData = async () =&gt; {    const tabs = await chrome.tabs.query({ active: true, currentWindow: true });    const requiredData = { title: tabs[0].title, url: tabs[0].url };    return requiredData;};async function someFunction(){    const data1 = getCurrentTabData() //❌ we won&amp;#x27;t get the expected value    const data2 = await getCurrentTabData(); //✔ as we wait for promise to resolve, we get expected value}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;summarizing-this-with-an-analogy&quot;&gt;Summarizing this with an analogy.&lt;/h2&gt;
&lt;p&gt;Suppose we go to a self-service restaurant and order Cheese Kulcha [&lt;em&gt;we invoked an asynchronous function&lt;/em&gt;].&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Then the receptionist will give us a token [&lt;em&gt;we got a promise in return&lt;/em&gt;].&lt;/li&gt;
&lt;li&gt;Now either we do some other work until our turn arrives [&lt;em&gt;callback&lt;/em&gt;] or wait [&lt;em&gt;async/await&lt;/em&gt;].&lt;/li&gt;
&lt;li&gt;When our turn comes and we go to take the order, these two possibilities may occur
&lt;ul&gt;
&lt;li&gt;We get our order [&lt;em&gt;promise is fulfilled / resolved, we get the value which we expected&lt;/em&gt;]&lt;/li&gt;
&lt;li&gt;The receptionist may say that due to some reasons order could not be prepared (gas khatm ho gaya hoga) [&lt;em&gt;promise is rejected, and we got a reason of error&lt;/em&gt;]&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Updating Node</title><link>https://chaitanyavaru.com/blogs/update-node</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/update-node</guid><description>Updating node on your system</description><pubDate>Tue, 15 Aug 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Keeping your Node.js version up to date is essential to ensure security and take advantage of the latest features. You can check current node version using the command &lt;code&gt;node --version&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;There are multiple ways of updating the node version in our system. Here are some of them:&lt;/p&gt;
&lt;h2 id=&quot;updating-via-nvm-node-version-manager&quot;&gt;Updating via NVM (Node Version Manager)&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;install nvm:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:79ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;-o-&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;start nvm:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:20ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;~/.nvm/nvm.sh&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;source ~/.nvm/nvm.sh&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;specify node version:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:14ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nvm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;install&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;18&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;nvm install 18&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;use it:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:10ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nvm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;18&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;nvm use 18&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Thats it! You can verify the version using &lt;code&gt;node -v&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;manual-update-from-the-official-website&quot;&gt;Manual Update from the Official Website:&lt;/h2&gt;
&lt;p&gt;You can also update Node.js manually by following these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Visit the &lt;a href=&quot;https://nodejs.org/&quot;&gt;official Node.js website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Download the latest stable version.&lt;/li&gt;
&lt;li&gt;Run the installer and follow the instructions.&lt;/li&gt;
&lt;/ol&gt;</content:encoded></item><item><title>What are SSH keys?</title><link>https://chaitanyavaru.com/blogs/what-are-ssh-keys</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/what-are-ssh-keys</guid><description>What are SSH keys. Steps to create SSH key and add it to github</description><pubDate>Mon, 01 May 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Secure Socket Shell (SSH) keys are mainly used to access systems remotely, without the need for a password.&lt;/p&gt;
&lt;p&gt;SSH keys are generated in pairs, public &amp;#x26; private key. The private key is kept on the local system and the public key is uploaded to the remote system.&lt;/p&gt;
&lt;p&gt;When accessing the remote system, it will use the public key to encrypt a message that can only be decrypted by the private key. If the local system decrypts the message successfully, the remote system will grant access.&lt;/p&gt;
&lt;h2 id=&quot;generating-ssh-key&quot;&gt;Generating SSH key&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$ ssh-keygen -t ed25519 -C &quot;your_email@example.com&quot; -f ~/.ssh/&amp;#x3C;file_name&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;-t specifies the type of encryption&lt;/li&gt;
&lt;li&gt;-C is for comment, write email id so that you can identify the key&lt;/li&gt;
&lt;li&gt;-f specifies the file name&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$ eval $(ssh-agent -s)&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to run the ssh-agent&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$ ssh-add ~/.ssh/fileName&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;in macOS add -k&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$ clip &amp;#x3C; ~/.ssh/fileName.pub&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;copy the content from the file to clipboard&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;adding-ssh-key-to-github&quot;&gt;Adding SSH key to github&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Go to settings in github&lt;/li&gt;
&lt;li&gt;Go to SSH and GPG keys&lt;/li&gt;
&lt;li&gt;Click on New SSH key button&lt;/li&gt;
&lt;li&gt;Give title to the system&lt;/li&gt;
&lt;li&gt;Paste the content from clipboard&lt;/li&gt;
&lt;li&gt;Done&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Improve blog reading by adding &apos;Other Posts&apos; section in Astro blog</title><link>https://chaitanyavaru.com/blogs/adding-other-posts-in-astro-blog</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/adding-other-posts-in-astro-blog</guid><description>How to add &apos;other posts&apos;/&apos;similar posts&apos; to your astro blog</description><pubDate>Sun, 21 Apr 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In this post, I will walk you through how I added ‘Other Posts you may like’ section in astro blog. Initially I wanted to have a ‘similar posts’ section, which would display posts which have same tags.&lt;/p&gt;
&lt;h2 id=&quot;but-why-to-have-similar-posts-section&quot;&gt;But why to have similar posts section?&lt;/h2&gt;
&lt;p&gt;While visting several blogs, I observed that I am reading more posts if there’s a list below compared to me going to all posts page and then reading them. Hence I thought to add one to my blog as well.&lt;/p&gt;
&lt;h2 id=&quot;iteration-1&quot;&gt;Iteration 1&lt;/h2&gt;
&lt;p&gt;First I added one function which gets all posts, filters them based on tag and then removes the post which we are already viewing.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;ts&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:114ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;similarPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(tag&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, excludingTitle&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// get all posts&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;blogPostList&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getBlogList&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// filter posts based on tag&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;similarPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;blogPostList&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;filter&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;((post) &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;?.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;includes&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tag&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;))&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// remove post based on title&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;excludingTitle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;!==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;similarPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;similarPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;filter&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(post &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;!==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;excludingTitle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;similarPosts&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;export async function similarPosts(tag: string, excludingTitle: string = &amp;#x27;&amp;#x27;) {  // get all posts  const blogPostList = await getBlogList()  // filter posts based on tag  let similarPosts = blogPostList.filter((post) =&gt; post.data.tags?.includes(tag))  // remove post based on title  if (excludingTitle !== &amp;#x27;&amp;#x27;) return similarPosts = similarPosts.filter(post =&gt; post.data.title !== excludingTitle)  return similarPosts}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;But it was looking incomplete. Some posts would have similar posts but many didn’t had any. So I changed the plan from ‘similar posts’ to ‘other posts you may like’.&lt;/p&gt;
&lt;p&gt;With that, if there are less or no similar posts then I could display few recent posts in the list.&lt;/p&gt;
&lt;h2 id=&quot;iteration-2&quot;&gt;Iteration 2&lt;/h2&gt;
&lt;p&gt;I added this function&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;ts&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:104ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;processedSimilarPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(tags&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[], excludingTitle&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;MINIMUM_NUMBER_OF_SIMILAR_POSTS&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;3&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;any&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[] &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; []&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// get similar posts of all tags&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tag&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tags&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;blogPostList&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;similarPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;tag&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;excludingTitle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;blogPostList&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// return posts if they are more than decided count&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.length &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;MINIMUM_NUMBER_OF_SIMILAR_POSTS&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;remainingPostsToFill&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;Math&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.length &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;MINIMUM_NUMBER_OF_SIMILAR_POSTS&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// again get all posts&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;additionalPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getBlogList&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// and then filter them if it is current post OR if it is already present in from the tag&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;additionalPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;additionalPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;filter&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(post &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;excludingTitle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;false&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;postExistsInOtherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;some&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(otherPost &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPost&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;slug&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;slug&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;postExistsInOtherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;})&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// take only the required number of posts&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;additionalPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;splice&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;remainingPostsToFill&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;combinedPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;otherPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;additionalPosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;combinedPosts&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;export async function processedSimilarPosts(tags: string[], excludingTitle: string = &amp;#x27;&amp;#x27;) {  const MINIMUM_NUMBER_OF_SIMILAR_POSTS = 3  let otherPosts: any[] = []  // get similar posts of all tags  for (const tag of tags) {    const blogPostList = await similarPosts(tag, excludingTitle)    otherPosts = [...otherPosts, ...blogPostList]  }  // return posts if they are more than decided count  if (otherPosts.length &gt;= MINIMUM_NUMBER_OF_SIMILAR_POSTS) return otherPosts  const remainingPostsToFill = Math.abs(otherPosts.length - MINIMUM_NUMBER_OF_SIMILAR_POSTS)  // again get all posts  let additionalPosts = await getBlogList()  // and then filter them if it is current post OR if it is already present in from the tag  additionalPosts = additionalPosts.filter(post =&gt; {    if (post.data.title === excludingTitle) return false    const postExistsInOtherPosts = otherPosts.some(otherPost =&gt; otherPost.data.slug === post.data.slug);    return !postExistsInOtherPosts;  })  // take only the required number of posts  additionalPosts.splice(remainingPostsToFill)  const combinedPosts = [...otherPosts, ...additionalPosts]  return combinedPosts}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;iteration-3&quot;&gt;Iteration 3&lt;/h2&gt;
&lt;p&gt;Later, I also added this function to remove duplicates because one post could have multiple tags.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;ts&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:51ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;removeDuplicatePosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(posts&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;any&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[]) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;titleMap&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;Map&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;any&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;of&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;posts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;postTitle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;title&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;titleMap&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;has&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;postTitle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;titleMap&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;postTitle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;uniquePosts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;Array&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;titleMap&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;values&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;())&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;uniquePosts&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;function removeDuplicatePosts(posts: any[]) {  const titleMap = new Map&lt;string, any&gt;()  for (const post of posts) {    const postTitle = post.data.title    if (!titleMap.has(postTitle)) {      titleMap.set(postTitle, post)    }  }  const uniquePosts = Array.from(titleMap.values())  return uniquePosts}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Now, I could just call processedSimilarPosts function and map over the result to display posts.&lt;/p&gt;
&lt;p&gt;&lt;sup&gt;&lt;sub&gt;Live example below 👇 &lt;/sub&gt;&lt;/sup&gt;&lt;/p&gt;</content:encoded></item><item><title>Data structure before code</title><link>https://chaitanyavaru.com/blogs/data-structure-before-code</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/data-structure-before-code</guid><description>Focus on the structure before code</description><pubDate>Sat, 13 Jul 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Last evening, I was reading &lt;a href=&quot;https://read.engineerscodex.com/p/good-programmers-worry-about-data&quot;&gt;this article&lt;/a&gt; from &lt;a href=&quot;https://read.engineerscodex.com&quot;&gt;Engineer’s Codex&lt;/a&gt; newsletter. In it, I read this quote by Linus Torvalds.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Bad programmers worry about the code. Good programmers worry about data structures and their relationships. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Article was about focusing on how we store the data first and then writing the code, to make it more maintainable.&lt;/p&gt;
&lt;p&gt;Initially, I didn’t understand the article much, but then I remembered a meeting I had with a senior developer that morning. After which, article was a lot clearer.&lt;/p&gt;
&lt;h2 id=&quot;meeting-with-senior-developer&quot;&gt;Meeting with senior developer&lt;/h2&gt;
&lt;p&gt;We were discussing about some issue, and then at one point, he was refactored some code that I had written. It was a service which would access different buckets based on the environment.&lt;/p&gt;
&lt;p&gt;Here’s what I had originally written:&lt;/p&gt;
&lt;p&gt;&lt;small&gt;Note: Excluded some code for brevity.&lt;/small&gt;&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;ruby&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:41ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;SomeClass&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &amp;#x3C; &lt;/span&gt;&lt;span style=&quot;--0:#9498D4&quot;&gt;ApplicationRecord&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;self.get_bucket_name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(environment)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; environment &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;staging&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;STAGING_BUCKET_NAME&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;elsif&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; environment &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;pre-production&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRE_PRODUCTION_BUCKET_NAME&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;elsif&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; environment &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;production&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRODUCTION_BUCKET_NAME&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;self.get_public_url&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(environment)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; environment &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;staging&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;STAGING_PUBLIC_URL&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;elsif&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; environment &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;pre-production&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRE_PRODUCTION_PUBLIC_URL&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;elsif&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; environment &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;production&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRODUCTION_PUBLIC_URL&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# Usage&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;SomeClass&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;get_bucket_name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(environment)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;SomeClass&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;get_public_url&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(environment)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;class SomeClass &lt; ApplicationRecord  def self.get_bucket_name(environment)    if environment == &amp;#x27;staging&amp;#x27;      ENV[&amp;#x27;STAGING_BUCKET_NAME&amp;#x27;]    elsif environment == &amp;#x27;pre-production&amp;#x27;      ENV[&amp;#x27;PRE_PRODUCTION_BUCKET_NAME&amp;#x27;]    elsif environment == &amp;#x27;production&amp;#x27;      ENV[&amp;#x27;PRODUCTION_BUCKET_NAME&amp;#x27;]    end  end  def self.get_public_url(environment)    if environment == &amp;#x27;staging&amp;#x27;      ENV[&amp;#x27;STAGING_PUBLIC_URL&amp;#x27;]    elsif environment == &amp;#x27;pre-production&amp;#x27;      ENV[&amp;#x27;PRE_PRODUCTION_PUBLIC_URL&amp;#x27;]    elsif environment == &amp;#x27;production&amp;#x27;      ENV[&amp;#x27;PRODUCTION_PUBLIC_URL&amp;#x27;]    end  endend# UsageSomeClass.get_bucket_name(environment)SomeClass.get_public_url(environment)&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Since the values were constant, he moved them into a hash.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;ruby&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:55ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;SomeClass&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &amp;#x3C; &lt;/span&gt;&lt;span style=&quot;--0:#9498D4&quot;&gt;ApplicationRecord&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;CONFIGURATION&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;staging&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; =&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;bucket_name:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;STAGING_BUCKET_NAME&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;],&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;public_url:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;STAGING_PUBLIC_URL&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;pre-production&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; =&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;bucket_name:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRE_PRODUCTION_BUCKET_NAME&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;],&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;public_url:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRE_PRODUCTION_PUBLIC_URL&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;production&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; =&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;bucket_name:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRODUCTION_BUCKET_NAME&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;],&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;public_url:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;PRODUCTION_PUBLIC_URL&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# Usage&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;SomeClass&lt;/span&gt;&lt;span style=&quot;--0:#9498D4&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;CONFIGURATION&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dig&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(environment, &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;:bucket_name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;SomeClass&lt;/span&gt;&lt;span style=&quot;--0:#9498D4&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;CONFIGURATION&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dig&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(environment, &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;:public_url&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;class SomeClass &lt; ApplicationRecord  CONFIGURATION = {    &amp;#x27;staging&amp;#x27; =&gt; {      bucket_name: ENV[&amp;#x27;STAGING_BUCKET_NAME&amp;#x27;],      public_url: ENV[&amp;#x27;STAGING_PUBLIC_URL&amp;#x27;]    },    &amp;#x27;pre-production&amp;#x27; =&gt; {      bucket_name: ENV[&amp;#x27;PRE_PRODUCTION_BUCKET_NAME&amp;#x27;],      public_url: ENV[&amp;#x27;PRE_PRODUCTION_PUBLIC_URL&amp;#x27;]    },    &amp;#x27;production&amp;#x27; =&gt; {      bucket_name: ENV[&amp;#x27;PRODUCTION_BUCKET_NAME&amp;#x27;],      public_url: ENV[&amp;#x27;PRODUCTION_PUBLIC_URL&amp;#x27;]    }  }end# UsageSomeClass::CONFIGURATION.dig(environment, :bucket_name)SomeClass::CONFIGURATION.dig(environment, :public_url)&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Now instead of two functions, everything was in a single hash. This definitely made the code more readable and maintable.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Now onwards, I will now try to refactor to be more clear.&lt;/p&gt;</content:encoded></item><item><title>Git cherry-pick</title><link>https://chaitanyavaru.com/blogs/git-cherry-pick</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/git-cherry-pick</guid><description>Git cherry-pick bascic usage</description><pubDate>Fri, 31 May 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Many times we need to move some commits from one branch to another. For example, you added commits for issue-1 in the branch of issue-2.  One way to fix this is by using git cherry-pick.&lt;/p&gt;
&lt;p&gt;This command creates a new commit with changes of specified commit(s).&lt;/p&gt;
&lt;h2 id=&quot;commit-hash&quot;&gt;Commit Hash&lt;/h2&gt;
&lt;p&gt;Git identifies each commit by a SHA-1 hash. It consists of 40 characters (61e42590b8d5e6691c311b47960be54c09b0583e). The hash can also be abbreviated to the first 7 characters (61e4259).&lt;/p&gt;
&lt;p&gt;Commit hash can be found using &lt;code&gt;git log&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;
&lt;h3 id=&quot;apply-single-commit&quot;&gt;Apply single commit&lt;/h3&gt;
&lt;p&gt;To apply commit from another branch to current branch, we just give the commit hash as an argument&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:25ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;cherry-pick&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;04527c084&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git cherry-pick 04527c084&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Now that commit will be applied to current branch&lt;/p&gt;
&lt;h3 id=&quot;apply-multiple-commits&quot;&gt;Apply multiple commits&lt;/h3&gt;
&lt;p&gt;When we have to move multiple commits,  we can pass all those to the command in order oldest to latest.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:45ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;cherry-pick&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;04527c084&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;68a0ffffd&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;0998c7ea4&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git cherry-pick 04527c084 68a0ffffd 0998c7ea4&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Alternately, we can give the range of the commits instead of writing all the hashes&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:36ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;cherry-pick&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;04527c084..0998c7ea4&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git cherry-pick 04527c084..0998c7ea4&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h3 id=&quot;edit-commit-before-applying&quot;&gt;Edit commit before applying&lt;/h3&gt;
&lt;p&gt;Sometimes, we want to add the commit but with some additional changes before committing it. For that, we can use —no-commit flag.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:37ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;cherry-pick&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;--no-commit&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;04527c084&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git cherry-pick --no-commit 04527c084&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;This will get the changes but will not commit them to current branch.&lt;/p&gt;
&lt;h2 id=&quot;caution&quot;&gt;Caution&lt;/h2&gt;
&lt;p&gt;Use cherry-pick with caution. Avoid using it in branches that are to be merged, as it could cause merge conflicts.&lt;/p&gt;</content:encoded></item><item><title>Using git rebase for altering git timeline</title><link>https://chaitanyavaru.com/blogs/git-rebase</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/git-rebase</guid><description>An introduction to git rebase</description><pubDate>Sun, 25 Aug 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/2gta5IZ.jpeg&quot; alt=&quot;doctor strange&quot;&gt;&lt;/p&gt;
&lt;p&gt;With time stone, Dr Strange can alter reality. With &lt;code&gt;rebase&lt;/code&gt;, you can alter reality, though it only alters history of your git repository.&lt;/p&gt;
&lt;p&gt;In this article, we’ll look at what &lt;code&gt;rebase&lt;/code&gt; is, how it works and how to use it.&lt;/p&gt;
&lt;h2 id=&quot;syntax&quot;&gt;Syntax&lt;/h2&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:24ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rebase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&amp;#x3C;base-branch&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git rebase &lt;base-branch&gt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;This command changes the starting point (base) of your current branch to the specified branch.&lt;/p&gt;
&lt;h2 id=&quot;why-rebase-instead-of-merge&quot;&gt;Why Rebase instead of Merge&lt;/h2&gt;
&lt;p&gt;The most common use case for rebase is to get the latest changes of the base branch into your feature branch.&lt;/p&gt;
&lt;p&gt;Suppose you started working on an issue. You created &lt;code&gt;feature&lt;/code&gt; branch from &lt;code&gt;main&lt;/code&gt; branch. After some time, &lt;code&gt;main&lt;/code&gt; got new commits by other developers.&lt;/p&gt;
&lt;p&gt;Now to get those commits, you would&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to base branch and get the updates from remote to local&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:21ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:1ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;pull&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;origin&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;main&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git pull origin main&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Then go to feature branch and rebase:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:15ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rebase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;main&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git rebase main&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;This way, you less likely to get any conflicts while raising a pull request (since you would have already fixed them while rebasing). And will have a linear git history.&lt;/p&gt;
&lt;p&gt;When we merge to get latest changes of base branch into current branch, we get extra ‘merge commits’. These could be avoided by rebase.&lt;/p&gt;
&lt;h2 id=&quot;how-rebase-works&quot;&gt;How rebase works&lt;/h2&gt;
&lt;p&gt;&lt;img  src=&quot;/_astro/rebase.CM-GbRPI_Z29IKbj.svg&quot; alt=&quot;git rebase workflow&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;1527&quot; height=&quot;1137&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now that we understand why rebase is useful, let’s see what git actually does while rebasing:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Puts your commits in a temporary area&lt;/li&gt;
&lt;li&gt;It then updates current branch to match the base branch&lt;/li&gt;
&lt;li&gt;And then one by one, adds your commits on top of updated branch&lt;/li&gt;
&lt;li&gt;If there is any conflict while adding a commit, then we have to fix it and add the files to staging area. After that we continue rebase&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:21ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rebase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;--continue&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git rebase --continue&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Note: Although the content of the commit is same, each reapplied commit is a new commit, resulting in a different commit hash.&lt;/p&gt;
&lt;h2 id=&quot;avoid-common-pitfalls&quot;&gt;Avoid common pitfalls&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Don’t rebase in shared branches&lt;/strong&gt;: Rebase only in your own branch. Otherwise, it could cause problems for people who were working based on that previous history&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Force push&lt;/strong&gt;: In case you had pushed commits to remote before rebase, then you will have to force push
&lt;ul&gt;
&lt;li&gt;At that point avoid &lt;code&gt;--force&lt;/code&gt; as it could cause irreveraible changes&lt;/li&gt;
&lt;li&gt;Instead use &lt;code&gt;--force-with-lease&lt;/code&gt; which ensures that you don’t overwrite others’ commits, by verifying that no one else has pushed changes since your last pull&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;undo-rebase-with-reflog&quot;&gt;Undo rebase with reflog&lt;/h3&gt;
&lt;p&gt;In case any commits are lost or you want to undo the rebase, then you can use &lt;code&gt;git reflog&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Reflog, short for reference log, tracks changes to HEAD in your local repository. Using these logs, we can revert our branch to its previous condition&lt;/p&gt;
&lt;p&gt;For example, these are the reflog after feature branch was rebased with main branch.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:84ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;df3a1a1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (HEAD -&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;feature&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;0}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rebase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (finish): returning to refs/heads/feature&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;df3a1a1&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (HEAD -&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;feature&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;) HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;1}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rebase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (pick): feature commit 2&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;231d8fc&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rebase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (pick): feature commit 1&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;0f4b92f&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (main) HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;3}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rebase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (start): checkout main&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;a73d641&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;checkout:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;moving&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;feature&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;0f4b92f&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (main) HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;5}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;b&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;06cfab3&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;a&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;fa670ea&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;checkout:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;moving&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;feature&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;main&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;a73d641&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;feature&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;1961335&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;feature&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;fa670ea&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;checkout:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;moving&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;feature&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;fa670ea&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;HEAD@{&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;}:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;commit&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;3&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;df3a1a1 (HEAD -&gt; feature) HEAD@{0}: rebase (finish): returning to refs/heads/featuredf3a1a1 (HEAD -&gt; feature) HEAD@{1}: rebase (pick): feature commit 2231d8fc HEAD@{2}: rebase (pick): feature commit 10f4b92f (main) HEAD@{3}: rebase (start): checkout maina73d641 HEAD@{4}: checkout: moving from main to feature0f4b92f (main) HEAD@{5}: commit: commit b06cfab3 HEAD@{6}: commit: commit afa670ea HEAD@{7}: checkout: moving from feature to maina73d641 HEAD@{8}: commit: feature commit 21961335 HEAD@{9}: commit: feature commit 1fa670ea HEAD@{10}: checkout: moving from main to featurefa670ea HEAD@{11}: commit: commit 3&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;There are rebase commits and before them, there is a ‘&lt;em&gt;checkout: moving from …&lt;/em&gt;’. This is the commit before rebase started.&lt;/p&gt;
&lt;p&gt;Move the HEAD to that commit, ie reset the state of branch to that state.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:30ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt; reset &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;--hard&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt; &amp;#x3C;commit-id&gt;`&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;&amp;#x60;git reset --hard &lt;commit-id&gt;&amp;#x60;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Thats it! Now your branch will be back to the state before the rebase.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Rebase is a very powerful command that can make project history cleaner. But before using it in a shared repository, practice and understand it in your personal repository to avoid any data loss.&lt;/p&gt;</content:encoded></item><item><title>Never Assume, Always Check</title><link>https://chaitanyavaru.com/blogs/never-assume-always-check</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/never-assume-always-check</guid><description>My learnings while working with external data</description><pubDate>Fri, 14 Jun 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Last week, I worked on a ticket where I was requesting data from frontend to backend. There was also an nginx server between them. Backend was a Rails API, and frontend was Rails application with javascript for interactivity.&lt;/p&gt;
&lt;p&gt;After deploying the backend on server, I got CORS error when making requests.&lt;/p&gt;
&lt;p&gt;Before deploying, I had tested it locally and the service worked. Since nginx was not involved locally, my first thought was that the problem must be with nginx server. It must not be passing the cors headers, since in the API’s cors policy the frontend was allowed.&lt;/p&gt;
&lt;p&gt;I spent lot of time checking for that, but found nothing.&lt;/p&gt;
&lt;p&gt;Then I moved to javascript part, which was an ajax request. In its &lt;code&gt;error&lt;/code&gt; section, if status was ‘404’ then another function had to be called else just print the statusText.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:33ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;error: &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(error) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;status&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;404&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; ) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// do something&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;statusText&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;error: function(error) {  if (error.status === 404 ) {    // do something  }  else {    console.log(error.statusText)  }}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Somehow, the browser console showed a status of 404, so I continued working, assuming it was actually a 404 error. After sometime, I checked the status with console.log and found it was 0 🤯.&lt;/p&gt;
&lt;p&gt;Later, the bug was fixed.&lt;/p&gt;
&lt;h2 id=&quot;learning&quot;&gt;Learning&lt;/h2&gt;
&lt;p&gt;With this issue, I realised that to always check and validate the values that you are getting. Especially when you receive them from  outside of your server.&lt;/p&gt;</content:encoded></item><item><title>Streamline API development with Postman Scripts</title><link>https://chaitanyavaru.com/blogs/postman-scripts</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/postman-scripts</guid><description>An introduction to postman variables and postman scripts</description><pubDate>Sat, 19 Oct 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Postman is a useful tool for API development that allows us to make requests to an API. However, when building APIs, we frequently update parameters &amp;#x26; request body, which becomes repetitive and prone to errors.&lt;/p&gt;
&lt;p&gt;With scripts, we can automate these repetitive tasks. In this article, we will explore postman variables and scripts to streamline your workflow.&lt;/p&gt;
&lt;h2 id=&quot;variables&quot;&gt;Variables&lt;/h2&gt;
&lt;p&gt;Before diving into scripts, it’s essential to understand variables.&lt;/p&gt;
&lt;p&gt;Scopes determine where the variable will be available.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Global&lt;/strong&gt;: Available throughout the application&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Collection&lt;/strong&gt;: Available only within that postman collection (ie, group of requests)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Environment&lt;/strong&gt;: Changes depending on active environment (eg, development or production)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can access these variables using following methods:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;pm.globals&lt;/li&gt;
&lt;li&gt;pm.collectionVariable&lt;/li&gt;
&lt;li&gt;pm.environment&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that we understand how to use variables, let’s explore how to automate tasks with scripts.&lt;/p&gt;
&lt;h2 id=&quot;scripts&quot;&gt;Scripts&lt;/h2&gt;
&lt;p&gt;We can write pre-request &amp;#x26; post-response scripts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pre-request scripts&lt;/strong&gt; are executed before making the request.&lt;/p&gt;
&lt;p&gt;For example, this pre-request script gets email from collection variable and sets name.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:54ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:1ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;collectionVariables&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;user_email&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:1ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;email&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;@&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)[&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;];&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:1ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;collectionVariables&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;user_name&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot; let email = pm.collectionVariables.get(&amp;#x27;user_email&amp;#x27;); let name = email.split(&amp;#x27;@&amp;#x27;)[0]; pm.collectionVariables.set(&amp;#x27;user_name&amp;#x27;, name);&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Post-response scripts&lt;/strong&gt; are executed after the response is received.&lt;/p&gt;
&lt;p&gt;For example, this post-response script sets auth headers and user_id from the response.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;js&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:65ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// set auth headers for upcoming requests&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;headersToFind&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;Set&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;([&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;uid&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;access-token&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;response&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;headers&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(header &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;headerName&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;key&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;toLowerCase&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;headersToFind&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;has&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;headerName&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)) {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;collectionVariables&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;headerName&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// set current user id to previous user id&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;previous_user_id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;collectionVariables&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;user_id&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;collectionVariables&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;previous_user_id&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;previous_user_id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;// set new current_user id&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;response&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;response&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;user_id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;response&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pm&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;collectionVariables&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;user_id&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;user_id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;// set auth headers for upcoming requestslet headersToFind = new Set([&amp;#x27;uid&amp;#x27;, &amp;#x27;access-token&amp;#x27;]);pm.response.headers.each(header =&gt; {    let headerName = header.key.toLowerCase();    if (headersToFind.has(headerName)) {        pm.collectionVariables.set(headerName, header.value);    }});// set current user id to previous user idlet previous_user_id = pm.collectionVariables.get(&amp;#x27;user_id&amp;#x27;)pm.collectionVariables.set(&amp;#x27;previous_user_id&amp;#x27;, previous_user_id);// set new current_user idlet response = pm.response.json();let user_id = response.data.id;pm.collectionVariables.set(&amp;#x27;user_id&amp;#x27;, user_id);&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;caution&quot;&gt;Caution&lt;/h2&gt;
&lt;p&gt;In the variables tab, update current value not initial. Initially, didn’t know how they worked so I had kept ‘current value’ column hidden. But all the updates take effect on this column. So I was thinking that scripts are not working. Spent quite some time due to this.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Using Postman scripts can significantly save time and reduce errors in your API development workflow. By automating repetitive tasks, you can focus on enhancing your API’s functionality and performance.&lt;/p&gt;
&lt;h2 id=&quot;further-reading&quot;&gt;Further reading&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Postman &lt;a href=&quot;https://learning.postman.com/docs/sending-requests/variables/variables&quot;&gt;variables&lt;/a&gt; and &lt;a href=&quot;https://learning.postman.com/docs/tests-and-scripts/write-scripts/intro-to-scripts&quot;&gt;scripts&lt;/a&gt; documentation&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Slack Productivity Tips I Use to Stay Focused</title><link>https://chaitanyavaru.com/blogs/slack-productivity-tips</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/slack-productivity-tips</guid><description>Slack productivity tips to to reduce distraction and have deep work.</description><pubDate>Sun, 15 Dec 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Slack is great for team communication, but its notifications can pile up quickly and make it hard to focus. I used to struggle with all the noise myself, but over time, I found a few simple ways to cut out distractions and stay productive.&lt;/p&gt;
&lt;p&gt;In this post, I’ll share the tips I use to make Slack work better for me.&lt;/p&gt;
&lt;h2 id=&quot;notifications&quot;&gt;Notifications&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Default Sound
&lt;ul&gt;
&lt;li&gt;The default notification sound, Knock Brush, plays two tones, which I find distracting. I replaced it with ‘Ta-da’, a single tone. This made a big difference — it was an instant upgrade to my focus.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Flash Window
&lt;ul&gt;
&lt;li&gt;Flash windows are those message previews that pop up over your screen when someone messages you.&lt;/li&gt;
&lt;li&gt;I keep it to ‘never’ so that they don’t interrupt the deep work (a habit that I am cultivating).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Mute Notifications
&lt;ul&gt;
&lt;li&gt;I mute channels that don’t require my immediate attention—like team-wide discussions or channels for specific projects I’m not actively working on.&lt;/li&gt;
&lt;li&gt;This helps me stay focused during the day while still being able to check muted channels when needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;display&quot;&gt;Display&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Compact Theme&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;img  src=&quot;/_astro/compact-theme.DLFt26ft_19sX4S.webp&quot; alt=&quot;compact theme&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;762&quot; height=&quot;380&quot;&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Preferences&lt;/code&gt; &gt; &lt;code&gt;Messages &amp;#x26; media&lt;/code&gt; &gt; &lt;code&gt;Theme&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Compact Theme reduces visual clutter by removing profile pictures and displaying only usernames next to messages, making it easier to scan through messages quickly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Channel Sections&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;img  src=&quot;/_astro/channel-sections.x3Y6GJos_Z1ymJIT.webp&quot; alt=&quot;channel sections&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;426&quot; height=&quot;636&quot;&gt;&lt;/li&gt;
&lt;li&gt;Slack allows you to organize your channels into custom sections. I’ve created three sections:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Active Channels&lt;/strong&gt;: These are the channels I use daily and have notifications enabled.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Occasional Channels&lt;/strong&gt;: Channels I check at specific times of the day, like for recurring tasks or event updates.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Muted Channels&lt;/strong&gt;: Channels I don’t need to monitor frequently, but I keep them muted so I can check them when something important comes up.
&lt;ul&gt;
&lt;li&gt;Here, I have also enabled ‘Show Unreads only’ so that I only see the required channels, instead of list of all channels.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;message&quot;&gt;Message&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;One-click Reactions&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;img  src=&quot;/_astro/one-click-reaction.DmKmMaW6_Zhli98.webp&quot; alt=&quot;one click reaction&quot; title=&quot;heres caption&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;728&quot; height=&quot;424&quot;&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Preferences&lt;/code&gt; &gt; &lt;code&gt;Messages &amp;#x26; media&lt;/code&gt; &gt; &lt;code&gt;Show one-click reactions&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;I use certain reactions frequently. With this setting, I don’t have to open the emoji panel each time—I can just click once and keep moving.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Start at newest message&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Preferences&lt;/code&gt; &gt; &lt;code&gt;Mark as read&lt;/code&gt; &gt; &lt;code&gt;Start me at the newest message, and mark the channel read&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;By default, Slack shows unread messages first when you open a channel. I prefer starting at the newest message instead. This way, I skip over older messages that don’t need my attention, and I can scroll up if I need to catch up on anything.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Markdown Formatting&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Preferences&lt;/code&gt; &gt; &lt;code&gt;Advanced&lt;/code&gt; &gt; &lt;code&gt;Input options&lt;/code&gt; &gt; &lt;code&gt;Format messages with markup&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;This is one of my favorite settings. Slack’s default formatting toolbar feels slow to me, so I use markdown to quickly format messages.&lt;/li&gt;
&lt;li&gt;Proper formatting helps me organize my thoughts more clearly and makes messages easier to understand for everyone, saving time for everyone involved.&lt;/li&gt;
&lt;li&gt;For this, I use:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;[some text](link)&lt;/code&gt; for hyperlinks&lt;/li&gt;
&lt;li&gt;&lt;code&gt;*bold text*&lt;/code&gt; for &lt;strong&gt;bold text&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;_italic text_&lt;/code&gt; for &lt;em&gt;italic text&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-&lt;/code&gt; for bullet points&lt;/li&gt;
&lt;li&gt;&lt;code&gt; `text` &lt;/code&gt;  for inline code highlights&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Threads&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;With threads, I can check recent messages across channels in same place&lt;/li&gt;
&lt;li&gt;This saves time of navigating to individual channels and then searching for particular chat.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Text Snippets&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If we share a loooong text in the default message window, then while scrolling the thread the full text will have to be scrolled.
&lt;ul&gt;
&lt;li&gt;With a text snippet, slack puts the text into an expandable window making the thread easy to navigate&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;To create a snippet, click on the &lt;code&gt;+&lt;/code&gt; button on the message box and select &lt;code&gt;Text Snippet&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;Create snippet popup will appear
&lt;ul&gt;
&lt;li&gt;&lt;img  src=&quot;/_astro/snippet-window.C60TsXfi_2sRFhS.webp&quot; alt=&quot;create-snippet&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;866&quot; height=&quot;799&quot;&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now, the messages can be expanded when needed
&lt;ul&gt;
&lt;li&gt;&lt;img  src=&quot;/_astro/expandable-snippet.Crng2cvZ_Z2mfDdy.webp&quot; alt=&quot;expandable-snippet&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;513&quot; height=&quot;611&quot;&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;We can’t eliminate all the noise, but with a few simple changes, we can create a more focused and productive workspace. Try these adjustments and see if they help improve your workflow.&lt;/p&gt;
&lt;h2 id=&quot;further-readings&quot;&gt;Further Readings&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://womanonrails.com/slack-keyboard-shortcuts&quot;&gt;https://womanonrails.com/slack-keyboard-shortcuts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Symlinks for efficient dotfile management</title><link>https://chaitanyavaru.com/blogs/symlinks-for-efficient-dotfile-management</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/symlinks-for-efficient-dotfile-management</guid><description>what are symlinks? How to use them for managing dotfiles efficiently?</description><pubDate>Sat, 05 Oct 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;As developers, we can have lots of config files (.zshrc, .psqlrc, init.lua etc) to customize our development environments. Over time, managing these files across multiple systems becomes a hassle.&lt;/p&gt;
&lt;p&gt;For this, I started saving them in a git repository. While this helped, it still an inefficient solution. Every time I changed a file, I had to manually update it in the repository as well. This resulted in extra work and sometimes I missed updating the repository.&lt;/p&gt;
&lt;p&gt;Then I learned about symlinks, which eliminated the need to manually update both the file and the repository.&lt;/p&gt;
&lt;h2 id=&quot;what-is-symlink&quot;&gt;What is symlink?&lt;/h2&gt;
&lt;p&gt;Symlink, short for symbolic link, is a file that points to another file called target.&lt;/p&gt;
&lt;p&gt;Instead of copying a configuration file across different systems, you can create a symlink that references the original file. Any changes made to the original file are automatically reflected in the symlink.&lt;/p&gt;
&lt;p&gt;You can create symlink for both file &amp;#x26; directory.&lt;/p&gt;
&lt;h2 id=&quot;how-to-create-a-symlink&quot;&gt;How to Create a Symlink?&lt;/h2&gt;
&lt;h3 id=&quot;creating-symlinks-in-windows&quot;&gt;Creating Symlinks in Windows&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Open command prompt as an administrator&lt;/li&gt;
&lt;li&gt;Use this command to create symlink&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;batch&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:48ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;mklink&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;\path\to\symlink&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;\path\to\target\file&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;mklink &amp;#x22;\path\to\symlink&amp;#x22; &amp;#x22;\path\to\target\file&amp;#x22;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Make sure symlink doesn’t exist already&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;eg&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;batch&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:63ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;mklink&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;C:\Users\user\alias.sh&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;D:\path\to\dotfiles\alias.sh&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;mklink &amp;#x22;C:\Users\user\alias.sh&amp;#x22;  &amp;#x22;D:\path\to\dotfiles\alias.sh&amp;#x22;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h3 id=&quot;creating-symlinks-in-linux&quot;&gt;Creating Symlinks in Linux&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Use this command to create symlink&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:47ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ln&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;-s&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;/path/to/source/file&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;/path/to/target/file&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;ln -s /path/to/source/file /path/to/target/file&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-s&lt;/code&gt;&lt;/strong&gt; stands for “symbolic” and tells &lt;code&gt;ln&lt;/code&gt; to create a symlink rather than a hard link&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;eg&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:32ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ln&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;-s&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;~/dotfiles/.zshrc&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;~/.zshrc&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;ln -s ~/dotfiles/.zshrc ~/.zshrc&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;To know the target file of the symlink, we could use the following command: &lt;code&gt;ls -l /path/to/symlink&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Linux syntax is opposite from windows, where target is given later&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In this article, we learned how to use symlinks for managing your files more efficiently. For further readings, check out symlink management tools such as stoa (linux), chezmoi (cross-platform).&lt;/p&gt;</content:encoded></item><item><title>Using alias in command line to increase productivity</title><link>https://chaitanyavaru.com/blogs/using-alias-in-command-line-to-increase-productivity</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/using-alias-in-command-line-to-increase-productivity</guid><description>What are command line alias and why to use them?</description><pubDate>Sun, 14 Jan 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In our daily workflow, there are few commands that we have to run multiple times. Like &lt;code&gt;npm run start&lt;/code&gt;, &lt;code&gt;git commit -m &quot;fixed the printer&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Typing the same command again and again is inefficient and also increases the chances of typo. I used to mistype (or still mistype 🤷‍♂️) git as gti a lot.&lt;/p&gt;
&lt;p&gt;And yes, using up arrow we could go back to that command, but why to keep searching for that one command that you executed 10-15 commands back, when there is a better solution available.&lt;/p&gt;
&lt;h2 id=&quot;enter-alias&quot;&gt;Enter alias&lt;/h2&gt;
&lt;p&gt;Aliases are text substitutions that we could configure for common commands, so that we don’t have to type them fully.&lt;/p&gt;
&lt;h2 id=&quot;how-to-add-alias&quot;&gt;How to add alias&lt;/h2&gt;
&lt;p&gt;To add aliases, we need to modify the configuration file of the shell.
Linux: file is usually present in the root folder
Windows: file is present at &lt;code&gt;C:\Users\&amp;#x3C;your user name&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;File name will depend on your shell. eg .bashrc for bash, .zshrc for zsh&lt;/p&gt;
&lt;p&gt;General syntax is &lt;code&gt;alias shortcut=&apos;full command&apos;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Now whenever the shortcut is typed, shell will execute as if the full command was typed.&lt;/p&gt;
&lt;h2 id=&quot;useful-aliases&quot;&gt;Useful Aliases&lt;/h2&gt;
&lt;p&gt;Here are some of the aliases that I use&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:96ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;clear&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# navigate directories&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;zshopen&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;vim ~/.zshrc &amp;#x26;&amp;#x26; source ~/.zshrc&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;..=&apos;cd ..&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;...=&apos;cd ../..&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;....=&apos;cd ../../..&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# git&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gcm&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git commit -m &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gc&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git checkout &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gcb&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git checkout -b &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ga&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git add &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gpo&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git push origin &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gpu&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git push origin HEAD &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gpl&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git pull &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gs&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git stash &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gsa&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git stash apply &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gsl&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git stash list &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;gss&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;git stash save &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# docker&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;WEB_CONTAINER&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;web_container_name&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;DB&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;database_container_name&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;docker &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;du&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;docker compose up&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ds&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;docker compose stop&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dr&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;docker compose restart &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;$WEB_CONTAINER&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dcd&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;docker compose down&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dps&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;docker ps&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;da&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;docker attach &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;$WEB_CONTAINER&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;de&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;docker exec -it &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;$WEB_CONTAINER&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt; /bin/bash&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dep&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;docker exec -it $DB /bin/bash -c &quot;psql -U &amp;#x3C;database-name&gt; -d &amp;#x3C;database-password&gt; -x&quot;&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# npm&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nr&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;npm run &apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nd&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;npm run dev&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# hugo&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;alias&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;hs&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;hugo server&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;alias c=&amp;#x27;clear&amp;#x27;alias zshopen=&amp;#x27;vim ~/.zshrc &amp;#x26;&amp;#x26; source ~/.zshrc&amp;#x27;alias ..=&amp;#x27;cd ..&amp;#x27;alias ...=&amp;#x27;cd ../..&amp;#x27;alias ....=&amp;#x27;cd ../../..&amp;#x27;alias g=&amp;#x27;git &amp;#x27;alias gcm=&amp;#x27;git commit -m &amp;#x27;alias gc=&amp;#x27;git checkout &amp;#x27;alias gcb=&amp;#x27;git checkout -b &amp;#x27;alias ga=&amp;#x27;git add &amp;#x27;alias gpo=&amp;#x27;git push origin &amp;#x27;alias gpu=&amp;#x27;git push origin HEAD &amp;#x27;alias gpl=&amp;#x27;git pull &amp;#x27;alias gs=&amp;#x27;git stash &amp;#x27;alias gsa=&amp;#x27;git stash apply &amp;#x27;alias gsl=&amp;#x27;git stash list &amp;#x27;alias gss=&amp;#x27;git stash save &amp;#x27;WEB_CONTAINER=&amp;#x22;web_container_name&amp;#x22;DB=&amp;#x22;database_container_name&amp;#x22;alias d=&amp;#x27;docker &amp;#x27;alias du=&amp;#x27;docker compose up&amp;#x27;alias ds=&amp;#x27;docker compose stop&amp;#x27;alias dr=&amp;#x22;docker compose restart $WEB_CONTAINER&amp;#x22;alias dcd=&amp;#x27;docker compose down&amp;#x27;alias dps=&amp;#x27;docker ps&amp;#x27;alias da=&amp;#x22;docker attach $WEB_CONTAINER&amp;#x22;alias de=&amp;#x22;docker exec -it $WEB_CONTAINER /bin/bash&amp;#x22;alias dep=&amp;#x27;docker exec -it $DB /bin/bash -c &amp;#x22;psql -U &lt;database-name&gt; -d &lt;database-password&gt; -x&amp;#x22;&amp;#x27;alias nr=&amp;#x27;npm run &amp;#x27;alias nd=&amp;#x27;npm run dev&amp;#x27;alias hs=&amp;#x27;hugo server&amp;#x27;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;
&lt;p&gt;Now we could just press &lt;code&gt;c&lt;/code&gt; instead of &lt;code&gt;clear&lt;/code&gt; to clear the terminal.&lt;/p&gt;
&lt;p&gt;Or type &lt;code&gt;gc &quot;hack internet&quot;&lt;/code&gt; and it will be executed as &lt;code&gt;git commit -m &quot;hack internet&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I have been using aliases from past 6 months and finding them very useful.&lt;/p&gt;
&lt;p&gt;PS: Add aliases which are personalized to you. With this, you won’t have to think which alias does what.&lt;/p&gt;</content:encoded></item><item><title>How I Debugged Unexpected Attribute Changes in Rails</title><link>https://chaitanyavaru.com/blogs/active-model-dirty</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/active-model-dirty</guid><description>Tracking attribute changes in Rails with ActiveModel::Dirty</description><pubDate>Tue, 09 Sep 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I was debugging an issue where a database record’s attribute was getting updated incorrectly.
There were lots of callbacks involved, so it was taking time to figure out from where the value was being updated.&lt;/p&gt;
&lt;p&gt;I needed a way to see exactly when the attribute was being changed. That’s when I came across &lt;a href=&quot;https://api.rubyonrails.org/classes/ActiveModel/Dirty.html&quot;&gt;&lt;code&gt;ActiveModel::Dirty&lt;/code&gt;&lt;/a&gt; module. With that, I found the error in no time.&lt;/p&gt;
&lt;h2 id=&quot;what-is-activemodeldirty&quot;&gt;What is ActiveModel::Dirty?&lt;/h2&gt;
&lt;p&gt;ActiveModel::Dirty lets you track when an object’s attributes change. It provides methods like &lt;code&gt;*_changed?&lt;/code&gt;, &lt;code&gt;*_will_change!&lt;/code&gt; that track when the value has been modified.&lt;/p&gt;
&lt;p&gt;However, this module only tracks in-memory changes, resetting after the object is saved.&lt;/p&gt;
&lt;p&gt;In most applications, we often need to know about attributes &lt;em&gt;after&lt;/em&gt; they’re saved to the database.&lt;/p&gt;
&lt;p&gt;ActiveRecord addresses this by building on the module through &lt;a href=&quot;https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Dirty.html&quot;&gt;ActiveRecord::AttributeMethods::Dirty&lt;/a&gt;, providing methods like &lt;code&gt;saved_change_to_*&lt;/code&gt; and &lt;code&gt;saved_changes?&lt;/code&gt; to track changes across the database lifecycle.&lt;/p&gt;
&lt;h2 id=&quot;back-to-debugging&quot;&gt;Back to debugging&lt;/h2&gt;
&lt;p&gt;With this info, I went back to debugging.&lt;/p&gt;
&lt;p&gt;The problem was that in a model, the attribute &lt;code&gt;field_id&lt;/code&gt; was being assigned an incorrect value. So I used &lt;code&gt;saved_change_to_*&lt;/code&gt; method inside an &lt;code&gt;after_save&lt;/code&gt; callback. This way, whenever the record was saved, the callback would run.&lt;/p&gt;
&lt;p&gt;Here’s the code I used:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;rb&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:102ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;after_save &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; saved_change_to_field_id?&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;puts&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;field_id changed from &lt;/span&gt;&lt;span style=&quot;--0:#E97E7C&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;saved_change_to_field_id.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;first&lt;/span&gt;&lt;span style=&quot;--0:#E97E7C&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt; to &lt;/span&gt;&lt;span style=&quot;--0:#E97E7C&quot;&gt;#{&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;saved_change_to_field_id.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;last&lt;/span&gt;&lt;span style=&quot;--0:#E97E7C&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;binding&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;pry&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;after_save -&gt; {  if saved_change_to_field_id?    puts &amp;#x22;field_id changed from #{saved_change_to_field_id.first} to #{saved_change_to_field_id.last}&amp;#x22;    binding.pry  end}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;With this in place, I could instantly see whenever field_id changed and pause execution to inspect the call stack. That helped me identify the callback responsible and fix the issue.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;It was a delight to learn about this module. It’s super useful for catching data changes. Try it out. It might save you a lot of time the next time your model behaves unexpectedly.&lt;/p&gt;</content:encoded></item><item><title>⚡ How to search in sites quickly with custom site-search</title><link>https://chaitanyavaru.com/blogs/browser-site-search</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/browser-site-search</guid><description>How to enable and use &apos;site search&apos; in browsers.</description><pubDate>Fri, 31 Jan 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When browsing the internet, we often return to the same websites—like YouTube, Tailwind Docs, or looking up the meaning of a word.&lt;/p&gt;
&lt;p&gt;Typically, we open a new tab, go to the website, and enter our query. With site search, we can reduce these three steps into one.&lt;/p&gt;
&lt;p&gt;It is a shortcut by which we can directly enter query from the address bar and get results inside the website.&lt;/p&gt;
&lt;h2 id=&quot;how-to-set-up-site-search&quot;&gt;How to set up Site Search&lt;/h2&gt;
&lt;p&gt;We can enable site search in the following way:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;From the options, go to settings&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;img  src=&quot;/_astro/settings.OO3HjOOR_1fjm2t.webp&quot; alt=&quot;settings&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;302&quot; height=&quot;741&quot;&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;In the side bar, select search engine&lt;/li&gt;
&lt;li&gt;In the site search section, click the &lt;strong&gt;Add&lt;/strong&gt; button&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;&lt;img  src=&quot;/_astro/add_site_search.BEBdUlmi_ZUfm1g.webp&quot; alt=&quot;add shortcut&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;505&quot; height=&quot;341&quot;&gt;&lt;/li&gt;
&lt;li&gt;Give name for the shortcut&lt;/li&gt;
&lt;li&gt;Shortcut you want to use&lt;/li&gt;
&lt;li&gt;URL&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;how-to-get-the-url&quot;&gt;How to get the URL&lt;/h4&gt;
&lt;p&gt;To get the search URL, first search for something on the website.&lt;/p&gt;
&lt;p&gt;For example, if you search ‘haikyuu’ on YouTube, the URL in the address bar will become &lt;code&gt;https://www.youtube.com/results?search_query=haikyuu&lt;/code&gt;. Now, replace  ‘haikyuu’ with &lt;code&gt;%s&lt;/code&gt; to make it dynamic &lt;code&gt;https://www.youtube.com/results?search_query=%s&lt;/code&gt;. That’s it!&lt;/p&gt;
&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;
&lt;p&gt;Now, you can type &lt;code&gt;yt&lt;/code&gt; in address bar, enter query and results will directly open in youtube.&lt;/p&gt;
&lt;p&gt;One shortcut that I frequently use is &lt;code&gt;mn&lt;/code&gt; for searching the meaning of any word. Another one is &lt;code&gt;cf&lt;/code&gt; for searching the confluence documentation in my workplace.&lt;/p&gt;
&lt;p&gt;Give site search a try with your most-visited websites and see how much time it saves you. Once you get the used to it, you’ll wonder how you ever browsed without it!&lt;/p&gt;</content:encoded></item><item><title>Your Git Commits Are Talking: What Are They Saying?</title><link>https://chaitanyavaru.com/blogs/communicating-with-git</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/communicating-with-git</guid><description>My thoughts on why to have better commits</description><pubDate>Tue, 24 Jun 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Git commit messages are more than technical logs. They are conversations we have with our future selves, our teammates, and sometimes even strangers. And just like spoken communication, they can be clear &amp;#x26; helpful or confusing &amp;#x26; frustrating.&lt;/p&gt;
&lt;p&gt;Here are some commit patterns that can feel just like unclear conversations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Filler words (‘uhm’, ‘ahh’)
&lt;ul&gt;
&lt;li&gt;Merge commits are like filler words&lt;/li&gt;
&lt;li&gt;Acceptable when merging feature branch into base branch. Avoid unnecessary merges elsewhere&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Rambling
&lt;ul&gt;
&lt;li&gt;Adding, then undoing changes&lt;/li&gt;
&lt;li&gt;Like explaining something, then backtracking and confusing your listener.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Speaking unclearly
&lt;ul&gt;
&lt;li&gt;Vague commit messages like “fix stuff”, “changes”, “update”&lt;/li&gt;
&lt;li&gt;We leave others guessing what we meant&lt;/li&gt;
&lt;li&gt;Be specific: what changed? why?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Speaking too fast (information overload)
&lt;ul&gt;
&lt;li&gt;Huge commits with many unrelated changes&lt;/li&gt;
&lt;li&gt;Hard to follow &amp;#x26; harder to review&lt;/li&gt;
&lt;li&gt;Break into logical chunks&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Over-communicating trivial details
&lt;ul&gt;
&lt;li&gt;“Fix typo”, “run formatter”, “resolve conflicts”&lt;/li&gt;
&lt;li&gt;Squash these into main message to avoid forcing readers through unnecessary noise&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Frequent pauses
&lt;ul&gt;
&lt;li&gt;Commits after every tiny edit (“added one line”, “changed one variable”)&lt;/li&gt;
&lt;li&gt;Forces the listener to keep reconnecting context&lt;/li&gt;
&lt;li&gt;Group related changes together&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Secure Your Users&apos; API Keys using Rails Encryption</title><link>https://chaitanyavaru.com/blogs/encryption-in-rails</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/encryption-in-rails</guid><description>How to store user&apos;s API keys using active record&apos;s encrypt</description><pubDate>Mon, 17 Mar 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I have an &lt;a href=&quot;https://github.com/hokageCV/simple-rss&quot;&gt;RSS aggregator app&lt;/a&gt; that helps me read newsletters and blogs from multiple sources without context switching. One of its features is to summarize articles using the Gemini API. I initially used my own API key for this, but I later decided to let users (if any, other than me) add their own key. Since we can’t store these keys directly in the database, encryption is necessary.&lt;/p&gt;
&lt;h2 id=&quot;why-encrypt-api-keys&quot;&gt;Why encrypt API keys?&lt;/h2&gt;
&lt;p&gt;Before we look at how to encrypt, let’s first understand why directly storing keys in the database is a bad idea.&lt;/p&gt;
&lt;p&gt;Suppose keys are stored directly in the database. If the database ever gets compromised, then all the keys would be immediately accessible to attackers. Encryption ensures that even in the worst-case scenario, the keys remain protected.&lt;/p&gt;
&lt;h2 id=&quot;how-to-encrypt&quot;&gt;How to encrypt?&lt;/h2&gt;
&lt;p&gt;Active record provides a built-in way to encrypt any model’s attributes. We will use that.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First, generate a random key set&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Run the command &lt;code&gt;rails db:encryption:init&lt;/code&gt; to generate keys&lt;/p&gt;
&lt;p&gt;This will generate three keys.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:55ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;active_record_encryption:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;primary_key:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;EGY8WhulUOXixybod7ZWwMIL68R9o5kC&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;deterministic_key:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;aPA5XyALhf75NNnMzaspW7akTfZp0lPY&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;key_derivation_salt:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;xEY0dt6TZcAMg52K7O84wYzkjvbA62Hz&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;active_record_encryption:  primary_key: EGY8WhulUOXixybod7ZWwMIL68R9o5kC  deterministic_key: aPA5XyALhf75NNnMzaspW7akTfZp0lPY  key_derivation_salt: xEY0dt6TZcAMg52K7O84wYzkjvbA62Hz&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Add them to .env (or credentials storage if preferred).&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Now add the generated keys to config in application.rb&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;rb&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:105ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;config.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;active_record&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;encryption&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;primary_key&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;config.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;active_record&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;encryption&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;deterministic_key&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;config.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;active_record&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;encryption&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;key_derivation_salt&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;config.active_record.encryption.primary_key = ENV[&amp;#x22;ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY&amp;#x22;]config.active_record.encryption.deterministic_key = ENV[&amp;#x22;ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY&amp;#x22;]config.active_record.encryption.key_derivation_salt = ENV[&amp;#x22;ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT&amp;#x22;]&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;Add api_key column&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If the &lt;code&gt;api_key&lt;/code&gt; is missing in &lt;code&gt;user&lt;/code&gt; model, add it with migration.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;rb&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:53ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;AddApiKeyToUsers&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &amp;#x3C; &lt;/span&gt;&lt;span style=&quot;--0:#9498D4&quot;&gt;ActiveRecord::Migration&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;8.0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;change&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;add_column &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;:users&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;:api_key&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;:text&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;class AddApiKeyToUsers &lt; ActiveRecord::Migration[8.0]  def change    add_column :users, :api_key, :text  endend&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;Then declare encrypted attributes in model&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Use &lt;code&gt;deterministic: true&lt;/code&gt; to ensure the key decrypts consistently. Without it, the result will differ on each decryption, making the application unable to use the correct API key for requests&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;rb&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:40ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;User&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &amp;#x3C; &lt;/span&gt;&lt;span style=&quot;--0:#9498D4&quot;&gt;ApplicationRecord&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;encrypts &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;:api_key&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;deterministic:&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#BE9820&quot;&gt;true&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;class User &lt; ApplicationRecord  encrypts :api_key, deterministic: trueend&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;That’s it! Use encrypted key in your application&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;rb&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:31ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;api_key&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;Current&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;user&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;api_key&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;@api_key = Current.user.api_key&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Rails will automatically encrypt the key when saving and decrypt it when accessed. This ensures the key is stored securely yet remains easily accessible.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Encrypting API keys is a simple yet powerful way to protect user data. With Rails’ built-in encryption, implementing this safeguard is straightforward and effective.&lt;/p&gt;
&lt;h2 id=&quot;further-reading&quot;&gt;Further Reading&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://guides.rubyonrails.org/active_record_encryption.html&quot;&gt;https://guides.rubyonrails.org/active_record_encryption.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Move changes across repositories with git format-patch</title><link>https://chaitanyavaru.com/blogs/git-format-patch</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/git-format-patch</guid><description>How to move code from one repo to another with git format-patch</description><pubDate>Fri, 28 Mar 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;We use &lt;code&gt;cherry-pick&lt;/code&gt; to move changes between branches in the same repository. But what if we need to move changes to a different repository?
This is where git format-patch helps — it allows us to move commits as patch files and apply them elsewhere, preserving history and reducing manual work.&lt;/p&gt;
&lt;p&gt;One common scenario where I use this is when setting up a new project and needing to apply default configurations to it.&lt;/p&gt;
&lt;p&gt;Let’s say I start a new Rails project and set up some common configurations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add debugging tools (e.g., pry-byebug)&lt;/li&gt;
&lt;li&gt;Configure logging for better visibility&lt;/li&gt;
&lt;li&gt;Set up authentication using Devise&lt;/li&gt;
&lt;li&gt;Add essential gems such as dotenv for environment variables&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Instead of manually reapplying these changes for every new project, I create a patch once and apply it to new repositories, avoiding repetitive work and reducing errors&lt;/p&gt;
&lt;h2 id=&quot;steps&quot;&gt;Steps&lt;/h2&gt;
&lt;p&gt;Here’s how you can create and apply a patch across repositories step by step.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create patch&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;shell&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:64ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;format-patch&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;--stdout&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;afe599d&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;780bc16&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;starter_config.patch&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git format-patch --stdout afe599d 780bc16 &gt; starter_config.patch&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Generates a patch containing all changes from commit afe599d to 780bc16&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--stdout&lt;/code&gt; combines all the patches into a single file
&lt;ul&gt;
&lt;li&gt;When stdout flag is omitted, a patch file is generated for each commit&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Move the patch&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Move the generated patch file to the root of second repository.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mv starter_config.patch path/to/new/repo&lt;/code&gt;&lt;/p&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;Apply the patch&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;shell&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:29ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;am&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;starter_config.patch&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git am &lt; starter_config.patch&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git am&lt;/code&gt; applies commits sequentially from the patch file.&lt;/li&gt;
&lt;li&gt;It will be as if they were committed in the new repository. This method saves time and ensures consistency across projects.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>My Git workflow for managing code changes</title><link>https://chaitanyavaru.com/blogs/git-workflow</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/git-workflow</guid><description>My current git workflow.</description><pubDate>Fri, 28 Feb 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A Git workflow is a structured way to manage code changes.&lt;/p&gt;
&lt;p&gt;Here’s my current git workflow, which makes it easier for me to navigate and understand my commits.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create feature branch from base branch.&lt;/li&gt;
&lt;li&gt;Commit changes regularly.
&lt;ul&gt;
&lt;li&gt;I often use &lt;code&gt;git commit --amend --no-edit&lt;/code&gt;, one of my favourite git commands, to refine a commit while preserving a working state.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Before a pull request, I like to squash related commits to keep things tidy.&lt;/li&gt;
&lt;li&gt;For feature branches, I like rebase instead of merge — it keeps commit history clean without extra merge commits.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;further-reading&quot;&gt;Further Reading&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://about.gitlab.com/topics/version-control/what-is-git-workflow&quot;&gt;https://about.gitlab.com/topics/version-control/what-is-git-workflow&lt;/a&gt;: This article covers other common git workflows.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>How Home Row Mods Changed the Way I Type</title><link>https://chaitanyavaru.com/blogs/home-row-mods</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/home-row-mods</guid><description>Experience with home row mods for the past six months.</description><pubDate>Tue, 22 Jul 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Six months ago, I made one small tweak to my keyboard that changed the way I type every day.&lt;/p&gt;
&lt;p&gt;They’re called &lt;a href=&quot;https://precondition.github.io/home-row-mods&quot;&gt;home row&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=sLWQ4Gx88h4&quot;&gt;mods&lt;/a&gt;. These are changes to the keyboard’s home row, which is the row with &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;s&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;f&lt;/code&gt; keys. The behaviour of these keys is changed. When held, the key acts like a modifier (like &lt;code&gt;Ctrl&lt;/code&gt;). When tapped, it types the letter as usual.&lt;/p&gt;
&lt;p&gt;For example, holding the &lt;code&gt;f&lt;/code&gt; key works like holding the &lt;code&gt;Ctrl&lt;/code&gt; key. Just tapping &lt;code&gt;f&lt;/code&gt; still types the letter &lt;code&gt;f&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I &lt;a href=&quot;https://www.youtube.com/watch?v=CLiZ5rAEx3A&quot;&gt;set this up&lt;/a&gt; on my NuPhy Air75 v2, which supports QMK firmware. With the &lt;a href=&quot;https://usevia.app&quot;&gt;usevia app&lt;/a&gt;, it was easy to assign the modifiers.&lt;/p&gt;
&lt;p&gt;This setup feels gentler on the wrists and involves fewer twists and stretches, which lowers the risk of Repetitive Strain Injury (RSI).&lt;/p&gt;
&lt;p&gt;At first, I was slow and made lots of typos. But eventually, I got used to it. Now it’s super useful, especially the Ctrl and Shift modifiers, since so many shortcuts rely on them.&lt;/p&gt;
&lt;p&gt;I can now switch windows faster using the &lt;code&gt;alt+number&lt;/code&gt; combo in my tiling window manager.&lt;/p&gt;
&lt;p&gt;That said, home row mods aren’t perfect. I make more typos when typing fast, so now I type a bit slower. And sometimes the keyboard’s firmware causes repeated key presses after using mods.
A common mistake is typing &lt;code&gt;d9&lt;/code&gt; when I mean to type &lt;code&gt;(&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Apart from home row mods, I have also remapped the Caps Lock key. Now, tapping it sends &lt;code&gt;Esc&lt;/code&gt;, and holding it acts as &lt;code&gt;Ctrl&lt;/code&gt;. This makes it easier to exit insert mode in Vim, without having to reach for the &lt;code&gt;Esc&lt;/code&gt; key way off in the corner.&lt;/p&gt;
&lt;p&gt;I’m still fine-tuning the layout, and might drop one of the modifiers later. But even with its flaws, this setup has been a big win for comfort and speed.&lt;/p&gt;</content:encoded></item><item><title>How to Use Multiple Git Accounts on One System</title><link>https://chaitanyavaru.com/blogs/multiple-git-accounts</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/multiple-git-accounts</guid><description>How to configure multiple git accounts in one system.</description><pubDate>Sun, 30 Nov 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;We usually have to switch between multiple git accounts for personal and work projects. This can be confusing at first because git doesn’t automatically know which account to use.&lt;/p&gt;
&lt;p&gt;In this post, we will set up separate SSH keys and connect each one to a different GitHub account.&lt;/p&gt;
&lt;h2 id=&quot;configure-multiple-git-accounts&quot;&gt;Configure Multiple Git Accounts&lt;/h2&gt;
&lt;p&gt;Create separate SSH keys for each GitHub account and add the public keys to GitHub. You can also see my &lt;a href=&quot;/blogs/what-are-ssh-keys&quot;&gt;article on SSH keys&lt;/a&gt; for this part.&lt;/p&gt;
&lt;p&gt;Now open ~/.ssh/config and add one profile for each account.&lt;/p&gt;
&lt;p&gt;For example, we will use two accounts, “hokageCV” &amp;#x26; “account_two”.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;plaintext&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:46ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;# personal github account (primary account)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;Host hokageCV&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;HostName github.com&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;PreferredAuthentications publickey&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;IdentityFile ~/.ssh/id_ed25519_hokageCV&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;# work github account&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;Host account_two&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;HostName github.com&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;PreferredAuthentications publickey&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;IdentityFile ~/.ssh/id_ed25519_account_two&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;# personal github account (primary account)Host hokageCV    HostName github.com    PreferredAuthentications publickey    IdentityFile ~/.ssh/id_ed25519_hokageCV# work github accountHost account_two    HostName github.com    PreferredAuthentications publickey    IdentityFile ~/.ssh/id_ed25519_account_two&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Each profile tells SSH which key to use when connecting.&lt;/p&gt;
&lt;p&gt;Here, hokageCV and account_two are just aliases. They don’t need to match your GitHub username or github.com.&lt;/p&gt;
&lt;h2 id=&quot;using-the-second-account&quot;&gt;Using the second account&lt;/h2&gt;
&lt;p&gt;Clone using the Host defined in SSH config:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;plaintext&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:61ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;git clone git@account_two:work-username/work-project-repo.git&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git clone git@account_two:work-username/work-project-repo.git&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Inside that repo, set the username and email for this account:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;plaintext&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:41ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;git config user.email &quot;your_work_email&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91a0a1&quot;&gt;git config user.name &quot;your_work_username&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;git config user.email &amp;#x22;your_work_email&amp;#x22;git config user.name &amp;#x22;your_work_username&amp;#x22;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;This ensures commits from this repo show up under the correct profile.&lt;/p&gt;
&lt;p&gt;With this setup, each GitHub account has its own SSH key and its own identity.
This keeps your work and personal projects separate without changing global Git settings.&lt;/p&gt;</content:encoded></item><item><title>New Domain Setup Manual: From DNS to Email Routing</title><link>https://chaitanyavaru.com/blogs/new-domain-setup</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/new-domain-setup</guid><description>Step-by-step guide to configure a new domain, including DNS, subdomains, and email routing</description><pubDate>Sun, 05 Oct 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;After getting a new domain, I usually follow a few setup steps to make everything work smoothly. Here’s a quick overview.&lt;/p&gt;
&lt;p&gt;Before diving in, let’s understand a few key elements first.&lt;/p&gt;
&lt;h2 id=&quot;what-is-domain--dns&quot;&gt;What is Domain &amp;#x26; DNS?&lt;/h2&gt;
&lt;p&gt;Websites are hosted on a server and servers are associated with IP addresses. You could visit a website by typing its IP address in the browser.
But remembering numbers for every site would be a hassle. That’s why domains exist, they map names to IP addresses, so you can just type example.com instead of 192.0.2.1.&lt;/p&gt;
&lt;p&gt;DNS (Domain Name System) is like the internet’s phone directory. It keeps track of which domain belongs to which IP address.  Whenever you visit a website, your browser looks up that record to find the right server.&lt;/p&gt;
&lt;h2 id=&quot;transfer-dns-authority-to-cloudflare&quot;&gt;Transfer DNS Authority to cloudflare&lt;/h2&gt;
&lt;p&gt;Before transferring the domain’s DNS authority to Cloudflare, let’s clarify a few related terms:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Domain Registrar: The service from where the domain was purchased (eg, Hostinger)&lt;/li&gt;
&lt;li&gt;DNS Authority: The service that manages your DNS records (eg, Cloudflare)&lt;/li&gt;
&lt;li&gt;Nameservers: Determines who is responsible for managing DNS of your domain&lt;/li&gt;
&lt;li&gt;DNS Records: Instructions that tell the internet how to route traffic for your domain&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this case, Hostinger is the domain registrar.&lt;/p&gt;
&lt;p&gt;To make Cloudflare the DNS authority, we will replace the existing Hostinger nameservers with the nameservers provided by Cloudflare from the Hostinger settings.&lt;/p&gt;
&lt;p&gt;After that, Cloudflare will take over DNS management. Domain Registrar will still be Hostinger.&lt;/p&gt;
&lt;h2 id=&quot;configure-apex-domain-and-subdomains&quot;&gt;Configure Apex domain and Subdomains&lt;/h2&gt;
&lt;p&gt;The apex domain (also called the root domain, like &lt;a href=&quot;https://chaitanyavaru.com&quot;&gt;chaitanyavaru.com&lt;/a&gt;) is the main address of your site.
A subdomain (like &lt;a href=&quot;https://resume.chaitanyavaru.com&quot;&gt;resume.chaitanyavaru.com&lt;/a&gt;) is a branch off that main address.&lt;/p&gt;
&lt;h3 id=&quot;apex-domain&quot;&gt;Apex Domain&lt;/h3&gt;
&lt;p&gt;Now we’ll set up the apex domain for your GitHub repository&lt;/p&gt;
&lt;p&gt;In Github, it is recommended to &lt;a href=&quot;https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/verifying-your-custom-domain-for-github-pages&quot;&gt;verify&lt;/a&gt; the domain for security reasons. For verification, we add the provided &lt;code&gt;TXT&lt;/code&gt; records in Cloudflare.&lt;/p&gt;
&lt;p&gt;Once ownership is verified, we can configure the apex domain. Go to the ‘Pages’ section in repository settings, add the domain in Github, and then create &lt;code&gt;A&lt;/code&gt; records in Cloudflare.&lt;/p&gt;
&lt;p&gt;Now, wait for the DNS configurations to propagate through the network.&lt;/p&gt;
&lt;h3 id=&quot;subdomain&quot;&gt;Subdomain&lt;/h3&gt;
&lt;p&gt;For subdomain, we will use &lt;code&gt;CNAME&lt;/code&gt; record.&lt;/p&gt;
&lt;p&gt;Example with Vercel:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open project’s Settings → Domains&lt;/li&gt;
&lt;li&gt;Add required subdomain&lt;/li&gt;
&lt;li&gt;Vercel will provide a CNAME record&lt;/li&gt;
&lt;li&gt;Add that CNAME record in Cloudflare&lt;/li&gt;
&lt;li&gt;Done&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;email-routing&quot;&gt;Email Routing&lt;/h2&gt;
&lt;p&gt;Cloudflare also provides Email Routing, which lets you forward emails from your domain to another address. For this, we will use MX records.&lt;/p&gt;
&lt;p&gt;To set this up:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to the Cloudflare dashboard&lt;/li&gt;
&lt;li&gt;Navigate to Email → Email Routing&lt;/li&gt;
&lt;li&gt;Add your custom email address and destination
&lt;ul&gt;
&lt;li&gt;Suppose custom email is &lt;code&gt;mail@domain.com&lt;/code&gt; and value is &lt;code&gt;yourmail@gmail.com&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Cloudflare will automatically add the required MX records if it manages your DNS&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That’s it. Now emails sent to &lt;code&gt;mail@domain.com&lt;/code&gt; are forwarded to your existing inbox at &lt;code&gt;yourmail@gmail.com&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;With these steps, your domain setup is complete.&lt;/p&gt;</content:encoded></item><item><title>My First Open Source Contribution: A Small Fix That Taught Me a Lot</title><link>https://chaitanyavaru.com/blogs/on-open-source</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/on-open-source</guid><description>Learning from my first open source contribution.</description><pubDate>Fri, 18 Apr 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;One day while going through one of the many dev newsletters I subscribe to, I came across a &lt;a href=&quot;https://github.com/thisisfranciswu/enterprise-ui-palette-generator&quot;&gt;color palette generator&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I used it to generate a palette for my ongoing project. At that moment, it had no copy or export button. To get the colors, you had to copy each one manually.&lt;/p&gt;
&lt;p&gt;I checked the GitHub repo. The export colors feature was planned, but not implemented yet. I figured I’d try adding it myself.&lt;/p&gt;
&lt;h2 id=&quot;adding-the-copy-colors-feature&quot;&gt;Adding the copy colors feature&lt;/h2&gt;
&lt;h3 id=&quot;first-pr&quot;&gt;First PR&lt;/h3&gt;
&lt;p&gt;I forked the repository and started working on the feature.&lt;/p&gt;
&lt;p&gt;After finishing the changes, I tested them locally, and everything worked. So I raised a PR.&lt;/p&gt;
&lt;p&gt;During the review, Francis (the creator) pointed out that I had unintentionally replaced an existing feature. I had meant to add a new button but ended up overwriting the old one.&lt;/p&gt;
&lt;p&gt;So instead of guessing, I asked how he had envisioned it. Based on his feedback, I &lt;a href=&quot;https://github.com/thisisfranciswu/enterprise-ui-palette-generator/pull/2&quot;&gt;updated the PR&lt;/a&gt;, and it was merged soon after.&lt;/p&gt;
&lt;h3 id=&quot;missing-bundle&quot;&gt;Missing bundle&lt;/h3&gt;
&lt;p&gt;Later, when I checked, the copy button wasn’t working on the deployed site.&lt;/p&gt;
&lt;p&gt;I realised that I hadn’t added &lt;code&gt;bundle.js&lt;/code&gt; to my commit. It still worked locally because the file was already present in my working directory.&lt;/p&gt;
&lt;p&gt;I raised &lt;a href=&quot;https://github.com/thisisfranciswu/enterprise-ui-palette-generator/pull/3&quot;&gt;another PR&lt;/a&gt; to fix that, and this time, everything worked as expected.&lt;/p&gt;
&lt;h2 id=&quot;learnings&quot;&gt;Learnings&lt;/h2&gt;
&lt;p&gt;This showed me how useful open source can be. People can contribute, collaborate, and improve things for everyone.&lt;/p&gt;
&lt;p&gt;I also learned that just testing things locally isn’t enough. It’s better to test in a setup that’s closer to production.&lt;/p&gt;</content:encoded></item><item><title>Simplifying popups using the Popover API</title><link>https://chaitanyavaru.com/blogs/popover-api</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/popover-api</guid><description>Introduction to Popover API and dialog element</description><pubDate>Tue, 05 Aug 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I’ve always found adding popups to be a bit of a pain. So I decided to learn just enough of the Popover API to handle common use cases.&lt;/p&gt;
&lt;p&gt;Here’s what I figured out.&lt;/p&gt;
&lt;p&gt;The Popover API is a native HTML feature that lets us create lightweight, interactive popups without relying much on javascript libraries.&lt;/p&gt;
&lt;p&gt;In this post, we will explore how to use it for some common use cases.&lt;/p&gt;
&lt;h2 id=&quot;simple-popup&quot;&gt;Simple popup&lt;/h2&gt;
&lt;p&gt;When we add the attribute &lt;code&gt;popover&lt;/code&gt; to a div, it behaves like a popover element.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;html&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:64ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;popover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;auto&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Popup content&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup-trigger&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;popovertarget&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;&lt;div id=&amp;#x27;popup&amp;#x27; popover=&amp;#x27;auto&amp;#x27;&gt;  &lt;p&gt;Popup content&lt;/p&gt;&lt;/div&gt;&lt;button id=&amp;#x27;popup-trigger&amp;#x27; popovertarget=&amp;#x27;popup&amp;#x27;&gt;Button&lt;/button&gt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;For the div, we added &lt;code&gt;popover&lt;/code&gt; attribute with value as &lt;code&gt;auto&lt;/code&gt;, which is also the default value.
With this, we get the &lt;em&gt;light dismiss&lt;/em&gt; property, which means that on clicking outside of the popup, it will be closed.&lt;/p&gt;
&lt;p&gt;On the button, we add a &lt;code&gt;popovertarget&lt;/code&gt; attribute with id of popover element. This makes the button an &lt;em&gt;invoker&lt;/em&gt; of the popover.&lt;/p&gt;
&lt;p&gt;For a simple popup, this is it. Clicking the button now shows the popup.&lt;/p&gt;
&lt;h2 id=&quot;position-the-popup&quot;&gt;Position the popup&lt;/h2&gt;
&lt;p&gt;By default, popover element opens in the center of the screen. Let’s see how to position the popup relative to the element that triggered them (its invoker).&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;html&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:64ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;popover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;auto&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Popup content&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup-trigger&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;popovertarget&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;#popup&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;margin&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;position-area: bottom right;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;&lt;div id=&amp;#x27;popup&amp;#x27; popover=&amp;#x27;auto&amp;#x27;&gt;  &lt;p&gt;Popup content&lt;/p&gt;&lt;/div&gt;&lt;button id=&amp;#x27;popup-trigger&amp;#x27; popovertarget=&amp;#x27;popup&amp;#x27;&gt;Button&lt;/button&gt;&lt;style&gt;  #popup {    margin: 0;    position-area: bottom right;  }&lt;/style&gt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;We clear the margin around the popup. And then &lt;a href=&quot;https://developer.chrome.com/blog/anchor-positioning-api#position_elements_relative_to_anchors&quot;&gt;anchor it&lt;/a&gt; relative to its invoker using &lt;code&gt;position-area&lt;/code&gt; css property.&lt;/p&gt;
&lt;p&gt;Now, the popup appears at bottom right of the button.&lt;/p&gt;
&lt;h2 id=&quot;invoke-via-hover&quot;&gt;Invoke via hover&lt;/h2&gt;
&lt;p&gt;Sometimes, we want the popup to show when the user hovers, like a tooltip or preview. For that, we will have to trigger popup via javascript.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;html&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:64ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;popover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;auto&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Popup content&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup-trigger&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;popovertarget&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;#popup&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;margin&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;position-area: bottom right;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;btn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup-trigger&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;popover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;popup&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;btn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;mouseenter&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, () &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;popover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;showPopover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;({ source: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;btn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; })&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;btn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;mouseleave&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, () &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;popover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;hidePopover&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;()&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;&lt;div id=&amp;#x27;popup&amp;#x27; popover=&amp;#x27;auto&amp;#x27;&gt;  &lt;p&gt;Popup content&lt;/p&gt;&lt;/div&gt;&lt;button id=&amp;#x27;popup-trigger&amp;#x27; popovertarget=&amp;#x27;popup&amp;#x27;&gt;Button&lt;/button&gt;&lt;style&gt;  #popup {    margin: 0;    position-area: bottom right;  }&lt;/style&gt;&lt;script&gt;  let btn = document.getElementById(&amp;#x27;popup-trigger&amp;#x27;);  let popover = document.getElementById(&amp;#x27;popup&amp;#x27;);  btn.addEventListener(&amp;#x27;mouseenter&amp;#x27;, () =&gt; {    popover.showPopover({ source: btn })  });  btn.addEventListener(&amp;#x27;mouseleave&amp;#x27;, () =&gt; {    popover.hidePopover()  });&lt;/script&gt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;When the mouse hovers over the button, we call &lt;code&gt;showPopover&lt;/code&gt; method and pass the button as the source. On mouse leave, we hide the popup.&lt;/p&gt;
&lt;h2 id=&quot;dialog&quot;&gt;Dialog&lt;/h2&gt;
&lt;p&gt;The Popover API is non-modal, meaning it doesn’t block interaction with the rest of the page&lt;/p&gt;
&lt;p&gt;To have a popup which makes the page inert (make rest of elements non-interactive), we can use &lt;code&gt;dialog&lt;/code&gt; element.&lt;/p&gt;
&lt;p&gt;Dialog elements don’t provide light-dismiss by default, so we will also create a close button for it.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;html&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:56ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;open-dialog&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Open modal&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dialog&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;dialog-modal&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Modal content&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;close-dialog&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;Close&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dialog&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dialog&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;dialog-modal&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;openBtn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;open-dialog&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;closeBtn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;close-dialog&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;openBtn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, () &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dialog&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;showModal&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;closeBtn&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, () &lt;/span&gt;&lt;span style=&quot;--0:#93A1A1;--0fw:bold&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;dialog&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--0:#91A0A4&quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;&lt;button id=&amp;#x27;open-dialog&amp;#x27;&gt;Open modal&lt;/button&gt;&lt;dialog id=&amp;#x27;dialog-modal&amp;#x27;&gt;  &lt;p&gt;Modal content&lt;/p&gt;  &lt;button id=&amp;#x27;close-dialog&amp;#x27;&gt;Close&lt;/button&gt;&lt;/dialog&gt;&lt;script&gt;  let dialog = document.getElementById(&amp;#x27;dialog-modal&amp;#x27;);  let openBtn = document.getElementById(&amp;#x27;open-dialog&amp;#x27;)  let closeBtn = document.getElementById(&amp;#x27;close-dialog&amp;#x27;)  openBtn.addEventListener(&amp;#x27;click&amp;#x27;, () =&gt; {    dialog.showModal();  });  closeBtn.addEventListener(&amp;#x27;click&amp;#x27;, () =&gt; {    dialog.close();  });&lt;/script&gt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;dialog.showModal&lt;/code&gt; makes page inert. To open the dialog while keeping rest of the elements interactive, we can use &lt;code&gt;dialog.show&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Use dialog for events that must be performed by the user.&lt;/p&gt;
&lt;h2 id=&quot;backdrop&quot;&gt;Backdrop&lt;/h2&gt;
&lt;p&gt;Popups can feel disconnected from the rest of the page if they don’t stand out. That’s where the backdrop helps.&lt;/p&gt;
&lt;p&gt;Both popover api and dialog element renders the popup in top layer, which is a layer outside of the usual document flow.
To highlight the popup, we could &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using#styling_the_popover_backdrop&quot;&gt;style&lt;/a&gt; using the &lt;code&gt;backdrop&lt;/code&gt; pseudo element.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;css&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:39ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#93A1A1&quot;&gt;::backdrop&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; {&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;background-color&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;rgba&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0.5&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;::backdrop {  background-color: rgba(0, 0, 0, 0.5);}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;This darkens the area behind the popup, making it feel more prominent.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Try the Popover API in your next project. It’s a great way to simplify your UI using native HTML, with no extra libraries, less code, and cleaner logic.&lt;/p&gt;
&lt;h2 id=&quot;further-readings&quot;&gt;Further Readings&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://frontendmasters.com/blog/menus-toasts-and-more&quot;&gt;Frontend masters blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://una.im/popover-hint&quot;&gt;Una Kravets blog on popover=hint&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Building a Rails app with Supabase &amp; Render</title><link>https://chaitanyavaru.com/blogs/rails-supabase-render</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/rails-supabase-render</guid><description>How to use supabase &amp; render to build rails application</description><pubDate>Tue, 11 Mar 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When building side projects or a prototype, it’s better to use managed services to build faster.&lt;/p&gt;
&lt;p&gt;Supabase is a managed service that provides a Postgres database. With Render, we can host our applications.&lt;/p&gt;
&lt;p&gt;In this article, we’ll walk through setting up Supabase as the database for a Rails app and deploying it on Render. I’ll also highlight two mistakes I made along the way, so you can avoid them.&lt;/p&gt;
&lt;h2 id=&quot;supabase&quot;&gt;Supabase&lt;/h2&gt;
&lt;p&gt;First, let’s set up Supabase as the database for our Rails app.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a project from Supabase dashboard&lt;/li&gt;
&lt;li&gt;After creating the project, click on connection button to get the connection URL&lt;/li&gt;
&lt;li&gt;Ensure &lt;code&gt;pg&lt;/code&gt; gem is installed in the application&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;DATABASE_URL&lt;/code&gt; in .env file&lt;/li&gt;
&lt;li&gt;In config/database.yml, configure the production database&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;yml&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:33ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;production&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;adaptor&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;postgresql&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;unicode&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&amp;#x3C;%= ENV[&quot;DATABASE_URL&quot;] %&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;production:  adaptor: postgresql  encoding: unicode  url: &lt;%= ENV[&amp;#x22;DATABASE_URL&amp;#x22;] %&gt;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Now, Active Record will use supabase as the postgres database.&lt;/p&gt;
&lt;h2 id=&quot;render&quot;&gt;Render&lt;/h2&gt;
&lt;p&gt;Next, let’s deploy our application on Render.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;From the dashboard, create new web service&lt;/li&gt;
&lt;li&gt;Select the repository you want to host&lt;/li&gt;
&lt;li&gt;Add build command&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:82ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bundle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;install&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bundle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;exec&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rake&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;assets:precompile&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bundle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;exec&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rake&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;assets:clean&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;bundle install; bundle exec rake assets:precompile; bundle exec rake assets:clean;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Add start command&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;bash&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:84ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bundle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;exec&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rails&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;db:migrate&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &amp;#x26;&amp;#x26; &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;bundle&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;exec&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;rails&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;-b&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;0.0.0.0&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;-p&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;PORT&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;:-&lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;3000&lt;/span&gt;&lt;span style=&quot;--0:#94A620&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;bundle exec rails db:migrate &amp;#x26;&amp;#x26; bundle exec rails server -b 0.0.0.0 -p ${PORT:-3000}&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Deploy!&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;common-mistakes&quot;&gt;Common Mistakes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Render
&lt;ul&gt;
&lt;li&gt;Ensure &lt;code&gt;db:migrate&lt;/code&gt; is included in the start command; without it, the database won’t be created.&lt;/li&gt;
&lt;li&gt;I forgot this and spent time figuring out why the database didn’t work.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Supabase
&lt;ul&gt;
&lt;li&gt;For the connection string, use ‘Session Pooler’.&lt;/li&gt;
&lt;li&gt;I had selected ‘Transaction Pooler’ initially, which caused queries to fail.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title>Save Hours Each Week with a Text Expander</title><link>https://chaitanyavaru.com/blogs/text-expander</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/text-expander</guid><description>How I use text-expander to have a productive workflow</description><pubDate>Sun, 27 Apr 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Imagine you are filling forms where you have to enter the same values in multiple places. Or maybe you have certain words or phrases that you type all the time in your work. Or any prompt for an AI tool. Typing them every time is tedious and error-prone.&lt;/p&gt;
&lt;p&gt;One solution is to keep these phrases somewhere and copy-paste when needed. But that’s quite slow. A better solution is to automate it altogether. That’s where text expanders come in.&lt;/p&gt;
&lt;h2 id=&quot;what-is-a-text-expander&quot;&gt;What is a text expander?&lt;/h2&gt;
&lt;p&gt;A text expander automatically replaces a short string you type with a longer, predefined text. You define a trigger phrase, and whenever you type it, the text expander replaces it with the corresponding expansion.&lt;/p&gt;
&lt;p&gt;For example, typing &lt;code&gt;:greet&lt;/code&gt; could expand into &lt;code&gt;Hello, How are, Khana kha ke jana&lt;/code&gt;. Or maybe you have a super secure password that you use for all sites. Typing &lt;code&gt;;pswd&lt;/code&gt; could expand into &lt;code&gt;ABCD@12340000&lt;/code&gt;, saving you time and effort.&lt;/p&gt;
&lt;video controls autoplay loop width=&quot;500&quot;&gt;
  &lt;source src=&quot;https://res.cloudinary.com/dmtacem5p/video/upload/v1745756342/blog/2025/text-expand.mp4&quot; type=&quot;video/mp4&quot;&gt;
  Your browser does not support the video tag.
&lt;/video&gt;
&lt;p&gt;In this post, we will explore how to use espanso as your text expander.&lt;/p&gt;
&lt;h2 id=&quot;install--configure&quot;&gt;Install &amp;#x26; Configure&lt;/h2&gt;
&lt;p&gt;Installing Espanso is quick and easy. Simply download the installer &lt;a href=&quot;https://espanso.org/install&quot;&gt;from the website&lt;/a&gt;, and follow the on-screen instructions to complete the setup.&lt;/p&gt;
&lt;p&gt;Once installed, you’ll need to configure Espanso by adding snippets to the &lt;em&gt;match/&lt;/em&gt; directory. This is where you store all the custom trigger phrases and their corresponding text replacements.&lt;/p&gt;
&lt;p&gt;The location of the match/ directory depends on your operating system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Linux:  &lt;code&gt;/home/$USER/.config/espanso&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Windows: &lt;code&gt;C:\Users\%username%\AppData\Roaming\espanso&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this directory, you can create multiple files to organize your snippets. Each snippet consists of a trigger (a short string you type) and its replacement text.
For example, to create a snippet that expands ;gc into @gmail.com, you’d add the following:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;yml&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:23ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;;gc&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;@gmail.com&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;- trigger: &amp;#x27;;gc&amp;#x27;  replace: &amp;#x27;@gmail.com&amp;#x27;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Now, whenever you type &lt;code&gt;;gc&lt;/code&gt; in your system, it will automatically expand to &lt;code&gt;@gmail.com&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;how-i-use-espanso&quot;&gt;How I use espanso&lt;/h2&gt;
&lt;p&gt;Here are some example snippets from my configuration, saving me countless keystrokes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Correcting common typos&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I often mistype simple words. So, I maintain a misspelled-words.yml file that automatically corrects them. One of its trigger is as follows:&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;yml&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:30ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;triggers&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: [&lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos; tehn&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos; hten&apos;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos; then&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;- triggers: [&amp;#x27; tehn&amp;#x27;, &amp;#x27; hten&amp;#x27;]  replace: &amp;#x27; then&amp;#x27;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Inserting a debugger&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As a developer, I frequently need to drop a binding.pry in my code. With this snippet, I can insert it almost instantly.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;yml&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:24ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;;bb&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;binding.pry&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;- trigger: &amp;#x27;;bb&amp;#x27;  replace: &amp;#x27;binding.pry&amp;#x27;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Adding current date&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I often need to enter today’s date when writing documents or messages. This snippet automatically expands to the current date in the format I prefer.&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;figure class=&quot;frame&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;yml&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:26ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&apos;;date&apos;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;{{mydate}}&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:2ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;vars&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:4ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;mydate&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;date&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:6ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;params&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot; style=&quot;--ecIndent:8ch&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span class=&quot;indent&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;%d %b %Y&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;- trigger: &amp;#x27;;date&amp;#x27;  replace: &amp;#x22;{{mydate}}&amp;#x22;  vars:    - name: mydate      type: date      params:        format: &amp;#x22;%d %b %Y&amp;#x22;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;h2 id=&quot;alternative&quot;&gt;Alternative&lt;/h2&gt;
&lt;p&gt;Before I found Espanso, I used &lt;a href=&quot;https://www.trankynam.com/atext&quot;&gt;aText&lt;/a&gt;, but it lacked linux support and relied on a GUI for configuration, which meant I had to manually recreate snippets on every machine. Espanso, on the other hand, allows easy configuration across all systems and platforms&lt;/p&gt;
&lt;p&gt;That said, aText is still a good choice if you prefer a GUI-based configuration tool.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Even small text expansions can collectively save a lot of time. I have been using a text expander for the past two or three years, and from the very first day, I noticed a clear improvement in my workflow. Today, a text expander has become a must-have tool for me along with a window manager (but that’s a story for another blog post).&lt;/p&gt;
&lt;p&gt;Take just a few minutes today to set up your first snippets. You’ll quickly see how this simple tool transforms your productivity.&lt;/p&gt;</content:encoded></item><item><title>Create Multiple Issues Quickly with Jira API</title><link>https://chaitanyavaru.com/blogs/jira-bulk-api</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/jira-bulk-api</guid><description>How to use Jira API to create issues in bulk</description><pubDate>Sun, 22 Feb 2026 00:00:00 GMT</pubDate></item><item><title>What Switching to Linux Taught Me</title><link>https://chaitanyavaru.com/blogs/switch-to-linux</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/switch-to-linux</guid><description>On switching to linux as full time OS.</description><pubDate>Thu, 22 Jan 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A couple of months back, I switched to Linux as my full time operating system. Earlier I had only used Windows as my main OS.
But with my laptop getting crashed frequently due to Window’s unexpected errors, I finally switched.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://support.microsoft.com/images/en-us/bcfbb8c5-a979-49bb-bf10-b21aebc09394?format=avif&amp;#x26;w=800#&quot; alt=&quot;microsoft_unexpected_error&quot;&gt;&lt;/p&gt;
&lt;p&gt;I had been using Workspacer, a tiling window manager, on Windows, so switching to Hyprland on Linux felt like the obvious next step.&lt;/p&gt;
&lt;p&gt;After installing hyprland, it was a completely different ecosystem. My initial thought was to not continue using hyprland. I was staring at an empty screen, with no panel, and no idea how to move a window. That was the moment I realized how much dependent I was on common GUI tools.&lt;/p&gt;
&lt;p&gt;I never thought about WiFi connectivity. It was a click away in the system tray. And with the new setup, following steps had to be configured to connect to WiFi&lt;/p&gt;
&lt;div class=&quot;expressive-code&quot;&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/_astro/ec.fxbh1.css&quot;&gt;&lt;script type=&quot;module&quot; src=&quot;/_astro/ec.0vx5m.js&quot;&gt;&lt;/script&gt;&lt;figure class=&quot;frame is-terminal&quot;&gt;&lt;figcaption class=&quot;header&quot;&gt;&lt;span class=&quot;title&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sr-only&quot;&gt;Terminal window&lt;/span&gt;&lt;/figcaption&gt;&lt;pre data-language=&quot;sh&quot; class=&quot;wrap&quot; style=&quot;--ecMaxLine:70ch&quot;&gt;&lt;code&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# get new connections&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nmcli&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;device&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;status&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nmcli&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;device&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;wifi&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;list&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# connect to a connection&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nmcli&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;device&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;wifi&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;connect&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;WIFI_NETWORK_NAME&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;password&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;PASSWORD&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# test&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;ping&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#DD8865&quot;&gt;-c&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#E27CAD&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;google.com&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#91A0A4;--0fs:italic&quot;&gt;# autoconnect on login&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;ec-line&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;span style=&quot;--0:#55A4DC&quot;&gt;nmcli&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;connection&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;modify&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;&quot;WIFI_NETWORK_NAME&quot;&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;connection.autoconnect&lt;/span&gt;&lt;span style=&quot;--0:#91A0A1&quot;&gt; &lt;/span&gt;&lt;span style=&quot;--0:#45ADA5&quot;&gt;yes&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;copy&quot;&gt;&lt;div aria-live=&quot;polite&quot;&gt;&lt;/div&gt;&lt;button title=&quot;Copy to clipboard&quot; data-copied=&quot;Copied!&quot; data-code=&quot;nmcli device statusnmcli device wifi listnmcli device wifi connect &amp;#x22;WIFI_NETWORK_NAME&amp;#x22; password &amp;#x22;PASSWORD&amp;#x22;ping -c 3 google.comnmcli connection modify &amp;#x22;WIFI_NETWORK_NAME&amp;#x22; connection.autoconnect yes&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/button&gt;&lt;/div&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;After some trial and error, the workflow started to click. I configured all tools and applications that I used in previous setup, one change at a time.&lt;/p&gt;
&lt;p&gt;One tool that helped a lot is &lt;code&gt;gnu stow&lt;/code&gt; to manage all the configs with git. It made experimentation to the setup easy. I could easily make changes and if anything broke, all I had to do was to switch back to the last working state.&lt;/p&gt;
&lt;p&gt;Now, after using hyprland for few months, setting up each tool as per need, this setup feels natural to me.&lt;/p&gt;</content:encoded></item><item><title>What is Thundering Herd Problem?</title><link>https://chaitanyavaru.com/blogs/thundering-herd</link><guid isPermaLink="true">https://chaitanyavaru.com/blogs/thundering-herd</guid><description>Thundering Herd problem and its solutions.</description><pubDate>Thu, 19 Mar 2026 00:00:00 GMT</pubDate></item></channel></rss>