<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Nandan Kumar's Blog | Software Engineer | Featured on BBC, Saudi Gazette, Times Of India | Tech Speaker | Mentor]]></title><description><![CDATA[Nandan Kumar's Blog | Software Engineer | Featured on BBC, Saudi Gazette, Times Of India | Tech Speaker | Mentor | Techie who "Hacked" an airline to retrieve his luggage]]></description><link>https://blog.nandan.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1662287805664/D9Nb8vZpE.png</url><title>Nandan Kumar&apos;s Blog | Software Engineer | Featured on BBC, Saudi Gazette, Times Of India | Tech Speaker | Mentor</title><link>https://blog.nandan.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 17:12:03 GMT</lastBuildDate><atom:link href="https://blog.nandan.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Convert Nested Objects to Flat Objects in JavaScript.]]></title><description><![CDATA[I am sure you have been asked this question in one of the interviews.
It looks simple at first. But the interviewer is actually checking whether you understand recursion, objects, and how JavaScript t]]></description><link>https://blog.nandan.dev/how-to-convert-nested-objects-to-flat-objects-in-javascript</link><guid isPermaLink="true">https://blog.nandan.dev/how-to-convert-nested-objects-to-flat-objects-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Objects]]></category><category><![CDATA[json]]></category><category><![CDATA[#js-interview]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Wed, 04 Mar 2026 00:59:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/628769bf89168247f55ee8b0/be8581d3-50f8-4780-915e-60b50525be70.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I am sure you have been asked this question in one of the interviews.</p>
<p>It looks simple at first. But the interviewer is actually checking whether you understand recursion, objects, and how JavaScript treats arrays.</p>
<p>So basically, you are given a nested object, and you are expected to simplify it by removing the nesting and printing it in a non-nested format.</p>
<h3>Here is a simple input and output :</h3>
<pre><code class="language-javascript">const input = {
  a: 1,
  b: {
    c: 2,
    d: {
      e: 3
    }
  }
};
</code></pre>
<h3>Output:</h3>
<pre><code class="language-javascript"> {  a: 1, 
    b_c: 2, 
    b_d_e: 3, 
 }
</code></pre>
<h3>Now look at the solution :</h3>
<pre><code class="language-javascript">function flatten(obj, prefix = "", res = {}) {
    // Loop through every key in the object
    for (let key in obj) {

        // Skip properties coming from prototype chain
        if (!obj.hasOwnProperty(key)) return;

        // If prefix exists, append current key using _
        // Otherwise just use the key itself
        let objKey = prefix ? `\({prefix}_\){key}` : key;

        let value = obj[key];

        // If value is an object and not null,
        // recursively flatten it
        if (typeof value === 'object' &amp;&amp; value !== null) {
            flatten(value, objKey, res);
        } else {
            // If it's a primitive value, assign it directly
            res[objKey] = value;
        }
    }

    // Return the accumulated result
    return res;
}
</code></pre>
<p>Let us test it.</p>
<pre><code class="language-javascript">const input = {
  a: 1,
  b: {
    c: 2,
    d: {
      e: [1, 2]
    }
  }
};

console.log(flatten(input));

//  {a: 1, b_c: 2, b_d_e_0: 1, b_d_e_1: 2 }
</code></pre>
<p>Now observe something interesting.</p>
<p>It flattens the nested object correctly.</p>
<p>But it also destructures the array and adds indexes as keys.</p>
<p><em>Why do you think that happened?</em></p>
<div>
<div>💡</div>
<div>As you know, everything in JavaScript is an object. Even <strong>Arrays</strong>.</div>
</div>

<p>So when we check:</p>
<pre><code class="language-javascript">typeof value === 'object'
</code></pre>
<p>Arrays also satisfy that condition.</p>
<p>That means our recursive call is going inside arrays as well, and treating indexes (0, 1) like object keys.</p>
<p>That is why we are getting:</p>
<pre><code class="language-javascript">b_d_e_0: 1
b_d_e_1: 2
</code></pre>
<h3><strong>So, how do we fix it?</strong></h3>
<p>Simple.</p>
<p>We add one more condition to ignore Arrays.</p>
<pre><code class="language-javascript">function flatten(obj, prefix = "", res = {}) {
    for (let key in obj) {

        // Ensure we are working only with object's own properties
        if (!obj.hasOwnProperty(key)) return;

        let objKey = prefix ? `\({prefix}_\){key}` : key;
        let value = obj[key];

        // Only recurse if:
        // 1. value is an object
        // 2. value is not null
        // 3. value is NOT an array
        if (
            typeof value === 'object' &amp;&amp;
            value !== null &amp;&amp;
            !Array.isArray(value)
        ) {
            flatten(value, objKey, res);
        } else {
            // Directly assign primitives and arrays
            res[objKey] = value;
        }
    }

    return res;
}
</code></pre>
<h2><strong>Testing Both Cases</strong></h2>
<pre><code class="language-javascript">const input1 = {
  a: 1,
  b: {
    c: 2,
    d: {
      e: [1, 2]
    }
  }
};

const input2 = {
  a: 1,
  b: {
    c: 2,
    d: {
      e: 3
    }
  }
};

console.log(flatten(input1));
console.log(flatten(input2));

// { a: 1, b_c: 2, b_d_e: [ 1, 2 ] }
// { a: 1, b_c: 2, b_d_e: 3 }
</code></pre>
<p>That is it.</p>
<p>A simple recursion problem. But it tests whether you truly understand:</p>
<ul>
<li><p>How objects work</p>
</li>
<li><p>How arrays behave internally</p>
</li>
<li><p>How recursion accumulates results</p>
</li>
<li><p>And how small edge cases can break your logic</p>
</li>
</ul>
<p>This is why interviewers love this question.</p>
<p>That’s all, folks! I hope you found this helpful. If you enjoyed this, check out more articles on my Blog, <a href="https://blog.nandan.dev/"><strong>https://blog.nandan.dev/</strong></a></p>
<p>Feel free to comment, email me at <a href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a href="https://www.instagram.com/nandandotdev"><strong>Instagram</strong></a> | <a href="https://github.com/sirius93"><strong>Github</strong></a> | <a href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[HTML Pitfalls and Gotchas Every Developer Should Avoid]]></title><description><![CDATA[HTML is easy, said every developer ever.
HTML is deceptively simple. You open a tag, you close a tag, and something appears on screen. But beneath that simplicity lurk gotchas that can silently break your layout, wreck your SEO, or make your site loo...]]></description><link>https://blog.nandan.dev/html-pitfalls-and-gotchas-every-developer-should-avoid</link><guid isPermaLink="true">https://blog.nandan.dev/html-pitfalls-and-gotchas-every-developer-should-avoid</guid><category><![CDATA[HTML5]]></category><category><![CDATA[Meta]]></category><category><![CDATA[Meta Tags]]></category><category><![CDATA[gotchas]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Fri, 05 Sep 2025 04:23:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1757046158565/25b1173b-f99c-4e7e-b343-558b1b387698.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><mark>HTML is easy, said every developer ever.</mark></p>
<p>HTML is deceptively simple. You open a tag, you close a tag, and something appears on screen. But beneath that simplicity lurk gotchas that can silently break your layout, wreck your SEO, or make your site look unprofessional when shared on social media.</p>
<p>In this world of frameworks and libraries, it’s easy to miss some of the basic stuff that needs to be taken care of in your webpage, because your framework’s boilerplate code adds up most of the stuff and takes care of the basics. But it’s always good to know some of them that are important or aren’t added by your framework by default.</p>
<p>Here are the critical HTML pitfalls to avoid and how to fix them immediately.</p>
<h2 id="heading-1-forgetting-the-doctype-declaration">1. Forgetting the DOCTYPE Declaration</h2>
<p>Skipping the doctype triggers something called as the <strong>quirks mode</strong>, where browsers start behaving like it's 1999. This results in inconsistent CSS rendering and unpredictable JavaScript behaviour across browsers.</p>
<p><strong>Always declare it at the very top of your HTML file:</strong></p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
</code></pre>
<h2 id="heading-2-missing-the-character-encoding-meta-tag">2. Missing the Character Encoding Meta Tag</h2>
<p>Without proper character encoding, special characters turn into garbled symbols i.e. (�). This breaks accented letters, smart quotes, and emojis, and it makes your webpage content look broken and unprofessional.</p>
<p><strong>Place this inside the</strong> <code>&lt;head&gt;</code> tag:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
</code></pre>
<h2 id="heading-3-forgetting-the-viewport-meta-tag">3. Forgetting the Viewport Meta Tag</h2>
<p>Has it ever happened to you? Your page zooms awkwardly when users double-tap on mobile; That’s because you're missing the viewport meta tag. Without it, your site isn't truly responsive, regardless of your CSS.</p>
<p><strong>Add this to your</strong> <code>&lt;head&gt;</code> <strong>section</strong>:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
</code></pre>
<h2 id="heading-4-skipping-open-graph-meta-tags">4. Skipping Open Graph Meta Tags</h2>
<p>Ever shared your blog on LinkedIn, Twitter, or Facebook only to see a bare URL with no preview card? That's because Open Graph tags are missing. These tags control how your content appears when shared on social media.</p>
<p><strong>Add these OG tags for rich sharing previews:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"og:title"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"My Blog Title"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"og:description"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"A quick guide to avoiding HTML gotchas."</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"og:image"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"https://example.com/preview.png"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"og:url"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"https://example.com/blog"</span>&gt;</span>
</code></pre>
<p><strong>Pro tip:</strong> Also consider adding Twitter Card tags for optimal Twitter/X previews.</p>
<h2 id="heading-5-ignoring-content-security-policy">5. Ignoring Content Security Policy</h2>
<p>Content Security Policy (CSP) helps prevent cross-site scripting (XSS) attacks and other code injection vulnerabilities. It tells browsers which scripts, styles, and resources are allowed to run on your page.</p>
<p><strong>Start with a basic CSP meta tag:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">"Content-Security-Policy"</span> 
      <span class="hljs-attr">content</span>=<span class="hljs-string">"default-src 'self'; script-src 'self' 'unsafe-inline';"</span>&gt;</span>
</code></pre>
<p><strong>Note:</strong> This is a starting point. Adjust the policy based on your specific needs and third-party resources.</p>
<h2 id="heading-6-improper-nesting-of-elements">6. Improper Nesting of Elements</h2>
<p>Browsers are forgiving, but invalid HTML nesting leads to unpredictable rendering and can break JavaScript that relies on the DOM structure.</p>
<p><strong>Common nesting mistakes:</strong></p>
<pre><code class="lang-html"><span class="hljs-comment">&lt;!-- Inline elements shouldn't contain block elements --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>Wrong!<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Paragraphs can't contain divs --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>Also wrong!<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p><strong>Follow these nesting rules:</strong></p>
<ul>
<li><p>Inline elements (<code>&lt;span&gt;</code>, <code>&lt;a&gt;</code>, <code>&lt;strong&gt;</code>) should <strong>never</strong> contain block-level elements (<code>&lt;div&gt;</code>, <code>&lt;section&gt;</code>, <code>&lt;p&gt;</code>)</p>
</li>
<li><p><code>&lt;p&gt;</code> Tags should only wrap inline content, never block-level elements</p>
</li>
<li><p>When in doubt, check the HTML specification for content models</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>These six HTML gotchas might seem minor, but they're the difference between a professional website and one that breaks in subtle, embarrassing ways. Take five minutes to audit your HTML templates—your future self (and your users) will thank you.</p>
<p><strong>Quick checklist for your next project:</strong></p>
<ul>
<li><p>DOCTYPE declaration at the top</p>
</li>
<li><p>UTF-8 character encoding</p>
</li>
<li><p>Viewport meta tag for mobile</p>
</li>
<li><p>Open Graph tags for social sharing</p>
</li>
<li><p>Basic Content Security Policy</p>
</li>
<li><p>Valid HTML nesting</p>
</li>
</ul>
<p>Remember: browsers are forgiving, but that doesn't mean we should be sloppy. Clean HTML is the foundation of a reliable web experience.</p>
<p>That’s all, folks! I hope you found this helpful. If you enjoyed this, check out more articles on my Blog, <a target="_blank" href="https://blog.nandan.dev/">https://blog.nandan.dev/</a></p>
<p>Feel free to comment, email me at <a target="_blank" href="http://mailto:connect@nandan.dev/"><strong>connect@nandan.dev</strong></a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/nandandotdev"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Front-End Developer Interviews: The Crucial Aspect of Accessibility]]></title><description><![CDATA[Let me start with this: Accessibility is not a buzzword; it’s a crucial feature that every web application should have.
It should not be mandated by the government, but rather it should be taken as the responsibility of every developer to make their ...]]></description><link>https://blog.nandan.dev/front-end-developer-interviews-the-crucial-aspect-of-accessibility</link><guid isPermaLink="true">https://blog.nandan.dev/front-end-developer-interviews-the-crucial-aspect-of-accessibility</guid><category><![CDATA[Accessibility]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[frontend]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Sat, 09 Aug 2025 16:57:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754758620254/32fa9796-0a0b-4228-943b-e2f20303e2a2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let me start with this: Accessibility is not a buzzword; it’s a crucial feature that every web application should have.</p>
<p>It should not be mandated by the government, but rather it should be taken as the responsibility of every developer to make their websites accessible to all users.</p>
<p>Making a website accessible will not just help you avoid government penalties, it will also give you a wider user base. Accessibility is all about making your website accessible to everyone.</p>
<p>On that note, let’s get this blog started -</p>
<h2 id="heading-what-is-accessibility">What is Accessibility</h2>
<p>Accessibility is ensuring that your web application is usable by people with disabilities, including people with</p>
<ul>
<li><p>Visual impairment (Blindness, Colour Blindness) -</p>
</li>
<li><p>Hearing loss</p>
</li>
<li><p>Motor Impairment ( Difficulty using the mouse)</p>
</li>
<li><p>Cognitive limitation (Dyslexia, Attention Disorder)</p>
</li>
</ul>
<h2 id="heading-accessibility-core-principle-pour">Accessibility Core Principle (POUR)</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Principle</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>P</strong>erceivable</td><td>Content must be perceivable by all (e.g., alt text, captions)</td></tr>
<tr>
<td><strong>O</strong>perable</td><td>All functionality must work via keyboard or assistive devices</td></tr>
<tr>
<td><strong>U</strong>nderstandable</td><td>Content should be readable and predictable</td></tr>
<tr>
<td><strong>R</strong>obust</td><td>Must work with various assistive technologies</td></tr>
</tbody>
</table>
</div><h2 id="heading-how-can-people-with-disabilities-use-the-applications">How can people with disabilities use the applications</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Visual impairment</td><td>Should be able to use with screen readers, VoiceOver, and Font Scaling support</td></tr>
</thead>
<tbody>
<tr>
<td>Hearing loss</td><td>Close Captions for Video and Audio</td></tr>
<tr>
<td>Motor Impairment</td><td>Keyboard Accessibility Support</td></tr>
<tr>
<td>Cognitive limitation</td><td>Simple Language</td></tr>
</tbody>
</table>
</div><h2 id="heading-accessibility-standards">Accessibility Standards</h2>
<h3 id="heading-web-content-accessibility-guidelines-wcag">Web Content Accessibility Guidelines (WCAG)</h3>
<p>Defines Accessibility levels as <strong>A</strong>, <strong>AA</strong> &amp; <strong>AAA</strong></p>
<p>Read More: <a target="_blank" href="https://www.w3.org/WAI/standards-guidelines/wcag/">https://www.w3.org/WAI/standards-guidelines/wcag/</a></p>
<h3 id="heading-accessible-rich-internet-applications-aria"><strong>Accessible Rich Internet Applications (ARIA)</strong></h3>
<p>Adds accessibility support to non-semantic elements.</p>
<p>Read More: <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label">https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/</a></p>
<h3 id="heading-americans-with-disabilities-act-ada">Americans with Disabilities Act (ADA)</h3>
<p>Legal mandate in the US for accessible digital content</p>
<p>Read More: <a target="_blank" href="https://www.ada.gov/">https://www.ada.gov/</a></p>
<blockquote>
<p><strong>AA</strong> is the most commonly required level of compliance.</p>
</blockquote>
<h2 id="heading-how-to-make-a-web-application-accessible">How to make a web application Accessible</h2>
<h3 id="heading-use-semantic-tags">Use Semantic Tags</h3>
<ul>
<li><p>Use tags like <code>&lt;button&gt;</code> , <code>&lt;nav&gt;</code>, <code>&lt;header&gt;</code>, <code>&lt;section&gt;</code> etc.</p>
</li>
<li><p>Avoid using div and span all over your application</p>
</li>
</ul>
<h3 id="heading-support-keyboard-accessibility">Support Keyboard Accessibility</h3>
<ul>
<li><p>Actions should be usable via. keyboard, including opening modals, dropdowns, and toasts.</p>
</li>
<li><p>Use <code>tabindex</code> to align focus correctly.</p>
</li>
<li><p>Use focus, keydown event listeners correctly</p>
</li>
</ul>
<h3 id="heading-use-aria-roles-when-needed">Use Aria Roles when needed</h3>
<ul>
<li><p>Use aria-label, aria-hidden, role="dialog", etc., when native semantics are not sufficient</p>
</li>
<li><p><a target="_blank" href="https://w3c.github.io/aria/">https://w3c.github.io/aria/</a></p>
</li>
</ul>
<h3 id="heading-focus-management">Focus Management</h3>
<ul>
<li><p>Trap focus in modals</p>
</li>
<li><p>Restore focus when modals close</p>
</li>
<li><p>Visibly indicate focus using focus-visible or outline</p>
</li>
</ul>
<h3 id="heading-maintain-colour-contrast">Maintain Colour Contrast</h3>
<ul>
<li><p>4.5: 1 for normal text in <strong>AA</strong> Standard</p>
</li>
<li><p>7:2 for <strong>AAA</strong></p>
</li>
<li><p>Check contrast: <a target="_blank" href="https://webaim.org/resources/contrastchecker/">https://webaim.org/resources/contrastchecker/</a></p>
</li>
</ul>
<h3 id="heading-using-images-and-other-media">Using Images and Other Media</h3>
<ul>
<li><p>Use alt text for images</p>
</li>
<li><p>Add transcripts/captions for videos/audio</p>
</li>
<li><p>Avoid autoplaying media files. i.e. Video</p>
</li>
</ul>
<h2 id="heading-tools-for-accessibility-testing">Tools for Accessibility Testing</h2>
<p>The tools listed below are some of the most common tools for testing accessibility in a web application.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Tool</strong></td><td><strong>Use Case</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>axe DevTools</strong></td><td>Chrome extension to audit a11y</td></tr>
<tr>
<td><strong>Lighthouse</strong></td><td>Built-in browser audits</td></tr>
<tr>
<td><strong>NVDA / VoiceOver</strong></td><td>Screen reader testing</td></tr>
<tr>
<td><strong>Tab key</strong></td><td>Test keyboard navigation</td></tr>
</tbody>
</table>
</div><blockquote>
<p>WCAG <strong>AAA is harder to implement, and most website are expected to maintain AA compliant.</strong></p>
</blockquote>
<p>I hope by the end of this post, you have a good idea of why accessibility is important and how you can add accessibility support to your application.</p>
<p>That’s all, folks! I hope you found this helpful. If you enjoyed this, check out more articles on my Blog, <a target="_blank" href="https://blog.nandan.dev/">https://blog.nandan.dev/</a></p>
<p>Feel free to comment, email me at <a target="_blank" href="http://mailto:connect@nandan.dev/"><strong>connect@nandan.dev</strong></a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/nandandotdev"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[How to Design Instagram: Front-End System Design]]></title><description><![CDATA[Let me start by putting one thing forward: System design is not about writing a memorised answer on paper. It’s more about thinking, planning and strategising.
Hence, there is no correct answer, but a correct Framework. Understanding and approaching ...]]></description><link>https://blog.nandan.dev/how-to-design-instagram-front-end-system-design</link><guid isPermaLink="true">https://blog.nandan.dev/how-to-design-instagram-front-end-system-design</guid><category><![CDATA[System Design]]></category><category><![CDATA[frontend]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Meta]]></category><category><![CDATA[instagram]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Fri, 01 Aug 2025 05:19:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754025466156/4dc4da77-f23b-42df-b348-af563ce429ae.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let me start by putting one thing forward: System design is not about writing a memorised answer on paper. It’s more about thinking, planning and strategising.</p>
<p>Hence, there is no correct answer, but a correct Framework. Understanding and approaching system design with the RADIO <strong>RADIO framework</strong> (Requirements, Architecture, Design, Implementation, Optimisation) helps you streamline your answer.</p>
<p>Additionally, you can treat this blog as a framework for everything that requires building a feed, i.e. Twitter, Facebook, or Orkut, for that matter.</p>
<p>But everything beyond that is dependent on your knowledge and understanding of the system.</p>
<p>Designing a platform like Instagram might sound overwhelming at first, but breaking it down using the <strong>RADIO framework</strong> (Requirements, Architecture, Design, Implementation, Optimisation) makes it manageable and actually kinda fun. I recently took a shot at this, and here's what I came up with, plus a few tweaks and lessons learned along the way.</p>
<hr />
<h2 id="heading-requirements">Requirements</h2>
<h3 id="heading-functional-requirements">🔧 Functional Requirements:</h3>
<ul>
<li><p>News Feed that shows text, images, and videos</p>
</li>
<li><p>User info (photo, username) on each post</p>
</li>
<li><p>Like, comment, and share buttons</p>
</li>
<li><p>Pagination or infinite scroll</p>
</li>
<li><p>Lazy loading for media</p>
</li>
</ul>
<h3 id="heading-non-functional-requirements">🚫 Non-Functional Requirements:</h3>
<ul>
<li><p>Fully responsive (mobile + desktop)</p>
</li>
<li><p>Accessibility compliant</p>
</li>
<li><p>Optimised for performance</p>
</li>
<li><p>Supports A/B testing for features</p>
</li>
<li><p>Localisation and translation support</p>
</li>
</ul>
<p>Bonus points if it supports offline mode and has a fallback UI.</p>
<hr />
<h2 id="heading-architecture">Architecture</h2>
<p>Start by defining your core building blocks:</p>
<h3 id="heading-components">📂 Components:</h3>
<pre><code class="lang-javascript">PostCard
├── TextContent
├── ImageGallery / VideoPlayer
├── UserHeader (avatar + name)
├── PostActions (like/comment/share)

