<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kishore Nemalipuri on Medium]]></title>
        <description><![CDATA[Stories by Kishore Nemalipuri on Medium]]></description>
        <link>https://medium.com/@kishorenl-official?source=rss-eb4389913387------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*e07Ux4doPLWNdRmI.jpg</url>
            <title>Stories by Kishore Nemalipuri on Medium</title>
            <link>https://medium.com/@kishorenl-official?source=rss-eb4389913387------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:12:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kishorenl-official/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[We’ve all had days where we feel unstoppable at work, and others where even simple tasks feel heavy.]]></title>
            <link>https://kishorenl-official.medium.com/weve-all-had-days-where-we-feel-unstoppable-at-work-and-others-where-even-simple-tasks-feel-heavy-6c9642fab036?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c9642fab036</guid>
            <category><![CDATA[career-success]]></category>
            <category><![CDATA[keep-going]]></category>
            <category><![CDATA[motivation]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 13:54:29 GMT</pubDate>
            <atom:updated>2025-06-22T13:54:29.167Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve all had days where we feel unstoppable at work, and others where even simple tasks feel heavy. The secret often lies in understanding — and mastering — motivation. Especially in corporate life, where goals, rewards, and pressures constantly shift, knowing how to activate both <strong>intrinsic</strong> and <strong>extrinsic</strong> motivation can be the difference between burnout and sustainable success.</p><p>Let’s explore what these are, how they differ, and how you can train yourself to leverage both.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4_32XV5bwyuzaR3MhoBLA.png" /></figure><h3>1. Extrinsic Motivation: The Outer Rewards</h3><p>Extrinsic motivation is driven by external rewards — salary increases, promotions, recognition, bonuses, praise from leadership, job titles, or even fear of punishment.</p><p><strong>Common in corporate settings:</strong></p><ul><li>Performance reviews</li><li>Quarterly bonuses</li><li>Promotions and titles</li><li>Manager praise or feedback</li><li>Public recognition (awards, shout-outs, “Employee of the Month”)</li></ul><p><strong>Pros:</strong></p><ul><li>Provides clear goals and structure</li><li>Easy to measure and track</li><li>Can push people to deliver results quickly</li></ul><p><strong>Cons:</strong></p><ul><li>Often short-lived</li><li>Can lead to burnout if overused</li><li>May create unhealthy competition</li></ul><h3>2. Intrinsic Motivation: The Inner Fire</h3><p>Intrinsic motivation comes from within — the personal satisfaction of solving a problem, learning new skills, contributing to a bigger purpose, or simply enjoying the work itself.</p><p><strong>Common triggers:</strong></p><ul><li>Curiosity and learning</li><li>Mastery and growth</li><li>Autonomy and ownership</li><li>Alignment with personal values or mission</li><li>Sense of purpose or contribution</li></ul><p><strong>Pros:</strong></p><ul><li>Long-lasting and self-sustaining</li><li>Increases creativity and innovation</li><li>Builds resilience and engagement</li></ul><p><strong>Cons:</strong></p><ul><li>Harder to measure</li><li>Can fade if not nurtured</li></ul><h3>Why You Need Both in Corporate Life</h3><p>In reality, most of us are fueled by a blend of both motivations. Extrinsic motivators often get us started (e.g. “I want that promotion”), but intrinsic motivators keep us going long-term (e.g. “I enjoy building new products”).</p><p>High-performing corporate professionals and leaders learn to <em>consciously</em> activate both types depending on their situation. Relying solely on one can be risky</p><ul><li><strong>Only extrinsic:</strong> You may climb quickly but feel empty, lose passion, or burn out.</li><li><strong>Only intrinsic:</strong> You may love your work but struggle to advocate for your growth or recognition.</li></ul><h3>Training Yourself: Building Intrinsic Motivation</h3><p>Intrinsic motivation requires intentional nurturing. Here are some practical ways to strengthen it:</p><p><strong>Align your work with your values</strong></p><p>Identify aspects of your job that align with your personal mission. If you value learning, seek complex projects. If you value mentoring, support junior teammates.</p><p><strong>Set personal mastery goals</strong></p><p>Focus on becoming better at your craft, independent of external recognition. Create learning sprints, read, take courses, or seek mentorship.</p><p><strong>Create autonomy</strong></p><p>Where possible, take ownership of projects, propose new ideas, and carve out space to experiment. Autonomy fosters ownership.</p><p><strong>Celebrate internal wins</strong></p><p>Pause to acknowledge personal growth milestones — not just external awards. Track your skill development, problem-solving abilities, or resilience in tough situations.</p><p><strong>Find meaning in small tasks</strong></p><p>Even mundane tasks can fuel intrinsic motivation if you connect them to a larger purpose (“this documentation helps future team members”).</p><h3>Training Yourself: Using Extrinsic Motivation Wisely</h3><p>While intrinsic motivation builds the foundation, extrinsic motivators provide necessary structure in corporate life. Here’s how to use them effectively:</p><p><strong>Set visible short-term goals</strong></p><p>Break long-term projects into visible wins that trigger recognition and momentum.</p><p><strong>Communicate achievements</strong></p><p>Don’t shy away from sharing your wins with leadership — visibility is a part of career growth.</p><p><strong>Seek external feedback loops</strong></p><p>Request feedback regularly, not just during formal reviews. It keeps you connected to progress expectations.</p><p><strong>Understand company reward systems</strong></p><p>Learn how your company defines and rewards success. Align your goals accordingly.</p><p><strong>Balance competition and collaboration</strong></p><p>Healthy competition can drive performance, but long-term career success is often built on strong collaboration and trust.</p><h3>The Best Leaders Cultivate Both</h3><p>The most successful corporate leaders foster environments where both intrinsic and extrinsic motivators thrive:</p><ul><li>They recognize achievements (extrinsic) while creating growth opportunities (intrinsic).</li><li>They reward results while nurturing curiosity.</li><li>They provide clear expectations while empowering autonomy.</li></ul><p>As you grow in your career, practice <em>self-managing your own motivation</em>. When you feel a dip in drive, ask yourself:</p><p>👉 <em>Am I missing an external reward? Or do I need to reconnect with my internal purpose?</em></p><p>Mastering both will give you a powerful, self-sustaining engine for long-term success.</p><p>✨ <em>“Motivation is what gets you started. Habit is what keeps you going.”</em> — Jim Ryun</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c9642fab036" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The PIE Method: The Secret to Career Growth]]></title>
            <link>https://kishorenl-official.medium.com/the-pie-method-the-secret-to-career-growth-0a162ba02657?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a162ba02657</guid>
            <category><![CDATA[pie]]></category>
            <category><![CDATA[career-growth]]></category>
            <category><![CDATA[career-success]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 13:29:42 GMT</pubDate>
            <atom:updated>2025-06-22T13:29:42.094Z</atom:updated>
            <content:encoded><![CDATA[<p>When it comes to career advancement, most of us focus heavily on <strong>Performance</strong> — delivering results, meeting deadlines, exceeding expectations. While performance is absolutely essential, it’s only one part of the equation. Many high performers feel frustrated when promotions or recognition don’t come despite their strong work. The reason often lies in two other critical factors: <strong>Image</strong> and <strong>Exposure</strong>.</p><p>This is where the <strong>PIE Model</strong> comes in — <strong>Performance, Image, Exposure</strong> — a simple yet powerful framework that explains how careers actually progress inside organizations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzkP0etKojxm16dBLytmOQ.png" /></figure><h3>Performance (P) — The Foundation</h3><p>Your performance is your entry ticket. It’s about your ability to:</p><ul><li>Deliver high-quality work</li><li>Solve complex problems</li><li>Meet or exceed expectations</li><li>Take ownership and accountability</li></ul><p>Without consistent performance, the rest of PIE doesn’t matter. You need to be reliable, competent, and a trusted contributor. But — and this is key — performance alone often has diminishing returns. At some point, additional effort doesn’t proportionally increase career growth.</p><h3>Image (I) — How You’re Perceived</h3><p>Your image is how others <strong>perceive</strong> you — your reputation inside and outside your team. This includes:</p><ul><li>Are you seen as a leader?</li><li>Are you known for being innovative or strategic?</li><li>Do others trust you with bigger responsibilities?</li><li>How do you handle conflicts and setbacks?</li></ul><p>Image is shaped not just by your work, but by how you communicate, collaborate, and project confidence. People promote those they believe can handle broader responsibilities, not just those who deliver individual tasks.</p><p><strong>Pro tip:</strong> Don’t assume people know your achievements — actively share your wins in a humble but visible way.</p><h3>Exposure (E) — Who Knows You</h3><p>Exposure is about <strong>visibility</strong>. Who knows you and your work? This includes:</p><ul><li>Senior leaders</li><li>Cross-functional teams</li><li>Influential peers and mentors</li></ul><p>Many talented people remain invisible because they work in silos. Exposure ensures decision-makers know your capabilities. It’s about building relationships, volunteering for cross-team initiatives, speaking in forums, and seeking mentorship.</p><p><strong>Pro tip:</strong> Seek opportunities to present your work, share insights in company forums, and engage in communities beyond your immediate team.</p><h3>The PIE Formula in Action</h3><ul><li>You may know someone who is excellent at their job (strong Performance) but is hardly known outside their team (low Exposure) and rarely seen as a leader (weak Image). They often get stuck.</li><li>On the other hand, someone with solid but not necessarily exceptional performance, but who is well-connected (Exposure) and seen as a strategic leader (Image), often moves faster in their career.</li></ul><h3>Final Thought(s)</h3><p>In organizational life, working hard is just the beginning. Leaders make promotion decisions based on who they <em>trust</em> can operate at the next level — which includes perception and visibility.</p><p>The PIE model is not about playing politics; it’s about being intentional. Own your narrative. Make sure people see your impact. Build trust across the organization.</p><p>To sum up —</p><ul><li><strong>Performance gets you in the game.</strong></li><li><strong>Image shapes your reputation.</strong></li><li><strong>Exposure puts you on the radar.</strong></li></ul><p>Investing in all three will dramatically improve your career trajectory.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a162ba02657" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Markdown to Html recursively]]></title>
            <link>https://kishorenl-official.medium.com/markdown-to-html-recursively-1726faab730f?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/1726faab730f</guid>
            <category><![CDATA[convert-md-dir-to-html]]></category>
            <category><![CDATA[markdown2-usage]]></category>
            <category><![CDATA[python-md-to-html]]></category>
            <category><![CDATA[markdown-to-html]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Mon, 05 Feb 2024 23:46:45 GMT</pubDate>
            <atom:updated>2024-02-05T23:46:45.946Z</atom:updated>
            <content:encoded><![CDATA[<p>Markdown, with its simplicity and readability, has become a popular choice for content creation. However, in the web environment, HTML remains a dominant format. This utility bridges this gap, offering a seamless way to transform Markdown files into HTML, recursively navigating through directories.</p><h3>The Utility in Action</h3><p>This utility, let’s call it “MDtoHTMLRec,” goes beyond a simple one-to-one conversion. Its recursive nature allows it to delve into subdirectories, converting Markdown files within each folder. This proves invaluable when dealing with projects organized into a hierarchy of directories.</p><h3>Features and Benefits</h3><ol><li>Recursive Operation: Traverse through the entire directory structure, ensuring no Markdown file is left untouched.</li><li>Customizable Configuration: Tailor the utility to your specific needs with customizable configuration options. Define output paths, HTML templates, and styling preferences.</li><li>Python &amp; markdown2 flavour: This utility is built on top of python using markdown2 library. This markdown flavour is pretty configurable.</li></ol><p>Installation and Usage To get started with MDtoHTMLRec, follow these simple steps:</p><h3>Installation:</h3><p>bash</p><pre>git clone github.com:Kishorenl/md2html.git<br>pip install markdown2</pre><h3>How to Run</h3><pre>mdtohtmlrec --input_folder /path/to/markdown_folder --output_folder /path/to/html_output</pre><h3>Advanced Configuration:</h3><p>Explore additional options such as tables, footenotes, and others for more advanced usage.</p><p>In this repo I used only tables from extras in this line#8 md2htmlred.py (converter = markdown2.Markdown(extras=[&quot;tables&quot;])). But this can be extended to many other features mentioned <a href="https://github.com/trentm/python-markdown2?tab=readme-ov-file#extra-syntax-aka-extensions">here</a>.</p><h3>Conclusion</h3><p>In the world of web development, the journey from Markdown to HTML should be smooth and efficient. The MDtoHTMLRec utility streamlines this process, offering a recursive approach that aligns with the organization of modern projects. Enhance your workflow, save time, and ensure consistency in your content.</p><p>Thank you. Happy coding! 🚀✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1726faab730f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Utility: Convert Urls to Pdfs]]></title>
            <link>https://kishorenl-official.medium.com/utility-convert-urls-to-pdfs-5b799ce60bb1?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b799ce60bb1</guid>
            <category><![CDATA[batch-urls-to-pdf]]></category>
            <category><![CDATA[url-to-pdf-converter]]></category>
            <category><![CDATA[url2pdf-github]]></category>
            <category><![CDATA[python-url-to-pdf]]></category>
            <category><![CDATA[pdf-generator-from-url]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 01:08:39 GMT</pubDate>
            <atom:updated>2024-02-02T01:08:39.397Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you find yourself in need of a quick and efficient way to convert a list of URLs into PDFs? I was in the similar situation to take snapshot of the existing website. Here is a easy-to-use tool that simplifies the process of generating PDFs from a list of web pages using python code “url2pdf” linked from my github account.</p><h3>Why url2pdf?</h3><p>The “url2pdf” was created to address the need for converting multiple web pages into PDF documents seamlessly. Its a simple and stand-alone utility.</p><h3>Key Features</h3><h3>1. Bulk URL Processing</h3><p>With “url2pdf”, you can convert an entire list of URLs into PDFs and this also has configurable batch-wise processing.</p><h3>2. Customizable Output</h3><p>Tailor your PDFs to meet your specific requirements. We have configurable “url2pdf” option that allows you to configure output settings, ensuring that the generated PDFs match your desired format.</p><h3>3. Webdriver Automation</h3><p>Under the hood, “url2pdf” leverages Selenium and a WebDriver (e.g., ChromeDriver) to automate the interaction with each URL, making the conversion process efficient and accurate.</p><h3>4. Open Source and Customizable</h3><p>“<a href="https://github.com/Kishorenl/url2pdf">url2pdf</a>” is an open-source project hosted on GitHub. Feel free to explore the source code, contribute to its development, or customize it to fit your unique needs.</p><h3>Getting Started</h3><p>To get started with this utility, follow these simple steps:</p><p>Pre requisites: python &amp; git are working on your machine</p><ol><li>Clone the Repository</li></ol><pre>git@github.com:Kishorenl/url2pdf.git</pre><p>2. Install Dependencies</p><pre>pip install selenium webdriver_manager</pre><p>3. Run the Utility</p><pre>python url2pdf.py</pre><p>More details at <a href="https://github.com/Kishorenl/url2pdf">https://github.com/Kishorenl/url2pdf</a></p><p>Feel free to leave your comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b799ce60bb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lychee link checker]]></title>
            <link>https://kishorenl-official.medium.com/lychee-link-checker-4443e9a4fee2?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/4443e9a4fee2</guid>
            <category><![CDATA[broken-link-checker]]></category>
            <category><![CDATA[continuos-integration]]></category>
            <category><![CDATA[content-writing]]></category>
            <category><![CDATA[content-creation-tips]]></category>
            <category><![CDATA[web-develoment]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Sat, 03 Sep 2022 01:13:57 GMT</pubDate>
            <atom:updated>2022-09-03T01:13:57.162Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Broken pages in a web page" src="https://cdn-images-1.medium.com/max/494/1*v759fSjGXUbGCxuSNoAxoA.png" /><figcaption>Broken links in a website (taken from google images)</figcaption></figure><p>As the technical owners of a production website, we have always been intrigued with broken links in the application. We tried to build a script that would allow the developer to find any broken links. The main problem in building such generic production is that —</p><ul><li>concurrency — in order to fasten the process of validation</li><li>tracking real-time status — to see which file is being checked</li><li>offline/online links — be in a position to check within VPN</li></ul><p>After spending some time with <a href="https://github.com/stevenvachon/broken-link-checker">broken-link-checker</a> and <a href="https://github.com/tcort/markdown-link-check">markdown-link-check</a> we thought none of open source utilities (at that time in 2020) came close to our needs as we wanted a little more power to validate the links/assets etc. We have built a custom typescript-based solution that works well for most of the cases. But it warranted us numerous development cycles and maintainaning/extending on top of it got harder.</p><p>But in order to solve this problem, the open-source community came up with a solution in the form of <a href="https://github.com/lycheeverse/lychee">lychee link checker</a> in the past 1–2 years. I have tried it and this solution covers most of the problems with the broken links. Here are some of my noteworthy points —</p><ul><li>Installation &amp; Integration: Super easy either in local machine or using any CI tools (example circleCI, Github Actions or docker)</li><li>Verbose option: To provide the information of which links worked</li><li>Caching: enables faster feedback cycles if you are running on the same content with few modifications</li><li>online/offline: to help test the external vs relative links within the code.</li><li>Website support: literally it checks the production web page (non-recursively), I liked the power it gives to us.</li></ul><p>Although “lychee” offers a lot more features, the above points definitely won my heart to use this tool. Please give it a try and appreciate the work (in form of stars in git) to the owners of it.</p><p>For a quick start on Mac:</p><ol><li>Open a terminal, and run brew install lychee</li><li>Try lychee --versbose &lt;folder of the files&gt; . Here is an example lychee --verbose content</li><li>lychee --verbose &lt;web-page url&gt; . Example: lychee — verbose <a href="https://kishorenl-official.medium.com/leader-election-in-distributed-systems-8228bc63f31">https://kishorenl-official.medium.com/leader-election-in-distributed-systems-8228bc63f31</a></li></ol><p>Try this, you would definitely appreciate the sheer genius of the utility. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4443e9a4fee2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modularization in JS]]></title>
            <link>https://kishorenl-official.medium.com/modularization-in-js-8c7bf57839ff?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c7bf57839ff</guid>
            <category><![CDATA[bundling-js]]></category>
            <category><![CDATA[tree-shaking-js]]></category>
            <category><![CDATA[cjs-and-esm]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Mon, 22 Feb 2021 02:32:05 GMT</pubDate>
            <atom:updated>2021-02-22T02:32:05.415Z</atom:updated>
            <content:encoded><![CDATA[<p>cjs and esm bundling techniques.</p><p>In the initial days, javascript suffered badly with code modularization compared to other established languages (like java). Mostly, developers used to have a single large file for all the javascript and used to download to the browser to perform any functionality within the client-side. In order to solve this problem (including others like tree shaking, sync/async module downloads, perf issues), people created various modularization techniques —</p><ul><li>CJS(common js)</li><li>ESM(Ecma Script Modules or mjs)</li></ul><blockquote><em>Note1: will not discuss AMD/UMD in this post.</em></blockquote><p><strong>Commonjs</strong>:</p><p>The CommonJS module specification is the standard used in nodejs for working with modules.</p><blockquote><em>Client-side JavaScript that runs in the browser uses </em><strong><em>ES Modules(ESM)</em></strong></blockquote><p>Modules are very cool because they let you encapsulate all sorts of functionality, and expose this functionality to other JavaScript files, as libraries. They let you create clearly separate and reusable snippets of functionality, each testable on its own.</p><p>The huge npm ecosystem is built upon this CommonJS format.</p><p>Example:</p><p>Create a library function (use exports/module.exports etc.)</p><pre># caseChange.js<br>exports.uppercase = (str) =&gt; str.toUpperCase()<br>exports.lowercase = (str) =&gt; str.toLowerCase()</pre><p>Use the above library using require —</p><pre># main.js</pre><pre>const { uppercase, lowercase } = require(&#39;./caseChange.js&#39;)<br>console.log(uppercase(&quot;Test&quot;); // results in TEST<br>console.log(lowercase(&quot;Test&quot;); // results in tet</pre><p><strong>ESM:</strong></p><p>While commonjs used as a module system in nodejs for years, the browser never got modules as this needs standardization and support from all the browsers. Now that ES6 has been accepted and implemented by all browsers, ESM is used in all modern browsers.</p><p>Basic syntax:</p><p>Create a library function using export</p><pre># caseChange.js<br>const uppercase = (str) =&gt; str.toUpperCase()<br>const lowercase = (str) =&gt; str.toLowerCase()<br>export { uppercase, lowercase}</pre><p>Use the above library using import</p><pre># main.js</pre><pre>import { uppercase, lowercase } from &#39;./caseChange.js&#39;<br>console.log(uppercase(&quot;Test&quot;); // results in TEST<br>console.log(lowercase(&quot;Test&quot;); // results in tet</pre><p>As you can see although there are minor differences in syntax the code organization is almost the same. So let&#39;s discuss the advantages and disadvantages of these both techniques:</p><p><strong>CJS</strong></p><ul><li>Allows dynamic synchronous require()</li><li>Exports are only known after evaluating the module</li><li>Exports can be added, replaced, and removed even after the module has initialized</li><li>Due to the above nature tree-shaking is hard</li></ul><p><strong>ESM</strong></p><ul><li>Only allows static synchronous import</li><li>Imports and exports are linked before evaluating the module</li><li>Imports and exports are immutable</li><li>ESM supports tree shaking.</li></ul><p>There are different bundlers like webpack, rollup, parcel to create both cjs and esm from the project.</p><p>TL;DR:</p><p>Tree-shaking:</p><p>The main interest here is</p><ul><li>Download only the functions which are needed for you.</li><li>Reduce the size of the bundle (mostly for open source projects)</li></ul><p>Lets take an example to discuss the above points:</p><p>Let’s import both modules via the lodash package (which exposes CJS modules).</p><pre>import { flow, add } from &#39;lodash&#39;; // &lt;--- we&#39;re importing &#39;named exports&#39; here</pre><pre>const square = n =&gt; n * n;</pre><pre>const app = () =&gt; {<br>  var addSquare = flow([add, square]);<br>  console.log(addSquare(1, 2));<br>};</pre><p>After running a build with Webpack (in production mode), you can see the output is 70.3 Kb.</p><pre>Hash: 969a53c51fd1bdfd1c59<br>Version: webpack 4.29.5<br>Time: 282ms<br>Built at: 02/22/2021 8:05:06 AM<br>  Asset      Size  Chunks             Chunk Names<br>main.js  70.3 KiB       0  [emitted]  main<br>Entrypoint main = main.js<br>[1] ./src/index.js 180 bytes {0} [built]<br>[2] (webpack)/buildin/global.js 472 bytes {0} [built]<br>[3] (webpack)/buildin/module.js 497 bytes {0} [built]<br>    + 1 hidden module</pre><p>As you can see, Webpack is including the entirety of Lodash. Due to the dynamic nature of CommonJS, it’s hard to determine what to remove.</p><p>By switching to lodash-es (the ES module version), Webpack can tree-shake (or shake a tree?) and removed 63 Kb of unused code.</p><pre>import { flow, add } from &#39;lodash-es&#39;; // &lt;--- only change</pre><pre>const square = n =&gt; n * n;</pre><pre>const app = () =&gt; {<br>  var addSquare = flow([add, square]);<br>  console.log(addSquare(1, 2));<br>};</pre><p>Now the build is 7 kb (which 10 times lesser than the above)</p><pre>Hash: 3594f44a845c0950451b<br>Version: webpack 4.29.5<br>Time: 1160ms<br>Built at: 02/21/2021 7:27:43 AM<br>  Asset      Size  Chunks             Chunk Names<br>main.js  7.01 KiB       0  [emitted]  main<br>Entrypoint main = main.js<br>  [1] (webpack)/buildin/global.js 472 bytes {0} [built]<br>  [2] ./src/index.js + 52 modules 38.2 KiB {0} [built]<br>      | ./src/index.js 183 bytes [built]<br>      |     + 52 hidden modules<br>[588] (webpack)/buildin/harmony-module.js 573 bytes [built]<br>    + 586 hidden modules</pre><p>Building time is impacted a bit, but the effect on the bundle size is enormous</p><p>References:</p><p>Y<a href="https://dev.to/bennypowers/you-should-be-using-esm-kn3">ou should be using esm.</a></p><p><a href="https://addyosmani.com/writing-modular-js/">Writing modular js</a></p><p><a href="https://developers.google.com/web/fundamentals/performance/optimizing-javascript/tree-shaking">Reduce javascript payloads with tree-shaking</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c7bf57839ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[npm packaging — dev tricks]]></title>
            <link>https://kishorenl-official.medium.com/npm-packaging-dev-tricks-bcb6a18e71?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcb6a18e71</guid>
            <category><![CDATA[npm-dist-tag]]></category>
            <category><![CDATA[npm-versions-for-dev]]></category>
            <category><![CDATA[npm-packaging]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Sat, 20 Feb 2021 01:49:12 GMT</pubDate>
            <atom:updated>2021-02-20T01:49:12.871Z</atom:updated>
            <content:encoded><![CDATA[<h3>npm packaging — dev tricks</h3><p>The power of npm-dist-tags</p><p>When we create npm packages, we often need to have multiple versions for different types of users — developers, beta users, and our real customers. While using the npm package <a href="https://semver.org/">semver</a> is a viable solution, it may get really tricky to know which version is released for which community of people without checking git tags/release notes etc.</p><p>Here we have <a href="https://docs.npmjs.com/cli/v7/commands/npm-dist-tag">npm-dist-tags</a> to our rescue.</p><p>Using these tags will help in</p><ol><li>Help differentiate the target users without much hassle.</li><li>Reduces the pain of changing the package version mentioned in the package.json</li></ol><p>Working model:</p><p>Assuming that we want to create 3 different packages for</p><ul><li>developers (tagged as dev)</li><li>qa/beta users (tagged as beta)</li><li>for real users/public(tagged as latest)</li></ul><p>We can publish packages (ideally lerna is a good tool for this) by running the below commands in the folder which contains package.json(I assume that you have npm login setup before running the below commands)</p><pre>npm version &lt;use semver&gt;<br>npm publish --tag dev  # this can have dev/beta/latest</pre><p>Once this package is published you can see these packages with proper tags in npm — and these can be used by the users</p><pre>npm install &lt;package-name&gt;@&lt;npm-dist-tag&gt;<br># For ex: if we use dev as the npm-dist-tag we get the highest version of dev tagged package.</pre><p>This way, we do not need the users to change their package.json every often even in case we change major, minor, patch versions.</p><p>When using a mono-repo, it is better to use Lerna as a publishing tool as it reduces the pain of</p><ul><li>update the versioning of the packages automatically for all packages</li><li>update the git with the latest files after publishing(custom step)</li></ul><pre>yarn lerna publish from-package ${TAG} --yes --no-git-tag-version</pre><p>Happy packaging!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcb6a18e71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leader Election in distributed systems]]></title>
            <link>https://kishorenl-official.medium.com/leader-election-in-distributed-systems-8228bc63f31?source=rss-eb4389913387------2</link>
            <guid isPermaLink="false">https://medium.com/p/8228bc63f31</guid>
            <category><![CDATA[paxos]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[leader-election]]></category>
            <dc:creator><![CDATA[Kishore Nemalipuri]]></dc:creator>
            <pubDate>Sun, 02 Aug 2020 11:13:13 GMT</pubDate>
            <atom:updated>2020-08-02T11:13:13.029Z</atom:updated>
            <content:encoded><![CDATA[<p>I am always fascinated to work on distributed systems and the challenges that this architecture brings to the table. In the below article, I would like to talk about one of the classic problems — “Leader Election”. Understanding how a leader is elected and the responsibilities of the leader is key to understanding a distributed system.</p><h3># What is Leader Election</h3><p>The leader election is an important problem in a distributed system as data is distributed among different nodes which may be geographically separated. Designating a single node as an organizer in distributed systems is a challenging issue that calls for suitable election algorithms.</p><p>Before I delve deep into this topic — let me introduce some of the use cases.</p><h3># Why(Use cases)</h3><p>It&#39;s a very common problem as we scale applications in a wide variety of domains —</p><ul><li>Transaction management (eg: banking systems)</li><li>Autoscaling of an application &amp; Membership management for new nodes(Cloud platforms)</li><li>Distributed data structures (using shards etc.)</li><li>Cluster management</li></ul><h3>#Tryst with java developers</h3><p>If you consider a thread as a node, it’s easy to imagine the same problem in a distributed system, but there is no synchronized keyword to the rescue. The reason being that synchronized is implemented using semaphores, and in turn, they are backed by the underlying operating system and the hardware it’s running on. But if we look at what synchronized does, we might adapt the concept to a distributed setting. When declaring a block of code as synchronized in Java, it is always synchronized to the monitor of a specific object. The size of this monitor is one. This means that only one thread may be inside the monitor at any given time. When a thread requests the monitor and the monitor is available, it is allowed to enter instantly. If the monitor is occupied, the thread is put in the waiting pool and suspended until the monitor is released.</p><h3># How</h3><p>Although it seems that doesn’t follow any pattern — this would follow the same classic CAP theorem(Consistency, Availability and Partition Tolerance). And we have to consider different approaches and their trade-offs.</p><ol><li>Hazelcast (AP system)(Latest can be configured as CP*)</li><li>Zookeeper (CP system **)</li><li>etcd using Raft.(CP system)</li></ol><p>In general, Hazelcast will be much more performant and be able to handle more failures than Raft and etcd, but at the cost of potential data loss or consistency issues. The way Hazelcast works is it partitions data and stores pieces of the data on different nodes. So, in a 5 node cluster, the key “foo” may be stored on nodes 1 and 2, and bar may be stored on nodes 3 and 4. You can control the number of nodes to which Hazelcast replicates data via the Hazelcast and map configuration. However, during a network or other failure, there is some risk that you’ll see old data or even lose data in Hazelcast.</p><h3># Are you still interested? — TL; DR;</h3><p>If you have a peer to peer background like myself you would probably suggest using a distributed hash table rather than a leader to decide which node implements the monitor for each resource. In fact, there are some really great DHT-implementations out there that deal with thousands of nodes leaving and joining every hour. Given that they also work in a heterogeneous network with no prior knowledge of underlying network topology, query response times of four to ten message hops are pretty good, but in a grid setting where the nodes are homogenous and the network is fairly stable, we can do better.</p><h3># General Approach</h3><p>We have a leader that regularly pushes the current version of the global cluster state to each node. What happens if the leader goes down? Just because our nodes are fairly reliable does not imply that we can accept a single point of failure. Provided that only the leader node has crashed and all other nodes are still capable of communicating, Elasticsearch will handle this gracefully as the remaining nodes will detect the failure of the leader — or rather the absence of messages from the leader — and initiate leader election. If you are using ZenDiscovery (default) then the process is like this:</p><ul><li>Each node calculates the lowest known node id and sends a vote for leadership to this node</li><li>If a node receives <em>sufficiently many votes</em> and the node also voted for itself, then it takes on the role of leader and starts publishing cluster state.</li></ul><p>The definition of <em>sufficiently many votes</em> to win an election is what is known as a quorum. In Elasticsearch the quorum size is a configurable parameter. A node in a distributed system is not able to determine whether another node is dead or whether the network is not able to deliver its messages to it, therefore, common to have a previously agreed upon threshold — the quorum size — to represent the other party’s votes.</p><p>Let’s exemplify with the following scenario: A cluster has nodes N1, N2, N3, N4, N5 and quorum size 3. N1is the leader. It so happens that N1 and N2 are on one network and N3, N4, N5 on another. The networks are connected through a link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*sfE4mwQuCEKoCcSISinh9g.png" /><figcaption>Ex: 5 Node cluster in a network</figcaption></figure><p>When this link fails, N1and N2 are still able to communicate with each other, but not with N3, N4 and N5. Similarly, on the other network N3, N4 and N5 may communicate with each other, but not with N1 and N2.</p><p>What happens next is this: nodes N3, N4 and N5 detect that they no longer have contact with the leader N1 and subsequently initiate leader election by sending votes to N3. Once N3 has received three votes it takes on the role of leader and starts publishing to N3, N4 and N5. On the other network, the leader N1 detects that it no longer has contact with nodes C, D and E. Leader N1 calculates that the new cluster size is less than the quorum size and gives up the “leader” role and effectively stops nodes N1and N2 from responding to queries until the link is restored.</p><p>In real life, it’s unlikely that someone trips over on a crucial network cable, but networks are more complex than the example above, and network partitions are actually not that uncommon. It is not hard to imagine a network split when a system is relying on multiple datacenters; another likely culprit of tricky network errors is a wrongly configured router or switch. As mentioned in <a href="http://aphyr.com/posts/288-the-network-is-reliable">the network is reliable</a>, it does occur that network cards do things like dropping all inbound packets while still delivering outbound packets, with the result that a server still sends heartbeats but is unable to service any requests.</p><h3>## Avoid Split Brain</h3><p>The concept of a quorum size has two immediate advantages.</p><ul><li>Firstly it simplifies the election process as votes only need to be delivered to the node they’re voting for.</li><li>Secondly and more importantly it is the only way to avoid a split-brain. Imagine the same cluster and the same network split, but with a quorum size of two. C would still be elected leader, but A would not give up its “leader” role. This would result in two leaders, with clusters unknown to each other. This is what is known as a split-brain. Both clusters would be accepting read and write operations, and as expected, they would be out of sync. Without human intervention, they would probably never recover. Depending on the data model it might be impossible to unify the two data versions, forcing one to simply discard all data on one of the clusters.</li></ul><h3>## Don’t Reinvent the Wheel</h3><p>As you might expect, leader election has been an intriguing topic in application architecture circles for many years and quite a few smart people have done a great deal of contemplation. If you are keen on getting your distributed system working than putting a massive effort into research and development, you’re probably better off with having a go at implementing a well-known algorithm. Some day in the future when you have finally figured out that crazy bug in your system, it’s more likely to be just a bug in the implementation than a major design flaw in the algorithm. Of course, the same argument applies to adapting or integrating an existing implementation rather than implementing from scratch, especially if you want one of the more advanced algorithms.</p><h3>### The Bully Algorithm</h3><p>The bully algorithm is one of the basic algorithms for leader election. It assumes that all nodes are given a unique ID that imposes a total ordering of the nodes. The current leader at any time is the node with the <strong>highest</strong> id participating in the cluster. The advantage of this algorithm is an easy implementation, but it does not cope well with a scenario whereby the node with the largest id is flaky. Especially in a situation where the node with the largest id tends to be overloaded by the chores of the leader role. Consequently, it will crash as the leader; the node with the second largest id will be elected; and the largest id node will recover — as it’s no longer overloaded — and subsequently initiate leader election again, only to be elected and crash yet again. However, in low-level hardware interfaces, the bully algorithm is quite common. It might be tempting to avoid “thrashing” by postponing election until the current leader fails, but that will easily lead to a split-brain.</p><h3><strong>### Paxos</strong></h3><p>Paxos is actually much more than a leader election algorithm. Paxos is a family of different protocols for maintaining consensus in a distributed system. I will not go into detail about the varieties of Paxos, but rather discuss the concepts and qualities of Paxos in general. The data model used in Paxos is a growing list of statements where each statement has a unique number. The mathematically proven guarantees of Paxos are that two nodes will never have different statements for the same number, and as long as there is a quorum of nodes participating the algorithm will make progress. This translates to the nodes never being inconsistent and the algorithm never going into deadlock, but it may halt if there are not enough nodes online. These guarantees are in fact quite similar to what we want for a leader election algorithm. We want all nodes participating in the cluster to agree on which node is the leader, and we do not want any other nodes to be able to run off and create their own cluster, resulting in a split brain.</p><p>Performing leader election with Paxos then becomes as simple as proposing the statement “I am the leader”. If it is accepted, then you are the leader until another node proposes to be the leader. However, this alone is not sufficient to avoid a split brain. In the partitioned network example above the existing leader N1 will not be notified of the election of Node N3 on the other switch. There need to be another criteria to end the leadership. One option is that when initiating leader election the statement used is on the form: “I am leader until ”, but a more preferred option is that the leader is able to detect that it no longer has contact with a quorum and then demotes itself.</p><p>Given the previous example of a network partition, let’s imagine N3 was disconnected and connected to the other switch — the interesting part here is that the quorum now consists of nodes N1, N2 and N3 instead of the previous N3, N4 and N5. If the nodes where running Paxos, their data could look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*4fkXJ9jli2miNFRZv__w_g.png" /><figcaption>Ex: Adding node from one switch to another</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*BNIYV4FsR_r8QC-UY611sA.png" /><figcaption>Paxos example</figcaption></figure><p>Depending on the exact implementation of leader election through Paxos, a number of outcomes are possible, but they all have two properties in common. Nodes N4 and N5 will not be able to elect a new leader as they do not have a majority. Nodes N1and N2 will not elect a new leader before learning that node N3 was elected in round 2. Assuming that the end criterion of each leader term is a timeout, there are two possible outcomes. If node N3 establishes contact with nodes N1 and N2 before its term is ended, it will reestablish a quorum, resume its “leader” role, and no leader election is necessary. If its term is ended, then either node N1, N2 or N3 may be elected. Assuming node N1 is the first to discover node N3 on the network, it will try to get re-elected as leader for term 2, but node N3 will reject this as it already has a leader for term 2. Node N1 then has the option to attempt to be elected for term 3. If it does, it will then also inform node N2 about node N3’s time as leader in term 2. Now, what if node N3 and N1 try to get elected at the same time? The full answer to that question requires delving into the specifics of Paxos, which out of scope for this article, but the short answer is that election will fail. In fact, the original paxos paper suggests using a leader election algorithm to decide which node should be the one initiating new proposals, but since the Paxos protocol guarantees that there will not be inconsistencies even if there are multiple nodes proposing conflicting statements, this leader election algorithm could be just a simple heuristic to avoid consecutive failed rounds. For instance, a node might decide to wait a randomized amount of time before reattempting to propose a failed statement. This flexibility of Paxos in terms of when and how to do leader election can be a great advantage over the simple bully algorithm, having in mind that in real life there are far more failure modes than a dead network link.</p><h3># Conclusion:</h3><p>If you reached this point — you really made good progress and definitely would like to implement this in your architecture. I would classify this as one of the complex problems to solve. And the below should be our primary considerations before we pick up any solution.</p><ul><li>Quorum size is really important if you care about your data.</li><li>Paxos is really robust, but not as easy to implement.</li><li>It’s better to implement a well-known algorithm where the strengths and flaws are known rather than getting a big surprise further down the road. There are certainly plenty of options out there.</li></ul><p>References:</p><p><a href="https://stackoverflow.com/questions/31011105/hazelcast-java-and-etcd-golang-differences-similarities#:~:text=Hazelcast%20is%20an%20AP%20system,between%20consistency%20and%20availability%2Fperformance.&amp;text=Alternatively%2C%20Raft%20and%20etcd%20is,stores%20data%20on%20all%20nodes.">Hazelcast (Java) and ETCD (golang) differences/similarities?</a></p><p>** Zookeeper has <strong>Sequential Consistency</strong> - Updates from a client will be applied in the order that they were sent.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8228bc63f31" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>