<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Arjun Sajeev</title><description>Arjun&apos;s personal website</description><link>https://arjun.xyz/</link><atom:link href="https://arjun.xyz/rss.xml" rel="self" type="application/rss+xml"/><item><title>On writing more</title><link>https://arjun.xyz/blog/on-writing-more/</link><guid isPermaLink="true">https://arjun.xyz/blog/on-writing-more/</guid><description>Future plans for this blog</description><pubDate>Thu, 16 Oct 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img alt=&quot;An image which AI thinks will inspire you to write&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;  width=&quot;1024&quot; height=&quot;1024&quot; src=&quot;https://arjun.xyz/_astro/reading-inspiration.Dvbh2AQE_Z1FNKUM.webp&quot; &gt;&lt;/p&gt;
&lt;p&gt;I have always been enamoured with writing. As a kid, I just loved reading fiction books. Back in the day, I didn’t have access to a lot of books. I used to look forward to getting my next Famous Five or Hardy boys over. Over time, I explored different kinds of fiction. I think the allure for me is the scope for creative imagination that a book provides. It lets you portray the characters in your own light. This is very different from a movie, where there is little scope for imagination or interpretation.&lt;/p&gt;
&lt;p&gt;On this blog though, my writing has been very sporadic. I have only written some succinct technical posts. I want to change that. I hope to at least write a single article every month.&lt;/p&gt;</content:encoded></item><item><title>Setting up fish shell</title><link>https://arjun.xyz/blog/fish-shell/</link><guid isPermaLink="true">https://arjun.xyz/blog/fish-shell/</guid><description>Migrating from ZSH to fish shell on macOS</description><pubDate>Sat, 24 May 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I have always used ZSH on Mac. There are many ways to customize ZSH. Recently, I felt that my shell was extremely slow. I had experimented with many ZSH plugins and themes. After testing a few options, I decided to switch to the Fish shell. This was not as straightforward as I expected, so I decided to write a blog post about it.&lt;/p&gt;
&lt;h3 id=&quot;installing-homebrew-and-fish-shell&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#installing-homebrew-and-fish-shell&quot;&gt;Installing Homebrew and Fish Shell&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you don’t have Homebrew, install it by following the instructions on &lt;a href=&quot;https://brew.sh/&quot;&gt;their website&lt;/a&gt;. Once Homebrew is set up, you can install the Fish shell by opening your terminal and running:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;brew&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; install&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; fish&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;making-fish-the-default-shell&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#making-fish-the-default-shell&quot;&gt;Making Fish the Default Shell&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To make Fish your default shell, you’ll need to follow a few important steps. First, verify the Fish path with &lt;code&gt;which fish&lt;/code&gt;. The path is likely &lt;code&gt;/opt/homebrew/bin/fish&lt;/code&gt;. Next, you need to add Fish to the list of known shells, which is a crucial step that’s often overlooked:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; sh&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -c&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; &apos;echo /opt/homebrew/bin/fish &gt;&gt; /etc/shells&apos;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After adding Fish to the shells list, change your default shell:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;chsh&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -s&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; /opt/homebrew/bin/fish&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, restart your terminal to activate the new shell.&lt;/p&gt;
&lt;h3 id=&quot;setting-up-starship-optional&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#setting-up-starship-optional&quot;&gt;Setting up Starship (Optional)&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Fish does not require much additional setup, but you can optionally enhance it with &lt;a href=&quot;https://starship.rs/&quot;&gt;Starship&lt;/a&gt; for a beautiful and fast prompt:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -sS&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; https://starship.rs/install.sh&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; sh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;echo&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; &apos;starship init fish | source&apos;&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; &gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; ~/.config/fish/config.fish&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;vs-code-integration&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#vs-code-integration&quot;&gt;VS Code Integration&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To use Fish as your default terminal in VS Code, update your VS Code settings:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;json&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;terminal.integrated.defaultProfile.osx&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;fish&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title>Apple touch icon</title><link>https://arjun.xyz/blog/apple-touch-icon/</link><guid isPermaLink="true">https://arjun.xyz/blog/apple-touch-icon/</guid><description>A tale of transparent pixels</description><pubDate>Wed, 27 Dec 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;On Apple devices, you can configure an app icon for your PWA(Progressive Web Application) using &lt;code&gt;apple-touch-icon&lt;/code&gt;. This can be configured using&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; rel&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;apple-touch-icon&quot;&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;apple-touch-icon.png&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My website favicon consists of an image with orange and white colors. On adding my website to the homescreen on iOS devices, iOS was somehow adding a black border. After some research, I found out that if the image had transparent pixels, iOS would replace it with a black color. I just had to replace the transparent pixels in the apple touch icon with white. I did not want to fiddle with a GUI editor for this. Thankfully this was pretty easy to accomplish with ImageMagick.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; find&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -name&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; &quot;*.png&quot;&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -exec&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; convert&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; &quot;{}&quot;&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -background&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; white&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -alpha&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; remove&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -alpha&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; off&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; &quot;{}&quot;&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; \;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title>Currying in javascript</title><link>https://arjun.xyz/blog/currying-in-javascript/</link><guid isPermaLink="true">https://arjun.xyz/blog/currying-in-javascript/</guid><description>A deep dive into currying in javascript</description><pubDate>Sat, 28 Aug 2021 00:00:00 GMT</pubDate><content:encoded>&lt;h3 id=&quot;what-is-currying&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#what-is-currying&quot;&gt;What is currying?&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Currying&lt;/strong&gt; is the technique of converting a function that takes multiple arguments into a sequence of functions that each take a single argument.&lt;/p&gt;
&lt;p&gt;So currying transforms &lt;code&gt;fn(a, b, c…n) to fn(a)(b)(c)…n)&lt;/code&gt; . Let’s dive right in to an example.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; sum&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; b;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; curriedSum&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; curry&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(sum);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;console.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;curriedSum&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)); &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// = 3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;curriedSum&lt;/code&gt; function converts the sum function into a sequence of two functions since the original sum function needs two arguments.&lt;/p&gt;
&lt;h3 id=&quot;naive-implementation&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#naive-implementation&quot;&gt;Naive implementation&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Based on the above example, we can implement a naive version of the curry function. So &lt;code&gt;curriedSum&lt;/code&gt; returns a function which accepts one argument &lt;code&gt;b&lt;/code&gt;. This is passed as the second argument to the function being curried. The first argument is stored in the function closure.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; curry&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; fn&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(a, b);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;currying-with-variadic-arguments&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#currying-with-variadic-arguments&quot;&gt;Currying with variadic arguments&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The previous implementation has a few problems&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It only works for functions which accept 2 arguments.&lt;/li&gt;
&lt;li&gt;The context value is not being propagated accurately.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s try implementing a generic currying function which supports variadic arguments.&lt;/p&gt;
&lt;p&gt;There are a couple of key insights behind the new implementation.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length&quot;&gt;Function.length&lt;/a&gt; returns the arity of the function. The arity of a function is the number of parameters expected by the function.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, consider this multiply function which returns the product of three numbers;&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; multiply&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; b &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; c;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;console.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(multiply.&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;We have to keep collecting arguments until we have enough arguments, i.e. till the number of arguments are greater than or equal to the arity of the function.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; curry&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; curried&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (args.&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; &gt;=&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; fn.&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;      // Execute the original function when we have enough arguments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; fn.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;apply&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, args);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    } &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;nextArgs&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; curried&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;args, &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;nextArgs); &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// otherwise keep on adding arguments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind&quot;&gt;bind&lt;/a&gt; for a more concise implementation.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; curry&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;fn&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; curried&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (args.&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; &gt;=&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; fn.&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; fn.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;apply&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, args);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    } &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; curried.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;bind&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;args);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;infinite-sum&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#infinite-sum&quot;&gt;Infinite sum&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This happens to be a popular interview question based on recursion. So here’s the infinite sum function that we have to implement&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)() &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)() &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// 5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(n)() &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// (1 + 2 + 3 ...n)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can make some observations based on the above example&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The sum function returns the sum when we call it with undefined.&lt;/li&gt;
&lt;li&gt;If the function is called with a valid number another function is returned&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; sum&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (b &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; undefined&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; a;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    } &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; sum&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(a &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; b);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;infinite-sum-with-variadic-arguments&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#infinite-sum-with-variadic-arguments&quot;&gt;Infinite sum with variadic arguments&lt;/a&gt;&lt;/h3&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)(); &lt;/span&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;//15&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a bit more tricky. We are not dealiing with single arguments anymore.Try implementing this on your own before checking the solution.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;Solution&lt;/summary&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; sum&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;moreArgs&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (moreArgs.&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; args.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;reduce&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; a &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; b);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    } &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; sum&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;args, &lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;moreArgs);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;h3 id=&quot;currying-with-placeholder-support&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#currying-with-placeholder-support&quot;&gt;Currying with placeholder support&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We are not done with currying yet, currying with placeholder support is something I might tackle in the future.&lt;/p&gt;</content:encoded></item><item><title>Custom fonts with TailwindCSS</title><link>https://arjun.xyz/blog/custom-fonts-tailwind-nextjs/</link><guid isPermaLink="true">https://arjun.xyz/blog/custom-fonts-tailwind-nextjs/</guid><description>Setting up custom fonts in a Tailwind NextJS project</description><pubDate>Wed, 28 Jul 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I recently set up custom fonts in a project using &lt;a href=&quot;https://nextjs.org/&quot;&gt;Next.js&lt;/a&gt; and &lt;a href=&quot;https://tailwindcss.com/&quot;&gt;Tailwind CSS&lt;/a&gt;. Here’s how you can do it:&lt;/p&gt;
&lt;h2 id=&quot;adding-font-files&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#adding-font-files&quot;&gt;Adding Font Files&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Add the font files to the public folder. For example, if you are using the &lt;a href=&quot;https://rsms.me/inter/&quot;&gt;Inter&lt;/a&gt; font family, you can create &lt;code&gt;public/fonts/&lt;/code&gt; and add the font files directly there.&lt;/p&gt;
&lt;h2 id=&quot;setting-up-font-faces&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#setting-up-font-faces&quot;&gt;Setting Up Font Faces&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Update your global CSS file to add the new font-face declarations:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;@tailwind&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; base;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;@tailwind&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; components;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;@tailwind&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; utilities;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/* Add the font using @font-face */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;@font-face&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;  font-family&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;Inter&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;  src&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#E36209&quot;&gt;/fonts/Inter-Regular.woff2&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;woff2&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;  font-weight&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;  font-style&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;normal&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;  font-display&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;swap&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;configuring-tailwind&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#configuring-tailwind&quot;&gt;Configuring Tailwind&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Update the Tailwind configuration file (&lt;code&gt;tailwind.config.js&lt;/code&gt;) to generate a class for the new font:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;exports&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  content: [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // your content paths&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  theme: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    extend: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;      fontFamily: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;        inter: [&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;Inter&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;sans-serif&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  plugins: [],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;using-the-custom-font&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#using-the-custom-font&quot;&gt;Using the Custom Font&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Use the generated class name to apply the custom font. In this case, you can use the generated &lt;code&gt;font-inter&lt;/code&gt; class in your components:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;jsx&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; className&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;font-inter text-2xl font-bold&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  This text uses the Inter font&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content:encoded></item><item><title>Combining images using ImageMagick</title><link>https://arjun.xyz/blog/combining-images-using-imagemagick/</link><guid isPermaLink="true">https://arjun.xyz/blog/combining-images-using-imagemagick/</guid><description>Manipulating images from the command line</description><pubDate>Sun, 21 Mar 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Recently, I had to combine two images of an ID card into a single image with both of them stacked vertically. You can do this using any image editing program like Adobe Photoshop. This can be accomplished significantly faster with a single command using &lt;a href=&quot;https://imagemagick.org/&quot;&gt;ImageMagick&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can install ImageMagick using Homebrew, if you are on a Mac.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;brew&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; install&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; imagemagick&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After installing ImageMagick, you can combine all the images in a particular folder into a single image with the following command. Although this command uses a glob pattern to target multiple files, you can specify file names as well. ImageMagick is a very flexible tool and can be used to perform a variety of image manipulation operations. It also supports popular image formats.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;convert&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; -append&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;.jpg&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; combined.jpg&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To stack images horizontally, you can use the following command&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;convert&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; +append&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;.jpg&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; combined.jpg&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Happy image editing!&lt;/p&gt;</content:encoded></item><item><title>Redirecting domains using Netlify</title><link>https://arjun.xyz/blog/redirecting-domains-using-netlify/</link><guid isPermaLink="true">https://arjun.xyz/blog/redirecting-domains-using-netlify/</guid><description>Setting up 301 wildcard redirect on Netlify</description><pubDate>Tue, 06 Oct 2020 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I recently decided to move one of my projects to a new domain. Since the old domain was on Namecheap, I thought about using the BasicDNS service provided by Namecheap. I had faced issues with Namecheap DNS in the past and the basic version did not seem to offer any uptime guarantees. Since the project was hosted on Netlify, using Netlify DNS was a no brainer. I just needed to configure Netlify DNS to redirect requests from the old domain to the new domain.&lt;/p&gt;
&lt;p&gt;This took some more digging than I thought!. I am writing this down so it will help me in the future or you. First, I added the domain to Netlify using the UI and updated the DNS settings on Namecheap to point to Netlify’s DNS servers. Then I needed to setup a wildcard redirect on Netlify. This was not exactly straightforward.&lt;/p&gt;
&lt;p&gt;Netlify lets you configure redirects using a &lt;code&gt;_redirects&lt;/code&gt; file or using netlify.toml. I decided to use an &lt;code&gt;_redirects&lt;/code&gt; file. I created a new git repository with an empty &lt;code&gt;_redirects&lt;/code&gt; file and pushed that to Github. Then I linked my old domain to this repo using the UI.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;sh&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;https://old.com&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; https://new.com&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; 301!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;https://old.com/*&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; https://new.com/:splat&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt; 301!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Adding the lines above to the &lt;code&gt;_redirects&lt;/code&gt; file and redeploying did the trick. All the links to the old domain were being redirected successfully to the new domain and the universe became a better place, atleast in terms of DNS resolution.&lt;/p&gt;</content:encoded></item><item><title>Custom Iterm2 layouts with itermocil</title><link>https://arjun.xyz/blog/custom-iterm2-layout/</link><guid isPermaLink="true">https://arjun.xyz/blog/custom-iterm2-layout/</guid><description>Speeding up your workflow with predefined Iterm2 layouts</description><pubDate>Tue, 21 Apr 2020 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;If you frequently work with web development projects, you tend to run a lot of scripts during development. For example, if you are working on a full stack node project you might run &lt;code&gt;npm start&lt;/code&gt;, &lt;code&gt;npm run watch&lt;/code&gt; and maybe &lt;code&gt;npm run server&lt;/code&gt;. It is usually convenient to run them in different panes in a single tab in Iterm2, so that you can see everything in one place.&lt;/p&gt;
&lt;p&gt;Iterm2 lets you save and restore layouts from Preferences but &lt;a href=&quot;https://github.com/TomAnthony/itermocil&quot;&gt;itermocil&lt;/a&gt; lets you write YAML files for custom layout arrangements and relaunch them quickly.&lt;/p&gt;
&lt;p&gt;Here is a sample YAML for a simple 2-pane layout.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;yaml&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22863A&quot;&gt;windows&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;  - &lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;website&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22863A&quot;&gt;    root&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;~/Dev/website&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22863A&quot;&gt;    layout&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;even-horizontal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#22863A&quot;&gt;    panes&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;npm run dev&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;      - &lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;npm run server&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You need to save your custom layouts in &lt;code&gt;~/.itermocil&lt;/code&gt; and then you can launch the layout using the following command.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;itermocil&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;layout-nam&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;#&amp;#x3C;layout-name&gt; is the filename of the layout file in ~/.itermocil&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I aliased &lt;code&gt;itermocil&lt;/code&gt; to &lt;code&gt;t&lt;/code&gt; so that I can launch any of my custom layouts with &lt;code&gt;t &amp;#x3C;layout-name&gt;&lt;/code&gt;. Now I can start working on my website by just using &lt;code&gt;t www&lt;/code&gt;. A nice side effect is that I no longer have to remember what scripts to run per project, I can start hacking on any project with a single command.&lt;/p&gt;</content:encoded></item><item><title>SMS Receiver API</title><link>https://arjun.xyz/blog/sms-receiver-api/</link><guid isPermaLink="true">https://arjun.xyz/blog/sms-receiver-api/</guid><description>Building an OTP based login experience</description><pubDate>Thu, 02 Jan 2020 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Many applications use an OTP(One Time Password) based login flow these days. Native apps can automatically retrieve OTP values from text messages. This translates to a better user experience since manually entering or copy pasting the OTP is a big hassle. Sadly web browsers don’t have access to text messages, until now. The experimental &lt;a href=&quot;https://web.dev/sms-receiver-api-announcement&quot;&gt;SMS Receiver API&lt;/a&gt; which is under Origin trial provides a way for Chrome browsers on Android (version 78 onwards) to automatically retrieve OTP values from text messages with a few limitations. The feature needs to be explicitly enabled by setting the relevant flags or used under Origin Trial. The API is still experimental and hence is subject to change. But that does not mean you can’t play around with it.&lt;/p&gt;
&lt;p&gt;Lets look at how we can use the SMS Receiver API.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;&quot;sms&quot;&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; navigator) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; sms&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; navigator.sms.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;receive&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;  // sms.content gives us the body of the text message&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt; otp&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt; sms.content.&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;match&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;[\s\S]&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;otp=(&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;[0-9]&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;{6}&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;[\s\S]&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;*$&lt;/span&gt;&lt;span style=&quot;color:#032F62&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#D73A49&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;)[&lt;/span&gt;&lt;span style=&quot;color:#005CC5&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292E&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292E&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When the browser detects the message(currently it imposes a few restrictions on the message format), it displays a bottom sheet with the OTP and verify button as shown in the video below.&lt;/p&gt;
&lt;video autoplay muted loop playsinline&gt;
 &lt;source src=&quot;https://developer.chrome.com/static/docs/identity/web-apis/web-otp/video/web-dev-assets/web-otp/demo.mp4&quot; type=&quot;video/mp4&quot;&gt;
&lt;/video&gt;
&lt;p&gt;This is based on the demo which the Chrome team has published on &lt;a href=&quot;https://sms-receiver-demo.glitch.me/&quot;&gt;Glitch&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This feature is currently under Origin Trial but you can test it locally by enabling the relevant flags in Chrome Beta.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;limitations&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#limitations&quot;&gt;Limitations&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Since &lt;code&gt;navigator.sms.receive()&lt;/code&gt; returns a promise there is no way to abort/cancel the request. If the user navigates away from the login page, then he might see the bottomsheet. There is no way to set a message timeout either. There is an open github issue for this and I think they are planning to resolve this soon.&lt;/p&gt;
&lt;p&gt;The text message format is kind of restrictive at the moment, but they are working on it. Here is an example message&lt;/p&gt;
&lt;pre class=&quot;astro-code github-light&quot; style=&quot;background-color:#fff;color:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Your OTP is: 123456. This is only valid for 10 minutes. Do not share it with anybody else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;For: https://sms-receiver-demo.glitch.me/?otp=123456&amp;#x26;xFJnfg75+8v&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The message should include a line just like the last line in the example message. It should contain&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The origin of URL of the website which invoked the API, preceded by &lt;code&gt;For :&lt;/code&gt;. There is no localization support at this point.&lt;/li&gt;
&lt;li&gt;URL must contain the hash of the user’s chrome instance as a query parameter. This is a static string, &lt;code&gt;xFJnfg75+8v&lt;/code&gt; for Chrome Beta and &lt;code&gt;EvsSSj4C6vl&lt;/code&gt; for Chrome Beta. The web.dev article mentions that this is just for the time being.&lt;/li&gt;
&lt;li&gt;The URL must contain &lt;code&gt;otp&lt;/code&gt; query parameter with its value being the OTP value.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;final-thoughts&quot;&gt;&lt;a class=&quot;heading-anchor-link&quot; href=&quot;#final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It was lot of fun experimenting with this API. The inability to abort is a major limitation, but this seems to be in the pipeline. I think this API certainly improves user experience for OTP based login flows. I am excited to see how this evolves. Kudos to the Chrome team for coming up with this.&lt;/p&gt;</content:encoded></item></channel></rss>