Feed
└── PostCard[]

CommentSection
LikeButton
ShareButton
</code></pre>
<p>Each of these is reusable and maintainable — the key to scalable front-end architecture.</p>
<hr />
<h2 id="heading-design">Design</h2>
<p>Keep your data models clean and normalised. Here's what worked well:</p>
<pre><code class="lang-ts"><span class="hljs-keyword">type</span> Post = {
  id: <span class="hljs-built_in">string</span>;
  text?: <span class="hljs-built_in">string</span>;
  images?: <span class="hljs-built_in">string</span>[];
  video?: <span class="hljs-built_in">string</span>;
  userId: <span class="hljs-built_in">string</span>;
  comments: Comment[];
  likes: Like[];
  createdAt: <span class="hljs-built_in">string</span>;
};

<span class="hljs-keyword">type</span> User = {
  id: <span class="hljs-built_in">string</span>;
  name: <span class="hljs-built_in">string</span>;
  username: <span class="hljs-built_in">string</span>;
  avatar: <span class="hljs-built_in">string</span>;
  postIds: <span class="hljs-built_in">string</span>[];
};

<span class="hljs-keyword">type</span> Like = {
  userId: <span class="hljs-built_in">string</span>;
  postId: <span class="hljs-built_in">string</span>;
};

<span class="hljs-keyword">type</span> Comment = {
  id: <span class="hljs-built_in">string</span>;
  userId: <span class="hljs-built_in">string</span>;
  postId: <span class="hljs-built_in">string</span>;
  text: <span class="hljs-built_in">string</span>;
  createdAt: <span class="hljs-built_in">string</span>;
};
</code></pre>
<ul>
<li><p>Avoid embedding full <code>User</code> objects inside posts</p>
</li>
<li><p>Use IDs to reference everything</p>
</li>
<li><p>Support multiple images per post (carousel style)</p>
</li>
</ul>
<hr />
<h2 id="heading-implementation">Implementation</h2>
<p>Here's how the main flow looks:</p>
<ul>
<li><p><strong>Feed Page</strong>: loads posts using a custom hook (<code>useFetchPosts</code>)</p>
</li>
<li><p>Loop through <code>PostCard</code> components to render UI</p>
</li>
<li><p>Use libraries like React Query or SWR for cache + fetch</p>
</li>
<li><p>Defer comment loading until user clicks "View all comments"</p>
</li>
</ul>
<h3 id="heading-suggested-folder-structure">Suggested folder structure:</h3>
<pre><code class="lang-javascript">/components
  /Post
    PostCard.tsx
    PostMedia.tsx
    PostFooter.tsx
  /User
  /Comment
/hooks
  useFetchPosts.ts
/pages
  index.tsx <span class="hljs-comment">// News Feed</span>
</code></pre>
<hr />
<h2 id="heading-optimization">Optimization</h2>
<p>Performance matters more than ever. Here's what to prioritise:</p>
<ul>
<li><p>📸 Lazy load images and videos</p>
</li>
<li><p>🔄 Use <code>IntersectionObserver</code> for infinite scroll</p>
</li>
<li><p>🏔️ PWA support (with service workers)</p>
</li>
<li><p>📑 Bundle splitting + code-splitting</p>
</li>
<li><p>🚀 Skeleton loaders while fetching</p>
</li>
<li><p>🌍 Localised text using <code>react-i18next</code></p>
</li>
<li><p>📉 Memoise unchanging components with <code>React.memo</code></p>
</li>
</ul>
<hr />
<h2 id="heading-tldr">TL;DR</h2>
<p>Designing Instagram from the front-end isn’t about copying their UI; it's about building a thoughtful system that can scale, perform, and feel native on any device. Use the RADIO framework to break down the chaos into manageable parts, and you'll be surprised how fast it comes together.</p>
]]></content:encoded></item><item><title><![CDATA[Polyfills of JS Array Methods - Flat, Map, Filter & Reduce (Because Why Not?)]]></title><description><![CDATA[Alright, confession time, I’ve been writing JavaScript for a while now, but there’s something oddly satisfying about going back to the basics. You know, like trying to bake your bread from scratch even though you live next to a bakery. That’s exactly...]]></description><link>https://blog.nandan.dev/polyfills-of-js-array-methods-flat-map-filter-and-reduce-because-why-not</link><guid isPermaLink="true">https://blog.nandan.dev/polyfills-of-js-array-methods-flat-map-filter-and-reduce-because-why-not</guid><category><![CDATA[polyfills]]></category><category><![CDATA[array methods]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Tue, 13 May 2025 14:03:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1747144915746/c275448b-a46c-4dad-8d0f-7d63dd154f7e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Alright, confession time, I’ve been writing JavaScript for a while now, but there’s something oddly satisfying about going back to the basics. You know, like trying to bake your bread from scratch even though you live next to a bakery. That’s exactly what this post is about: baking our versions of some classic array methods.</p>
<p>Want to understand what polyfills are? <a target="_blank" href="https://blog.nandan.dev/polyfills-for-call-apply-and-bind-lets-build-them-from-scratch">I have covered them in my blog Polyfills for Call, Apply &amp; Bind.</a></p>
<p>Why? Because it's fun. Because it's educational. And because the next time someone throws a technical interview curveball at you, like "Can you write your own <code>reduce</code>" and you’ll casually say, "Sure, do you want it with comments or without?"</p>
<p>Today, we’re building polyfills for:</p>
<ul>
<li><p><code>flat()</code></p>
</li>
<li><p><code>map()</code></p>
</li>
<li><p><code>filter()</code></p>
</li>
<li><p><code>reduce()</code></p>
</li>
</ul>
<p>Let’s roll.</p>
<h2 id="heading-flat-a-pancake-stack-for-arrays"><code>flat()</code> — A Pancake Stack for Arrays</h2>
<pre><code class="lang-javascript"><span class="hljs-keyword">if</span>(!<span class="hljs-built_in">Array</span>.prototype.myFlat){
    <span class="hljs-built_in">Array</span>.prototype.myFlat = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">depth</span>)</span>{
        <span class="hljs-keyword">if</span>(depth &lt; <span class="hljs-number">0</span>) <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>;

        <span class="hljs-keyword">const</span> flatten = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">arr, depth</span>)</span>{
            <span class="hljs-keyword">return</span> arr.reduce(<span class="hljs-function">(<span class="hljs-params">acc,ele</span>)=&gt;</span>{
                <span class="hljs-keyword">if</span>(<span class="hljs-built_in">Array</span>.isArray(ele) &amp;&amp; depth &gt; <span class="hljs-number">0</span>){
                    acc = acc.concat(flatten(ele,depth <span class="hljs-number">-1</span>));
                }<span class="hljs-keyword">else</span>{
                    acc.push(ele);
                }
                <span class="hljs-keyword">return</span> acc;
            },[])
        }

        <span class="hljs-keyword">return</span> flatten(<span class="hljs-built_in">this</span>,depth);
    }
}

<span class="hljs-keyword">const</span> nestedArray = [<span class="hljs-number">1</span>, [<span class="hljs-number">2</span>, [<span class="hljs-number">3</span>, [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>]]], <span class="hljs-number">6</span>];

<span class="hljs-built_in">console</span>.log(nestedArray.myFlat()); <span class="hljs-comment">// Default depth = 1 =&gt; [1, 2, [3, [4, 5]], 6]</span>
<span class="hljs-built_in">console</span>.log(nestedArray.myFlat(<span class="hljs-number">2</span>)); <span class="hljs-comment">// Depth = 2 =&gt; [1, 2, 3, [4, 5], 6]</span>
<span class="hljs-built_in">console</span>.log(nestedArray.myFlat(<span class="hljs-number">3</span>)); <span class="hljs-comment">// Depth = 3 =&gt; [1, 2, 3, 4, 5, 6]</span>
<span class="hljs-built_in">console</span>.log(nestedArray.myFlat(<span class="hljs-number">0</span>)); <span class="hljs-comment">// Depth = 0 =&gt; [1, [2, [3, [4, 5]]], 6]</span>
</code></pre>
<p>Just a basic flattening function. Will it replace your backend job? No. But will it make you feel cool? Absolutely.</p>
<h2 id="heading-map-because-sometimes-arrays-need-a-makeover"><code>map()</code> — Because Sometimes Arrays Need a Makeover</h2>
<pre><code class="lang-javascript"><span class="hljs-keyword">if</span>(!<span class="hljs-built_in">Array</span>.prototype.myMap){
    <span class="hljs-built_in">Array</span>.prototype.myMap = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">fn, thisArg</span>)</span>{
       <span class="hljs-keyword">if</span>(<span class="hljs-built_in">this</span> == <span class="hljs-literal">null</span>)  { <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Not an array"</span>)};

       <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span>(fn) != <span class="hljs-string">'function'</span>) {<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Not an array"</span>)}

       <span class="hljs-keyword">let</span> result = [];

       <span class="hljs-keyword">for</span>(<span class="hljs-keyword">let</span> i=<span class="hljs-number">0</span>; i&lt; <span class="hljs-built_in">this</span>.length; i++){
           <span class="hljs-keyword">if</span>(i <span class="hljs-keyword">in</span> <span class="hljs-built_in">this</span>){
               result.push(fn.call(thisArg,<span class="hljs-built_in">this</span>[i], i, <span class="hljs-built_in">this</span>));
           }
       }
       <span class="hljs-keyword">return</span> result;
    }
}

a = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>].myMap(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">mem</span>) </span>{
    <span class="hljs-keyword">return</span> mem*mem;
})

<span class="hljs-built_in">console</span>.log(a); <span class="hljs-comment">// [ 1, 4, 9, 16, 25 ]</span>
</code></pre>
<p>Simple and clean. No magical spells involved.</p>
<h2 id="heading-filter-only-the-worthy-shall-pass"><code>filter()</code> — Only the Worthy Shall Pass</h2>
<pre><code class="lang-javascript"><span class="hljs-keyword">if</span>(!<span class="hljs-built_in">Array</span>.prototype.myFilter){
    <span class="hljs-built_in">Array</span>.prototype.myFilter = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">fn, thisArg</span>)</span>{
       <span class="hljs-keyword">if</span>(<span class="hljs-built_in">this</span> == <span class="hljs-literal">null</span>)  { <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Not an array"</span>)};

       <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span>(fn) != <span class="hljs-string">'function'</span>) {<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Not an array"</span>)}

       <span class="hljs-keyword">let</span> result = [];

       <span class="hljs-keyword">for</span>(<span class="hljs-keyword">let</span> i=<span class="hljs-number">0</span>; i&lt; <span class="hljs-built_in">this</span>.length; i++){
           <span class="hljs-keyword">if</span>(i <span class="hljs-keyword">in</span> <span class="hljs-built_in">this</span> &amp;&amp; fn.call(thisArg,<span class="hljs-built_in">this</span>[i], i, <span class="hljs-built_in">this</span>)){
               result.push(<span class="hljs-built_in">this</span>[i]);
           }
       }
       <span class="hljs-keyword">return</span> result;
    }
}

b = [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>].myFilter(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">mem</span>) </span>{
    <span class="hljs-keyword">return</span> mem &gt; <span class="hljs-number">1</span>;
})

<span class="hljs-built_in">console</span>.log(b) <span class="hljs-comment">//[ 2, 3, 4, 5 ]</span>
</code></pre>
<p>Give it a test run with your own weird conditions. Even filter out people who don't like coffee; your call.</p>
<h2 id="heading-reduce-the-boss-level"><code>reduce()</code> — The Boss Level</h2>
<pre><code class="lang-javascript"><span class="hljs-keyword">if</span>(!<span class="hljs-built_in">Array</span>.prototype.myReduce){
    <span class="hljs-built_in">Array</span>.prototype.myReduce = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">callback,initialValue</span>)</span>{
        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">this</span> == <span class="hljs-literal">null</span>) {<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Not an Array"</span>);}

        <span class="hljs-keyword">if</span>(<span class="hljs-keyword">typeof</span>(callback) != <span class="hljs-string">'function'</span>) {
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Not a function"</span>);
        }

        <span class="hljs-keyword">let</span> arr = <span class="hljs-built_in">this</span>;
        <span class="hljs-keyword">let</span> len = arr.length;

        <span class="hljs-keyword">let</span> hasInitial = <span class="hljs-built_in">arguments</span>.length &gt; <span class="hljs-number">1</span>;
        <span class="hljs-keyword">let</span> accumulator = hasInitial ? initialValue : arr[<span class="hljs-number">0</span>];
        <span class="hljs-keyword">let</span> startIndex = hasInitial ? <span class="hljs-number">0</span> : <span class="hljs-number">1</span>;

        <span class="hljs-keyword">if</span> (len === <span class="hljs-number">0</span> &amp;&amp; !hasInitial) {
          <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Reduce of empty array with no initial value"</span>);
        }


        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = startIndex; i &lt; len; i++) {
          <span class="hljs-keyword">if</span> (i <span class="hljs-keyword">in</span> arr) {
            accumulator = callback(accumulator, arr[i], i, arr);
          }
        }

        <span class="hljs-keyword">return</span> accumulator;
    }
}

