<?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 Tarun Kumar on Medium]]></title>
        <description><![CDATA[Stories by Tarun Kumar on Medium]]></description>
        <link>https://medium.com/@tarunkr?source=rss-2af62eb8d2e1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uS4sz5Zu6G8vysx1jnQuAg.png</url>
            <title>Stories by Tarun Kumar on Medium</title>
            <link>https://medium.com/@tarunkr?source=rss-2af62eb8d2e1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 10:41:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tarunkr/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[Murphy’s Law: How Chaos Can Actually Make You Stronger]]></title>
            <link>https://tarunkr.medium.com/murphys-law-how-chaos-can-actually-make-you-stronger-6465dede5f01?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6465dede5f01</guid>
            <category><![CDATA[murphys-law]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[resilience]]></category>
            <category><![CDATA[personal-growth]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Mon, 30 Jun 2025 17:39:38 GMT</pubDate>
            <atom:updated>2025-06-30T17:45:43.160Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwhFk-dHQXyNJFf8DXSIqQ.png" /><figcaption>Murphy’s Law: How Chaos Can Actually Make You Stronger</figcaption></figure><p>Free Readers can read <a href="https://tarunkr.medium.com/murphys-law-how-chaos-can-actually-make-you-stronger-6465dede5f01?sk=578a4f6ca37292c75082c00341229673">here</a>.</p><p><strong>It was supposed to be perfect.</strong></p><p>The morning of her wedding, Sarah stood by the window, watching storm clouds swallow the sky. Weeks of planning. Countless checklists. The forecast promised sunshine, but the universe had other plans.</p><p>The DJ’s sound system blew out. The wedding cake toppled onto the grass. The photographer’s camera died just as Sarah and her soon-to-be husband said, “I do.” By sunset, guests huddled under a dripping tent, snapping selfies with muddy shoes and rain-soaked hair.</p><p>If this sounds familiar — if you’ve ever spilled coffee on yourself before a big interview, or watched your computer crash with seconds left before a deadline — congratulations. You’ve met Murphy’s Law, life’s most reliable troublemaker.</p><p>But here’s the twist: Murphy’s Law isn’t your enemy. In fact, it might just be your secret weapon.</p><h3>What Is Murphy’s Law?</h3><p><strong>Murphy’s Law:</strong> “Anything that can go wrong, will go wrong.”</p><p>It sounds like a joke for pessimists, but really, it’s about humility, preparation, and learning to expect the unexpected. Murphy’s Law isn’t about bad luck — it’s about being human in a world we can’t fully control.</p><h3>How Murphy’s Law Was Born</h3><p>Murphy’s Law wasn’t created in a philosophy class. It was born in a cloud of rocket fuel and adrenaline at Edwards Air Force Base in the late 1940s.</p><p>Engineers were racing to understand how to keep pilots safe in high-speed crashes, launching rocket sleds down tracks at terrifying speeds. Enter Captain Edward A. Murphy Jr. — a stickler for detail and relentless about safety.</p><p>On a crucial day, Murphy’s team fitted sensors onto a rocket sled to measure the violent g-forces of a crash test. But when the test ended, every single gauge read zero. Not a glitch — every sensor was wired backward, rendering the whole experiment useless.</p><p>Frustrated, Murphy muttered, “If there’s any way to do it wrong, he’ll find it.” That quip became “Murphy’s Law” — an inside joke that grew into an engineering mantra and, eventually, a part of popular culture.</p><h3>When Murphy’s Law Strikes: Real-Life Examples</h3><h3>NASA’s $327 Million Mistake</h3><p>In 1999, NASA’s Mars Climate Orbiter was set to unlock secrets of the Red Planet. Hundreds of scientists, years of work, and a spacecraft loaded with hopes and hardware.</p><p>The result? The orbiter burned up in Mars’ atmosphere — gone before it could send back a single photo. Why? One engineering team used imperial units (pounds-force) while another used metric (newtons). A tiny oversight — a missed unit conversion — cost $327 million and years of research.</p><p><strong>Murphy’s Law in action: when something <em>can</em> go wrong, sometimes it really, really does.</strong></p><h3>The Wedding Day Wipeout</h3><p>Back to Sarah and Mike’s wedding: rain poured, the cake toppled, and the carefully curated playlist vanished with the DJ’s fried equipment. But as guests sang under the tent and took muddy selfies, the mishaps became memories. By the end of the night, no one remembered the ruined cake — only the laughter and love.</p><p>Murphy’s Law didn’t ruin their wedding. It made it unforgettable.</p><h3>The Checklist That Saved Lives</h3><p>In hospitals worldwide, preventable mistakes — wrong meds, missed allergies, even surgical tools left behind — were shockingly common. Dr. Atul Gawande realized that even the best doctors can’t outsmart Murphy’s Law when under pressure.</p><p>His answer? The humble checklist. It forced teams to slow down, double-check, and confirm every step. The result? Fewer errors, more lives saved.</p><p>Sometimes, Murphy’s Law doesn’t just cause problems — it inspires solutions that change the world.</p><h3>How to Use Murphy’s Law to Your Advantage</h3><p>Don’t fear Murphy’s Law — embrace it:</p><ul><li><strong>Do a pre-mortem:</strong> Before a big project, ask, “What could go wrong?” Make a plan for every risk.</li><li><strong>Build in redundancy:</strong> Backup your files. Carry a spare charger. Expect tiny failures, and you’ll never be caught off guard.</li><li><strong>Turn mess-ups into memories:</strong> Remember, some of life’s best stories come from things not going as planned.</li><li><strong>Stay humble:</strong> If top engineers and surgeons can make mistakes, so can you. Double-check, ask questions, and always be ready to adapt.</li></ul><h3>The Upside of Murphy’s Law</h3><p>Murphy’s Law isn’t here to make you cynical. It’s a reminder that life is unpredictable, and that’s what keeps it interesting.</p><p>So next time something goes sideways, smile. You’re in good company. And who knows? That unexpected twist could become the best part of your story.</p><h4>Want more stories about how to thrive in an unpredictable world? Follow me for more insights on resilience, creativity, and real-world wisdom.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6465dede5f01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Stopped Paying for VPNs. Here’s How I Built My Own for $3.50/Month (No Coding Needed)]]></title>
            <link>https://tarunkr.medium.com/i-stopped-paying-for-vpns-heres-how-i-built-my-own-for-3-50-month-no-coding-needed-205d07a5bd2c?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/205d07a5bd2c</guid>
            <category><![CDATA[self-hosting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[openvpn]]></category>
            <category><![CDATA[vpn]]></category>
            <category><![CDATA[aws-lightsail]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 17:35:17 GMT</pubDate>
            <atom:updated>2026-01-09T08:03:21.776Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ovayfoTY2wlxUeVlVhRtw.png" /></figure><h3>Introduction</h3><p>I used to pay $10 a month for a well-known VPN. It promised privacy, speed, and freedom.</p><p>Instead, I got throttled speeds, targeted ads, and a growing suspicion that my data was still being watched. So I asked myself: <em>What if I could build my own VPN? One that’s fast, ad-free, and 100% in my control?</em></p><p>Turns out, it’s not just possible — it’s actually dead simple — for just <strong>$3.50 a month.</strong></p><p>In this guide, I’ll show you how I set up my own VPN server using <strong>AWS Lightsail</strong> and <strong>OpenVPN</strong> — without writing a single line of code. You’ll learn how to create your own private, encrypted internet tunnel in under an hour, and never rely on shady “free” VPNs again.</p><p>Are you excited? Let’s dive in. 🌊🚀</p><h3>Prerequisites</h3><p>Setting up your own VPN doesn’t require a massive toolbox — just:</p><ul><li>A computer (Mac/Windows/Linux)</li><li>An AWS account (new users get <strong>free trial months</strong>)</li><li>30–60 minutes of focused time</li></ul><h3>Choosing the Right Cloud for Your VPN</h3><p>Before you dive into setup, you’ll need a place to host your VPN. The ideal server is affordable, reliable, and comes with enough bandwidth to handle everyday use. Here are 2 popular options worth considering — each with its own strengths (and some caveats). When choosing a cloud server to host your VPN, there are several options. Each has trade-offs in terms of <strong>price, bandwidth, and ease of use</strong>.</p><h4>AWS Lightsail — Best Overall Choice for Most People</h4><p><strong>Price</strong>:</p><ul><li>$3.50/month (512MB RAM, 1 vCPU, 20GB SSD, <strong>1 TB</strong> transfer)</li><li>$5/month (1GB RAM, 1 vCPU, 40GB SSD, <strong>2 TB</strong> transfer)</li></ul><p><strong>Free Tier</strong>: New AWS users get <strong>3 months free</strong> on the $3.50 plan. So you have trail before you go :)</p><p><strong>Why it’s great</strong>: Lightsail is AWS’s simplified VPS service, with a beginner-friendly interface and predictable pricing. It’s perfect for running a personal VPN with generous monthly bandwidth and an easy setup experience.</p><p><strong>Heads-up</strong>: When creating your instance, choose <strong>IPv6 only</strong> if you want to keep costs low. Dual-stack (IPv4 + IPv6) will require a static IPv4, which <strong>adds extra cost</strong>.</p><h4>Oracle Cloud Free Tier (Great if You’re Budget-Conscious)</h4><p><strong>Price</strong>: $0 — yes, totally free<br><strong>Resources</strong>:</p><ul><li>2 VMs (1GB RAM each), <strong>10 TB</strong> outbound bandwidth/month</li></ul><p><strong>Why it’s great</strong>: Oracle’s free tier gives you enough power and bandwidth to run a solid personal VPN for free — forever. The catch? The interface is a bit clunky, and the service occasionally flags or throttles accounts without warning.</p><h4>Quick Comparison</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9L3xksuZW2aqk_oRAXGHYg.png" /><figcaption>Compare Cloud Service</figcaption></figure><h3>Building the VPN: Step-by-Step Setup on Lightsail</h3><p>Let’s get to the fun part — launching your VPN server!</p><h4>1. Create a Lightsail Instance</h4><ul><li>Head to <a href="https://lightsail.aws.amazon.com/">AWS Lightsail</a></li><li>Select your preferred region where you want your sever to be.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaMH1-1UnfZXnXsT1oIKxA.png" /><figcaption>Select Region</figcaption></figure><ul><li>Choose <strong>Ubuntu 22.04</strong> as your OS</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHsBkjNpjTMm2aOlezELmA.png" /><figcaption>Selecte OS</figcaption></figure><ul><li>Pick the $3.50 or $5 plan (select IPv6 option if you don’t see the $3.5 plan)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QnU9DKayrn1ZAZKbObvf3g.png" /><figcaption>Selecte Network and Host Type</figcaption></figure><ul><li>Name your instance and launch it</li></ul><h4>2. Configure the Firewall</h4><p>Once the service is running, In Lightsail’s got to, <strong>Networking tab</strong>, open the following ports:</p><ul><li><strong>22 (TCP)</strong> for SSH</li><li><strong>1194 (UDP)</strong> for OpenVPN</li><li><strong>443 (TCP)</strong> as a backup/fallback</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5NWFpNwG0YQitXSfn2nsQ.png" /><figcaption>IPv6 Configuration for Lightsail Server</figcaption></figure><h4>3. <strong>SSH Into Your Server</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*il_MFrjvpr3w5c2lbibJJA.png" /><figcaption>Connect to Server using SSH</figcaption></figure><h4>4. Install OpenVPN</h4><p>Run this trusted install script:</p><pre>curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh<br>chmod +x openvpn-install.sh<br>sudo ./openvpn-install.sh</pre><p>Follow the prompts:</p><ul><li>Choose <strong>UDP</strong>, port 1194 (Default)</li><li>Use <strong>AdGuard DNS</strong> (to block ads and trackers), you can also choose other DNS as preferred.</li><li>Choose a client name like laptop</li></ul><p>Boom — it’ll create laptop.ovpn right there.</p><h4>5.📲 Adding More Devices? Don’t Reuse the Same Config! (Skip if you don’t need multiple device)</h4><p>By default, OpenVPN allows <strong>one device per </strong><strong>.ovpn file</strong>. If two devices use the same one, they’ll knock each other offline.</p><p>To add more clients:</p><pre>sudo ./openvpn-install.sh<br># Choose: Add a new client<br># Name it: phone, work-laptop, etc.</pre><h4>6. Download profile `.ovpn`</h4><p>Each device gets its own .ovpn file. Now use cat command and copy the output on a new file on your device:</p><pre>cat laptop.ovpn</pre><p>On your device create new file rename it to laptop.ovpn and paste the content copied from the server. Repeat the process for all client files.</p><h4>7. Connect Using VPN Client</h4><ul><li>Install <a href="https://openvpn.net/client/"><strong>OpenVPN Connect</strong></a> (Windows, macOS, Linux, Android, iOS)</li><li>Import the laptop.ovpn file</li><li>Connect — and you’re secured!</li></ul><h3>Found This Valuable?</h3><p>If this post helped you or saved you time, please consider <strong>buying me a coffee</strong> — it really encourages me to keep writing, exploring, and sharing more content like this. Your support means a lot. 🙏</p><figure><a href="https://www.buymeacoffee.com/tarunkumar"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*Dpw8-hNGI2fDmosV4E8DVQ.png" /></a></figure><p>Have questions, suggestions, or noticed something off? Drop a comment or email me at <strong>tarun12.tarunkr@gmail.com</strong> — I’m always happy to hear from readers.</p><p><strong>Follow me for more:</strong> <a href="https://www.linkedin.com/in/tarun-kumar-iit-ism/">Linkedin</a> • <a href="https://github.com/tarunk04/">GitHub</a></p><p>Thanks for taking the time to read. If you liked it, please share it with someone who might benefit!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=205d07a5bd2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Repo Rate Changes Impact Debt Mutual Funds: A Complete Guide]]></title>
            <link>https://tarunkr.medium.com/how-repo-rate-changes-impact-debt-mutual-funds-a-complete-guide-8a562effe8d1?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a562effe8d1</guid>
            <category><![CDATA[mutual-funds]]></category>
            <category><![CDATA[capital-gain-bonds]]></category>
            <category><![CDATA[debt-mutual-funds]]></category>
            <category><![CDATA[rbi-repo-rate]]></category>
            <category><![CDATA[repo-rate]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Wed, 09 Apr 2025 19:47:22 GMT</pubDate>
            <atom:updated>2025-04-12T21:28:12.672Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cpR5Xi7fQ8YM0FHpH6tjnQ.png" /><figcaption>Repo Rate vs Debt Mutual Funds</figcaption></figure><p>Interest rates and bond prices may sound like dry topics, but if you’ve ever invested in a <strong>debt mutual fund</strong>, these two concepts can make or break your returns. One of the most important levers in this space is the <strong>repo rate</strong> — a key monetary policy tool used by the <strong>Reserve Bank of India (RBI)</strong>.</p><p>In this article, we’ll break down:</p><ul><li>What is the repo rate?</li><li>How it affects bond interest rates and prices</li><li>The impact on various types of debt mutual funds</li><li>Real-world return simulations with charts</li><li>Investment strategy tips based on interest rate outlook</li></ul><p>Let’s dive in.</p><h3>🏦 What is the Repo Rate?</h3><p>The <strong>repo rate</strong> is the interest rate at which the RBI lends short-term money to banks. It’s one of the primary tools RBI uses to control inflation, manage liquidity, and influence economic growth.</p><ul><li>When inflation is high, the RBI <strong>increases</strong> the repo rate to make borrowing expensive and slow down spending.</li><li>When economic growth is slow, it <strong>lowers</strong> the repo rate to encourage borrowing and investment.</li></ul><blockquote><em>Think of the repo rate as the “anchor” of the interest rate ecosystem in India.</em></blockquote><h3>🔄 Bond Prices and Interest Rates: The Inverse Relationship</h3><p>Here’s the golden rule of fixed income investing:</p><blockquote><strong><em>When interest rates fall, bond prices rise.</em></strong><em><br> </em><strong><em>When interest rates rise, bond prices fall.</em></strong></blockquote><p><strong>Why?</strong></p><p>If you own a bond that pays 6% interest and new bonds in the market are now paying 7%, your bond becomes less attractive. To sell it, you’ll need to lower the price. The reverse is true when rates fall.</p><p>This simple dynamic has major implications for <strong>debt mutual funds</strong>.</p><h3>📈 How Repo Rate Affects Debt Mutual Fund Returns</h3><p>Debt funds invest in bonds. So, when bond prices change, the <strong>Net Asset Value (NAV)</strong> of the fund also changes.</p><p>Here’s how it works:</p><p><strong>Repo Rate Movement</strong> <strong>Bond Prices</strong> <strong>Debt Fund NAV</strong> <strong>Return Type</strong> Repo rate falls Rises Increases Capital gain + interest Repo rate rises Falls Decreases Interest only (low NAV)</p><h3>⏳ Types of Debt Mutual Funds and Rate Sensitivity</h3><p>Each type of debt fund invests in bonds of different <strong>maturities</strong>. The <strong>longer the duration</strong>, the <strong>more sensitive</strong> the fund is to interest rate changes.</p><p><strong>Fund Type</strong> <strong>Average Duration</strong> <strong>Interest Rate Sensitivity</strong> Liquid Fund ~0.1 years Very Low Ultra Short-Term Fund ~0.3 years Low Short-Term Fund ~2 years Moderate Medium Duration Fund ~4 years High Long Duration Fund ~7 years Very High Gilt Fund (Gov Bonds) ~10 years Extremely High</p><h3>📊 Scenario 1: Impact of a 1% Repo Rate Cut</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xMG7K9dFANuGYVB3D-Kabg.png" /><figcaption>Impact of repo rate cut</figcaption></figure><p>Let’s assume RBI cuts the repo rate by <strong>1%</strong>. Here’s how various debt funds would perform:</p><p><strong>Fund Type</strong> <strong>Interest Return (%)</strong> <strong>Capital Gain (%)</strong> <strong>Total Return (%)</strong> Liquid Fund 6.00 0.07 6.07 Ultra Short-Term Fund 6.20 0.21 6.41 Short-Term Fund 6.50 1.40 7.90 Medium Duration Fund 6.80 2.80 9.60 Long Duration Fund 7.00 4.90 11.90 Gilt Fund 7.20 7.00 14.20</p><p><em>Total return = Interest return + capital gain due to bond price rise</em></p><h3>📉 Scenario 2: Impact of a 1% Repo Rate Hike</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSKcGtfVHXtG10xg3Gqbiw.png" /><figcaption>Impact of repo rate increase</figcaption></figure><p>Now let’s flip the situation. If the repo rate rises by 1%, here’s how the returns are affected:</p><p><strong>Fund Type</strong> <strong>Interest Return (%)</strong> <strong>Capital Loss (%)</strong> <strong>Total Return (%)</strong> Liquid Fund 6.00 -0.07 5.93 Ultra Short-Term Fund 6.20 -0.21 5.99 Short-Term Fund 6.50 -1.40 5.10 Medium Duration Fund 6.80 -2.80 4.00 Long Duration Fund 7.00 -4.90 2.10 Gilt Fund 7.20 -7.00 0.20</p><p><em>You still earn interest, but capital losses eat into total return</em></p><h3>🔎 Practical Investment Strategies</h3><h4>✅ If You Expect Interest Rates to Fall:</h4><ul><li>Invest in <strong>long-duration</strong> or <strong>gilt funds</strong></li><li>Benefit from both interest and <strong>capital gains</strong></li></ul><h4>❌ If You Expect Interest Rates to Rise:</h4><ul><li>Stick with <strong>liquid</strong>, <strong>ultra short</strong>, or <strong>short-term</strong> funds</li><li>Minimize capital losses, focus on stable interest income</li></ul><h4>❓ If You’re Not Sure:</h4><ul><li>Use a <strong>laddering strategy</strong> (mix of short, medium, and long-duration funds)</li><li>Rebalance as the interest rate outlook becomes clearer</li></ul><h3>📆 Final Thoughts</h3><p>Understanding how the <strong>repo rate impacts debt mutual funds</strong> is essential for smart fixed-income investing. Even a 1% change in repo rate can have a huge impact on your returns, especially for longer-duration funds.</p><p>Keep an eye on RBI monetary policy, track inflation data, and align your debt fund investments with the rate cycle.</p><p><strong>Remember</strong>: In bonds, time (duration) magnifies everything — including both gains and losses.</p><p><em>Was this helpful? Share it with your fellow investors or drop a comment below if you want a similar breakdown for equity or hybrid funds!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a562effe8d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Understanding the CAP Theorem: The Backbone of Distributed System Design]]></title>
            <link>https://tarunkr.medium.com/understanding-the-cap-theorem-the-backbone-of-distributed-system-design-1104514038bc?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1104514038bc</guid>
            <category><![CDATA[cap-theorm]]></category>
            <category><![CDATA[availability]]></category>
            <category><![CDATA[consistency]]></category>
            <category><![CDATA[cap-theorem]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Sat, 05 Apr 2025 11:44:19 GMT</pubDate>
            <atom:updated>2025-04-05T11:44:19.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*59p2xa4NkggJ0PVw" /></figure><h3>✍️ Introduction</h3><p>Imagine you’re transferring money from one bank account to another. You hit the “Transfer” button, and suddenly — the money disappears. It hasn’t reached the recipient, and your own balance shows nothing. Welcome to the world of distributed systems gone wrong.</p><p>Modern applications — whether it’s Google Docs, WhatsApp, or Amazon — rely heavily on distributed systems to scale and stay resilient. But distributed systems bring a complex trade-off between three fundamental properties: <strong>Consistency</strong>, <strong>Availability</strong>, and <strong>Partition Tolerance</strong>. This is formalised in the <strong>CAP Theorem</strong>.</p><p>Understanding CAP is vital for designing reliable, fault-tolerant, and scalable systems. In this post, we’ll simplify the CAP theorem through analogies, deep dives, visual illustrations, and real-world applications.</p><h3>📚 What is the CAP Theorem?</h3><p>The <strong>CAP Theorem</strong>, proposed by Eric Brewer and later proven by Gilbert and Lynch, states:</p><blockquote><em>In a distributed system, it is impossible to simultaneously guarantee </em><strong><em>Consistency (C )</em></strong><em>, </em><strong><em>Availability (A)</em></strong><em>, and </em><strong><em>Partition Tolerance (P)</em></strong><em>. You can only choose </em><strong><em>two</em></strong><em> out of the three.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QU5myEPgh9LsixsYXu-SUQ.png" /><figcaption>CAP Theorem</figcaption></figure><h3>💡 Let’s define these:</h3><p><strong>Consistency</strong>: All nodes return the same data for the same request, no matter which node is accessed.</p><p><strong>Availability</strong>: Every request receives a non-error response, even if some nodes are down.</p><p><strong>Partition Tolerance</strong>: The system continues to function even if there’s a communication breakdown between nodes.</p><p>📌 In distributed systems, partitions <strong>will</strong> happen. That means you’re always picking between <strong>Consistency</strong> and <strong>Availability</strong>.</p><h3>🧪 An Intuitive Analogy: The Postal Office Dilemma</h3><p>Imagine you manage two post offices — <strong>Office A</strong> and <strong>Office B</strong>. Normally, they sync data every hour. Now imagine a storm breaks communication between them.</p><ul><li>If both offices <strong>wait</strong> until they can talk again before handling new packages, you’re favoring <strong>Consistency</strong> over <strong>Availability</strong>. (CP)</li><li>If both offices <strong>continue</strong> processing, despite being out of sync, you’re choosing <strong>Availability</strong> over <strong>Consistency</strong>. (AP)</li></ul><p>That’s the CAP dilemma — <strong>you can’t have it all</strong> when there’s a network partition.</p><h3>🧩 Deep Dive into the Three Properties</h3><h4>🟠 Consistency</h4><p>Every read receives the most recent write. For example, if you update your profile picture from Node A, reading it from Node B should show the updated photo instantly.</p><h4>🟢 Availability</h4><p>Every request gets a response — even if it’s not the most updated data. No system downtime.</p><h4>🔵 Partition Tolerance</h4><p>The system keeps running even if some network nodes can’t talk to each other. This is a <strong>must-have</strong> for distributed systems.</p><h4>📋 Comparison Table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C6B5v5v6SZI3BsN6BG8TZw.png" /></figure><h3>⚖️ CAP Trade-offs — You Can Only Pick Two</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RF7a1JY1Rvl2lCfs" /></figure><h4>CP (Consistency + Partition Tolerance)</h4><ul><li>Sacrifices <strong>Availability</strong></li><li>During a partition, nodes stop processing to avoid inconsistency</li><li><strong>Example:</strong> Banking systems</li><li><strong>Tools:</strong> Google Spanner, MongoDB (strong mode), Zookeeper</li></ul><h4>AP (Availability + Partition Tolerance)</h4><ul><li>Sacrifices <strong>Consistency</strong></li><li>Continues operating, possibly with stale data</li><li><strong>Example:</strong> DNS, social media feeds</li><li><strong>Tools:</strong> Cassandra, CouchDB, DynamoDB</li></ul><h4>CA (Consistency + Availability)</h4><ul><li>Sacrifices <strong>Partition Tolerance</strong></li><li>Only works if network never fails — ideal but unrealistic in distributed systems</li><li><strong>Example:</strong> Standalone RDBMS like MySQL (non-distributed mode)</li></ul><h3>🧠 Visualizing with Replicated Nodes</h3><p>Let’s say we have three nodes: <strong>N1</strong>, <strong>N2</strong>, and <strong>N3</strong>.</p><h4>Normal Scenario:</h4><ul><li>A write to N1 is replicated to N2 and N3.</li><li>A read from any node gives the latest data.</li></ul><h4>Partition Scenario:</h4><ul><li><strong>N3</strong> loses connectivity.</li><li>In a <strong>CP system</strong>, writes are blocked on N1 and N2 to prevent inconsistency.</li><li>In an <strong>AP system</strong>, writes continue on N1 and N2; N3 syncs later.</li></ul><h3>🛠️ Real-World Applications of CAP Theorem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OxY2u4Vnj3OQd_cxxCo19w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WpC37IyFbIh6LsSQ" /></figure><h3>🤔 How to Choose the Right CAP Model?</h3><p>When designing your system, ask:</p><ul><li>Is <strong>data correctness</strong> critical?</li><li>Can users <strong>tolerate stale data</strong>?</li><li>Is <strong>uptime more important</strong> than perfect data?</li><li>Are <strong>network partitions</strong> likely?</li></ul><p>Choose the pair of guarantees that best matches your app’s <strong>user experience</strong>, <strong>data integrity needs</strong>, and <strong>fault tolerance</strong>.</p><h3>🔎 Common Myths Around CAP</h3><ul><li><strong>Myth:</strong> CA systems are ideal<br> ✅ <em>Fact:</em> They only work in non-partitioned networks</li><li><strong>Myth:</strong> AP means poor data<br> ✅ <em>Fact:</em> Eventual consistency still ensures correct data — just not immediately</li><li><strong>Myth:</strong> CP is always slow<br> ✅ <em>Fact:</em> Not true — latency depends on implementation, not CAP alone</li></ul><h3>📌 Conclusion</h3><p>The <strong>CAP Theorem</strong> isn’t a limitation — it’s a <strong>framework</strong> to help you design better systems.</p><p>Because <strong>partitions are inevitable</strong>, you must choose between <strong>Consistency</strong> and <strong>Availability</strong>.</p><p>💡 Choose based on your use case:</p><ul><li>Bank system? Go CP.</li><li>Social app? Go AP.</li></ul><p>There’s no one-size-fits-all. Only <strong>smart trade-offs</strong>.</p><p>👉 <strong>Design for failure. Embrace trade-offs. Architect wisely.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1104514038bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Backend Frameworks Comparison: Express.js, Django, FastAPI, Go, Spring Boot, and REST]]></title>
            <link>https://tarunkr.medium.com/the-ultimate-backend-frameworks-comparison-express-js-django-fastapi-go-spring-boot-and-rest-b1a4494b0f3b?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1a4494b0f3b</guid>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[backend-framework]]></category>
            <category><![CDATA[golan]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Tue, 01 Apr 2025 20:22:57 GMT</pubDate>
            <atom:updated>2025-04-12T20:29:10.018Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L1QUZciyIeJrMmVMuV05Vg.png" /><figcaption>Ultimate Comparision</figcaption></figure><h3>Introduction</h3><p>Choosing the right backend framework is crucial for building a scalable, efficient, and maintainable web application. With so many options available — Express.js, Django, FastAPI, Go, Spring Boot, and traditional REST architectures — it can be challenging to determine which one best suits your needs.</p><p>In this article, we’ll break down each of these frameworks, comparing their performance, architecture, use cases, and when to choose one over the other. Whether you’re a beginner or an experienced developer, this guide will help you make an informed decision.</p><h3>1. Overview of Backend Frameworks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8KxRfdWWP4pbhHg_BMtFA.png" /><figcaption>overview of all major backend frameworks</figcaption></figure><h3>2. Performance and Scalability</h3><p>Performance is a key factor when selecting a backend framework. Here’s how they compare:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OjqgEHr9mPqFJi_E5eLeJw.png" /><figcaption>Performance and scalability comparison</figcaption></figure><p><strong>Key Takeaways:</strong></p><ul><li><strong>Go (net/http)</strong> offers the best raw performance due to compiled execution and goroutines.</li><li><strong>FastAPI</strong> is the best for Python-based APIs, leveraging asynchronous processing.</li><li><strong>Spring Boot</strong> is great for enterprise applications requiring stability and high scalability.</li><li><strong>Express.js</strong> is lightweight and great for microservices.</li></ul><h3>3. Frameworks Explained in Detail</h3><h4>1️⃣ Express.js (Node.js)</h4><p>Uses <strong>I/O Multiplexing (event loop)</strong> to handle many connections without blocking.</p><p><strong>Best for:</strong> APIs, real-time chat apps, microservices.</p><p><strong>Pros:</strong> 🚀 Lightweight, easy to learn, large ecosystem (npm).</p><p><strong>Cons:</strong> ❌ Not great for CPU-heavy tasks, lacks built-in scalability.<strong>Example Use Cases:</strong><br> ✅ REST APIs, WebSockets, Real-time apps (e.g., Slack, Discord).</p><h4>2️⃣ Django (WSGI)</h4><p>Uses <strong>Multi-threading / Multi-processing</strong> (WSGI-based servers like Gunicorn).</p><p><strong>Best for:</strong> Web apps with a database, CMS, e-commerce.</p><p><strong>Pros:</strong> ✅ Built-in admin panel, security, batteries-included.</p><p><strong>Cons:</strong> ❌ Synchronous (blocking), not good for real-time apps.</p><p><strong>Example Use Cases:</strong><br> ✅ Instagram, Pinterest, Shopify-like e-commerce platforms.</p><h4>3️⃣ Django + ASGI (with Uvicorn)</h4><p>Uses <strong>I/O Multiplexing + Async</strong> for fast API performance.</p><p><strong>Best for:</strong> WebSockets, high-performance APIs, async tasks.</p><p><strong>Pros:</strong> 🚀 Faster than WSGI, supports WebSockets, async queries.</p><p><strong>Cons:</strong> ❌ Still not as fast as Go or FastAPI for high concurrency.</p><p><strong>Example Use Cases:</strong><br> ✅ Chat apps, real-time dashboards, async APIs.</p><h4>4️⃣ FastAPI (Python)</h4><p>Uses <strong>I/O Multiplexing (async)</strong> via <strong>Starlette &amp; Uvicorn</strong>.</p><p><strong>Best for:</strong> High-performance APIs, machine learning services.</p><p><strong>Pros:</strong> ⚡ Blazing fast, async-first, auto-generates OpenAPI docs.</p><p><strong>Cons:</strong> ❌ Less mature ecosystem than Django or Node.js.</p><p><strong>Example Use Cases:</strong><br> ✅ AI services, OpenAI APIs, ML inference systems.</p><h4>5️⃣ Go (Gin, Fiber, Echo, etc.)</h4><p>Uses <strong>Goroutines (lightweight threads)</strong> for extreme concurrency.</p><p><strong>Best for:</strong> High-performance APIs, distributed systems.</p><p><strong>Pros:</strong> 🏎️ Super fast, very low memory footprint, compiled binary.</p><p><strong>Cons:</strong> ❌ Requires compiling, not as beginner-friendly.</p><p><strong>Example Use Cases:</strong><br> ✅ Google Cloud services, Kubernetes, real-time APIs (e.g., Uber).</p><h4>6️⃣ Spring Boot (Java/Kotlin)</h4><p>Uses <strong>Multi-threading + Multi-processing</strong> for handling requests.</p><p><strong>Best for:</strong> Large enterprise applications, banking, fintech.</p><p><strong>Pros:</strong> ✅ Battle-tested, scalable, robust security.</p><p><strong>Cons:</strong> ❌ Heavy, slow startup, complex setup.</p><p><strong>Example Use Cases:</strong><br> ✅ Banking apps, financial systems, large-scale enterprise software (e.g., Netflix, Airbnb).</p><h3>4. Ease of Development &amp; Learning Curve</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZutleFVOWEJvmrVI2-PBw.png" /></figure><h3>6. When to Choose Which?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qC6ryA60ziCfV_85H9VSTw.png" /></figure><h3>7. Overall comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzgbXsT3Co46z7KRwB4TbQ.png" /></figure><h3>8. Conclusion: Which Backend Framework is Right for You?</h3><ul><li><strong>Choose Express.js</strong> if you want a simple, fast, and flexible backend.</li><li><strong>Go with Django</strong> if you need an all-in-one framework with built-in security.</li><li><strong>Pick FastAPI</strong> if you need high-speed Python APIs with async capabilities.</li><li><strong>Use Go (net/http)</strong> for performance-critical applications that handle thousands of concurrent requests.</li><li><strong>Opt for Spring Boot</strong> if you need enterprise-grade robustness and scalability.</li></ul><p>Each of these backend technologies has its strengths and weaknesses, and the best choice depends on your application’s requirements. 🚀</p><figure><a href="https://www.buymeacoffee.com/tarunkumar"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*Dpw8-hNGI2fDmosV4E8DVQ.png" /></a></figure><h3>Feedback</h3><p>That’s all for Today’s Post. If you have any questions, please let me know in the comments. Also, if you found any errors in the post, please write to me at tarun12.tarunkr@gmail.com.</p><p>If you want me to cover some specific topics in the upcoming posts, please let me know in the comments.</p><p>Follow me:</p><ul><li><a href="https://www.linkedin.com/in/tarun-kumar-iit-ism/">Linkedin</a></li><li><a href="https://github.com/tarunk04/">GitHub</a></li><li><a href="https://www.kaggle.com/tarunk04">Kaggle</a>.</li></ul><p>Thank you for your the time to read this article. Please share it if you like.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1a4494b0f3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Multiprocessing, Multithreading, and I/O Multiplexing: A Deep Dive]]></title>
            <link>https://tarunkr.medium.com/understanding-multiprocessing-multithreading-and-i-o-multiplexing-a-deep-dive-acdc0bef283a?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/acdc0bef283a</guid>
            <category><![CDATA[multiprocessing]]></category>
            <category><![CDATA[multiplexing]]></category>
            <category><![CDATA[multithreading]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Tue, 01 Apr 2025 20:00:59 GMT</pubDate>
            <atom:updated>2025-04-12T20:26:44.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syLNd6lK976N2EskiRfQBw.png" /></figure><h3>Introduction</h3><p>In the world of computing, speed and efficiency matter. Whether you’re writing a backend server, a data processing pipeline, or a real-time application, the way your system handles multiple tasks can make or break its performance. Three fundamental techniques enable modern software to execute multiple tasks efficiently:</p><ol><li><strong>Multithreading</strong> — Running multiple threads within the same process.</li><li><strong>Multiprocessing</strong> — Running multiple processes, each with its own memory space.</li><li><strong>I/O Multiplexing</strong> — Efficiently handling multiple I/O operations without creating multiple threads or processes.</li></ol><p>In this article, we’ll break down these concepts in an easy-to-understand way, then take a deep dive into their inner workings and use cases.</p><h3>1. Multiprocessing, Multithreading, and I/O Multiplexing</h3><h4>Multithreading: The Art of Juggling Tasks in One Hand</h4><p>Imagine you’re a single chef cooking multiple dishes. You can chop vegetables while waiting for water to boil, then stir a pot while a steak is grilling. You’re doing multiple things at once, but you still have only one pair of hands.</p><p>This is what multithreading is like. A program (process) can create multiple “threads” that run concurrently. However, they share the same memory space and CPU resources, meaning they can’t all work at full speed at the same time.</p><ul><li><strong>Pros</strong>: Efficient for tasks that involve waiting (e.g., fetching data from a database, downloading a file).</li><li><strong>Cons</strong>: If one thread is doing heavy computation, it can slow down all other threads (due to the <strong>Global Interpreter Lock (GIL)</strong> in Python, for example).</li></ul><h4>Multiprocessing: Hiring More Chefs in the Kitchen</h4><p>Instead of one chef juggling everything, imagine hiring multiple chefs. Each chef has their own cutting board, stove, and workspace. They can truly cook in parallel without interfering with each other.</p><p>This is how multiprocessing works. Each process runs separately, with its own memory and CPU resources.</p><ul><li><strong>Pros</strong>: Great for CPU-heavy tasks (e.g., video processing, machine learning training, number crunching).</li><li><strong>Cons</strong>: More overhead since each process requires its own memory and inter-process communication can be slow.</li></ul><h4>I/O Multiplexing: Being Smart About Waiting</h4><p>Let’s say you’re a waiter in a busy restaurant. Instead of standing at one table waiting for a customer to decide, you take multiple orders at once and check back when needed. This way, you efficiently serve many tables without wasting time.</p><p>This is how I/O multiplexing works. Instead of blocking the CPU while waiting for I/O operations (like reading a file or making a network request), the program can monitor multiple I/O sources at once and process them as soon as they’re ready.</p><ul><li><strong>Pros</strong>: Best for handling many network requests, like in web servers (e.g., Nginx, Node.js, Redis).</li><li><strong>Cons</strong>: Not ideal for CPU-heavy tasks, since it relies on the CPU being idle while waiting for I/O.</li></ul><h3>2. Deep Dive into the Mechanisms</h3><h4>🔹 How Multiprocessing Works Under the Hood</h4><p>Unlike multithreading, multiprocessing spawns separate processes, each with its own memory space. These processes don’t share memory, making them immune to issues like race conditions.</p><h4>🔥 Key Concepts in Multiprocessing:</h4><ul><li><strong>Process Pooling</strong>: Similar to thread pooling, but for processes.</li><li><strong>Inter-Process Communication (IPC)</strong>: Mechanisms like pipes and message queues allow processes to talk to each other.</li><li><strong>Parallel Execution</strong>: Since each process runs independently, CPU-intensive tasks benefit greatly from multiprocessing.</li></ul><h4>🛠 Best Use Cases:</h4><ul><li>Machine learning model training.</li><li>Image and video processing.</li><li>Running multiple simulations in parallel.</li></ul><h4>🔹 How Multithreading Works Under the Hood</h4><p>Multithreading is based on creating multiple <strong>threads</strong> inside a single process. Threads share the same memory space but can execute different instructions simultaneously.</p><h4>🔥 Key Concepts in Multithreading:</h4><ul><li><strong>Thread Pooling</strong>: Instead of creating and destroying threads repeatedly, a thread pool maintains a set number of worker threads ready to execute tasks.</li><li><strong>Context Switching</strong>: The CPU rapidly switches between threads, making it seem like they are running in parallel.</li><li><strong>Global Interpreter Lock (GIL)</strong>: In Python, the GIL prevents multiple threads from executing Python bytecode at the same time, limiting true parallelism.</li></ul><h4>🛠 Best Use Cases:</h4><ul><li>Web scraping (making multiple HTTP requests simultaneously).</li><li>Handling multiple client connections in chat applications.</li><li>UI applications where background tasks run without freezing the main window</li></ul><h4>🔹 How I/O Multiplexing Works Under the Hood</h4><p>I/O multiplexing is built on system calls like <strong>select(), poll(), and epoll()</strong> (Linux) or <strong>kqueue</strong> (macOS/BSD). Instead of blocking each operation, the system monitors multiple file descriptors (network connections, disk files, etc.) and processes them as they become available.</p><h4>🔥 Key Concepts in I/O Multiplexing:</h4><ul><li><strong>Event Loops</strong>: Used in frameworks like Node.js and FastAPI, allowing a single thread to handle thousands of connections.</li><li><strong>Non-blocking I/O</strong>: A single process doesn’t wait for an operation to finish; it moves on to other tasks and checks back later.</li><li><strong>Reactor Pattern</strong>: A design pattern where one thread listens for events and dispatches them to handlers.</li></ul><h4>🛠 Best Use Cases:</h4><ul><li>High-performance web servers (e.g., Nginx, Express.js, FastAPI).</li><li>Handling thousands of concurrent WebSocket connections.</li><li>Event-driven applications (e.g., Redis, Kafka).</li></ul><h3>3. Comprehensive Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ePp0QO8SrisYcYsOlRNCgA.png" /></figure><h3>4. Conclusion: Which One Should You Use?</h3><ul><li><strong>Use multithreading</strong> when your task involves <strong>waiting</strong> (e.g., fetching API data, running UI updates in the background).</li><li><strong>Use multiprocessing</strong> when your task involves <strong>heavy computation</strong> (e.g., training a deep learning model, processing large datasets).</li><li><strong>Use I/O multiplexing</strong> when handling <strong>many simultaneous connections</strong> (e.g., building a high-performance API server).</li></ul><p>By understanding these techniques, you can build applications that run faster, scale better, and use system resources efficiently. 🚀</p><figure><a href="https://www.buymeacoffee.com/tarunkumar"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*Dpw8-hNGI2fDmosV4E8DVQ.png" /></a></figure><h3>Feedback</h3><p>That’s all for Today’s Post. If you have any questions, please let me know in the comments. Also, if you found any errors in the post, please write to me at tarun12.tarunkr@gmail.com.</p><p>If you want me to cover some specific topics in the upcoming posts, please let me know in the comments.</p><p>Follow me:</p><ul><li><a href="https://www.linkedin.com/in/tarun-kumar-iit-ism/">Linkedin</a></li><li><a href="https://github.com/tarunk04/">GitHub</a></li><li><a href="https://www.kaggle.com/tarunk04">Kaggle</a>.</li></ul><p>Thank you for your the time to read this article. Please share it if you like.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acdc0bef283a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to setup SSL/TLS for your domain for Free: Cloudflare and Nginx]]></title>
            <link>https://tarunkr.medium.com/how-to-setup-ssl-tls-for-your-domain-for-free-cloudflare-and-nginx-28ca308b895b?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/28ca308b895b</guid>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[free-ssl-certificate]]></category>
            <category><![CDATA[ssltls]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Wed, 02 Mar 2022 20:00:34 GMT</pubDate>
            <atom:updated>2025-04-12T21:34:56.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvIVedxhDAQsJF1IbMWQPw.png" /><figcaption>Secure your website with SSL</figcaption></figure><h3>Introduction</h3><p>Have you ever had a tough time bringing your website to the top of Google search results? Have you or your users ever seen this annoying screen when you or they visit your website?<br>“Your connection to this website is not secure”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*N50YRhaqpJWa0HZvLbda9Q.png" /></figure><p>You might already be knowing that these two problems are most likely a result of you not having an SSL certificate for your domain name. You might have already visited some hosting service provider and would have jumped in your seat on seeing the pricing. What if you could get a free SSL for your domain name with all the important security features you need? Let’s see how -</p><p>There are a few ways to do that.</p><ol><li><strong>Self Signed SSL Certificate:</strong> You can create and secure your connection using OpenSSL, but the only problem with this method is, as the Certificate is not signed by any of your browser&#39;s trusted certificate authorities, you will see something like below in your browser:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*NRXpyTanLfVRtNiATmocFg.png" /><figcaption>Not Secure Message on Chrome</figcaption></figure><p>2. <strong>Let&#39;s Encrypt:</strong> It is a nonprofit Certificate Authority. Many hosting providers provide integration support, and you can integrate free SSL. But not all hosting/domain services do. Still, you can do it manually, but the problem is Let&#39;s Encrypt provide a Certificate for 90 days only, and you have to renew it again after 90 days for free.</p><p>3. <strong>Cloudflare:</strong> It provides CDN, security firewall, DNS, SSL, and a lot more, and that&#39;s too for free.</p><h3>Cloudflare</h3><p>Cloudflare provides a lot of excellent features for free. We are going to discuss SSL setup in this article.</p><p>Cloudflare also provides an external DNS service, so if you have a domain name with any service provider still, you can use Cloudflare as DNS. Cloudflare also provides a free SSL Certificate. It provides a bunch of different options to select.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*AwX6LpJjKUBiMSXqAtWzAA.png" /><figcaption>Cloudflare SSL/TLS encryption mode</figcaption></figure><ol><li><strong>Flexible:</strong> All the traffic from the browser to the Cloudflare will be secure, but Cloudflare to the origin server will be on HTTP only and not HTTPS. Flexible mode is good enough if your website does not handle sensitive data. Do not require any extra effort to enable this method. You need to enable this from the Cloudflare SSL dashboard, and you are done.</li><li><strong>Full:</strong> End-to-end encryption, all the traffic from the browser to the origin server is secure.</li><li><strong>Full (strict)</strong>: It is the same as Full, but the only difference is that the connection between Cloudflare to the origin server is secure with trusted CA or Cloudflare Origin CA. We will see how to set up this method in the latter part of the article.</li></ol><p><strong>Prerequisite</strong></p><ol><li>a VM (virtual machine) with NGINX, running on any hosting service such as GCP, AWS, Azure, etc.</li><li>Cloudflare account it&#39;s free to create.</li><li>A domain name, such as example.com , setup DNS on Cloudflare to point the Nginx Server. Refer to docs to setup DNS on Cloudflare: <a href="https://developers.cloudflare.com/dns/">https://developers.cloudflare.com/dns/</a></li></ol><h4>1. Create Origin Certificate</h4><p>Cloudflare offers you to create a free SSL Certificate which you can install on the Nginx Server. This Certificate will secure the connection between Cloudflare and the origin server.</p><p>Go to <strong>SSL/TLS </strong>section, select <strong>Origin Server</strong>, and there click on <strong>Create Certificate</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*k-GYhiC0VI7x_UeulhOJuw.png" /><figcaption>Create SSL Certificate</figcaption></figure><p>Click on <strong>Create </strong>to generate the Certificate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*ogg7S18QzPn5bDrd4ii3Jg.png" /><figcaption>Create an SSL Certificate for the origin server</figcaption></figure><p>Now the Certificate is created, you need to<strong> install </strong>this on your origin server. Keep a <strong>copy </strong>of your <strong>Private Key</strong> in a safe place. Once <strong>OK</strong> is pressed, you can not reaccess the <strong>Private Key</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*diNUOr_rAOzoVPOQudi4sg.png" /><figcaption>Generated SSL Certificate</figcaption></figure><p>First copy <strong>Origin Certificate </strong>to /etc/ssl/certs/cert.pem on your server.</p><pre>$ sudo nano /etc/ssl/certs/cert.pem</pre><p>Then copy <strong>Private Key </strong>to /etc/ssl/private/key.pem on your server.</p><pre>$ sudo nano /etc/ssl/private/key.pem</pre><p><strong>Note: Sometimes, an extra line is added while pasting. Check for any additional lines left at the top of the file. The Nginx configuration test will fail otherwise.</strong></p><h4><strong>2. Configure Nginx</strong></h4><p>We have created the Certificate and Private Key and copied them to the server. The next step is to configure the Nginx.</p><p>Next, open the Nginx configuration file:</p><pre>$ sudo nano /etc/nginx/sites-available/example.com</pre><p>Example Nginx configuration, your config may be different.</p><pre>server {<br>    listen 80;<br>    listen [::]:80;<br><br>    server_name example.com www.example.com;<br><br>    location / {<br>        include proxy_params;<br>        proxy_pass <a href="http://localhost:3000/">http://localhost:3000/</a>;<br>    }<br>}</pre><p>Let&#39;s modify it to handle the requests on port 443 to use the HTTPS protocol.</p><p>We will change port 80 to 443 and add ssl_certificate and ssl_certificate_key directive to the configuration. <em>I am removing port 80 and redirect the http request to HTTPS from Cloudflare.</em></p><pre>server {<br>    listen 443;<br>    listen [::]:443;</pre><pre>    ssl_certificate         /etc/ssl/certs/cert.pem;<br>    ssl_certificate_key     /etc/ssl/private/key.pem;</pre><pre>    server_name example.com www.example.com;<br><br>    location / {<br>        include proxy_params;<br>        proxy_pass <a href="http://localhost:3000/">http://localhost:3000/</a>;<br>    }<br>}</pre><p>Save the file and run the test.</p><pre>$ sudo nginx -t</pre><p>If the test is passed, then restart the Nginx server to enable the change</p><pre>$ sudo systemctl restart nginx</pre><p>Next, go to the <strong>SSL/TLS </strong>section and select <strong>Overview, </strong>and select the <strong>Full (strict)</strong> option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*_zjc_lK3zPeteQ-27RNJyw.png" /><figcaption>Enable Full(strict) mode SSL</figcaption></figure><p>Go to the <strong>SSL/TLS</strong> section, select <strong>Edge Certificate,</strong> and enable the <strong>Always Use HTTPS </strong>option. This will redirect all the HTTP requests to HTTPS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*bn5MXWuqqiB8jP86dujtEA.png" /><figcaption>Enable Always use HTTPS on Cloudflare to redirect all http request</figcaption></figure><h4>3. Setup Authenticated Origin Pull</h4><p>Authenticated Origin Pulls will ensure that the request is coming through Cloudflare to sever and not directly to the origin server.</p><blockquote>Authenticated Origin Pulls allow you to cryptographically verify that requests to your origin server have come from Cloudflare using a TLS client certificate. This prevents clients from sending requests directly to your origin, bypassing security measures provided by Cloudflare, such as IP and Web Application Firewalls, logging, and encryption.</blockquote><p>Refer More: <a href="https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/">https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/</a></p><p>We need to add the Cloudflare TLS client certificate to our Nginx server:</p><pre>-----BEGIN CERTIFICATE-----<br>MIIGCjCCA/KgAwIBAgIIV5G6lVbCLmEwDQYJKoZIhvcNAQENBQAwgZAxCzAJBgNV<br>BAYTAlVTMRkwFwYDVQQKExBDbG91ZEZsYXJlLCBJbmMuMRQwEgYDVQQLEwtPcmln<br>aW4gUHVsbDEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzETMBEGA1UECBMKQ2FsaWZv<br>cm5pYTEjMCEGA1UEAxMab3JpZ2luLXB1bGwuY2xvdWRmbGFyZS5uZXQwHhcNMTkx<br>MDEwMTg0NTAwWhcNMjkxMTAxMTcwMDAwWjCBkDELMAkGA1UEBhMCVVMxGTAXBgNV<br>BAoTEENsb3VkRmxhcmUsIEluYy4xFDASBgNVBAsTC09yaWdpbiBQdWxsMRYwFAYD<br>VQQHEw1TYW4gRnJhbmNpc2NvMRMwEQYDVQQIEwpDYWxpZm9ybmlhMSMwIQYDVQQD<br>ExpvcmlnaW4tcHVsbC5jbG91ZGZsYXJlLm5ldDCCAiIwDQYJKoZIhvcNAQEBBQAD<br>ggIPADCCAgoCggIBAN2y2zojYfl0bKfhp0AJBFeV+jQqbCw3sHmvEPwLmqDLqynI<br>42tZXR5y914ZB9ZrwbL/K5O46exd/LujJnV2b3dzcx5rtiQzso0xzljqbnbQT20e<br>ihx/WrF4OkZKydZzsdaJsWAPuplDH5P7J82q3re88jQdgE5hqjqFZ3clCG7lxoBw<br>hLaazm3NJJlUfzdk97ouRvnFGAuXd5cQVx8jYOOeU60sWqmMe4QHdOvpqB91bJoY<br>QSKVFjUgHeTpN8tNpKJfb9LIn3pun3bC9NKNHtRKMNX3Kl/sAPq7q/AlndvA2Kw3<br>Dkum2mHQUGdzVHqcOgea9BGjLK2h7SuX93zTWL02u799dr6Xkrad/WShHchfjjRn<br>aL35niJUDr02YJtPgxWObsrfOU63B8juLUphW/4BOjjJyAG5l9j1//aUGEi/sEe5<br>lqVv0P78QrxoxR+MMXiJwQab5FB8TG/ac6mRHgF9CmkX90uaRh+OC07XjTdfSKGR<br>PpM9hB2ZhLol/nf8qmoLdoD5HvODZuKu2+muKeVHXgw2/A6wM7OwrinxZiyBk5Hh<br>CvaADH7PZpU6z/zv5NU5HSvXiKtCzFuDu4/Zfi34RfHXeCUfHAb4KfNRXJwMsxUa<br>+4ZpSAX2G6RnGU5meuXpU5/V+DQJp/e69XyyY6RXDoMywaEFlIlXBqjRRA2pAgMB<br>AAGjZjBkMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgECMB0GA1Ud<br>DgQWBBRDWUsraYuA4REzalfNVzjann3F6zAfBgNVHSMEGDAWgBRDWUsraYuA4REz<br>alfNVzjann3F6zANBgkqhkiG9w0BAQ0FAAOCAgEAkQ+T9nqcSlAuW/90DeYmQOW1<br>QhqOor5psBEGvxbNGV2hdLJY8h6QUq48BCevcMChg/L1CkznBNI40i3/6heDn3IS<br>zVEwXKf34pPFCACWVMZxbQjkNRTiH8iRur9EsaNQ5oXCPJkhwg2+IFyoPAAYURoX<br>VcI9SCDUa45clmYHJ/XYwV1icGVI8/9b2JUqklnOTa5tugwIUi5sTfipNcJXHhgz<br>6BKYDl0/UP0lLKbsUETXeTGDiDpxZYIgbcFrRDDkHC6BSvdWVEiH5b9mH2BON60z<br>0O0j8EEKTwi9jnafVtZQXP/D8yoVowdFDjXcKkOPF/1gIh9qrFR6GdoPVgB3SkLc<br>5ulBqZaCHm563jsvWb/kXJnlFxW+1bsO9BDD6DweBcGdNurgmH625wBXksSdD7y/<br>fakk8DagjbjKShYlPEFOAqEcliwjF45eabL0t27MJV61O/jHzHL3dknXeE4BDa2j<br>bA+JbyJeUMtU7KMsxvx82RmhqBEJJDBCJ3scVptvhDMRrtqDBW5JShxoAOcpFQGm<br>iYWicn46nPDjgTU0bX1ZPpTpryXbvciVL5RkVBuyX2ntcOLDPlZWgxZCBp96x07F<br>AnOzKgZk4RzZPNAxCXERVxajn/FLcOhglVAKo5H0ac+AitlQ0ip55D2/mf8o72tM<br>fVQ6VpyjEXdiIXWUq/o=<br>-----END CERTIFICATE-----</pre><p>you can also download the Certificate from <a href="https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/set-up/">here</a>.</p><p>Copy the above Certificate to /etc/ssl/certs/cloudflare.crt on your server.</p><pre>$ sudo nano /etc/ssl/certs/cloudflare.crt</pre><p>Now add ssl_verify_client and ssl_client_certificate directives to Nginx configuration.</p><pre>server {<br>    listen 443;<br>    listen [::]:443;</pre><pre>    ssl_certificate         /etc/ssl/certs/cert.pem;<br>    ssl_certificate_key     /etc/ssl/private/key.pem;</pre><pre>    ssl_verify_client on;<br>    ssl_client_certificate /etc/ssl/certs/cloudflare.crt;</pre><pre>    server_name example.com www.example.com;<br><br>    location / {<br>        include proxy_params;<br>        proxy_pass <a href="http://localhost:3000/">http://localhost:3000/</a>;<br>    }<br>}</pre><p>Save the configuration and test the for syntax error, then restart the server:</p><pre>$ sudo nginx -t<br>$ sudo systemctl restart nginx</pre><p>Finally, enable the <strong>Authenticated Origin Pulls,</strong> go to the <strong>SSL/TLS </strong>section and select <strong>Origin Server</strong>, then enable it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*tCRiNQJWoTLQlXEjV7erVg.png" /><figcaption>Enable Authenticated Origin Pulls</figcaption></figure><p>Now, to check if everything works, enter your domain <a href="https://example.com/">https://example.com</a> in the browser to verify setup.</p><figure><a href="https://www.buymeacoffee.com/tarunkumar"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*Dpw8-hNGI2fDmosV4E8DVQ.png" /></a></figure><h3>Feedback</h3><p>That&#39;s all for Today&#39;s Post. If you have any questions, please let me know in the comments. Also, if you found any errors in the post, please write to me at tarun12.tarunkr@gmail.com.</p><p>If you want me to cover some specific topics in the upcoming posts, please let me know in the comments.</p><p>Follow me:</p><ul><li><a href="https://www.linkedin.com/in/tarun-kumar-iit-ism/">Linkedin</a></li><li><a href="https://github.com/tarunk04/">GitHub</a></li><li><a href="https://www.kaggle.com/tarunk04">Kaggle</a>.</li></ul><p>Thank you for your the time to read this article. Please share it if you like.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28ca308b895b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clipping Mask in Photoshop]]></title>
            <link>https://medium.com/concept-canvas/clipping-mask-in-photoshop-fe223ed3baa?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe223ed3baa</guid>
            <category><![CDATA[clipping-mask]]></category>
            <category><![CDATA[photoshop]]></category>
            <category><![CDATA[effect]]></category>
            <category><![CDATA[photoshop-tutorials]]></category>
            <category><![CDATA[photoshop-clipping-path]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Sun, 20 Dec 2020 17:53:27 GMT</pubDate>
            <atom:updated>2020-12-20T17:53:27.423Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FWPNPXPfMOT0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DWPNPXPfMOT0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FWPNPXPfMOT0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9aa6bef57da6230a2f50415c2c814a6d/href">https://medium.com/media/9aa6bef57da6230a2f50415c2c814a6d/href</a></iframe><p><strong>Clipping Mask</strong></p><p>Clipping mask allows you to limit the effect to the underlying layer. It can be used for several purposes. A most common use is to limit the adjustment layer effect to a particular layer. Also, it can be used to limit the above layer to the underlying layer shape. In the below layer, the layer2 is the clipped layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*tc5MWQpOXXa6YpsLmIB0cg.jpeg" /></figure><p>Shortcut key for clipping mask — Alt+left click (move your cursor to between of two-layer then you will see clipping mask symbol then click)</p><p><strong>Stock Images used in the above video:</strong></p><p><a href="https://www.pexels.com/photo/photography-of-roadway-during-dusk-1034662/"><strong>City Image</strong></a></p><p><a href="https://drive.google.com/file/d/1iD69oQLhgYzbs2j57_AZb_UzppJx06w8/view"><strong>Final PSD</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtUPXrJLIiXmXtxXW_pXXQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe223ed3baa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/concept-canvas/clipping-mask-in-photoshop-fe223ed3baa">Clipping Mask in Photoshop</a> was originally published in <a href="https://medium.com/concept-canvas">Concept Canvas</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Progress Bar Python- For Jupyter Notebook]]></title>
            <link>https://medium.com/analytics-vidhya/progress-bar-python-for-jupyter-notebook-f68224955810?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f68224955810</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[progress-bar]]></category>
            <category><![CDATA[custom-progress-bar]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 13:38:45 GMT</pubDate>
            <atom:updated>2025-04-12T20:46:03.475Z</atom:updated>
            <content:encoded><![CDATA[<h3>Simple Progress Bar-Integrate with any python project in a few seconds</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b02LwUuLkzeZ7L08A5T7eA.png" /><figcaption>Python progress bar</figcaption></figure><p>Why do you need a progress bar? Yeah, sometimes you need to monitor the progress of the task. Most of the time I find issues building the progress bar from scratch. Sometimes a very basic one can do the job, but not always. Have you ever used Keras (Machine Learning API for Python)? It has its own custom progress bar to give a good idea of the training. When I started working with PyTorch, I feel something is missing, because every time I need to build a progress monitor. So, I decided to build a package a simple one but can do a lot very easily.</p><p>Today, I will guide you on how to use my progress bar. You can find the documentation and package on my <a href="https://github.com/tarunk04/progress-bar-python">GitHub</a> repository. I have tried to keep things simple and very intuitive.</p><p>You can use this for many different usages but I have built this for progress monitoring with PyTorch.</p><h3>Installation</h3><p>Just need a file progress.py into your working directory. Get the file from <a href="https://github.com/tarunk04/progress-bar-python">GitHub</a>.</p><p><strong>Note: I will soon make the python package available through pip install.</strong></p><h3>How To Use</h3><p>I am going to explain through two simple examples. Further documentation can be found on my <a href="https://github.com/tarunk04/progress-bar-python">GitHub</a>.</p><ol><li><strong>EXAMPLE 1:</strong> Suppose you need to process the images and you have 2478 images to process. Let’s see how you can make a simple progress monitor as in the figure below.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bRMe-Phi-fpYXL43iKqNFQ.jpeg" /><figcaption>Option 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GUmF7t8Wte1sPcuSHcMIkQ.jpeg" /><figcaption>Option 2</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c1af65a10adb2706986fa0fc1907c5f/href">https://medium.com/media/7c1af65a10adb2706986fa0fc1907c5f/href</a></iframe><p>Setting up a progress bar involved a few steps. Create a progress bar object, create different Element instances as per requirement, compile all the elements, and use the compiled progress bar where you want.</p><p><strong>Line 6:</strong> Create an instance of a progress bar. Mode can be barand no-bar .</p><p><strong>Line 9:</strong> Create a single Element as required in this example. The first parameter of the element is the name to show for the progress monitor and the second parameter takes the initial value of the Element.</p><p><strong>For option 2: </strong>you just need to add the Element parameters like this. counter = P.Element(&quot;Images Processed&quot;, max_value=images, value_display_mode=1)</p><p>Read Documentation for more parameters on <a href="https://github.com/tarunk04/progress-bar-python/">GitHub</a>.</p><p><strong>Compiling </strong>is very easy just like stacking the Elements in order. One more thing to note, you can <strong>add </strong>a <strong>custom string</strong> in between the element stack. You can choose from 2 different Syntax as shown below:</p><p>p = p(Element1)(Element2)...(&quot;String is also allowed&quot;)...(ElementN)</p><p>OR</p><p>p = p + Element1 + Element2 + ...+ &quot;String is also allowed&quot; + ...+ (ElementN)</p><p><strong>Line12:</strong> Compile the single element.</p><p>Now you are ready to plug the custom made progress monitor into your application to track the progress. Just you need to initialize the progress bar before using it and then update it at each step.</p><p>Updating values of the Elements also very easy just follow the syntax Element1(updated_value) . After updating the values of all the elements you need to render the progress bar to show up with the updated value that can be done by calling p.update(step =1) . That’s it.</p><p>2. <strong>EXAMPLE 2:</strong> Suppose you want to create a progress bar for training progress in PyTorch. So, let’s create a progress bar like below in this example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6oI_7RC77efkQmwwYFNiQ.png" /></figure><p>First thing first, decide what elements you need.</p><p>Elements:</p><ol><li>Epoch (To track each epochs)</li><li>Bar (Predefined element)</li><li>Batch (Progress of batches in each epoch)</li><li>ProgressTime (Predefined element) (Time for each epoch)</li><li>Loss (To track loss during training)</li><li>Acc (To track accuracy during training)</li></ol><p>See the code and try to understand it. Most of the things are the same as before but few things I will cover which I have not discussed yet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4e9602e197bda265b0ea07925119625/href">https://medium.com/media/b4e9602e197bda265b0ea07925119625/href</a></iframe><p>See the mode in line 1 has been changed to bar. Here I have defined 6 Elements (4 custom elements and 2 predefined elements). Bar and ProgressTime elements are predefined elements as shown in the example code. Bar elements can take a few parameters as well, check the documentation on <a href="https://github.com/tarunk04/progress-bar-python/">GitHub</a>. ProgressTime takes only one parameter postfix any string you want to add after the time otherwise leave it blank.</p><p>The compiling part is the same as the previous example. You may check the final format of the progress bar after compiling by calling p.get_format() .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76300ed6fa8c45eb26abb621a6bf2c93/href">https://medium.com/media/76300ed6fa8c45eb26abb621a6bf2c93/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HsM34gksYkxCe0tJqILKyw.png" /><figcaption>Final Result</figcaption></figure><p>In this part, everything works the same except <strong>line 23. </strong>If you don&#39;t set the new cursor position the progress for the new epoch will be overwritten on the old one. If you want to save the progress for each epoch then you need to call p.set_cursor_postion() after the completion of each epoch.</p><p>That’s it 😎. I hope this post helps you. Please share if you find my work helpful.</p><h3>Full Code and Documentation</h3><p>Find full code on my GitHub: <a href="https://github.com/tarunk04/progress-bar-python/">https://github.com/tarunk04/progress-bar-python/</a></p><figure><a href="https://www.buymeacoffee.com/tarunkumar"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*Dpw8-hNGI2fDmosV4E8DVQ.png" /></a></figure><h3>Feedback</h3><p>That’s all for Today’s Post, if you have any questions please let me know in the comments. Also, if you found any error in the post please write to me at tarun12.tarunkr@gmail.com.</p><p>If you want me to cover some specific topics in the upcoming posts please let me know in the comments.</p><p>Follow:</p><ul><li>me on <a href="https://github.com/tarunk04/">GitHub</a> for more such projects</li><li>me on <a href="https://www.kaggle.com/tarunk04">Kaggle</a>.</li></ul><p>Thank You for your the time to read this article. Please share it if you like.</p><p><strong>I am looking for people with different skill sets to build a closed community so that we can build together awesome products. If you are interested reach me out on Linkedin or mail me</strong> tarun12.tarunkr@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f68224955810" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/progress-bar-python-for-jupyter-notebook-f68224955810">Progress Bar Python- For Jupyter Notebook</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sudoku- Backtracking algorithm and visualization]]></title>
            <link>https://medium.com/analytics-vidhya/sudoku-backtracking-algorithm-and-visualization-75adec8e860c?source=rss-2af62eb8d2e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/75adec8e860c</guid>
            <category><![CDATA[sudoku-solver]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[visualizer]]></category>
            <category><![CDATA[backtracking]]></category>
            <dc:creator><![CDATA[Tarun Kumar]]></dc:creator>
            <pubDate>Fri, 08 May 2020 09:38:37 GMT</pubDate>
            <atom:updated>2025-04-12T20:51:54.744Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Sudoku-Backtracking algorithm and visualization</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-vaMfQbZbSglG7RPwSDCw.png" /><figcaption>Sudoku</figcaption></figure><p>Isn’t it cool to visualize the backtracking algorithm while solving Sudoku? Yeh, I am going to discuss the algorithm and also share how I developed a simple program to visualize the algorithm. About the program:</p><ul><li>Algorithm is in Python</li><li>GUI is in HTML, CSS, JavaScript/JQuery using eel library of python. Read more about <a href="https://pypi.org/project/Eel/">eel</a>.</li><li>Check the full code on <a href="https://github.com/tarunk04/sudoku-backtracking-visualizer">GitHub</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*kqC2K0tffcSTqHHNe99Zzg.gif" /><figcaption>Backtracking</figcaption></figure><h3>Backtracking Algorithm</h3><p>One of the classic algorithm which approaches a problem recursively to solve it. Trying to build the solution one by one and eliminating those which fail to solve. One of the famous problems is N-Quene Problem, you may have heard about it. Where N Queens need to be placed on the NxN board so that none of the queens are in attacking positions. Check out here to read more about the N-Queen problem <a href="https://www.geeksforgeeks.org/n-queen-problem-backtracking-3/">here</a>. Sudoku is also one of the famous problem/puzzles which can be solved using the backtracking algorithm.</p><p>In the backtracking algorithm, we build a solution tree for the problem and eliminate the solutions which do not satisfy the required conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-DyKa25eozOeMdN5YQONA.png" /><figcaption>solution tree for 4-queen problem</figcaption></figure><h3><strong>Sudoku</strong></h3><p>Sudoku is a number puzzle game in which numbers from 1–9 are to be placed in a 9x9 grid such that no numbers are repeated in each row, column, and 3x3 sub-grid/blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*lJqEatT4iXIvxiPJr_ONiA.gif" /><figcaption>Row, Column, and Block</figcaption></figure><p><strong>How to solve using backtracking:</strong> We start with the first empty cell and iterate over 1–9 one by one, and if a number satisfies all 3 conditions i.e., that particular number is not present in the row, column, and block, we fill with that number. Then we move forward to the next empty cell and we do the same iteration of numbers but with the updated sudoku board. As we move forward with the new empty cell, we may reach a cell where we can’t place a number between 1–9. So, this solution is rejected and now we move backward and try new possible values in those previous cells. As we know that a sudoku board has only one solution, we will keep rejecting the solution until we find the one which satisfies all conditions for each cell that was empty initially.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e80861a4fd141ba2150c21cffffcde8/href">https://medium.com/media/6e80861a4fd141ba2150c21cffffcde8/href</a></iframe><p>The above code is validating the particular cell for the different values between 0–9. If the value satisfies all 3 conditions it returns true otherwise false.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0370eec7253fb044b1f1403b6fa80b7d/href">https://medium.com/media/0370eec7253fb044b1f1403b6fa80b7d/href</a></iframe><p>The above function is called recursively to build the solution tree and reject all the solutions which do not satisfy the conditions. The value of the variable visualize is by default False which means it will not update the GUI and solve the puzzle quickly. If the value is true then GUI will be updated at each step while solving. So, to visualize the backtracking algorithm in action this variable needs to be True .</p><h3><strong>Generating the Sudoku</strong></h3><p>Moving a little forward, and let’s discuss how we can generate sudoku before we go to the visualization part.</p><p><strong>How to approach?</strong></p><ul><li>First thing is to generate a solved sudoku board.</li><li>Second thing is to delete a few cells from the solved sudoku board such that it is solvable and the solution must is unique.</li></ul><ol><li><strong>Generating the solved sudoku board</strong>: The approach is very similar to that of solving the sudoku board. The only thing that changed here is that we have an empty board. So we can start from the first cell i.e., the upper-left cell, and fill the value randomly. Move to the next empty cell, now we have one value on the board so we have to check the sudoku conditions before filling with the value in the new cell. Again generate a random value between 1–9 and check for the sudoku conditions. If it satisfies all the conditions place the value in the cell and move to the next cell. At a point, it may happen that no values between 1–9 are possible for that cell then move back to the previous cells and try different combinations until the solved sudoku board is ready.</li><li><strong>Deleting cells to generate the puzzle: </strong>Randomly pick a cell that is not empty, remove the value then try to solve using our solving algorithm, and count the number of solutions. If the number solution is not one put the value back to the cell and try a different cell. Do this repeatedly until you get the required difficulty for the puzzle. 2 things to keep in mind</li></ol><ul><li>The more cells you remove, the more difficult the puzzle will be.</li><li>The more cells you remove, it will take more time to generate the puzzle.</li></ul><p>Removing 30–55 cells will give easy to the very hardpuzzles. But removing cells beyond 55 cells will take much more time to generate the puzzle. This has been suggested that the minimum number of cells required as a clue for the sudoku puzzle is 17. That means you can remove up to 64 cells. But to find such a puzzle may be very time-consuming. I have not tested my algorithm to find such a puzzle and it may fail.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c09842d6abd0591766e607784d44ce21/href">https://medium.com/media/c09842d6abd0591766e607784d44ce21/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab0d50064b874309a85103a7b3af77ff/href">https://medium.com/media/ab0d50064b874309a85103a7b3af77ff/href</a></iframe><h3><strong>Visualize the algorithm in Realtime</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*TeOkuhMEEaCIhw9t4-Y4xg.png" /><figcaption>GUI Preview</figcaption></figure><p>GUI is developed using HTML, CSS, and JavaScript/JQuery. For connecting, frontend and backend eel library is used.</p><blockquote>Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries.</blockquote><p>Check about <a href="https://github.com/samuelhwilliams/Eel">eel</a> on GitHub</p><p>eel allows you to call Python functions from JavaScript and vice-versa.</p><p><strong>JavaScript Functions exposed to Python.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b8b0da523812d1769a4fab78e30688c/href">https://medium.com/media/7b8b0da523812d1769a4fab78e30688c/href</a></iframe><p>The function draw_sudoku displays the sudoku to GUI, here data is a parameter that has a 9x9 array, passed through python to JavaScript. Whereas update_sudoku taking parameters val and i from Python to update the GUI while solving the sudoku. Where val is the value for the cell i . Cell i means ith cell out of 81 cells.</p><p><strong>Python Functions exposed to JavaScript</strong></p><p>These functions can be called from JavaScript. For example, if you need a new puzzle, then click on the new puzzle button on GUI then JavaScript will call the generate_new_sudoku the function of python and pass the level as the parameter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6069271131c12f24147b7e19fada90ac/href">https://medium.com/media/6069271131c12f24147b7e19fada90ac/href</a></iframe><h3><strong>Visualizing Example:</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMaoqFMVYgsQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMaoqFMVYgsQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMaoqFMVYgsQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4841bd236b79528d2967276e29259cfc/href">https://medium.com/media/4841bd236b79528d2967276e29259cfc/href</a></iframe><h3><strong>Full Code</strong></h3><p>Find full code on my GitHub: <a href="https://github.com/tarunk04/sudoku-backtracking-visualizer">https://github.com/tarunk04/sudoku-backtracking-visualizer</a></p><figure><a href="https://www.buymeacoffee.com/tarunkumar"><img alt="" src="https://cdn-images-1.medium.com/max/170/1*Dpw8-hNGI2fDmosV4E8DVQ.png" /></a></figure><h3><strong>Feedback</strong></h3><p>That’s all for Today’s Post, if you have any questions please let me know in the comments. Also, if you found any error in the post please write to me at tarun12.tarunkr@gmail.com.</p><p>If you want me to cover some specific topics in the upcoming posts please let me know in the comments.</p><p>Follow:</p><ul><li>me on <a href="https://github.com/tarunk04/">GitHub</a> for more such projects</li><li>me on <a href="https://www.kaggle.com/tarunk04">Kaggle</a>.</li></ul><p>Thank You for your the time to read this article. Please share it if you like.</p><p><strong>I am looking for people with different skill sets to build a closed community so that we can build together awesome products. If you are interested reach me out on Linkedin or mail me</strong> tarun12.tarunkr@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75adec8e860c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/sudoku-backtracking-algorithm-and-visualization-75adec8e860c">Sudoku- Backtracking algorithm and visualization</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>