<span class="hljs-keyword">let</span> a = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].myReduce(<span class="hljs-function">(<span class="hljs-params">acc, val</span>) =&gt;</span> acc + val, <span class="hljs-number">0</span>);
<span class="hljs-built_in">console</span>.log(a);
</code></pre>
<p>Reduce is like that friend who seems intimidating at first, but once you get to know them, they carry the whole squad.</p>
<h3 id="heading-why-do-this">Why Do This?</h3>
<p>You may never need to use these in a production app. But knowing how they work helps you:</p>
<ul>
<li><p>Understand JavaScript fundamentals better.</p>
</li>
<li><p>Appreciate the built-in methods more.</p>
</li>
<li><p>Have something cool to say in interviews or while pretending to debug in coffee shops.</p>
</li>
</ul>
<p>So go ahead, mess around with these, add your own flavour, and maybe even extend a couple more methods just for fun.</p>
<p>That’s all, folks! I hope you found this helpful. If you enjoyed this, check out more articles on my Blog, <a target="_blank" href="https://blog.nandan.dev/">https://blog.nandan.dev/</a></p>
<p>Feel free to comment, email me at <a target="_blank" href="http://mailto:connect@nandan.dev/"><strong>connect@nandan.dev</strong></a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/nandandotdev"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Polyfills for Call, Apply, and Bind — Let’s Build Them From Scratch]]></title><description><![CDATA[https://store.nandan.dev/l/javascript-interview-prep-handbook
 
Okay, so if you have ever deep-dived into JavaScript interviews or just casually scrolled through dev Twitter (yes, that’s a thing), you would have stumbled upon someone throwing around ...]]></description><link>https://blog.nandan.dev/polyfills-for-call-apply-and-bind-lets-build-them-from-scratch</link><guid isPermaLink="true">https://blog.nandan.dev/polyfills-for-call-apply-and-bind-lets-build-them-from-scratch</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[polyfills]]></category><category><![CDATA[call apply and bind methods]]></category><category><![CDATA[interview questions]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Mon, 28 Apr 2025 16:51:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1745858731907/fc43c7fc-0191-42ff-bdd1-19518625c8b7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://store.nandan.dev/l/javascript-interview-prep-handbook">https://store.nandan.dev/l/javascript-interview-prep-handbook</a></div>
<p> </p>
<p>Okay, so if you have ever deep-dived into JavaScript interviews or just casually scrolled through dev Twitter (yes, that’s a thing), you would have stumbled upon someone throwing around the words <strong>polyfill</strong> like they were born building web browsers.</p>
<p>And if you’re like me, you probably nodded along, opened a tab to Google it later, and… procrastinated.</p>
<p><img src="https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExd2NhODEycGhiZjJmZGsweG4xaHc5ODAzbnB0eGk4dWZjM241Yjd4YSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/3o6gbenQcUjEGTaNfW/giphy.gif" alt class="image--center mx-auto" /></p>
<p>But no worries. You’re here now, and we are going to figure this out <em>together.</em></p>
<h2 id="heading-first-things-first-what-the-heck-is-a-polyfill"><strong>First things first — What the heck is a polyfill?</strong></h2>
<p>A <strong>polyfill</strong> is just a piece of code (usually JavaScript) that <strong>adds functionality to older browsers</strong> that do not natively support a certain feature.</p>
<p>Think of it like you bringing a power bank to an event where there are no charging points. Your phone is old? No problem. You got the backup.</p>
<h2 id="heading-now-why-call-apply-and-bind"><strong>Now… Why Call, Apply, and Bind?</strong></h2>
<p>Because they’re like the Avengers of function manipulation in JavaScript.</p>
<p>And also because they confuse almost everyone at first.</p>
<ul>
<li><p><code>call</code> lets you call a function with a given this value and arguments.</p>
</li>
<li><p><code>apply</code> is like <code>call</code>, but arguments are passed as an array.</p>
</li>
<li><p><code>bind</code> doesn’t immediately invoke the function. It <em>returns a new function</em> with a given this.</p>
</li>
</ul>
<p><a target="_blank" href="https://blog.nandan.dev/yet-another-blog-on-call-apply-bind">Here is a detailed write-up on call, apply &amp; bind</a>.</p>
<p>Simple enough, right? Now let’s make our versions</p>
<h2 id="heading-polyfill-for-call"><strong>Polyfill for call</strong></h2>
<p>Here’s how we can build a <strong>polyfill for call</strong>:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Function</span>.prototype.myCall = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">context,...args</span>)</span>{ 
    context = context || globalThis;
    <span class="hljs-keyword">let</span> Symbolfn = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"fn"</span>); <span class="hljs-comment">// Unique key</span>
    context[Symbolfn] = <span class="hljs-built_in">this</span>; <span class="hljs-comment">// Assign 'this' function to the context</span>
    <span class="hljs-keyword">let</span> result = context[Symbolfn](...args); <span class="hljs-comment">// Call the function</span>
    <span class="hljs-keyword">delete</span> context[Symbolfn];  <span class="hljs-comment">// Clean up</span>
    <span class="hljs-keyword">return</span> result;
}

<span class="hljs-comment">// Usage</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sayHello</span>(<span class="hljs-params">greeting</span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${greeting}</span>, <span class="hljs-subst">${<span class="hljs-built_in">this</span>.name}</span>`</span>);
}

<span class="hljs-keyword">const</span> user = { <span class="hljs-attr">name</span>: <span class="hljs-string">"Nandan"</span> };
sayHello.myCall(user, <span class="hljs-string">"Hello"</span>);
</code></pre>
<p>Cool, right? Not rocket science.</p>
<h2 id="heading-polyfill-for-apply"><strong>Polyfill for apply</strong></h2>
<p>Now, let’s tweak it a bit for <strong>apply</strong>:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Function</span>.prototype.myApply = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">context,args</span>)</span>{
    context = context || globalThis;
    <span class="hljs-keyword">let</span> Symbolfn = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"fn"</span>);
    context[Symbolfn] = <span class="hljs-built_in">this</span>;
    <span class="hljs-keyword">let</span> result = args ? context[Symbolfn](...args) : context[Symbolfn]();
    <span class="hljs-keyword">delete</span> context[Symbolfn];
    <span class="hljs-keyword">return</span> result;
}

<span class="hljs-comment">// Usage</span>
sayHello.myApply(user, [<span class="hljs-string">"Hi"</span>]);
</code></pre>
<h2 id="heading-polyfill-for-bind"><strong>Polyfill for bind</strong></h2>
<p>Now comes the big boss <strong>bind</strong>.</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">Function</span>.prototype.myBind = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">context,...initialArgs</span>)</span>{
    <span class="hljs-keyword">let</span> fn = <span class="hljs-built_in">this</span>;
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">...functArgs</span>)</span>{
        <span class="hljs-keyword">return</span> fn.apply(context, [...initialArgs,...functArgs])
    }
}

<span class="hljs-comment">// Usage</span>
<span class="hljs-keyword">const</span> boundSayHello = sayHello.myBind(user, <span class="hljs-string">"Hey"</span>);
boundSayHello(); <span class="hljs-comment">// Outputs: Hey, Nandan</span>
</code></pre>
<ul>
<li><p>bind doesn’t call the function right away.</p>
</li>
<li><p>It returns a <em>new function</em> that you can call later.</p>
</li>
<li><p>We merge the arguments provided at bind-time and call-time.</p>
</li>
</ul>
<h2 id="heading-thats-it-you-just-built-call-apply-and-bind-polyfills"><strong>That’s it — You just built call, apply, and bind polyfills!</strong></h2>
<p>Honestly, when I first read about polyfills, I thought it was some deep internal browser magic. Turns out, it’s just about creatively manipulating JavaScript’s behavior.</p>
<p>If you take one thing from this post, let it be this:</p>
<blockquote>
<p>“The cowards never started and the weak died along the way. That leaves us, ladies and gentlemen. Us.”</p>
</blockquote>
<p>(Yeah, that’s a quote from <em>Shoe Dog</em>. Still fits perfectly here, doesn’t it?)</p>
<p><a target="_blank" href="https://kitaaben.com/p/just-do-it-the-real-story-behind-nike-s-rise">Here’s one if you want to read a review of the book Shoe Dog, written by me.</a></p>
<p>That’s all, folks! I hope you found this short note on Polyfills of Call, Apply &amp; Bind helpful. If you enjoyed this, check out more articles on my Blog, <a target="_blank" href="https://blog.nandan.dev/">https://blog.nandan.dev/</a></p>
<p>Feel free to comment, email me at <a target="_blank" href="http://mailto:connect@nandan.dev/"><strong>connect@nandan.dev</strong></a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/nandandotdev"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[I built an AI Book Recommendation App and was DDOS-ed for it.]]></title><description><![CDATA[Last week, Google introduced its AI copilot Firebase Studio, and I decided to give it a try. It got me thinking about what I want to do next.
If you may be following me on socials, I just started a newsletter for book reviews & suggestions. Check htt...]]></description><link>https://blog.nandan.dev/i-built-an-ai-book-recommendation-app-and-was-ddos-ed-for-it</link><guid isPermaLink="true">https://blog.nandan.dev/i-built-an-ai-book-recommendation-app-and-was-ddos-ed-for-it</guid><category><![CDATA[AI]]></category><category><![CDATA[vibe coding]]></category><category><![CDATA[ddos]]></category><category><![CDATA[DDoS Protection ]]></category><category><![CDATA[cloudflare]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Tue, 15 Apr 2025 10:37:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1744713215395/d734f5ba-48fe-43da-a994-8232425c0fac.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Last week, Google introduced its AI copilot Firebase Studio, and I decided to give it a try. It got me thinking about what I want to do next.</p>
<p>If you may be following me on socials, I just started a newsletter for book reviews &amp; suggestions. Check <a target="_blank" href="https://kitaaben.com">https://kitaaben.com</a>. That got me thinking: What if I built a small book recommendation application that can help users get book recommendations based on their interests?</p>
<p>I started building it on Firebase studio. Started with a simple prompt to build an AI-based book recommendation application that shows a good variety of genres by default and an interest field for additional context. The Number of books you want to be recommended is either 1/3/6 or 12.</p>
<p>The initial version came with these fields. But after some iterations, I decided to add the email field and email integration to help users get the recommendation directly to their email.</p>
<p>The tech stack looks something like this:</p>
<ul>
<li><p>Nextjs + Reactjs ( For the application)</p>
</li>
<li><p>Gemini API (For AI)</p>
</li>
<li><p>Firebase (For Hosting)</p>
</li>
<li><p>Resend (For Email - Free Tier)</p>
</li>
</ul>
<p>The final version looked like this:</p>
<p><a target="_blank" href="https://bookwise.kitaaben.com/"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744711016863/dd4268f4-7f57-4399-9fc3-83b724e4b07f.png" alt class="image--center mx-auto" /></a></p>
<p>After some testing and a lot of dopamine, I went ahead and made it public. Mapped it to a subdomain and made it public. Here is the URL if you want to give it a try: <a target="_blank" href="https://bookwise.kitaaben.com/">https://bookwise.kitaaben.com</a></p>
<p>I shared it in my friend’s WhatsApp group, Instagram, Twitter( now X), Linkedin almost everywhere I could.</p>
<p>But seems like someone didn’t like the spamming and decided to do something about it. By launching a DDOS attack on my website.Targeting my email functionality, trying to exhaust my email limit and increasing my cloud hosting + AI usage cost.</p>
<p>See the sudden spike in the requests?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1744711671403/431a9532-9260-4fd6-9a0b-e89038891b24.png" alt class="image--center mx-auto" /></p>
<p>Panic set in; I didn’t know what to do. Should I bring down the site and end this or something else? I decided not to give up and just think and act quickly</p>
<p>I did and quickly signed up for Cloudflare, added the Cloudflare protection layer to my app and observed the behaviour for some time. By this time, my email limit of 200 emails by resend had already been exhausted, so I waited for the next day and added a caching layer to store the emails and rate limit the emails to 3 emails per hour.</p>
<p>Things seem to be stable for now. The traffic has dropped as well. However, I would not mind some humans trying the app, benefiting from it and providing some real feedback.</p>
<p>If you are a human reading this, give the app a try. Tell me what you like/dislike. I am always just an email away at <a target="_blank" href="mailto:connect@nandan.dev">connect@nandan.dev</a></p>
<hr />
<p>That’s all, folks! I hope you enjoyed this. Check out more articles on my website, <a target="_blank" href="https://nandan.dev/"><strong>https://nandan.dev/</strong></a></p>
<p>Feel free to comment, email me at <a target="_blank" href="http://mailto:connect@nandan.dev/"><strong>connect@nandan.dev</strong></a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/nandandotdev"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Yet another blog on Call, Apply & Bind..!!]]></title><description><![CDATA[Bla Bla Bla..
Okay, Hear me out..!!
Hundreds of blogs and tutorials explain call, bind, and apply. Heck, even ChatGPT and Copilot can simplify them for you!
So why another post? Well, this one’s not for you—it’s my self-note as I revisit JavaScript f...]]></description><link>https://blog.nandan.dev/yet-another-blog-on-call-apply-bind</link><guid isPermaLink="true">https://blog.nandan.dev/yet-another-blog-on-call-apply-bind</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[learning]]></category><category><![CDATA[this keyword]]></category><category><![CDATA[Objects]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Fri, 22 Nov 2024 11:05:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1732273207021/92fa831e-80f5-415e-b1ab-9e46cb5b6998.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-bla-bla-bla">Bla Bla Bla..</h2>
<p>Okay, Hear me out..!!</p>
<p>Hundreds of blogs and tutorials explain call, bind, and apply. Heck, even ChatGPT and Copilot can simplify them for you!</p>
<p>So why another post? Well, this one’s not for <em>you</em>—it’s my self-note as I revisit JavaScript fundamentals.</p>
<p>Even after 8 years in front-end development, I sometimes mix up these methods. Turns out, the confusion often stems from how they’re grouped in interview questions. Let me break it down for you—this time, in a way that sticks.</p>
<h2 id="heading-can-we-skip-to-the-good-part">Can we skip to the good part.</h2>
<p>Why is it always call, bind, and apply in interviews? Functionally, call and apply are closer—they invoke the function immediately—while bind returns a new function. That’s why I’ve grouped them this way in the title.</p>
<p>Let's look at their usage to understand it better.</p>
<h3 id="heading-what-is-common-among-call-bind-amp-apply">What is common among Call, Bind &amp; Apply?</h3>
<p><strong>call</strong>, <strong>bind</strong>, and <strong>apply</strong> are methods available on functions that allow you to explicitly set the value of <strong>this</strong> and pass arguments to the function.</p>
<h3 id="heading-what-is-the-difference-between-call-bind-amp-apply">What is the difference between Call, Bind &amp; Apply?</h3>
<p>While Call and Apply Immediately invoke the function, the Bind method does not immediately invoke the function. instead, it returns a new function with <strong>this</strong> set to a specified value, and this returned function can be invoked/executed later.</p>
<h3 id="heading-what-is-the-difference-between-call-and-apply-then">What is the difference between Call and Apply then?</h3>
<p>While both Call and Apply immediately invoke the function with the custom this, it’s how they take the additional argument that differentiates them.</p>
<p>While Call takes the individual arguments, Apply takes an array of arguments.</p>
<h3 id="heading-examples">Examples</h3>
<p>Let’s look at the below example to understand the use of call, apply and bind.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Greetings</span>(<span class="hljs-params">greeting,punctuation</span>)</span>{
    <span class="hljs-keyword">return</span> <span class="hljs-string">`<span class="hljs-subst">${greeting}</span> <span class="hljs-subst">${<span class="hljs-built_in">this</span>.name}</span> <span class="hljs-subst">${punctuation}</span>`</span>
}

<span class="hljs-keyword">var</span> person = {
    <span class="hljs-attr">name</span> : <span class="hljs-string">"Nandan"</span>
}

<span class="hljs-comment">// Call: Immediately invokes the function with individual arguments</span>
<span class="hljs-built_in">console</span>.log(Greetings.call(person,<span class="hljs-string">"Hello"</span>,<span class="hljs-string">"!"</span>)); <span class="hljs-comment">// Output : Hello Nandan !</span>

<span class="hljs-comment">// Apply: Immediately invokes the function, but takes arguments as an array</span>
<span class="hljs-built_in">console</span>.log(Greetings.apply(person,[<span class="hljs-string">"Hello"</span>,<span class="hljs-string">"!"</span>])); <span class="hljs-comment">// Output : Hello Nandan !</span>

<span class="hljs-comment">// Bind: Returns a new function with `this` bound to the specified value</span>
<span class="hljs-keyword">let</span> greet = Greetings.bind(person,<span class="hljs-string">"Hello"</span>,<span class="hljs-string">"!"</span>);
<span class="hljs-built_in">console</span>.log(greet()); <span class="hljs-comment">// Output : Hello Nandan !</span>

<span class="hljs-comment">//Note:</span>
<span class="hljs-built_in">console</span>.log(Greetings.bind(person,<span class="hljs-string">"Hello"</span>,<span class="hljs-string">"!"</span>)); <span class="hljs-comment">// Output : It will return a function</span>
</code></pre>
<h3 id="heading-some-additional-examples">Some Additional Examples</h3>
<p>• <strong>Using</strong> call<strong>:</strong> Borrowing methods from another object:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> person1 = { <span class="hljs-attr">name</span>: <span class="hljs-string">"Nandan"</span> };
<span class="hljs-keyword">let</span> person2 = { <span class="hljs-attr">name</span>: <span class="hljs-string">"Kumar"</span> };

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">introduce</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Hi, my name is <span class="hljs-subst">${<span class="hljs-built_in">this</span>.name}</span>`</span>);
}

introduce.call(person1); <span class="hljs-comment">// Hi, my name is Nandan</span>
introduce.call(person2); <span class="hljs-comment">// Hi, my name is Kumar</span>
</code></pre>
<p>• <strong>Using</strong> apply<strong>:</strong> Finding the max value in an array:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Math</span>.max.apply(<span class="hljs-literal">null</span>, numbers)); <span class="hljs-comment">// 5</span>
</code></pre>
<p>• <strong>Using</strong> bind<strong>:</strong> Event handling with custom this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> button = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"myButton"</span>);
<span class="hljs-keyword">let</span> user = {
    <span class="hljs-attr">name</span>: <span class="hljs-string">"Nandan"</span>,
    greet() {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Hello, <span class="hljs-subst">${<span class="hljs-built_in">this</span>.name}</span>`</span>);
    }
};

button.addEventListener(<span class="hljs-string">"click"</span>, user.greet.bind(user));
</code></pre>
<p>Additionally, I hope this table will help you understand it better.</p>
<table><tbody><tr><td><p><strong>Feature</strong></p></td><td><p><strong>Execution</strong></p></td><td><p><strong>Arguments</strong></p></td><td><p><strong>Use Case</strong></p></td></tr><tr><td><p><strong>call</strong></p></td><td><p>Executes the function immediately</p></td><td><p>Passed individually</p></td><td><p>When you know arguments at call time</p></td></tr><tr><td><p><strong>apply</strong></p></td><td><p>Executes the function immediately</p></td><td><p>Passed as an array</p></td><td><p>When arguments are in an array</p></td></tr><tr><td><p><strong>bind</strong></p></td><td><p>Returns a new function (does not execute)</p></td><td><p>Optionally pre-filled for the new function</p></td><td><p>When you need a reusable or pre-configured function</p></td></tr></tbody></table>

<p>That’s all, folks! I hope you found this short note on Call, Apply &amp; Bind helpful. If you enjoyed this, check out more articles on my website, <a target="_blank" href="https://nandan.dev/"><strong>https://nandan.dev/</strong></a></p>
<p>Feel free to comment, email me at <a target="_blank" href="http://mailto:connect@nandan.dev/"><strong>connect@nandan.dev</strong></a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/nandandotdev"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[What are Javascript Closures?]]></title><description><![CDATA[Closures are a fundamental concept in JavaScript that enables powerful features like data privacy, state persistence, and functional programming. This blog will demystify closures with examples and practical use cases.
When are closures created?
Clos...]]></description><link>https://blog.nandan.dev/what-are-javascript-closures</link><guid isPermaLink="true">https://blog.nandan.dev/what-are-javascript-closures</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[closures in javascript]]></category><category><![CDATA[lexical scope]]></category><category><![CDATA[interview questions]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Mon, 18 Nov 2024 17:04:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1731949387166/3ba3dbdd-5437-4a59-92a0-633e5d59405d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Closures are a fundamental concept in JavaScript that enables powerful features like data privacy, state persistence, and functional programming. This blog will demystify closures with examples and practical use cases.</p>
<h2 id="heading-when-are-closures-created">When are closures created?</h2>
<p>Closures are created when a function <strong>(inner function)</strong> is defined inside another function <strong>(outer function).</strong> The inner function has access to the outer function's lexical scope <strong>(variables)</strong> even after the outer function is executed.</p>
<h3 id="heading-lexical-scope-in-javascript">Lexical Scope in Javascript</h3>
<p>Lexical scope means a function’s scope is determined by where it is written in the code, not where it is executed. This allows inner functions to access variables from their outer functions even if the outer function has already finished executing.</p>
<h3 id="heading-usage">Usage</h3>
<p>Closures are used for creating Private variables and persistent States (Cache, Memoisation etc.).</p>
<h3 id="heading-closures-with-examples">Closures with Examples</h3>
<p><strong>A Simple counter</strong></p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Outer</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">let</span> count = <span class="hljs-number">0</span>; <span class="hljs-comment">// count is a private variable</span>
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">inner</span>(<span class="hljs-params"></span>) </span>{
        count++; <span class="hljs-comment">// count is updated every time inner is called</span>
        <span class="hljs-keyword">return</span> count; <span class="hljs-comment">// the updated value of count is returned</span>
    };
}

<span class="hljs-keyword">let</span> Counter = Outer(); 
Counter(); <span class="hljs-comment">// 1 (count starts at 0, incremented to 1)</span>
Counter(); <span class="hljs-comment">// 2 (incremented again)</span>
Counter(); <span class="hljs-comment">// 3</span>
</code></pre>
<p><strong>Building a cache leveraging closure</strong></p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ObjectCache</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">let</span> Obj = {}; <span class="hljs-comment">// Obj acts as a private cache</span>
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ObjectUpdate</span>(<span class="hljs-params">key, value</span>) </span>{
        <span class="hljs-keyword">if</span> (!Obj[key]) {
            Obj[key] = value; <span class="hljs-comment">// Add key-value to cache if not already present</span>
            <span class="hljs-keyword">return</span> Obj; <span class="hljs-comment">// Return updated cache</span>
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Duplicate Key"</span>); <span class="hljs-comment">// Prevent overwriting</span>
        }
    };
}

<span class="hljs-keyword">let</span> cache = ObjectCache();
cache(<span class="hljs-string">"a"</span>, <span class="hljs-string">"b"</span>); <span class="hljs-comment">// {a: 'b'}</span>
cache(<span class="hljs-string">"a"</span>, <span class="hljs-string">"c"</span>); <span class="hljs-comment">// Error: Duplicate Key</span>
cache(<span class="hljs-string">"alpha"</span>, <span class="hljs-string">"romeo"</span>); <span class="hljs-comment">// {a: 'b', alpha: 'romeo'}</span>
</code></pre>
<h3 id="heading-real-world-examples">Real World Examples</h3>
<p><strong>Event Listeners - Click Counter</strong></p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">attachListener</span>(<span class="hljs-params">element</span>) </span>{
    <span class="hljs-keyword">let</span> count = <span class="hljs-number">0</span>;
    element.addEventListener(<span class="hljs-string">'click'</span>, <span class="hljs-function">() =&gt;</span> {
        count++;
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Clicked <span class="hljs-subst">${count}</span> times`</span>);
    });
}
</code></pre>
<p><strong>A Better Counter</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> CounterModule = (<span class="hljs-function">() =&gt;</span> {
    <span class="hljs-keyword">let</span> count = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">return</span> {
        <span class="hljs-attr">increment</span>: <span class="hljs-function">() =&gt;</span> ++count,
        <span class="hljs-attr">reset</span>: <span class="hljs-function">() =&gt;</span> (count = <span class="hljs-number">0</span>),
        <span class="hljs-attr">decrement</span>: <span class="hljs-function">() =&gt;</span> --count
    };
})();

CounterModule.increment(); <span class="hljs-comment">// 1</span>
CounterModule.increment(); <span class="hljs-comment">// 2</span>
CounterModule.decrement(); <span class="hljs-comment">// 1</span>
CounterModule.reset(); <span class="hljs-comment">// 0</span>
</code></pre>
<p>That’s all, folks! I hope you found this short blog on closures helpful. If you enjoyed this, check out more articles on my website, <a target="_blank" href="https://nandan.dev/">https://nandan.dev/</a></p>
<p>Feel free to comment, email me at <a target="_blank" href="http://mailto:connect@nandan.dev">connect@nandan.dev</a>, or connect with me on Twitter, Instagram, or GitHub. Don’t forget to subscribe to my newsletter for regular updates on JavaScript topics!</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_">Twitter</a> | <a target="_blank" href="https://www.instagram.com/nandandotdev">Instagram</a> | <a target="_blank" href="https://github.com/sirius93">Github</a> | <a target="_blank" href="https://nandan.dev">Website</a></p>
]]></content:encoded></item><item><title><![CDATA[System Design : SQL vs NoSQL databases]]></title><description><![CDATA[In the realm of databases, two primary types of solutions exist, SQL (relational) and NoSQL (non-relational) databases. These two categories differ significantly in their construction, the nature of the data they store, and their storage methods. Rel...]]></description><link>https://blog.nandan.dev/system-design-sql-vs-nosql-databases</link><guid isPermaLink="true">https://blog.nandan.dev/system-design-sql-vs-nosql-databases</guid><category><![CDATA[System Design]]></category><category><![CDATA[Databases]]></category><category><![CDATA[SQL]]></category><category><![CDATA[NoSQL]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Tue, 13 Aug 2024 17:01:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1723568306196/0a61975f-c413-49e2-9356-d45dc2078bcf.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the realm of databases, two primary types of solutions exist, SQL (relational) and NoSQL (non-relational) databases. These two categories differ significantly in their construction, the nature of the data they store, and their storage methods. Relational databases are structured with predefined schemas, while non-relational databases are unstructured, distributed, and feature dynamic schemas.</p>
<h2 id="heading-high-level-differences">High-level differences</h2>
<p>Here are some high-level differences between SQL and NoSQL:</p>
<h3 id="heading-storage">Storage</h3>
<p>SQL stores data in tables where each row represents an entity, and each column represents a data point related to that entity.</p>
<p>NoSQL databases utilize various data storage models, including key-value, graph, and document-oriented approaches.</p>
<h3 id="heading-schema">Schema</h3>
<p>In SQL, each record follows a fixed schema, which means that the columns must be determined and chosen before data entry, and each row must contain data for each column. The schema can be modified later, but this involves modifying the database using migrations.</p>
<p>NoSQL schemas are dynamic. Fields can be added on the fly, and each <em>record</em> doesn’t have to contain data for each <em>field</em>.</p>
<h3 id="heading-querying">Querying</h3>
<p>SQL databases use Structured Query Language (SQL) to define and manipulate data, which is highly powerful.</p>
<p>In a NoSQL database, queries focus on a collection of documents, with different databases having different syntax for querying.</p>
<h3 id="heading-scalability"><strong>Scalability</strong></h3>
<p>In most cases, SQL databases can be scaled vertically, which can become very costly. While it's feasible to scale a relational database across multiple servers, it's a difficult and time-consuming process.</p>
<p>NoSQL databases are horizontally scalable, which means it's easy to add more servers to handle large traffic. They can be hosted on inexpensive hardware or cloud instances, making them cost-effective compared to vertical scaling. Many NoSQL technologies also distribute data across servers automatically.</p>
<h3 id="heading-reliability">Reliability</h3>
<p>The majority of relational databases are ACID compliant. Therefore, SQL databases are still the best choice for data reliability and transaction safety.</p>
<p>Many NoSQL solutions prioritize performance and scalability over ACID compliance.</p>
<h2 id="heading-reasons">Reasons</h2>
<p>As always we should always pick the technology that fits the requirements better. So, let’s look at some reasons for picking SQL or NoSQL based database:</p>
<p><strong>For SQL</strong></p>
<ul>
<li><p>Structured data with strict schema</p>
</li>
<li><p>Relational data</p>
</li>
<li><p>Need for complex joins</p>
</li>
<li><p>Transactions</p>
</li>
<li><p>Lookups by index are very fast</p>
</li>
</ul>
<p><strong>For NoSQL</strong></p>
<ul>
<li><p>Dynamic or flexible schema</p>
</li>
<li><p>Non-relational data</p>
</li>
<li><p>No need for complex joins</p>
</li>
<li><p>Very data-intensive workload</p>
</li>
<li><p>Very high throughput for IOPS</p>
</li>
</ul>
<p>That's all folks.</p>
<p>Feel free to comment on how you like my blog on the system design series or shoot me an email at <a target="_blank" href="http://mailto:connect@nandan.dev">connect@nandan.dev</a> If you have any queries I will try to answer them.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="https://nandan.dev/">https://nandan.dev/</a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p>If you're interested in learning about system design, you can join Design Guru's course on <a target="_blank" href="https://www.designgurus.io/course/grokking-system-design-fundamentals?aff=y0pphf">System Design Fundamentals</a>.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_">Twitter</a> | <a target="_blank" href="https://www.instagram.com/nandandotdev">Instagram</a> | <a target="_blank" href="https://github.com/sirius93">Github</a> | <a target="_blank" href="https://nandan.dev">Website</a></p>
]]></content:encoded></item><item><title><![CDATA[System Design: Databases and DBMS]]></title><description><![CDATA[What is a Database?
A database is a structured collection of information or data that is typically stored electronically in a computer system. The management of the database is usually done by a Database Management System (DBMS). The combination of t...]]></description><link>https://blog.nandan.dev/system-design-databases-and-dbms</link><guid isPermaLink="true">https://blog.nandan.dev/system-design-databases-and-dbms</guid><category><![CDATA[Databases]]></category><category><![CDATA[System Design]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[software architecture]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Wed, 01 May 2024 14:46:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1714574316849/b1e9a1fc-40ed-4676-ac2c-2459738c6a53.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-a-database">What is a Database?</h2>
<p>A database is a structured collection of information or data that is typically stored electronically in a computer system. The management of the database is usually done by a Database Management System (DBMS). The combination of the data and the DBMS, along with the related applications, is commonly referred to as a database system, which is often shortened to just database.</p>
<h2 id="heading-what-is-dbms">What is DBMS?</h2>
<p>A database is a collection of data that requires a comprehensive database software program, known as a Database Management System (DBMS), to function. Essentially, a DBMS serves as an interface between the database and its end-users or programs, allowing users to retrieve, update, and manage how the information is organized and optimized. Additionally, a DBMS enables oversight and control of databases, enabling a variety of administrative operations such as performance monitoring, tuning, backup, and recovery.</p>
<h2 id="heading-components">Components</h2>
<p>Here are some commonly found components that are present in different databases:</p>
<h3 id="heading-schema">Schema</h3>
<p>A schema is responsible for defining the structure of a data storage system and specifying the types of data that can be stored in it. Schemas can be strictly enforced throughout the entire database, enforced loosely in some areas, or not enforced at all.</p>
<h3 id="heading-table">Table</h3>
<p>Each table can have anywhere from two to over a hundred columns, depending on the type of information it contains, similar to a spreadsheet.</p>
<h3 id="heading-column">Column</h3>
<p>A database column contains a single data value of a particular type for each row. The data value can be text, number, enum, timestamp, etc.</p>
<h3 id="heading-row">Row</h3>
<p>Data in a table is recorded in rows. There can be thousands or millions of rows in a table having any particular information.</p>
<h2 id="heading-types">Types</h2>
<p><img src="https://nandan.dev/system-design/images/database-types.png" alt="database-types" /></p>
<p>Below are different types of databases:</p>
<ul>
<li><p><a target="_blank" href="https://nandan.dev/pages/courses/system-design/sql-databases"><strong>SQL</strong></a></p>
</li>
<li><p><a target="_blank" href="https://nandan.dev/pages/courses/system-design/nosql-databases"><strong>NoSQL</strong></a></p>
<ul>
<li><p>Document</p>
</li>
<li><p>Key-value</p>
</li>
<li><p>Graph</p>
</li>
<li><p>Timeseries</p>
</li>
<li><p>Wide column</p>
</li>
<li><p>Multi-model</p>
</li>
</ul>
</li>
</ul>
<h2 id="heading-challenges">Challenges</h2>
<p>Here's a revised version of the text to make it clearer and free of spelling, grammar, and punctuation errors:</p>
<p>Running databases at scale can pose some common challenges that need to be addressed.</p>
<ul>
<li><p><strong>Absorbing significant increases in data volume</strong>: The explosion of data from sensors, connected machines, and other sources is increasing rapidly.</p>
</li>
<li><p><strong>Ensuring data security</strong>: Data breaches are becoming increasingly common, making it more important than ever to prioritize both data security and user accessibility.</p>
</li>
<li><p><strong>Keeping up with demand</strong>: For timely decision-making and seizing new opportunities, companies require real-time access to their data.</p>
</li>
<li><p><strong>Managing and maintaining the database and infrastructure</strong>: As data volumes increase and databases become more complex, companies face the expense of hiring additional talent to manage them.</p>
</li>
<li><p><strong>Removing scalability limits</strong>: A business needs to grow to survive, and its data management must grow with it. However, predicting the required capacity of on-premises databases can be challenging.</p>
</li>
<li><p><strong>Ensuring data residency, data sovereignty, or latency requirements</strong>: Some organizations have use cases that are better suited to run on-premises. In those cases, engineered systems that are pre-configured and pre-optimized for running the database are ideal..</p>
</li>
</ul>
<h1 id="heading-sql-databases">SQL databases</h1>
<p>A SQL or relational database is a collection of items that are related to each other and organized into tables consisting of columns and rows. These tables hold the information about the objects to be represented in the database. Each column in a table holds a specific type of data, and each field stores the actual value of an attribute. The rows in the table represent a collection of related values of one object or entity.</p>
<p>Each row in a table can be identified uniquely with a primary key, and the rows among multiple tables can be related to each other using foreign keys. This data can be accessed in many different ways without the need to reorganize the database tables themselves. SQL databases usually follow the <a target="_blank" href="https://nandan.dev/pages/courses/system-design/acid-and-base-consistency-models#base#acid">ACID consistency model</a>.</p>
<h2 id="heading-materialized-views">Materialized views</h2>
<p>A materialized view is a pre-computed dataset that is derived from a query specification and stored for later use. The data is pre-computed, which makes querying a materialized view faster than executing a query against the base table of the view. This performance difference is significant when a query is run frequently or is complex.</p>
<p>Materialized views enable data subsetting, which improves the performance of complex queries that run on large datasets and reduces network loads. Though there are other uses of materialized views, they are primarily used for performance and replication purposes.</p>
<h2 id="heading-n1-query-problem">N+1 query problem</h2>
<p>The N+1 query problem occurs when the data access layer executes additional SQL statements (N) to retrieve the same data that could have been obtained when executing the primary SQL query. The greater the value of N, the more queries will be executed, leading to a performance impact.</p>
<p>This problem is commonly observed in GraphQL and ORM (Object-Relational Mapping) tools. It can be solved by optimizing the SQL query or by using a dataloader that batches consecutive requests and makes a single data request under the hood.</p>
<h2 id="heading-advantages">Advantages</h2>
<p>Let’s look at some advantages of using relational databases:</p>
<ul>
<li><p>Simple and accurate</p>
</li>
<li><p>Accessibility</p>
</li>
<li><p>Data consistency</p>
</li>
<li><p>Flexibility</p>
</li>
</ul>
<h2 id="heading-disadvantages">Disadvantages</h2>
<p>Below are the disadvantages of relational databases:</p>
<ul>
<li><p>Expensive to maintain</p>
</li>
<li><p>Difficult schema evolution</p>
</li>
<li><p>Performance hits (join, denormalization, etc.)</p>
</li>
<li><p>Difficult to scale due to poor horizontal scalability</p>
</li>
</ul>
<h2 id="heading-examples">Examples</h2>
<p>Here are some commonly used relational databases:</p>
<ul>
<li><p><a target="_blank" href="https://www.postgresql.org/">PostgreSQL</a></p>
</li>
<li><p><a target="_blank" href="https://www.mysql.com/">MySQL</a></p>
</li>
<li><p><a target="_blank" href="https://mariadb.org/">MariaDB</a></p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/rds/aurora">Amazon Aurora</a></p>
</li>
</ul>
<h1 id="heading-nosql-databases">NoSQL databases</h1>
<p>NoSQL refers to a category of databases that do not primarily use SQL as their data access language. These databases are also known as non-relational databases. Unlike relational databases, NoSQL databases do not require data to follow a predefined schema. NoSQL databases follow <a target="_blank" href="https://nandan.dev/pages/courses/system-design/acid-and-base-consistency-models#base">BASE consistency model</a>.</p>
<p>Below are different types of NoSQL databases:</p>
<h3 id="heading-document">Document</h3>
<p>A document database, also known as a document-oriented database or a document store, is a versatile database that stores information in the form of documents. These databases can be used for transactional and analytical applications.</p>
<p><strong>Advantages</strong></p>
<ul>
<li><p>Intuitive and flexible</p>
</li>
<li><p>Easy horizontal scaling</p>
</li>
<li><p>Schemaless</p>
</li>
</ul>
<p><strong>Disadvantages</strong></p>
<ul>
<li><p>Schemaless</p>
</li>
<li><p>Non-relational</p>
</li>
</ul>
<p><strong>Examples</strong></p>
<ul>
<li><p><a target="_blank" href="https://www.mongodb.com/">MongoDB</a></p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/documentdb">Amazon DocumentDB</a></p>
</li>
<li><p><a target="_blank" href="https://couchdb.apache.org/">CouchDB</a></p>
</li>
</ul>
<h3 id="heading-key-value">Key-value</h3>
<p>One of the simplest types of NoSQL databases, key-value databases save data as a group of key-value pairs made up of two data items each. They’re also sometimes referred to as a key-value store.</p>
<p><strong>Advantages</strong></p>
<ul>
<li><p>Simple and performant</p>
</li>
<li><p>Highly scalable for high volumes of traffic</p>
</li>
<li><p>Session management</p>
</li>
<li><p>Optimized lookups</p>
</li>
</ul>
<p><strong>Disadvantages</strong></p>
<ul>
<li><p>Basic CRUD</p>
</li>
<li><p>Values can’t be filtered</p>
</li>
<li><p>Lacks indexing and scanning capabilities</p>
</li>
<li><p>Not optimized for complex queries</p>
</li>
</ul>
<p><strong>Examples</strong></p>
<ul>
<li><p><a target="_blank" href="https://redis.io/">Redis</a></p>
</li>
<li><p><a target="_blank" href="https://memcached.org/">Memcached</a></p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/dynamodb">Amazon DynamoDB</a></p>
</li>
<li><p><a target="_blank" href="https://aerospike.com/">Aerospike</a></p>
</li>
</ul>
<h3 id="heading-graph">Graph</h3>
<p>A graph database is a type of NoSQL database that uses graph structures to store and represent data. Instead of tables or documents, it uses nodes, edges, and properties to create relationships between data items.</p>
<p>The nodes represent the data items, while the edges represent the relationships between them. The relationships allow data in the store to be linked together directly and can be retrieved with a single operation in many cases.</p>
<p><strong>Advantages</strong></p>
<ul>
<li><p>Query speed</p>
</li>
<li><p>Agile and flexible</p>
</li>
<li><p>Explicit data representation</p>
</li>
</ul>
<p><strong>Disadvantages</strong></p>
<ul>
<li><p>Complex</p>
</li>
<li><p>No standardized query language</p>
</li>
</ul>
<p><strong>Use cases</strong></p>
<ul>
<li><p>Fraud detection</p>
</li>
<li><p>Recommendation engines</p>
</li>
<li><p>Social networks</p>
</li>
<li><p>Network mapping</p>
</li>
</ul>
<p><strong>Examples</strong></p>
<ul>
<li><p><a target="_blank" href="https://neo4j.com/">Neo4j</a></p>
</li>
<li><p><a target="_blank" href="https://www.arangodb.com/">ArangoDB</a></p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/neptune">Amazon Neptune</a></p>
</li>
<li><p><a target="_blank" href="https://janusgraph.org/">JanusGraph</a></p>
</li>
</ul>
<h3 id="heading-time-series">Time series</h3>
<p>A time-series database is a database optimized for time-stamped, or time series, data.</p>
<p><strong>Advantages</strong></p>
<ul>
<li><p>Fast insertion and retrieval</p>
</li>
<li><p>Efficient data storage</p>
</li>
</ul>
<p><strong>Use cases</strong></p>
<ul>
<li><p>IoT data</p>
</li>
<li><p>Metrics analysis</p>
</li>
<li><p>Application monitoring</p>
</li>
<li><p>Understand financial trends</p>
</li>
</ul>
<p><strong>Examples</strong></p>
<ul>
<li><p><a target="_blank" href="https://www.influxdata.com/">InfluxDB</a></p>
</li>
<li><p><a target="_blank" href="https://druid.apache.org/">Apache Druid</a></p>
</li>
</ul>
<h3 id="heading-wide-column">Wide column</h3>
<p>Wide column databases, also known as wide column stores, are schema-agnostic. Data is stored in column families, rather than in rows and columns.</p>
<p><strong>Advantages</strong></p>
<ul>
<li><p>Highly scalable, can handle petabytes of data</p>
</li>
<li><p>Ideal for real-time big data applications</p>
</li>
</ul>
<p><strong>Disadvantages</strong></p>
<ul>
<li><p>Expensive</p>
</li>
<li><p>Increased write time</p>
</li>
</ul>
<p><strong>Use cases</strong></p>
<ul>
<li><p>Business analytics</p>
</li>
<li><p>Attribute-based data storage</p>
</li>
</ul>
<p><strong>Examples</strong></p>
<ul>
<li><p><a target="_blank" href="https://cloud.google.com/bigtable">BigTable</a></p>
</li>
<li><p><a target="_blank" href="https://cassandra.apache.org/">Apache Cassandra</a></p>
</li>
<li><p><a target="_blank" href="https://www.scylladb.com/">ScyllaDB</a></p>
</li>
</ul>
<h3 id="heading-multi-model">Multi-model</h3>
<p>Multi-model databases combine different database models (i.e. relational, graph, key-value, document, etc.) into a single, integrated backend. This means they can accommodate various data types, indexes, queries, and store data in more than one model.</p>
<p><strong>Advantages</strong></p>
<ul>
<li><p>Flexibility</p>
</li>
<li><p>Suitable for complex projects</p>
</li>
<li><p>Data consistent</p>
</li>
</ul>
<p><strong>Disadvantages</strong></p>
<ul>
<li><p>Complex</p>
</li>
<li><p>Less mature</p>
</li>
</ul>
<p><strong>Examples</strong></p>
<ul>
<li><p><a target="_blank" href="https://www.arangodb.com/">ArangoDB</a></p>
</li>
<li><p><a target="_blank" href="https://azure.microsoft.com/en-in/services/cosmos-db">Azure Cosmos DB</a></p>
</li>
<li><p><a target="_blank" href="https://www.couchbase.com/">Couchbase</a></p>
</li>
</ul>
<p>That's all folks.</p>
<p>In the next blog, I will try to cover more about SQL V/s NoSQL Databases.</p>
<p>Feel free to comment on how you like my blog on the system design series or shoot me an email at <a target="_blank" href="http://mailto:connect@nandan.dev">connect@nandan.dev</a> If you have any queries I will try to answer them.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="https://nandan.dev/">https://nandan.dev/</a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p>If you're interested in learning about system design, you can join Design Guru's course on <a target="_blank" href="https://www.designgurus.io/course/grokking-system-design-fundamentals?aff=y0pphf">System Design Fundamentals</a>.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_">Twitter</a> | <a target="_blank" href="https://www.instagram.com/nandandotdev">Instagram</a> | <a target="_blank" href="https://github.com/sirius93">Github</a> | <a target="_blank" href="https://nandan.dev">Website</a></p>
]]></content:encoded></item><item><title><![CDATA[System Design: Availablity, Scalability, and Types Of Storage.]]></title><description><![CDATA[Availability
Availability refers to the duration for which a system performs its intended function within a given timeframe. It measures the percentage of time a system or machine remains operational under normal circumstances, serving as a simple me...]]></description><link>https://blog.nandan.dev/system-design-availablity-scalability-and-types-of-storage</link><guid isPermaLink="true">https://blog.nandan.dev/system-design-availablity-scalability-and-types-of-storage</guid><category><![CDATA[System Architecture]]></category><category><![CDATA[System Design]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[technology]]></category><category><![CDATA[learning]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Wed, 13 Dec 2023 03:58:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702439760323/bf3f9a76-f0e4-4a56-a0c6-1e0ed4fc55c4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-availability">Availability</h2>
<p>Availability refers to the duration for which a system performs its intended function within a given timeframe. It measures the percentage of time a system or machine remains operational under normal circumstances, serving as a simple metric of operational continuity.</p>
<h3 id="heading-the-nines-of-availability">The Nine’s of availability</h3>
<p>The "Nine's of availability" is a way to measure the reliability and uptime of a system. It is expressed as a percentage or number of nines, where each "nine" represents an additional decimal place of uptime.</p>
<p>$$Availability = \frac{Uptime}{(Uptime + Downtime)}$$</p><p>If availability is 99.00% available, it is said to have “2 nines” of availability, and if it is 99.9%, it is called “3 nines”, and so on.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Availability (Percent)</strong></td><td><strong>Downtime (Year)</strong></td><td><strong>Downtime (Month)</strong></td><td><strong>Downtime (Week)</strong></td></tr>
</thead>
<tbody>
<tr>
<td>90% (one nine)</td><td>36.53 days</td><td>72 hours</td><td>16.8 hours</td></tr>
<tr>
<td>99% (two nines)</td><td>3.65 days</td><td>7.20 hours</td><td>1.68 hours</td></tr>
<tr>
<td>99.9% (three nines)</td><td>8.77 hours</td><td>43.8 minutes</td><td>10.1 minutes</td></tr>
<tr>
<td>99.99% (four nines)</td><td>52.6 minutes</td><td>4.32 minutes</td><td>1.01 minutes</td></tr>
<tr>
<td>99.999% (five nines)</td><td>5.25 minutes</td><td>25.9 seconds</td><td>6.05 seconds</td></tr>
<tr>
<td>99.9999% (six nines)</td><td>31.56 seconds</td><td>2.59 seconds</td><td>604.8 milliseconds</td></tr>
<tr>
<td>99.99999% (seven nines)</td><td>3.15 seconds</td><td>263 milliseconds</td><td>60.5 milliseconds</td></tr>
<tr>
<td>99.999999% (eight nines)</td><td>315.6 milliseconds</td><td>26.3 milliseconds</td><td>6 milliseconds</td></tr>
<tr>
<td>99.9999999% (nine nines)</td><td>31.6 milliseconds</td><td>2.6 milliseconds</td><td>0.6 milliseconds</td></tr>
</tbody>
</table>
</div><h2 id="heading-availability-in-sequence-vs-parallel">Availability in Sequence vs Parallel</h2>
<p>If a service consists of multiple components prone to failure, the service’s overall availability depends on whether the components are in sequence or in parallel.</p>
<h3 id="heading-sequence">Sequence</h3>
<p>Overall availability decreases when two components are in sequence.</p>
<p>$$Availability \space (Total) = Availability \space (Foo) * Availability \space (Bar)$$</p><p>For example, if both <code>Foo</code> and <code>Bar</code> each had 99.9% availability, their total availability in sequence would be 99.8%.</p>
<h3 id="heading-parallel">Parallel</h3>
<p>Overall availability increases when two components are in parallel.</p>
<p>$$Availability \space (Total) = 1 - (1 - Availability \space (Foo)) * (1 - Availability \space (Bar))$$</p><p>For example, if both <code>Foo</code> and <code>Bar</code> each had 99.9% availability, their total availability in parallel would be 99.9999%.</p>
<h2 id="heading-availability-vs-reliability">Availability vs Reliability</h2>
<p>If a system is reliable, it means it is available. However, if a system is available, it does not necessarily mean it is reliable. This means that a system with high reliability will also have high availability, but a system can still achieve high availability without being reliable.</p>
<h2 id="heading-high-availability-vs-fault-tolerance">High Availability vs Fault Tolerance</h2>
<p>Both high availability and fault tolerance are methods for achieving high uptime levels, but they work differently.</p>
<p>A fault-tolerant system ensures that there is no service interruption, but it comes at a higher cost. On the other hand, a highly available system minimizes service interruption. To achieve fault tolerance, hardware redundancy is essential. In case the main system fails, another system takes over without any loss in uptime.</p>
<h1 id="heading-scalability">Scalability</h1>
<p>Scalability is the measure of how well a system responds to changes by adding or removing resources to meet demands.</p>
<p><img src="https://nandan.dev/system-design/images/scalability.png" alt="scalability" /></p>
<p>Let’s discuss different types of scaling:</p>
<h2 id="heading-vertical-scaling">Vertical scaling</h2>
<p>Vertical scaling (also known as scaling up) expands a system’s scalability by adding more power to an existing machine. In other words, vertical scaling refers to improving an application’s capability via increasing hardware capacity.</p>
<h3 id="heading-advantages">Advantages</h3>
<ul>
<li><p>Simple to implement</p>
</li>
<li><p>Easier to manage</p>
</li>
<li><p>Data consistent</p>
</li>
</ul>
<h3 id="heading-disadvantages">Disadvantages</h3>
<ul>
<li><p>Risk of high downtime</p>
</li>
<li><p>Harder to upgrade</p>
</li>
<li><p>Can be a single point of failure</p>
</li>
</ul>
<h2 id="heading-horizontal-scaling">Horizontal scaling</h2>
<p>Horizontal scaling (also known as scaling out) expands a system’s scale by adding more machines. It improves the performance of the server by adding more instances to the existing pool of servers, allowing the load to be distributed more evenly.</p>
<h3 id="heading-advantages-1">Advantages</h3>
<ul>
<li><p>Increased redundancy</p>
</li>
<li><p>Better fault tolerance</p>
</li>
<li><p>Flexible and efficient</p>
</li>
<li><p>Easier to upgrade</p>
</li>
</ul>
<h3 id="heading-disadvantages-1">Disadvantages</h3>
<ul>
<li><p>Increased complexity</p>
</li>
<li><p>Data inconsistency</p>
</li>
<li><p>Increased load on downstream services</p>
</li>
</ul>
<h1 id="heading-storage">Storage</h1>
<p>Storage is a mechanism that enables a system to retain data, either temporarily or permanently. This topic is mostly skipped over in the context of system design, however, it is important to have a basic understanding of some common types of storage techniques that can help us fine-tune our storage components. Let’s discuss some important storage concepts:</p>
<h2 id="heading-raid">RAID</h2>
<p>RAID (Redundant Array of Independent Disks) is a way of storing the same data on multiple hard disks or solid-state drives (SSDs) to protect data in the case of a drive failure.</p>
<p>There are different RAID levels, however, and not all have the goal of providing redundancy. Let’s discuss some commonly used RAID levels:</p>
<ul>
<li><p><strong>RAID 0</strong>: Also known as striping, data is split evenly across all the drives in the array.</p>
</li>
<li><p><strong>RAID 1</strong>: Also known as mirroring, at least two drives contains the exact copy of a set of data. If a drive fails, others will still work.</p>
</li>
<li><p><strong>RAID 5</strong>: Striping with parity. Requires the use of at least 3 drives, striping the data across multiple drives like RAID 0, but also has a parity distributed across the drives.</p>
</li>
<li><p><strong>RAID 6</strong>: Striping with double parity. RAID 6 is like RAID 5, but the parity data are written to two drives.</p>
</li>
<li><p><strong>RAID 10</strong>: Combines striping plus mirroring from RAID 0 and RAID 1. It provides security by mirroring all data on secondary drives while using striping across each set of drives to speed up data transfers.</p>
</li>
</ul>
<h3 id="heading-comparison">Comparison</h3>
<p>Let’s compare all the features of different RAID levels:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Features</strong></td><td><strong>RAID 0</strong></td><td><strong>RAID 1</strong></td><td><strong>RAID 5</strong></td><td><strong>RAID 6</strong></td><td><strong>RAID 10</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Description</td><td>Striping</td><td>Mirroring</td><td>Striping with Parity</td><td>Striping with double parity</td><td>Striping and Mirroring</td></tr>
<tr>
<td>Minimum Disks</td><td>2</td><td>2</td><td>3</td><td>4</td><td>4</td></tr>
<tr>
<td>Read Performance</td><td>High</td><td>High</td><td>High</td><td>High</td><td>High</td></tr>
<tr>
<td>Write Performance</td><td>High</td><td>Medium</td><td>High</td><td>High</td><td>Medium</td></tr>
<tr>
<td>Cost</td><td>Low</td><td>High</td><td>Low</td><td>Low</td><td>High</td></tr>
<tr>
<td>Fault Tolerance</td><td>None</td><td>Single-drive failure</td><td>Single-drive failure</td><td>Two-drive failure</td><td>Up to one disk failure in each sub-array</td></tr>
<tr>
<td>Capacity Utilization</td><td>100%</td><td>50%</td><td>67%-94%</td><td>50%-80%</td><td>50%</td></tr>
</tbody>
</table>
</div><h2 id="heading-volumes">Volumes</h2>
<p>"Volume" refers to a fixed amount of storage space on a disk or tape. Although the term "volume" is often used interchangeably with "storage," it is important to note that a single disk can contain multiple volumes, or a volume can span across multiple disks.</p>
<h2 id="heading-file-storage">File storage</h2>
<p>File storage is a method used to store data in a hierarchical directory structure and present it to users. It is a user-friendly solution that provides easy storage and retrieval of files. In order to locate a file in file storage, one must know the complete path of the file. It is an economical and well-structured method that is commonly used on hard drives. This means that files appear exactly the same for the user and on the hard drive.</p>
<p>Example: <a target="_blank" href="https://aws.amazon.com/efs">Amazon EFS</a>, <a target="_blank" href="https://azure.microsoft.com/en-in/services/storage/files">Azure files</a>, <a target="_blank" href="https://cloud.google.com/filestore">Google Cloud Filestore</a>, etc.</p>
<h2 id="heading-block-storage">Block storage</h2>
<p>Block storage is a method of storing data by dividing it into blocks or chunks, which are then stored as separate entities. Each block is given a unique identifier, which enables the system to store the smaller pieces of data wherever it is most convenient.</p>
<p>Block storage separates data from user environments, making it possible for data to be spread across multiple environments. This creates multiple paths to the data and enables users to retrieve it quickly. When a user or application requests data from the block storage system, the system reassembles the data blocks and presents the data to the user or application.</p>
<p>Example: <a target="_blank" href="https://aws.amazon.com/ebs">Amazon EBS</a>.</p>
<h2 id="heading-object-storage">Object Storage</h2>
<p>Object storage, also known as object-based storage, divides data files into smaller units called objects. These objects are then stored in a single repository that can be distributed across multiple networked systems.</p>
<p>Example: <a target="_blank" href="https://aws.amazon.com/s3">Amazon S3</a>, <a target="_blank" href="https://azure.microsoft.com/en-in/services/storage/blobs">Azure Blob Storage</a>, <a target="_blank" href="https://cloud.google.com/storage">Google Cloud Storage</a>, etc.</p>
<h2 id="heading-nas">NAS</h2>
<p>A Network Attached Storage (NAS) is a device that is connected to a network and allows authorized users to store and retrieve data from a central location. The NAS device is flexible, which means that we can easily add more storage capacity as needed. It is faster and less expensive than using a public cloud service, and it provides all the benefits of cloud storage while giving us complete control over our data.</p>
<h2 id="heading-hdfs">HDFS</h2>
<p>The Hadoop Distributed File System (HDFS) is a file system that can be distributed across multiple machines in a cluster. It's designed to run on inexpensive hardware and is highly fault-tolerant. HDFS offers high-throughput access to large datasets, making it ideal for applications that require handling of massive data.</p>
<p>HDFS uses a block-based approach for storing files. Each file is divided into a sequence of blocks, with all blocks in a file (except the last one) being of the same size. For reliability, the blocks of a file are replicated across different machines in the cluster.</p>
<p>That's all folks.</p>
<p>In the next blog, I will try to cover more about Databases.</p>
<p>Feel free to comment on how you like my blog on the system design series or shoot me a mail at <a target="_blank" href="http://mailto:connect@nandan.dev">connect@nandan.dev</a> If you have any queries I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="https://nandan.dev/">https://nandan.dev/</a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p>If you're interested in learning about system design, you can join Design Guru's course on <a target="_blank" href="https://www.designgurus.io/course/grokking-system-design-fundamentals?aff=y0pphf">System Design Fundamentals</a>.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_">Twitter</a> | <a target="_blank" href="https://www.instagram.com/nandandotdev">Instagram</a> | <a target="_blank" href="https://github.com/sirius93">Github</a> | <a target="_blank" href="https://nandan.dev">Website</a></p>
]]></content:encoded></item><item><title><![CDATA[The Power of ChatGPT Prompts: Unleashing Creativity and Utility..!!]]></title><description><![CDATA[In the world of artificial intelligence, ChatGPT is a breakthrough that has captured the attention of developers, writers, and businesses alike. It's an AI model developed by OpenAI, powered by GPT-3 technology, and it's revolutionizing the way we in...]]></description><link>https://blog.nandan.dev/the-power-of-chatgpt-prompts-unleashing-creativity-and-utility</link><guid isPermaLink="true">https://blog.nandan.dev/the-power-of-chatgpt-prompts-unleashing-creativity-and-utility</guid><category><![CDATA[chatgpt]]></category><category><![CDATA[#PromptEngineering]]></category><category><![CDATA[prompts]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Tue, 03 Oct 2023 02:30:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1696299897177/8c8cc38c-6bd7-4faa-8d43-94e985cd108e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the world of artificial intelligence, ChatGPT is a breakthrough that has captured the attention of developers, writers, and businesses alike. It's an AI model developed by OpenAI, powered by GPT-3 technology, and it's revolutionizing the way we interact with and leverage artificial intelligence. At the heart of this innovation are prompts, a simple yet remarkably powerful concept that drives ChatGPT's capabilities.</p>
<h2 id="heading-the-basics-of-prompts"><strong>The Basics of Prompts</strong></h2>
<p>To understand the magic behind ChatGPT, let's start with the basics. A prompt is essentially a piece of text or code that you provide to the AI model to initiate a conversation or request a specific task. It's like giving instructions to an intelligent assistant, and ChatGPT responds based on the input you provide.</p>
<p>For example, if you want to ask ChatGPT to generate a creative story about a space adventure, your prompt might look like this:</p>
<pre><code class="lang-xml">"Once upon a time, in a galaxy far, far away, there was a brave astronaut named Buzz Lightyear. Write a story about Buzz's thrilling journey through the cosmos."
</code></pre>
<p>The prompt instructs ChatGPT to generate a story about an astronaut named Buzz Lightyear in a space adventure setting. What makes this fascinating is that prompts can be as simple or as complex as you need them to be.</p>
<h2 id="heading-creative-writing"><strong>Creative Writing</strong></h2>
<p>Prompts have opened up exciting possibilities for writers and content creators. ChatGPT can assist with brainstorming ideas, generating story outlines, and even producing entire articles or pieces of fiction. By providing a well-crafted prompt, you can tap into the AI's creative abilities to jumpstart your writing process.</p>
<p>For instance, you could use ChatGPT to:</p>
<ul>
<li><p>Generate creative story plots or twists.</p>
</li>
<li><p>Compose catchy headlines for blog posts or articles.</p>
</li>
<li><p>Draft engaging dialogue for characters in a novel.</p>
</li>
<li><p>Create captivating product descriptions for e-commerce websites.</p>
</li>
</ul>
<p>The flexibility of prompts makes ChatGPT an invaluable tool for writers seeking inspiration or assistance with their projects.</p>
<h2 id="heading-problem-solving-and-information-retrieval"><strong>Problem Solving and Information Retrieval</strong></h2>
<p>Prompts are not limited to creative writing; they are equally adept at solving problems and retrieving information. ChatGPT can be your virtual assistant for tasks such as:</p>
<ul>
<li><p>Answering questions on a wide range of topics.</p>
</li>
<li><p>Providing code snippets for programming challenges.</p>
</li>
<li><p>Translating text from one language to another.</p>
</li>
<li><p>Summarizing lengthy documents or articles.</p>
</li>
<li><p>Assisting with research by generating ideas and insights.</p>
</li>
</ul>
<p>By crafting precise prompts, you can harness the AI's knowledge and problem-solving abilities to tackle a variety of tasks efficiently.</p>
<h2 id="heading-conversation-and-chatbots"><strong>Conversation and Chatbots</strong></h2>
<p>ChatGPT is also well-suited for creating chatbots and simulating human-like conversations. You can use prompts to initiate dialogue with the AI model and build chat-based applications. Whether it's for customer support, virtual assistants, or interactive storytelling, ChatGPT's conversation capabilities are impressive and adaptable.</p>
<h2 id="heading-tips-for-crafting-effective-prompts"><strong>Tips for Crafting Effective Prompts</strong></h2>
<p>While prompts are incredibly versatile, there are a few tips to keep in mind when crafting them:</p>
<ol>
<li><p><strong>Be Clear and Specific</strong>: Clearly define your request or question in the prompt to get the desired response.</p>
</li>
<li><p><strong>Experiment</strong>: Don't be afraid to experiment with different prompts to see what works best for your needs.</p>
</li>
<li><p><strong>Use Context</strong>: You can provide context in your prompts, reference previous messages in a conversation, or set the persona of the AI to guide the responses.</p>
</li>
<li><p><strong>Review Output</strong>: Always review and edit the output generated by ChatGPT to ensure accuracy and coherence.</p>
</li>
</ol>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>Prompts are the gateway to unlocking the potential of ChatGPT. Whether you're a writer seeking creative inspiration, a developer building applications, or someone looking for quick answers and solutions, ChatGPT's capabilities are at your fingertips. With a well-crafted prompt, you can harness the power of artificial intelligence to enhance your productivity and creativity.</p>
<p>As technology continues to advance, the possibilities for ChatGPT prompts are only limited by our imagination. So, go ahead, experiment, and see how ChatGPT can assist you in achieving your goals and bringing your ideas to life. The future of AI-powered interactions is here, and it all starts with a prompt.</p>
<p>Feel free to comment on how you like my blog or shoot me an mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="http://nandan.dev"><strong>nandan.dev</strong></a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Design Patterns: Module Design Pattern in JavaScript]]></title><description><![CDATA[Module Design Pattern is a way to encapsulate and organize code in a self-containing module that can expose certain functionalities while keeping the rest of the code private.
This helps prevent variable and function name clashes, improves code maint...]]></description><link>https://blog.nandan.dev/design-patterns-module-design-pattern-in-javascript</link><guid isPermaLink="true">https://blog.nandan.dev/design-patterns-module-design-pattern-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[design patterns]]></category><category><![CDATA[module-pattern]]></category><category><![CDATA[learn coding]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Fri, 18 Aug 2023 16:41:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1692376676555/d6d19109-6e9f-4605-864b-83682ab0f4b7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Module Design Pattern is a way to encapsulate and organize code in a self-containing module that can expose certain functionalities while keeping the rest of the code private.</p>
<p>This helps prevent variable and function name clashes, improves code maintainability, and promotes the concept of separation of concerns.</p>
<p>Here's an example of how you can implement the Module Design Pattern in JavaScript:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Module using the Module Design Pattern</span>
<span class="hljs-keyword">var</span> Module = (<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-comment">// Private variable</span>
  <span class="hljs-keyword">var</span> privateVariable = <span class="hljs-string">"I am a private variable"</span>;

  <span class="hljs-comment">// Private function</span>
  <span class="hljs-keyword">var</span> privateFunction = <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">privateFunction</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"This is a private function"</span>);
  }

  <span class="hljs-comment">// Public function</span>
  <span class="hljs-keyword">var</span> publicFunction = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"This is a public function"</span>);
  }
  <span class="hljs-comment">// Public interface</span>
  <span class="hljs-keyword">return</span> {
    <span class="hljs-attr">publicFunction</span>:publicFunction,
    <span class="hljs-comment">// Public variable accessing private variable</span>
    <span class="hljs-attr">publicVariable</span>: privateVariable
  };
})();

<span class="hljs-comment">// Usage of the module</span>
<span class="hljs-built_in">console</span>.log(Module.publicVariable); <span class="hljs-comment">// Output: "I am a private variable"</span>
Module.publicFunction(); <span class="hljs-comment">// Output: "This is a public function"</span>

<span class="hljs-comment">// Trying to access private members directly (will result in an error)</span>
<span class="hljs-built_in">console</span>.log(Module.privateVariable); <span class="hljs-comment">// Output: undefined</span>
Module.privateFunction(); <span class="hljs-comment">// Output: Uncaught TypeError: MyModule.privateFunction is not a function</span>
</code></pre>
<p>In the above example, we've created a module called <code>Module</code> using an <strong>Immediately Invoked Function Expression (IIFE)</strong>. Inside the IIFE, we define private variables and functions that are not accessible from outside the module. We then return an object containing the public members (functions and variables) that we want to expose.</p>
<p>Benefits of the Module Design Pattern:</p>
<ol>
<li><p><strong>Encapsulation:</strong> Private members are not accessible from outside the module, which helps prevent unintended modifications or conflicts with other parts of the codebase.</p>
</li>
<li><p><strong>Organization:</strong> Code is organized into logical modules, making it easier to manage and understand.</p>
</li>
<li><p><strong>Namespacing:</strong> The module acts as a namespace, reducing the chances of naming collisions in a global scope.</p>
</li>
<li><p><strong>Reusability:</strong> Modules can be easily reused in different parts of your application or different projects.</p>
</li>
<li><p><strong>Maintenance:</strong> Separation of concerns and encapsulation make it easier to maintain and refactor code.</p>
</li>
</ol>
<p>That's a concise explanation of the module design pattern in Javascript.</p>
<p>Feel free to comment on how you like my blog or shoot me a mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="http://nandan.dev"><strong>nandan.dev</strong></a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[The dilemma of being a front-end developer..!!]]></title><description><![CDATA[TL;DR,
From Design to APIs, You have to master all! The life of a front-end developer: juggling frameworks, libraries, and everything in between. Ultimately, you become everything but just a front-end developer.

You graduate from college and get out...]]></description><link>https://blog.nandan.dev/the-dilemma-of-being-a-front-end-developer</link><guid isPermaLink="true">https://blog.nandan.dev/the-dilemma-of-being-a-front-end-developer</guid><category><![CDATA[Frontend Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[rant]]></category><category><![CDATA[non tech ]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Sun, 09 Jul 2023 17:22:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/bKjHgo_Lbpo/upload/d2fa6a73f5d5b058139dcbd775d0b14e.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>TL;DR,</p>
<p>From Design to APIs, You have to master all! The life of a front-end developer: juggling frameworks, libraries, and everything in between. Ultimately, you become everything but just a front-end developer.</p>
<hr />
<p>You graduate from college and get out in the job market. You have done Leetcode or CodeChef or just basic DSA and algo..!!</p>
<p>You sit in an interview and get through it by doing everything you could do right. Your stars are aligned and you get your first job..!!</p>
<p>Elated, you tell your parents all about it, it’s a good salary package for a fresher and the brand is also good.</p>
<p>It’s your first day, They tell you, you are going to be a front-end Engineer. You will be working on HTML, CSS, JavaScript, jquery, Angular, and whatnot..!!</p>
<p>Every day there is a new framework, Vue is the new guy in the corner one day, and the next day it’s Aurelia. They all claim it’s going to be the next big thing..!!</p>
<p>You learn one new library/framework, do some POC, and add it to your resume. Because you see it’s a game of keywords. You have learned enough SEO to understand that it’s all about Keywords..! So you add SEO as an additional skill in your resume.</p>
<p>With time you have become better, you can tell if a font is not correct or if it’s different by one pixel from the design..!!</p>
<p>Oh design, you have come a long way from Photoshop to Figma..!! You have seen Sketch be the rage and then die a slow death. You have got a great design sense by now. So much so you can train a fresher designer, who is a design school grad,  about design sense.</p>
<p>Oh Don't forget accessibility, you know all about it, yet somehow you forget to add it to your resume. It’s such a crucial skill but yet you miss adding it because not everyone cares about it unless a client escalates about it.</p>
<p>All said and done, you have 100 skills in your resume and less space to put them all in, so you add most of them in your LinkedIn and ask your friends and colleagues to endorse you because that’s going to give you some additional visibility..!!</p>
<p>It’s been 5 years, you have been a front-end developer, and you are good at your craft. Master of JavaScript and Pro at React, but you are sick of waiting for the middleware team to provide you with the API endpoint till the last day of the release.</p>
<p>Everyone asking you what’s taking so long, as you have been given the design a month in advance, but no one seems to understand that, you need to wire the APIs, test the fail case, add handlers, and whatnot..!!</p>
<p>Sick of it, you decide to write your APIs,  oh come on, how hard writing a controller could be. It’s just <code>api/bla/bla</code>..!!</p>
<p>You write APIs and you write the front end, you wire them together, and you feel now you are a <a target="_blank" href="https://www.bairesdev.com/blog/how-to-become-a-full-stack-developer/">full stack developer</a>. But no one tells you that there is more to writing APIs than writing controllers.</p>
<p>And the expectations, oh don’t get me started, now you are expected to write APIs, front end, and everything in the same amount of time you used to take to build a part of it( the front end).</p>
<p>While, juggling between Front end and APIs, you realize, you are already a veteran in the field and the job market has changed a lot.</p>
<p>While they are asking DSA and Algo in the interviews, you have forgotten all of it to keep up with frameworks and libraries.</p>
<p>In between all the chaos of, DSA, Algo, system design, accessibility, frameworks, and whatnot, You realize,  you are back to where you started.</p>
<p>In the quest of being a front-end developer, you become everything but a front-end developer..!!</p>
<p>Regards,</p>
<p>A front-end developer</p>
<hr />
<p>That's the rant..!!</p>
<p>Feel free to comment on how you like my blog or shoot me a mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="http://nandan.dev"><strong>nandan.dev</strong></a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[NLP: A Beginner's Guide to Large Language Models, Transformers, and Fine-tuning.]]></title><description><![CDATA[Learning is challenging in your late 20s, You are adulting i.e. you have to take care of house chores, complete office work, try to get some workout done and then in your spare time, you fire up your laptop to start learning.
I got the opportunity to...]]></description><link>https://blog.nandan.dev/nlp-a-beginners-guide-to-large-language-models-transformers-and-fine-tuning</link><guid isPermaLink="true">https://blog.nandan.dev/nlp-a-beginners-guide-to-large-language-models-transformers-and-fine-tuning</guid><category><![CDATA[large language models]]></category><category><![CDATA[chatgpt]]></category><category><![CDATA[natural language processing]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[technology]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Fri, 19 May 2023 20:30:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1684645028690/3491c4e4-6ebc-43e3-acf1-0dc6e67efb79.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Learning is challenging in your late 20s, You are adulting i.e. you have to take care of house chores, complete office work, try to get some workout done and then in your spare time, you fire up your laptop to start learning.</p>
<p>I got the opportunity to learn about large language models recently and I have been thinking of writing about it since then.</p>
<p>While you may have read many blogs on large language models (LLM). This is yet another blog talking about the same topic that has been discussed in various forums in the past few weeks and has been in the news for quite some time now.</p>
<p>So Let's get going.</p>
<h3 id="heading-what-is-a-large-language-model">What is a Large Language Model?</h3>
<p>A large language model (LLM) is a type of artificial intelligence (AI) that can generate text, translate sentences from one language to another, write different kinds of creative content, and answer your questions in an informative way.</p>
<h3 id="heading-training-a-large-language-model">Training a Large Language Model.</h3>
<p>LLMs are trained on massive datasets available over the internet. The "large" in the large language model refers to the number of adjustable parameters in the model. The more parameters a model has, the more complex it is and the more data it can learn from. Some of the most successful LLMs have hundreds of billions of parameters, which allows them to learn from massive datasets and perform complex tasks.</p>
<p><strong>Here is an analogy that may help to explain this concept:</strong></p>
<p>Imagine a model with only a few parameters. This model would be like a simple machine with a few moving parts. It could only perform simple tasks, such as adding two numbers together.</p>
<p>Now imagine a model with hundreds of billions of parameters. This model would be like a complex machine with thousands of moving parts. It could perform much more complex tasks, such as translating languages or writing creative content.</p>
<p>The more parameters a model has, the more complex it is and the more data it can learn from. This allows LLMs to perform complex tasks that would be impossible for smaller models.</p>
<p>Some of The most well-known examples of large language models:</p>
<ul>
<li><p>GPT</p>
</li>
<li><p>BERT</p>
</li>
<li><p>BARD</p>
</li>
</ul>
<h3 id="heading-what-is-transformer">What is Transformer?</h3>
<p>Most LLMs are pre-trained on a large, general-purpose dataset and Can be fine-tuned further to be used for specific cases. All this could be possible because of the transformer architecture.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1684521955293/090f0780-ed28-4a67-8c5f-9fb138752b16.png" alt class="image--center mx-auto" /></p>
<p>Transformers are a type of neural network architecture that is used for natural language processing (NLP) tasks. They were first introduced in the paper "Attention Is All You Need" by Vaswani et al. (2017).</p>
<p>Transformers work by using self-attention mechanisms to learn long-range dependencies in sequences. This makes them much more powerful than traditional neural network architectures, such as recurrent neural networks (RNNs), for NLP tasks.</p>
<p>The transformer architecture has made the wide adaptability of LLMs possible. It has made the training of the models progressive in the sense that someone creating a model may not have to train the model completely from scratch and they can use a pre-trained model to fine-tune them to perform their specific task.</p>
<h3 id="heading-what-is-fine-tuning">What is Fine-Tuning?</h3>
<p>Fine-tuning is a process in which a pre-trained large language model (LLM) is further trained on a smaller, task-specific dataset. This allows the model to learn the specific features of the task and improve its performance.</p>
<p>Let's take the example of creating a chatbot that can answer all the queries related to one specific set of documents. Assume these documents are proprietary and are not available over the Internet.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1684523284662/d368e06b-3169-4003-8125-78ec0aa6a88f.png" alt class="image--center mx-auto" /></p>
<p>Someone can fine-tune an existing LLM by feeding the data specific to these documents and with some iterations of training, the Model will start answering questions related to these documents.</p>
<p>Here are some of the benefits of fine-tuning LLMs:</p>
<ul>
<li><p>It can improve the performance of an LLM on a specific task.</p>
</li>
<li><p>It can be used to adapt an LLM to a new domain or task.</p>
</li>
<li><p>It can be used to improve the accuracy and reliability of an LLM.</p>
</li>
</ul>
<p>Here are some of the challenges of fine-tuning LLMs:</p>
<ul>
<li><p>It can be time-consuming and computationally expensive.</p>
</li>
<li><p>It can be difficult to find a task-specific dataset that is large enough and high-quality enough to train the LLM.</p>
</li>
<li><p>It can be difficult to tune the hyperparameters of the fine-tuning process.</p>
</li>
</ul>
<p>In this blog, I have covered the basics of LLMs and How LLMs work. In my next blog, I will try to cover different types of transformers and different components of the transformer model.</p>
<p>That's all folks for now.</p>
<p>Feel free to comment on how you like my blog or shoot me a mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="http://nandan.dev"><strong>nandan.dev</strong></a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Revolutionize Your News Consumption: The Top 10 Tech News Websites/Apps for Developers]]></title><description><![CDATA[Staying up-to-date with the latest technology news is crucial for developers. It not only helps them stay relevant in the fast-paced tech world but also ensures they are equipped with the necessary knowledge to make informed decisions about their wor...]]></description><link>https://blog.nandan.dev/revolutionize-your-news-consumption-the-top-10-tech-news-websitesapps-for-developers</link><guid isPermaLink="true">https://blog.nandan.dev/revolutionize-your-news-consumption-the-top-10-tech-news-websitesapps-for-developers</guid><category><![CDATA[technology]]></category><category><![CDATA[news]]></category><category><![CDATA[devbytes]]></category><category><![CDATA[Developer Tools]]></category><category><![CDATA[learning]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Fri, 10 Mar 2023 12:40:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678394901057/c73d22aa-8889-48fb-9f53-be4a35930746.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Staying up-to-date with the latest technology news is crucial for developers. It not only helps them stay relevant in the fast-paced tech world but also ensures they are equipped with the necessary knowledge to make informed decisions about their work. In the digital age, we have access to a plethora of information sources, and tech news apps are one of the most convenient and efficient ways to keep up with the latest happenings. In this blog, we will take a look at the top 10 tech news apps for developers.</p>
<h3 id="heading-hacker-news">Hacker News:</h3>
<p>Hacker News is a popular community-driven news aggregator that has become a go-to source for developers, entrepreneurs, and tech enthusiasts. It features a wide range of topics, including programming, startups, artificial intelligence, cybersecurity, and more. Hacker News is known for its no-nonsense approach to news, where the content is curated by the community, ensuring that only the most relevant and interesting stories make it to the front page. It is run by the investment fund and startup incubator Y Combinator.</p>
<p>Link: <a target="_blank" href="https://news.ycombinator.com/">https://news.ycombinator.com/</a></p>
<h3 id="heading-techcrunch">TechCrunch:</h3>
<p>TechCrunch is a popular technology news website that covers the latest in the world of tech, startups, gadgets, and entrepreneurship. The website features news, reviews, analysis, and opinions on a wide range of topics, including artificial intelligence, blockchain, cybersecurity, and more. TechCrunch is known for its in-depth reporting, insightful commentary, and its focus on the people and companies that are shaping the future of technology. The website also hosts numerous conferences and events, including Disrupt, which brings together the best and brightest minds in the tech industry.</p>
<p>Link: <a target="_blank" href="https://techcrunch.com/">https://techcrunch.com/</a></p>
<h3 id="heading-the-verge">The Verge:</h3>
<p>The Verge is a popular technology news website that covers the latest in the world of tech, science, art, and culture. The website features news, reviews, analysis, and opinions on a wide range of topics, including smartphones, laptops, gaming, entertainment, and more. The Verge is known for its in-depth reporting, investigative journalism, and engaging storytelling. The website also hosts numerous podcasts and video series, including The Vergecast and Verge Science, which delve deeper into the latest tech news and trends.</p>
<p>Link: <a target="_blank" href="https://www.theverge.com/">https://www.theverge.com/</a></p>
<h3 id="heading-devbytes">DevBytes:</h3>
<p>Devbytes is one of the latest news apps that brings highly curated tech news to your phone. DevBytes provides coding news in a short and crisp format. This short news app has been designed especially for developers, product managers, and engineering managers to stay updated with what is happening in the technology world. DevBytes selects the latest advanced coding and technology news from multiple national and international sources, famous tech blogs, and social media and summarizes them in less than 64 words. Additionally, The App UI is pretty cool too.</p>
<p>Link: <a target="_blank" href="https://play.google.com/store/apps/details?id=com.candelalabs.devbytes&amp;utm_source=website&amp;pcampaignid=pcampaignidMKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1">https://devbytes.co.in</a></p>
<h3 id="heading-pocket">Pocket:</h3>
<p>Pocket is a popular application that allows users to save articles, videos, and other web content to read later. With Pocket, users can save content from their web browser, social media apps, or other sources by simply clicking on the "Save to Pocket" button or sharing the content to the app. The app then syncs the content across devices, so users can access their saved content from their smartphone, tablet, or computer. Pocket also offers a recommendation feature that suggests articles based on the user's reading history, and users can also follow other Pocket users to see what they are reading and recommending.</p>
<p>Link: <a target="_blank" href="https://getpocket.com/en/">https://getpocket.com/en/</a></p>
<h3 id="heading-feedly">Feedly:</h3>
<p>Feedly is a news aggregator that allows users to read and curate content from various sources. With Feedly, users can subscribe to RSS feeds from blogs, news sites, and other online sources. The app categorizes and organizes content based on the user's interests and presents articles in a visually appealing and easy-to-navigate interface. Feedly also offers a discovery feature that suggests new content based on the user's reading history and interests. Overall, Feedly is a great tool for people who want to streamline their online reading experience and stay up-to-date on the latest news and trends from various sources.</p>
<p>Link: <a target="_blank" href="https://feedly.com/">https://feedly.com/</a></p>
<h3 id="heading-github">GitHub:</h3>
<p>GitHub is a code hosting platform that also features a news feed. It is a great resource for developers who want to stay updated on the latest open-source projects and development trends. The news feed displays notifications for events such as pull requests, comments, and issues that are relevant to the user. Users can customize their news feed to filter out notifications they don't want to see and focus on the ones they care about. The news feed is a convenient way for developers and collaborators to stay up-to-date on project activity and stay engaged with the GitHub community.</p>
<p>Link: <a target="_blank" href="https://github.com">https://github.com</a></p>
<h3 id="heading-zdnet">ZDNet:</h3>
<p>ZDNet is a business technology news website that provides coverage on various topics such as security, artificial intelligence, cloud computing, and internet of things. It offers a combination of news, analysis, and commentary for IT professionals, developers, and business executives. ZDNet also features a variety of multimedia content including videos, podcasts, and webinars. With a focus on business technology, ZDNet is a valuable resource for anyone looking to stay informed on the latest trends and developments in the tech industry.</p>
<p>Link: <a target="_blank" href="https://www.zdnet.com/">https://www.zdnet.com/</a></p>
<h3 id="heading-engadget">Engadget:</h3>
<p>Engadget is a tech news website that covers everything from gadgets and gaming to software and the internet. Its mobile app makes it easy for developers to stay updated on the latest tech news and product launches. The website's team of expert journalists and reviewers provides insightful and informative articles, videos, and podcasts to help readers stay up-to-date on the latest tech trends and products.</p>
<p>Link: <a target="_blank" href="https://www.engadget.com/">https://www.engadget.com/</a></p>
<h3 id="heading-cnet">CNET:</h3>
<p>CNET is a leading technology media outlet that offers comprehensive coverage of the latest tech news, reviews, and analysis. CNET has become a trusted source of information for millions of readers, providing insights and opinions on a wide range of topics, including smartphones, laptops, home entertainment, gaming, and much more. The website also features video content, podcasts, and interactive tools to help users stay connected with the latest in tech.</p>
<p>Link:<a target="_blank" href="https://www.cnet.com/">https://www.cnet.com/</a></p>
<p>In conclusion, keeping up with the latest tech news is essential for developers, and there are plenty of apps that make it easy to do so. The apps listed above are just a few of the many options available, and developers should choose the ones that best fit their needs and preferences. With these apps, developers can stay informed, stay ahead of the curve, and revolutionize their news consumption.</p>
<p>That's all folks for now.</p>
<p>Feel free to comment on how you like my blog or shoot me a mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="http://blog.nandan.dev"><strong>nandan.dev</strong></a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[How to use gitignore, git hooks for better code management..!!]]></title><description><![CDATA[Hey Everyone, I know it's been a long time since I have written something in the git pro series and You all must be waiting for it. So here I am with another blog post in the git series.
In this blog post, I will be taking you through the quirks of g...]]></description><link>https://blog.nandan.dev/how-to-use-gitignore-git-hooks-for-better-code-management</link><guid isPermaLink="true">https://blog.nandan.dev/how-to-use-gitignore-git-hooks-for-better-code-management</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[technology]]></category><category><![CDATA[version control]]></category><category><![CDATA[code]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Sun, 05 Mar 2023 15:49:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678031198177/ad42397a-1584-4345-a153-e05f139174d7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey Everyone, I know it's been a long time since I have written something in the <a target="_blank" href="https://blog.nandan.dev/series/the-git-pro-series">git pro series</a> and You all must be waiting for it. So here I am with another blog post in the git series.</p>
<p>In this blog post, I will be taking you through the quirks of gitigore and will talk about how what git hooks are and how to write a basic hook. You can use these two git features to manage your codebase and write cleaner code. So Let's get going...</p>
<p>As I have mentioned this in my previous blog <a target="_blank" href="https://blog.nandan.dev/understanding-version-control-and-mastering-git-resolving-merge-conflicts-cherry-picking">post</a>, managing code in a collaborative environment can be a challenging task, particularly when it comes to version control.</p>
<p>Git is one of the most popular tools for managing code, and it offers many features that can help make code management easier. In this blog, we'll discuss how to use gitignore and git hooks for better code management.</p>
<h2 id="heading-what-is-gitignore">What is gitignore?</h2>
<p>When working on a project, there are often files and directories that you don't want to track with Git. These might include log files, build artifacts or configuration files that contain sensitive information. Gitignore is a feature of Git that allows you to specify patterns of files and directories that should be ignored by Git.</p>
<p>To use gitignore, create a file called .gitignore in the root directory of your Git repository. In this file, you can list patterns of files and directories that Git should ignore. For example, if you want to ignore all log files, you can add the following line to your .gitignore file:</p>
<pre><code class="lang-bash">*.<span class="hljs-built_in">log</span>
</code></pre>
<p>This will tell Git to ignore all files with the extension .log. You can also use wildcards to ignore entire directories, like this:</p>
<pre><code class="lang-bash">logs/
</code></pre>
<p>This will tell Git to ignore the entire logs directory and all of its contents.</p>
<p>Using gitignore is important because it keeps your Git repository clean and organized. When you commit changes to your repository, you only want to include the files that are relevant to your project. Ignoring unnecessary files and directories can help prevent your repository from becoming cluttered and difficult to manage.</p>
<h2 id="heading-gitignore-patterns">Gitignore patterns</h2>
<p>Gitignore patterns are a way of telling Git which files or directories to ignore. A pattern is simply a string that Git uses to match file and directory names. Here are some common Gitignore patterns:</p>
<ul>
<li><p><code>*.log</code>: Ignore all files with the extension .log.</p>
</li>
<li><p><code>logs/</code>: Ignore the entire logs directory and all of its contents.</p>
</li>
<li><p><a target="_blank" href="http://config.py"><code>config.py</code></a>: Ignore the file <a target="_blank" href="http://config.py">config.py</a>.</p>
</li>
<li><p><code>/build/</code>: Ignore the build directory only if it is in the root directory of the repository.</p>
</li>
<li><p><code>**/build/</code>: Ignore the build directory and all of its contents, no matter where it is in the repository.</p>
</li>
</ul>
<p>The double asterisk (<code>**</code>) is a special pattern that matches any number of subdirectories. Using <code>**</code> in a pattern can be useful if you want to ignore a particular file or directory no matter where it is in the repository.</p>
<p>You can also use negation patterns to specify files or directories that should not be ignored. Negation patterns start with an exclamation mark (<code>!</code>). For example, if you want to ignore all files in a directory except for one, you can use a pattern like this:</p>
<pre><code class="lang-bash">mydir/*
!mydir/file.txt
</code></pre>
<p>This tells Git to ignore all files in the <code>mydir</code> directory except for <code>file.txt</code>.</p>
<h2 id="heading-what-are-git-hooks">What are git hooks?</h2>
<p>Git hooks are scripts that Git runs before or after certain Git events, such as committing or pushing changes. Git hooks are stored in the .git/hooks directory of your Git repository, and they can be used to automate tasks or enforce rules for your team's workflow.</p>
<p>There are two types of Git hooks: client-side hooks and server-side hooks. Client-side hooks are run on the local machine where changes are being made, while server-side hooks are run on the remote Git server.</p>
<p>Some common uses of Git hooks include:</p>
<ul>
<li><p>Enforcing code quality standards</p>
</li>
<li><p>Running tests automatically before committing changes</p>
</li>
<li><p>Preventing commits that don't meet certain criteria (such as a commit message that doesn't follow a specific format)</p>
</li>
</ul>
<h2 id="heading-git-hook-types">Git hook types</h2>
<p>Git has a number of hooks that can be used to automate tasks or enforce rules for your team's workflow. Here are some of the most commonly used Git hooks:</p>
<h3 id="heading-pre-commit-hook">Pre-commit hook</h3>
<p>The pre-commit hook is run before a commit is made, and it can be used to perform checks or tests on the changes being committed. This hook is useful for enforcing coding standards, running linters or static analysis tools, and preventing commits that don't meet certain criteria.</p>
<p>For example, you can use a pre-commit hook to ensure that all of the code being committed passes a linting check. This can help maintain consistent code quality and prevent bugs caused by common coding errors.</p>
<h3 id="heading-post-commit-hook">Post-commit hook</h3>
<p>The post-commit hook is run after a commit has been made, and it can be used to perform tasks or updates that need to happen after the commit has been made. This hook is useful for performing tasks such as updating a database, sending notifications, or triggering a build process.</p>
<p>For example, you can use a post-commit hook to trigger a build process that automatically deploys your changes to a test environment.</p>
<h3 id="heading-pre-push-hook">Pre-push hook</h3>
<p>The pre-push hook is run before changes are pushed to a remote repository, and it can be used to perform checks or tests on the changes being pushed. This hook is useful for preventing bad code from being pushed to a remote repository and ensuring that all changes meet certain criteria.</p>
<p>For example, you can use a pre-push hook to ensure that all of the code being pushed has passed a test suite. This can help ensure that your codebase remains stable and consistent.</p>
<h3 id="heading-post-receive-hook">Post-receive hook</h3>
<p>The post-receive hook is run after changes have been pushed to a remote repository, and it can be used to perform tasks or updates that need to happen after the changes have been received. This hook is useful for performing tasks such as updating a database, sending notifications, or triggering a build process.</p>
<p>For example, you can use a post-receive hook to trigger a build process that automatically deploys your changes to a production environment.</p>
<h3 id="heading-prepare-commit-msg-hook">Prepare-commit-msg hook</h3>
<p>The prepare-commit-msg hook is run after a commit message has been entered, but before the commit is made. This hook can be used to modify the commit message or add additional information to it.</p>
<p>For example, you can use a prepare-commit-msg hook to automatically add the branch name or issue number to the commit message. This can help keep your commit messages consistent and organized.</p>
<h3 id="heading-pre-rebase-hook">Pre-rebase hook</h3>
<p>The pre-rebase hook is run before a rebase operation is performed, and it can be used to perform checks or tests on the changes being rebased. This hook is useful for preventing bad code from being rebased and ensuring that all changes meet certain criteria.</p>
<p>For example, you can use a pre-rebase hook to ensure that all of the code being rebased has passed a test suite. This can help ensure that your codebase remains stable and consistent.</p>
<h3 id="heading-post-merge-hook">Post-merge hook</h3>
<p>The post-merge hook is run after a merge operation has been performed, and it can be used to perform tasks or updates that need to happen after the merge has been completed. This hook is useful for performing tasks such as updating a database, sending notifications, or triggering a build process.</p>
<p>For example, you can use a post-merge hook to trigger a build process that automatically deploys your changes to a test environment.</p>
<h2 id="heading-how-to-use-git-hooks">How to use git hooks</h2>
<p>To use Git hooks, you first need to create a script that Git will run. The script should be named after the Git hook you want to use (for example, pre-commit or post-commit). The script should be saved in the .git/hooks directory of your Git repository, and it should be executable.</p>
<p>Here's an example of a pre-commit hook that runs a script to check the formatting of all Python files in your repository:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Checking Python formatting..."</span>

<span class="hljs-keyword">if</span> ! black --check .
<span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"Python files are not formatted correctly!"</span>
    <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>
</code></pre>
<p>To make this script executable, you need to run the following command:</p>
<pre><code class="lang-bash">chmod +x .git/hooks/pre-commit
</code></pre>
<p>This will allow Git to run the script when the pre-commit hook is triggered.</p>
<p>Once you've created your Git hook script, you need to configure Git to use it. You can do this by adding a line to the appropriate Git configuration file. For example, if you want to use a pre-commit hook, you would add the following line to the .git/config file:</p>
<pre><code class="lang-bash">[core]
    hooksPath = .git/hooks
</code></pre>
<p>This tells Git to use the hooks in the .git/hooks directory of your Git repository.</p>
<p>Git hooks are one of the most important git tools as it can enable you to automate a lot of things in your project i.e. running a code lint or running all the tests before a commit happens. You can even run both lint and test if you want to.</p>
<p>This can help you assure that no bad commits get into the code repository and you can have lesser bugs in the live environment.</p>
<p>That's all folks for now.</p>
<p>Feel free to comment on how you like my blog or shoot me a mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="https://nandan.dev"><strong>https://nandan.dev</strong></a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Will Artificial Intelligence(AI) replace my job: An IT Engineer's perspective?]]></title><description><![CDATA[Around the first week of this Month (Feb 23) I was invited as a guest speaker at a webinar by Coding Invaders by Mentorspro. I was invited there to guide people who want to switch to switch to IT careers and are looking at IT as an alternate career c...]]></description><link>https://blog.nandan.dev/will-artificial-intelligenceai-replace-my-job-an-it-engineers-perspective</link><guid isPermaLink="true">https://blog.nandan.dev/will-artificial-intelligenceai-replace-my-job-an-it-engineers-perspective</guid><category><![CDATA[technology]]></category><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[chatgpt]]></category><category><![CDATA[information technology]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Sun, 26 Feb 2023 19:14:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677438750725/24e536e3-2d3b-4e7d-9ab7-bf61ba8ab859.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Around the first week of this Month (Feb 23) I was invited as a guest speaker at a webinar by Coding Invaders by Mentorspro. I was invited there to guide people who want to switch to switch to IT careers and are looking at IT as an alternate career choice.</p>
<p>While I was answering their questions, I could see a lot of their questions revolved around recent layoffs and the evolution of Artificial Intelligence(AI).</p>
<p>While we all know these layoffs are completely business decisions of individual organizations and an impact of current market instability, which I hope will be settled soon and the IT job markets soar again. The fear of AI eating up IT jobs is still there among people and might keep bothering them for some time to come.</p>
<p>We all know AI is a rapidly advancing technology transforming various industries, including IT. AI does have the potential to automate many IT jobs, leading to fears that it will replace human workers. However, in this blog, we will try to break down how AI is unlikely to replace IT jobs entirely. While AI will change the nature of some IT jobs, it will also create new opportunities for IT professionals.</p>
<p>To understand why AI is unlikely to replace IT jobs, it is essential to consider what AI can and cannot do. AI refers to the ability of machines to perform tasks that typically require human intelligence, such as speech recognition, visual perception, decision-making, and language translation. AI systems use machine learning algorithms to analyze and learn from large amounts of data, allowing them to improve their accuracy and performance over time.</p>
<p>While AI can automate many routine tasks, it cannot replace the creativity, problem-solving skills, and emotional intelligence that humans bring to the table. This means that IT jobs that involve critical thinking, creativity, and human interaction are less likely to be automated by AI. These jobs include software engineering, computer programming, IT support, and customer service.</p>
<p>Software engineering and computer programming require creativity and critical thinking skills that cannot be easily replicated by AI. These jobs require a deep understanding of programming languages, algorithms, and software development methodologies, which are areas where AI still has a long way to go. Similarly, jobs that require human interaction, such as IT support and customer service, are unlikely to be replaced by AI. These roles require empathy, problem-solving skills, and the ability to communicate effectively with customers, which are difficult for machines to replicate.</p>
<p>Furthermore, AI is expected to create new job opportunities in the IT industry. As companies adopt AI technology, they will need skilled professionals to manage and maintain these systems. This includes data scientists, machine learning engineers, and AI developers who can create and improve AI algorithms and systems. In fact, AI is already creating new jobs in the IT industry. For example, the demand for data scientists and machine learning engineers has increased dramatically. These professionals are responsible for developing and implementing AI algorithms and systems that can analyze large amounts of data and provide insights for businesses.</p>
<p>Another reason why AI is unlikely to replace IT jobs is that AI technology is still in its infancy. While AI has made significant advances in recent years, many areas still have yet to make a substantial impact. For example, AI is not yet capable of performing tasks that require human emotions or empathy, such as counseling or social work. There are also many areas where AI cannot replace human judgment, such as legal or ethical decision-making. Therefore, humans will always need to work alongside AI to provide context, make decisions, and provide empathy.</p>
<p>Furthermore, the impact of AI on jobs is a complex issue. While AI may not replace all IT jobs, it may lead to job displacement for some workers. This is why it is essential for governments, businesses, and individuals to prepare for the impact of AI on the workforce. This includes investing in education and training programs to help workers develop the skills needed for the jobs of the future. It also means that companies should develop strategies to ensure that workers are not left behind as AI technology advances.</p>
<p>It is also essential to consider the ethical implications of AI and automation. The rise of AI and automation could exacerbate income inequality and lead to joblessness. Therefore, it is essential to ensure that the benefits of AI are distributed equitably across society. Governments and businesses must work together to create policies that promote social inclusion and prevent job displacement.</p>
<p>In conclusion, while AI will undoubtedly impact the IT industry, it is unlikely to replace all IT jobs. Instead, it will transform the way we work, creating new opportunities and changing the nature of existing roles. By embracing AI, and leveraging it for our productivity and help we can actually get better results and improve our final outcome.</p>
<p>That's all folks.</p>
<p>Feel free to comment on how you like my blog or shoot me a mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="https://nandan.dev"><strong>https://nandan.dev</strong></a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Understanding Natural Language Processing: The Basics..!!]]></title><description><![CDATA[Hey there, If you have been following my blogs, You may be wondering why I keep on creating new series of blogs every now and then.
Someone once told me, If you want to learn about something start teaching it to others. While I am not good at 1:1 tea...]]></description><link>https://blog.nandan.dev/understanding-natural-language-processing-the-basics</link><guid isPermaLink="true">https://blog.nandan.dev/understanding-natural-language-processing-the-basics</guid><category><![CDATA[natural language processing]]></category><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[chatgpt]]></category><category><![CDATA[chatbot]]></category><dc:creator><![CDATA[Nandan Kumar]]></dc:creator><pubDate>Fri, 27 Jan 2023 18:50:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674845119964/06f02b45-c6fe-43a8-a856-82d956d29090.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey there, If you have been following my blogs, You may be wondering why I keep on creating new series of blogs every now and then.</p>
<p>Someone once told me, If you want to learn about something start teaching it to others. While I am not good at 1:1 teaching or creating youtube videos, I chose to blog as my medium of teaching.</p>
<p>While I chose <a target="_blank" href="https://blog.nandan.dev/how-to-become-a-front-end-developer-part-1">front-end</a> and <a target="_blank" href="https://blog.nandan.dev/series/the-git-pro-series">git</a> as my initial topics for my blogs because I felt I was already good at them and that helped me gain initial confidence but now I blog while I learn and hence my frequency of new blogs has been a bit on the lower side.</p>
<p>I will try to be more frequent so I can cover various topics, Series by series.</p>
<p>Around the start of the year 2022, I made a switch from a full-time front-end engineer to Natural Language Processing (NLP) Engineer in my current organization. I started learning more about the NLP technologies that were being widely used. I got introduced to Stanford NLP, BERT, and related technologies.</p>
<p>While I was getting comfortable with all of these, Chatgpt started to gain traction and everyone was talking about it and that is when I got introduced to terms like transformer learning, self-supervised learning, etc. It is when I decided to re-learn the concepts of Natural Language Processing (NLP) that I started this series.</p>
<p>I will start with the basics of NLP and take you through my learnings along the way in the upcoming months. So let's get going.</p>
<h3 id="heading-natural-language-processing-nlp">Natural Language Processing (NLP)</h3>
<p>Natural Language Processing (NLP) is a branch of Artificial Intelligence (AI) that focuses on the interaction between computers and human language. It is an interdisciplinary field that combines linguistics, computer science, and information engineering to understand, interpret, and generate human language.</p>
<h3 id="heading-why-use-nlp">Why use NLP</h3>
<p>One of the main goals of NLP is to enable computers to understand and analyze human language in a way that is similar to how humans do it. This allows computers to perform tasks such as language translation, text summarization, sentiment analysis, and more.</p>
<p>Some of the most common NLP techniques include:</p>
<ul>
<li><p><strong>Tokenization:</strong> breaking down the text into individual words or phrases</p>
</li>
<li><p><strong>Lemmatization:</strong> reducing words to their base form</p>
</li>
<li><p><strong>Part-of-speech tagging:</strong> identifying the role of each word in a sentence (e.g. noun, verb, adjective)</p>
</li>
<li><p><strong>Named Entity Recognition:</strong> identifying and classifying proper nouns in the text (e.g. people, places, organizations)</p>
</li>
<li><p><strong>Sentiment Analysis:</strong> determining the emotional tone of text (e.g. positive, negative, neutral)</p>
</li>
</ul>
<h3 id="heading-usage-of-nlp">Usage of NLP</h3>
<p>NLP is used in a wide range of applications such as chatbots, virtual assistants, language translation, and text summarization. In recent years, NLP has become increasingly important in industries such as finance, healthcare, and customer service.</p>
<p>NLP is a rapidly growing field, and new techniques and technologies are constantly being developed to improve the accuracy and functionality of NLP systems. With the increasing amount of data being generated and the growing importance of understanding and analyzing human language, NLP is set to play an increasingly important role in the future of technology.</p>
<p>In conclusion, NLP is a powerful tool that can be used to analyze and understand human language. From chatbots to text summarization, NLP is being used in a wide range of applications and industries. With the rapid pace of development in the field, it is an exciting time for NLP and its potential to revolutionize the way we interact with technology.</p>
<p>That's all folks for now. In the next blog in this series, I will cover more details on the NLP techniques I have listed above.</p>
<p>Feel free to comment on how you like my blog or shoot me a mail at <a target="_blank" href="mailto:connect@nandan.dev"><strong>connect@nandan.dev</strong></a> If you have any queries and I will try to answer.</p>
<p>You can also visit my website to read some of the articles at <a target="_blank" href="https://nandan.dev">https://nandan.dev</a></p>
<p>Stay tuned &amp; connect with me on my social media channels. Make sure to subscribe to my newsletter to get regular updates on my upcoming posts.</p>
<p><a target="_blank" href="https://twitter.com/_sirius93_"><strong>Twitter</strong></a> | <a target="_blank" href="https://www.instagram.com/_sirius93_"><strong>Instagram</strong></a> | <a target="_blank" href="https://github.com/sirius93"><strong>Github</strong></a> | <a target="_blank" href="https://nandan.dev/"><strong>Website</strong></a></p>
]]></content:encoded></item></channel></rss>