<?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 Yogendra Saxena on Medium]]></title>
        <description><![CDATA[Stories by Yogendra Saxena on Medium]]></description>
        <link>https://medium.com/@yogi-dev?source=rss-85dbd9b5e21f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Urq2gJnEZpYgwnCJOORrDg.jpeg</url>
            <title>Stories by Yogendra Saxena on Medium</title>
            <link>https://medium.com/@yogi-dev?source=rss-85dbd9b5e21f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 04:49:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yogi-dev/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[Why “Meri Pyaari Bindu” Is the Most Honest Love Story You’ll Ever Watch]]></title>
            <link>https://medium.com/@yogi-dev/why-meri-pyaari-bindu-is-the-most-honest-love-story-youll-ever-watch-5eaf4e1fd998?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eaf4e1fd998</guid>
            <category><![CDATA[meri-pyaari-bindu]]></category>
            <category><![CDATA[lovestory]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Sun, 11 May 2025 08:11:01 GMT</pubDate>
            <atom:updated>2025-05-11T08:14:49.427Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“Some love stories have no name. Some goodbyes are not bitter. And some people live in our memories longer than they ever stayed in our lives.”</blockquote><p>Let me take you on a journey.</p><p>Not of grand gestures or sweeping romance, but of quiet heartbreaks, unforgettable mixtapes, and a girl named Bindu, who taught a boy to fall in love… and to let go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*u-kf-SPNOr8W1ClEKwCphw.jpeg" /></figure><h3>Chapter 1: The Beginning of Every Beginning, Childhood</h3><p>Abhimanyu Roy or <em>Abhi</em> is not your typical romantic hero. He’s awkward, bookish, and slightly obsessive. But he falls in love the way all great heartbreaks begin: slowly, deeply, and without a backup plan.</p><p>And then there’s Bindu , the cyclone next door. Wild, messy, magnetic. She dances to 90s Bollywood, dreams of being a singer, and wears her pain like eyeliner, bold and unapologetic.</p><p>They grow up side by side in Kolkata, wrapped in cassette tapes, laughter, and moments stolen from time.</p><p>The chemistry? Electric.<br>The love? Unspoken.</p><blockquote><strong><em>Moral #1: The people we grow up with shape us in ways even time cannot undo.</em></strong></blockquote><h3>Chapter 2: Mixtapes and Misunderstandings</h3><p>Then life… happens.</p><p>Bindu, scarred by her mother’s death and a broken family, begins to drift from cities to dreams, and everything in between.</p><p>Abhi? He writes letters he never sends. Waits. Writes more. Drinks. Waits again.</p><p>She falls in and out of love. He stays right there in the shadows, in the silences.</p><blockquote><em>“Why didn’t you ever tell her?”<br> </em>Because sometimes, telling ruins the very thing you cherish most.</blockquote><blockquote><strong><em>Moral #2: Love isn’t always about holding on. Sometimes, it’s about staying when they walk away and knowing when to let them go.</em></strong></blockquote><h3>Chapter 3: The Reunion , But Not the One You Expect</h3><p>Years later, they meet again.</p><p>The spark? Still there.<br> The tapes? Still there.<br> The awkwardness? Oh, definitely.<br> Hope? Somehow, always.</p><p>Abhi finally confesses.<br> Bindu smiles and that kind of smile. The one that says, <em>“I love you… just not the way you want me to.”</em></p><blockquote><em>“You were my home, Abhi. But I was always searching for a house with a view.</em></blockquote><blockquote><strong><em>Moral #3: Closure doesn’t always come with answers. Sometimes, it arrives wrapped in acceptance.</em></strong></blockquote><h3>Chapter 4: The Real Love Story, With Yourself</h3><p>Abhi goes on to become a bestselling author.<br>Not <em>despite</em> Bindu, but <em>because</em> of her.</p><p>He writes <em>Meri Pyaari Bindu</em> , not a happy love story, but a real one.<br>In telling her story, he rewrites his own.</p><blockquote><strong><em>Moral #4: Some people come into your life to teach you how to lose and how to survive it.</em></strong></blockquote><h3>So, What Is This Story Really About?</h3><p>It’s about <strong>letting go</strong> , and doing it with grace.</p><p>It’s about how <strong>not every love story is meant to last</strong>, but every one leaves a mark.</p><p>It’s about <strong>nostalgia</strong> , not the kind that begs to be fixed, just remembered.</p><p>It’s about the quiet strength of <strong>loving from afar</strong>, and doing so, forever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*s9ttk3diLAeHUqh_NWfDsQ.jpeg" /></figure><h3>The Final Moral: Sometimes, They’re Not “The One”,But They’re the One Who Changed You</h3><p><em>Meri Pyaari Bindu</em> doesn’t give us grand romantic payoffs.</p><p>No airport chase.<br>No wedding to crash.<br>No declarations in the rain.</p><p>Just peace.</p><p>The peace of knowing that the love was real, even if it wasn’t returned the way we hoped.</p><p>The peace of understanding that some people are meant to be <strong>chapters</strong>, not <strong>endings</strong>.</p><p>So here’s to the Bindus of our lives , wild, beautiful, unforgettable.<br>And to the Abhis, the ones who loved wholly and let go when it mattered most.</p><p>Because sometimes…</p><blockquote>Not every love story needs a lover. Some just need a listener.<em><br>And sometimes, that’s enough.</em></blockquote><p>Thank you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eaf4e1fd998" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying React Reconciliation: The Magic Behind Your UI Updates]]></title>
            <link>https://medium.com/@yogi-dev/demystifying-react-reconciliation-the-magic-behind-your-ui-updates-7b2857219e61?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b2857219e61</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[reconciliation]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 10:06:50 GMT</pubDate>
            <atom:updated>2025-04-23T10:22:29.951Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you’re directing a blockbuster movie called <em>Your React App</em>. The scenes are your UI components, the actors are your DOM elements, and the script is your JavaScript code. Every time you yell “Action!” (or update your state), the set needs to transform — fast, efficiently, and without blowing the budget. Enter <strong>React Reconciliation</strong>, the genius stage manager who ensures the show goes on smoothly, with minimal chaos and maximum performance. In this article, we’ll break down the reconciliation process in a way that’s professional, digestible, and — dare I say — entertaining, with some code examples to make it crystal clear. Let’s roll!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMhvqKEAVvhROphQHTlKUA.jpeg" /></figure><h3>What Is React Reconciliation, Anyway?</h3><p>At its core, React reconciliation is the process React uses to update the user interface when your app’s state or props change. It’s like a cosmic choreographer syncing the <em>Virtual DOM</em> (React’s lightweight blueprint of your UI) with the <em>Real DOM</em> (the actual HTML in the browser). The goal? Make updates fast, avoid unnecessary work, and keep your app feeling snappier than a stand-up comedian’s punchline.</p><p>But here’s the kicker: the browser’s DOM is slow. Manipulating it directly for every little change would tank performance. React’s solution? Be smart about updates. Reconciliation is how React decides what’s changed, what stays the same, and how to apply those changes with surgical precision.</p><h3>The Virtual DOM: React’s Secret Weapon</h3><p>Before we dive into reconciliation, let’s talk about the Virtual DOM. Picture it as a stunt double for the Real DOM — a lightweight, in-memory representation of your UI. It’s like a sketch of your app’s HTML structure, stored as JavaScript objects. When you update your state (say, a user clicks a button), React creates a new Virtual DOM snapshot.</p><p>Now, React doesn’t just chuck the old Virtual DOM in the trash and start over. That’d be like firing your entire movie cast every time you need a scene change. Instead, React compares the new Virtual DOM with the old one to figure out what’s different. This comparison is the heart of reconciliation, and it’s where the magic happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*YskfEtIOLFMSfIecsu-QDw.jpeg" /></figure><h3>The Reconciliation Process: A Step-by-Step Comedy</h3><p>Let’s break down how reconciliation works, with a sprinkle of humor and some code to keep things lively.</p><h3>Step 1: Something Changes (Cue the Drama)</h3><p>Your app’s state or props change — maybe a user types in a form, or a counter increments. React hears the news and shouts, “We’ve got a situation!” It triggers a re-render, generating a new Virtual DOM tree for the affected components.</p><p>Here’s a simple example of a component that updates its state:</p><pre>import React, { useState } from &#39;react&#39;;<br>function Counter() {<br>  const [count, setCount] = useState(0);<br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times!&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>When you click the button, setCount triggers a state change, and React kicks off reconciliation to update the UI.</p><h3>Step 2: Diffing (The Great Detective Work)</h3><p>Here’s where React puts on its Sherlock Holmes hat. The reconciliation algorithm (affectionately called the <em>diffing algorithm</em>) compares the new Virtual DOM tree with the old one to spot differences. This process is blazing fast because it’s all happening in JavaScript, not the sluggish browser DOM.</p><p>React doesn’t compare every single node like a micromanaging boss. Instead, it uses clever heuristics to keep things efficient:</p><ul><li><strong>Same Type, Same Spot?</strong> If two elements are of the same type (e.g., both are &lt;div&gt;s) and in the same position in the tree, React assumes they’re similar and only checks their props for changes. This is like saying, “Hey, you’re still playing the lead role, but did your costume change?”</li><li><strong>Different Types? Start Over.</strong> If the element types differ (say, a &lt;div&gt; becomes a &lt;span&gt;), React says, “Nope, you’re fired!” It tears down the old subtree and builds a new one from scratch.</li><li><strong>Lists Need Keys!</strong> When dealing with lists of elements (like a todo list), React relies on the key prop to track items. Without keys, React might get confused, like a director mixing up identical twins on set. With keys, it knows exactly who’s who, making updates precise.</li></ul><p>Here’s an example of a list with and without keys to show the difference:</p><pre>// Bad: No keys, React might get confused<br>function TodoList({ todos }) {<br>  return (<br>    &lt;ul&gt;<br>      {todos.map(todo =&gt; (<br>        &lt;li&gt;{todo.text}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}<br>// Good: With keys, React tracks items efficiently<br>function TodoList({ todos }) {<br>  return (<br>    &lt;ul&gt;<br>      {todos.map(todo =&gt; (<br>        &lt;li key={todo.id}&gt;{todo.text}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>Without keys, if you reorder or add items, React might unnecessarily re-render or shuffle DOM elements. With keys, reconciliation is smooth and efficient.</p><h3>Step 3: Updating the Real DOM (The Grand Finale)</h3><p>Once React knows what’s changed, it applies the minimal set of updates to the Real DOM. Think of this as the stage crew swapping props between scenes — only the necessary changes happen. Updated props? React tweaks them. New elements? They’re added. Old elements? They’re removed. The result is a silky-smooth UI update that feels instantaneous.</p><p>In our Counter example, when count changes, React updates only the text inside the &lt;p&gt; tag, leaving the rest of the DOM untouched.</p><h3>Step 4: Rinse and Repeat</h3><p>Every time state or props change, React runs this process again. It’s like filming take after take, each one refining the performance. Thanks to reconciliation’s efficiency, your app stays responsive even when the script gets complex.</p><h3>Why Reconciliation Is So Darn Cool</h3><p>Reconciliation is the unsung hero of React’s performance. Here’s why it deserves a standing ovation:</p><ul><li><strong>Speed:</strong> By minimizing Real DOM updates, React keeps your app zippy, even with frequent changes.</li><li><strong>Simplicity:</strong> Developers don’t need to manually manage DOM updates. Just update your state, and React handles the rest.</li><li><strong>Reliability:</strong> The diffing algorithm ensures consistent updates, so your UI stays in sync with your data.</li></ul><p>But it’s not all sunshine and rainbows. Reconciliation has its quirks. For example, if you forget keys in a list, React might shuffle elements like a drunk DJ, leading to weird bugs. And if your component tree is massive, even the Virtual DOM can slow down. That’s where tools like React.memo or useMemo come in to optimize performance.</p><p>Here’s an example using React.memo to prevent unnecessary re-renders:</p><pre>import React, { memo } from &#39;react&#39;;<br>const ExpensiveComponent = memo(({ value }) =&gt; {<br>  console.log(&#39;Rendering ExpensiveComponent&#39;);<br>  return &lt;div&gt;Expensive Value: {value}&lt;/div&gt;;<br>});<br>function App() {<br>  const [count, setCount] = React.useState(0);<br>  return (<br>    &lt;div&gt;<br>      &lt;ExpensiveComponent value=&quot;I&#39;m static!&quot; /&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Count: {count}&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Without memo, ExpensiveComponent would re-render on every count change, even though its props are static. With memo, React skips the re-render, saving precious CPU cycles.</p><h3>A Funny Story to Drive It Home</h3><p>Picture this: I once worked on a React app where a developer (let’s call them Bob) forgot to add keys to a list of 100 animated cards. Every time the list updated, React got so confused it started swapping card positions like a bad magic trick. The UI looked like a dance party gone wrong — cards sliding everywhere, users laughing (or crying). One quick fix with unique key props, and the app was back to its polished, professional self. Moral of the story? Respect the reconciliation process, and it’ll respect you back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NlwlB_-nr0SPu4GO4tYPWA.jpeg" /></figure><h3>Tips for Working with Reconciliation</h3><p>Want to make reconciliation your BFF? Here are some pro tips:</p><ol><li><strong>Always Use Keys in Lists:</strong> Give each list item a unique, stable key prop to help React track elements efficiently.</li><li><strong>Keep Components Lean:</strong> Smaller components mean faster diffing. Break up monolithic components like you’re decluttering a closet.</li><li><strong>Use</strong> React.memo <strong>for Pure Components:</strong> If a component’s output doesn’t change with the same props, wrap it in React.memo to skip unnecessary re-renders.</li><li><strong>Profile Performance:</strong> Tools like React Developer Tools can show you where reconciliation is slowing down. It’s like a fitness tracker for your app.</li><li><strong>Avoid Unnecessary State Changes:</strong> If you’re updating state in a loop (yikes!), reconciliation will be working overtime. Be kind to it.</li></ol><h3>Wrapping Up: Reconciliation Is Your UI’s Best Friend</h3><p>React reconciliation is like the stage manager you never see but can’t live without. It takes the chaos of state changes and turns them into seamless UI updates, all while keeping performance tight and developer sanity intact. By understanding how it works — diffing, updating, and optimizing — you can write React apps that shine brighter than a Hollywood premiere.</p><p>So, next time you’re building a React app, give a mental high-five to reconciliation. It’s the behind-the-scenes hero making your UI updates look effortless. Now go forth and code, you reconciliation rockstar!</p><p>Happy Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b2857219e61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why NextJS is a Game Changer]]></title>
            <link>https://medium.com/@yogi-dev/why-next-js-is-a-game-changer-and-why-some-people-still-underestimate-react-d6bb46f9fa7f?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6bb46f9fa7f</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 14:10:44 GMT</pubDate>
            <atom:updated>2025-03-12T17:25:06.115Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Next.js: The Game Changer Frontend Devs Can’t Ignore</strong></h3><p>Let’s talk about something that’s been buzzing in the frontend world for a while now: <strong>Next.js</strong>. If you’re a frontend developer and you haven’t given Next.js a proper look, you’re either living under a rock or you’re still writing vanilla JS like it’s 2010. And while we’re at it, let’s address the elephant in the room: <strong>React</strong>. Yes, React. The library that everyone loves to hate but secretly can’t live without. People <em>still</em> underestimate its worth, and it’s time to set the record straight.</p><p>So grab your coffee, sit back, and let’s dive into why Next.js is the Beyoncé of frontend frameworks and why React deserves more respect than it gets.</p><h3>Next.js: The Swiss Army Knife of Frontend Development</h3><p>If frontend development were a video game, Next.js would be that overpowered weapon you find halfway through the game that makes you wonder how you ever survived without it. It’s not just a framework; it’s a <em>mindset</em>. Here’s why:</p><h3>1. Server-Side Rendering (SSR) and Static Site Generation (SSG) Out of the Box</h3><p>Remember the days when you had to manually configure Webpack, Babel, and a dozen other tools just to get SSR working? Yeah, me neither, because I’ve blocked those memories. Next.js handles all of that for you.</p><p>Want SSR? Done. Need SSG? Easy. Want to mix both depending on the page? No problem. It’s like having a personal chef who also does your laundry.</p><p>Here’s a little SSR example:</p><pre>export async function getServerSideProps() {<br>  const res = await fetch(&#39;https://api.example.com/data&#39;);<br>  const data = await res.json();<br>  return { props: { data } };<br>}<br>export default function Page({ data }) {<br>  return &lt;div&gt;{JSON.stringify(data)}&lt;/div&gt;;<br>}</pre><h3>2. App-Based Routing</h3><p>Next.js introduces app-based routing, which is basically magic for developers who hate writing boilerplate code. Define your routes inside the app directory, and Next.js handles the rest. No more react-router configs that look like a spider web.</p><pre>// app/about/page.js<br>export default function About() {<br>  return &lt;h1&gt;About Page&lt;/h1&gt;;<br>}</pre><h3>3. API Routes</h3><p>Need a backend API? Next.js has you covered. Just create a file in the app/api directory, and you&#39;ve got yourself an endpoint.</p><pre>// app/api/hello/route.js<br>export default function handler(req, res) {<br>  res.status(200).json({ message: &#39;Hello, world!&#39; });<br>}</pre><p>No need to spin up a separate server or deal with CORS issues. It’s like having a mini-backend inside your frontend app.</p><h3>4. Incremental Static Regeneration (ISR)</h3><p>This is where Next.js flexes its muscles. ISR allows you to update static pages <em>after</em> they’ve been built, without rebuilding the entire site.</p><pre>export async function getStaticProps() {<br>  const res = await fetch(&#39;https://api.example.com/data&#39;);<br>  const data = await res.json();<br>  return { props: { data }, revalidate: 60 };<br>}</pre><p>It’s like being able to edit a printed book without having to reprint it. Mind-blowing, right?</p><h3>React: The Unsung Hero</h3><p>Now, let’s talk about React. The library that revolutionized frontend development but somehow still doesn’t get the credit it deserves.</p><h3>1. Component-Based Architecture</h3><p>React introduced the idea of building UIs as a collection of reusable components.</p><pre>function Button({ text }) {<br>  return &lt;button&gt;{text}&lt;/button&gt;;<br>}<br><br>export default function App() {<br>  return &lt;Button text=&quot;Click Me&quot; /&gt;;<br>}</pre><h3>2. Hooks: A Little Love-Hate Relationship</h3><p>Yes, hooks can be confusing at first. But once you get the hang of them, you’ll wonder how you ever lived without them.</p><pre>import { useState } from &#39;react&#39;;<br>function Counter() {<br>  const [count, setCount] = useState(0);<br>  return &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Count: {count}&lt;/button&gt;;<br>}</pre><h3>3. The Little Ecosystem</h3><p>React’s ecosystem is massive, and that’s a good thing. Whether you need state management (Redux, Zustand), routing (React Router), or animations (Framer Motion), there’s a library for that.</p><h3>Why Next.js + React = Frontend Nirvana</h3><p>Next.js and React are like peanut butter and jelly. They’re great on their own, but together, they’re unstoppable. Next.js takes all the pain points of React (routing, SSR, performance) and solves them, while React provides the flexibility and power to build anything you can imagine.</p><p>If you’re still on the fence about Next.js, ask yourself this: Do you like spending hours configuring tools and debugging performance issues? No? Then give Next.js a try. It’s not just a framework; it’s a productivity booster.</p><p>And if you’re one of those people who still underestimates React, it’s time to give it the respect it deserves. It’s not just a library; it’s the foundation of modern frontend development.</p><h3>Final Thoughts</h3><p>Frontend development is constantly evolving, and tools like Next.js and React are leading the charge. They’re not just making our lives easier; they’re pushing the boundaries of what’s possible on the web.</p><p>So, the next time you’re starting a new project, ask yourself: Do I want to spend my time solving interesting problems or wrestling with tooling? If the answer is the former, give Next.js and React a shot.</p><p>And remember, in the world of frontend development, the only constant is change. But with Next.js and React in your toolkit, you’ll always be ready for whatever comes next.</p><p>Now go forth and build something amazing. Your future self will thank you.</p><p><em>P.S. If you’re still writing class components in React, it’s time to let go. Hooks are here to stay, and they’re not as scary as they seem. Trust me.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6bb46f9fa7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gRPC: The Superhero of App Communication — A Beginner’s Guide with Code]]></title>
            <link>https://medium.com/@yogi-dev/grpc-the-superhero-of-app-communication-a-beginners-guide-with-code-2928245907cd?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2928245907cd</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[rest]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 08:50:06 GMT</pubDate>
            <atom:updated>2025-02-15T08:51:00.726Z</atom:updated>
            <content:encoded><![CDATA[<h3>gRPC: The Superhero of App Communication</h3><p><strong>What Is gRPC?</strong></p><p>At its core, gRPC is a framework for remote procedure calls (RPC). Instead of using the traditional REST style (sending HTTP requests), gRPC leverages HTTP/2 to send binary data. This means:</p><ul><li><strong>Speed:</strong> Faster data exchange.</li><li><strong>Efficiency:</strong> Less bandwidth and lower latency.</li><li><strong>Simplicity:</strong> Well-structured contracts using Protocol Buffers (Protobuf).</li></ul><p>In simple terms, gRPC lets different parts of your application (or even different apps) communicate like a well-organized team with clear instructions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NkBSmiDonMzx2VBcppMtWw.jpeg" /></figure><h3>How Does gRPC Work?</h3><p>gRPC works by defining services and the messages they exchange using a .proto file. This file serves as a blueprint, ensuring both the server and client know exactly what to expect.</p><h3>The Flow in Simple Terms</h3><ol><li><strong>Define Your Service:</strong> Write a .proto file that describes the service and the messages.</li><li><strong>Generate Code:</strong> Use tools to generate code in your language of choice (Node.js, Python, Go, etc.) from the .proto file.</li><li><strong>Implement the Service:</strong> Write server-side code that handles incoming requests.</li><li><strong>Call the Service:</strong> Your client calls the service, and gRPC handles the rest.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCMhx0b6X3x_5-xBo7ntXg.png" /></figure><h3>gRPC in Action: A Simple “Hello World” Example</h3><p>Let’s build a simple gRPC service in Node.js that greets you with a “Hello” message.</p><h3>Step 1: Define the Service with a .proto File</h3><p>Create a file named helloworld.proto</p><pre>syntax = &quot;proto3&quot;;<br><br>package helloworld;<br><br>// The greeting service definition.<br>service Greeter {<br>  // Sends a greeting<br>  rpc SayHello (HelloRequest) returns (HelloReply) {}<br>}<br><br>// The request message containing the user&#39;s name.<br>message HelloRequest {<br>  string name = 1;<br>}<br><br>// The response message containing the greetings.<br>message HelloReply {<br>  string message = 1;<br>}</pre><blockquote><strong>Explanation</strong>: This file defines a service called Greeter with a single RPC method SayHello that takes a HelloRequest (containing a name) and returns a HelloReply (containing a greeting message).</blockquote><p><em>Defining clear service contracts makes development a breeze!</em></p><h3>Step 2: Create the gRPC Server</h3><p>Create a file named server.js with the following content:</p><pre>const grpc = require(&#39;@grpc/grpc-js&#39;);<br>const protoLoader = require(&#39;@grpc/proto-loader&#39;);<br>const path = require(&#39;path&#39;);<br><br>const PROTO_PATH = path.join(__dirname, &#39;helloworld.proto&#39;);<br><br>// Load the protobuf definitions<br>const packageDefinition = protoLoader.loadSync(PROTO_PATH, {<br>  keepCase: true,       // Retain field names<br>  longs: String,<br>  enums: String,<br>  defaults: true,<br>  oneofs: true<br>});<br>const helloProto = grpc.loadPackageDefinition(packageDefinition).helloworld;<br><br>// Implement the SayHello RPC method<br>function sayHello(call, callback) {<br>  const name = call.request.name;<br>  callback(null, { message: `Hello ${name}` });<br>}<br><br>// Start the server and listen on port 50051<br>function main() {<br>  const server = new grpc.Server();<br>  server.addService(helloProto.Greeter.service, { sayHello: sayHello });<br>  server.bindAsync(&#39;0.0.0.0:50051&#39;, grpc.ServerCredentials.createInsecure(), (error, port) =&gt; {<br>    if (error) {<br>      console.error(error);<br>      return;<br>    }<br>    console.log(`Server running at http://0.0.0.0:${port}`);<br>    server.start();<br>  });<br>}<br><br>main();</pre><p><em>Explanation:</em></p><ul><li>The server loads the .proto file using <strong>protoLoader</strong>.</li><li>The sayHello function reads the name from the request and returns a greeting.</li><li>The server listens on port 50051 for incoming gRPC calls.</li></ul><p><em>Our server is set up to handle incoming messages like a pro!</em></p><h3>Step 3: Create the gRPC Client</h3><p>Now, create a file named client.js:</p><pre>const grpc = require(&#39;@grpc/grpc-js&#39;);<br>const protoLoader = require(&#39;@grpc/proto-loader&#39;);<br>const path = require(&#39;path&#39;);<br><br>const PROTO_PATH = path.join(__dirname, &#39;helloworld.proto&#39;);<br><br>// Load the protobuf definitions<br>const packageDefinition = protoLoader.loadSync(PROTO_PATH, {<br>  keepCase: true,<br>  longs: String,<br>  enums: String,<br>  defaults: true,<br>  oneofs: true<br>});<br>const helloProto = grpc.loadPackageDefinition(packageDefinition).helloworld;<br><br>function main() {<br>  // Create a client that connects to the gRPC server<br>  const client = new helloProto.Greeter(&#39;localhost:50051&#39;, grpc.credentials.createInsecure());<br>  <br>  // Call the SayHello method<br>  client.sayHello({ name: &#39;World&#39; }, (error, response) =&gt; {<br>    if (error) {<br>      console.error(error);<br>    } else {<br>      console.log(&#39;Greeting:&#39;, response.message);<br>    }<br>  });<br>}<br><br>main();</pre><p><em>Explanation:</em></p><ul><li>The client loads the same .proto file to ensure a consistent contract.</li><li>It connects to our server running on localhost:50051 and calls the sayHello method with the name &quot;World&quot;.</li><li>The server processes the request and returns a greeting message, which the client then prints.</li></ul><p><em>The client connects to our server and requests a greeting!</em></p><h3>Why Use gRPC?</h3><p>For developers working with React, Node.js, and other technologies, gRPC offers:</p><ul><li><strong>Speed &amp; Efficiency:</strong> Binary protocols and HTTP/2 make data transfer incredibly fast.</li><li><strong>Clear Contracts:</strong> Protobuf files define exactly what data is expected.</li><li><strong>Cross-Language Support:</strong> Easily integrate services written in different languages.</li><li><strong>Modern Streaming:</strong> Supports bidirectional streaming for real-time applications.</li></ul><h3>Final Thoughts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mepx6C0K4H8ORjsOv9XIcw.jpeg" /><figcaption>gRPC is like a Superhero</figcaption></figure><p>gRPC is like a superpower for your applications. It takes the complexity out of inter-service communication, making your apps faster and more reliable. With clear and simple contracts (thanks to Protobuf) and robust performance, gRPC is a great tool whether you’re building microservices or integrating different parts of your application.</p><p>Give gRPC a try in your next project, and see how it can elevate your app’s communication to superhero levels!</p><p>Happy Learning :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2928245907cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Tasks on macOS with Automator: A Comprehensive Guide]]></title>
            <link>https://medium.com/@yogi-dev/automating-tasks-on-macos-with-automator-a-comprehensive-guide-272cb942df72?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/272cb942df72</guid>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 13:04:02 GMT</pubDate>
            <atom:updated>2025-05-02T13:47:21.404Z</atom:updated>
            <content:encoded><![CDATA[<p>Automator is a powerful built-in macOS tool that allows you to create workflows, apps, and scripts to automate repetitive tasks. In this guide, we’ll explore how to use Automator to create apps, incorporate shell scripts, and execute specific commands. We’ll demonstrate the process with an example: automating the task of turning off Bluetooth using the blueutil command-line tool.</p><h3>What is Automator?</h3><p>Automator is a graphical application available on macOS that enables users to automate tasks without needing extensive programming knowledge. You can create workflows that:</p><ul><li>Rename files in bulk.</li><li>Extract text from documents.</li><li>Execute shell scripts for system-level commands.</li><li>And much more!</li></ul><h3>Key Features:</h3><ul><li><strong>Drag-and-Drop Interface</strong>: Easily assemble workflows using predefined actions.</li><li><strong>Custom Scripts</strong>: Integrate custom shell scripts or AppleScripts for advanced tasks.</li><li><strong>App Creation</strong>: Save workflows as standalone applications for quick execution.</li></ul><h3>Example: Automating Bluetooth Toggle</h3><p>Let’s dive into a practical example. We’ll create an Automator app to turn off Bluetooth using the blueutil tool. This will also demonstrate how to use shell commands in Automator workflows.</p><h3>Step 1: Install blueutil Using Homebrew</h3><p>blueutil is a command-line tool to control Bluetooth settings. Here’s how to install it:</p><p><strong>Install blueutil:</strong></p><pre>brew install blueutil</pre><p><strong>Verify Installation</strong>: Use the following command to confirm blueutil is installed:</p><pre>which blueutil</pre><p>This will output the full path to the blueutil binary, e.g., /opt/homebrew/bin/blueutil.</p><p><strong>Test the Command</strong>: Run the following to turn off Bluetooth:</p><pre>/opt/homebrew/bin/blueutil --power 0</pre><p>Use /opt/homebrew/bin/blueutil --power 1 to turn Bluetooth back on.</p><h3>Step 2: Create an Automator App</h3><p>Now, we’ll create an Automator app to execute the blueutil command.</p><p><strong>Open Automator</strong>:</p><ul><li>Press Cmd + Space, type <strong>Automator</strong>, and hit Enter.</li><li>Choose <strong>Application</strong> as the document type.</li></ul><p><strong>Add a Run Shell Script Action</strong>:</p><ul><li>In the Automator window, search for <strong>Run Shell Script</strong> in the left panel and drag it to the workflow area.</li><li>In the script text box, enter the following command:</li></ul><pre>/opt/homebrew/bin/blueutil --power 0</pre><ul><li>Replace /opt/homebrew/bin/blueutil with the path you found earlier using which blueutil.</li></ul><p><strong>Save the App</strong>:</p><ul><li>Press Cmd + S to save the app.</li><li>Name it (e.g., turn_off_bluetooth) and save it to your Application.</li><li>Now go to <strong>System-setting-&gt;privacy-&gt;bluethooth</strong> and Add this app turn_off_bluetooth</li></ul><p><strong>Test the App</strong>:</p><ul><li>Double-click the app on your Application. Bluetooth should turn off.</li></ul><h3>Step 3: Automate with SleepWatcher</h3><p>To execute the Automator app automatically when the MacBook lid is closed, we’ll use a tool called SleepWatcher.</p><h4>Install SleepWatcher</h4><p><strong>Install SleepWatcher via Homebrew</strong>:</p><pre>brew install sleepwatcher</pre><p><strong>Create a Sleep Script</strong>:</p><p>Open Terminal and create a new file:</p><pre>vim ~/.sleep</pre><ul><li>Add the following line to the file:</li></ul><pre>open &quot;/Users/your_username/Desktop/myapp.app&quot;</pre><ul><li>Replace /Users/your_username/Desktop/myapp.app with the full path to your Automator app. To find the full path:</li></ul><p><strong>Make the Script Executable</strong>:</p><pre>chmod +x ~/.sleep</pre><p><strong>Start SleepWatcher</strong>:</p><ul><li>Run this command to start SleepWatcher and ensure it executes your script:</li></ul><pre>brew services start sleepwatcher</pre><p>SleepWatcher will now run your script whenever the Mac goes to sleep (e.g., when the lid is closed).</p><h3>Conclusion</h3><p>You’ve now learned how to create a simple Automator app and automate its execution using SleepWatcher. This example focused on toggling Bluetooth, but the same principles can be applied to automate various tasks on macOS. Experiment with Automator to explore its full potential!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=272cb942df72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Agile Developer’s Guide to Metrics: Not Just a Numbers Game]]></title>
            <link>https://medium.com/@yogi-dev/the-agile-developers-guide-to-metrics-not-just-a-numbers-game-5e55b08faea0?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e55b08faea0</guid>
            <category><![CDATA[scrum]]></category>
            <category><![CDATA[agile]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Sun, 18 Feb 2024 08:25:16 GMT</pubDate>
            <atom:updated>2024-02-21T07:36:32.410Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-evolving world of software development, Agile has become the superhero cape that almost every team wants to implement.</p><p>It’s like the cool trend that everyone is following. The concept is simple: deliver bite-sized pieces of value, get feedback, improve, and repeat. Easy, right? Well, not always.</p><p>One of the trickiest parts of this Agile adventure is figuring out how to measure success. Sure, you’ve got story points, but let’s be honest, they can be as mysterious as the dark side of the moon.</p><p>What does it really mean when your team jumps from 10 to 13 story points per sprint? Is it like leveling up in a video game or just another number?</p><p>Let’s look at four key metrics that are easier to unders</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVxi0m2c0NdtRHREquvjSA.jpeg" /></figure><ol><li><strong>Deployment Frequency</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bx2KoSL7eGAvfXwzryoX7Q.png" /></figure><p>Think of deployment frequency as your software’s pulse rate. In the olden days of waterfall methodologies, deployments were like those family reunions: happening once in a blue moon with a whole lot of buildup and often, a whole lot of drama.</p><p>In Agile, the idea is to make deployments as frequent as your Tea breaks. This means smaller, less daunting updates, and a happier, less nervous team.</p><p>Gone are the days of manual, error-prone deployments that everyone feared like a visit to the dentist. With modern tools like CI/CD pipelines, infrastructure as code, and feature flags, deployments become very smooth.</p><p>Remember, frequent deployments are not just for the elite microservices or MFE’s even the monolithic can join the party.</p><p><strong>2. Lead Time for Changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f9I6ggqW9_9c3i-GeSnPRA.jpeg" /></figure><p>Now, frequent deployments are great, but if it takes an eternity to go from idea to production, you’re still stuck in the mud.</p><p>One significant bottleneck is the approvals process, which often takes a long time due to the need for approval from multiple levels and various stakeholders. This layered approval process can significantly slow down the deployment pipeline.</p><p>The goal is to make this process as quick as a flash of lightning. This means breaking down big, scary tasks into smaller, manageable ones, streamlining the approval process, perhaps by delegating decision-making or using automated approval workflows, and using feature flags to avoid the drama of merge conflicts.</p><p><strong>3. Mean Time to Restore</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*qlKwX0sTx0GCqqgQwel0uw.jpeg" /></figure><p>Mistakes happen. That’s life. But in the world of Agile, it’s about how fast you can pick yourself up. The mean time to restore is all about resilience. It’s like having a superhero’s healing factor. Whether it’s a bug or a system outage, the quicker you can restore normalcy, the more unbeatable your team becomes.</p><p>This could mean having backup systems ready to spring into action or being able to roll back to a previous version faster than you can say “Oops!”</p><p><strong>4. Change Failure Rate</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*8InmWooTzB3D2lOrWlOZ3A.jpeg" /></figure><p>Lastly, we have the change failure rate. It’s great to deploy fast and fix things quickly, but if every deployment is a gamble, you’re playing a risky game. This metric tells you how often your changes lead to problems.</p><p>To improve, Sometimes, the answer lies in writing better tests or simplifying that legacy complicated code.</p><p><strong>Conclusion: It’s a Bird, It’s a Plane, It’s Agile!</strong></p><p>So there you have it, the four metrics to keep your Agile journey on track. Remember, it’s not just about chasing numbers. It’s about making the process smoother, faster, and more responsive to change.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e55b08faea0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Power of Node.js: CPU Intensive Tasks Done Right]]></title>
            <link>https://medium.com/@yogi-dev/unlocking-the-power-of-node-js-cpu-intensive-tasks-done-right-942a8bda4084?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/942a8bda4084</guid>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Fri, 19 May 2023 08:19:59 GMT</pubDate>
            <atom:updated>2023-05-19T08:25:10.795Z</atom:updated>
            <content:encoded><![CDATA[<p>Node.js has been making waves in the developer community ever since its inception. Traditionally, Node.js has been celebrated for its fantastic ability to handle I/O-bound tasks, such as managing network connections and interfacing with databases. But is it equipped to handle CPU-intensive tasks as well? Surprisingly, yes! While it’s not exactly Node.js’s forte, with the right approach, Node.js can be harnessed to perform CPU-intensive tasks effectively. Let’s explore how.</p><p><strong>Understanding Node.js</strong></p><p>Before we delve into how Node.js can handle CPU-intensive tasks, it’s essential to have a basic understanding of Node.js’s architecture. At its core, Node.js is a JavaScript runtime built on Chrome’s V8 engine. Its primary power comes from its event-driven, non-blocking I/O model, which makes it lightweight and efficient.</p><p>Traditionally, Node.js has been known to falter when it comes to CPU-bound tasks, such as computations and data processing. The reason is Node.js’s single-threaded architecture. When Node.js is given a CPU-bound task, it blocks the event loop and hogs all the CPU power until it’s done, which could slow down the entire application.</p><p>But this is where we need to differentiate between ‘not ideal’ and ‘not possible.’ Here’s how we can leverage the Node.js ecosystem to its full potential to perform CPU-intensive tasks.</p><p><strong>Utilizing Worker Threads</strong></p><p>Since Node.js 10.5.0, a new feature called ‘worker threads’ was introduced to deal with CPU-intensive tasks. Worker threads allow you to run JavaScript in parallel, thus taking full advantage of today’s multi-core systems. This is great for performing CPU-bound tasks, as the work can be split amongst different threads.</p><p>This doesn’t block the main thread, enabling the app to continue serving other requests without slowdown. Therefore, if you have a CPU-intensive task, you can spawn a worker thread to do it, and when it’s done, it can send a message back to the main thread.</p><pre>const { Worker, isMainThread, parentPort } = require(&#39;worker_threads&#39;);<br><br>if (isMainThread) {<br>    // This is the main thread. Spawn a worker.<br>    const worker = new Worker(__filename);<br>    worker.once(&#39;message&#39;, (message) =&gt; {<br>        console.log(message);  // &#39;Hello, world!&#39;<br>    });<br>    worker.postMessage(&#39;Hello, worker&#39;);<br>} else {<br>    // This is the worker thread.<br>    parentPort.once(&#39;message&#39;, (message) =&gt; {<br>        parentPort.postMessage(`${message} world!`);<br>    });<br>}</pre><p><strong>Going Native with Node.js Addons</strong></p><p>Another route to tackling CPU-bound tasks with Node.js is by creating Node.js addons using C++. The V8 JavaScript engine, which powers Node.js, is actually written in C++. Therefore, by creating addons, you can perform operations at the lower level, which is more CPU-efficient than JavaScript.</p><p>Node.js Addons provide an interface between JavaScript running in Node.js and C/C++ libraries. They’re built on top of V8’s API and the Node.js Event Loop. By going this route, you’ll be able to take full advantage of the speed that C++ provides for CPU-bound tasks.</p><pre>#include &lt;node.h&gt;<br><br>void Add(const v8::FunctionCallbackInfo&lt;v8::Value&gt;&amp; args) {<br>    v8::Isolate* isolate = args.GetIsolate();<br>    double value = args[0].As&lt;v8::Number&gt;()-&gt;Value() + args[1].As&lt;v8::Number&gt;()-&gt;Value();<br>    args.GetReturnValue().Set(v8::Number::New(isolate, value));<br>}<br><br>void Initialize(v8::Local&lt;v8::Object&gt; exports) {<br>    NODE_SET_METHOD(exports, &quot;add&quot;, Add);<br>}<br><br>NODE_MODULE(addon, Initialize)</pre><pre>const addon = require(&#39;./addon&#39;);<br><br>console.log(addon.add(3, 5));  // Outputs: 8</pre><p><strong>Offloading Tasks</strong></p><p>One final approach to consider when dealing with CPU-intensive tasks in Node.js is offloading tasks to a separate service dedicated to CPU-intensive operations. This way, your Node.js application can remain focused on what it does best: handling many requests concurrently, while a separate service (or services) can handle the CPU-bound tasks. This microservices approach can provide an effective way to handle both I/O-bound and CPU-bound tasks efficiently.</p><pre>const { fork } = require(&#39;child_process&#39;);<br><br>const compute = fork(&#39;compute.js&#39;);<br><br>// Send numbers to child process<br>compute.send({ num1: 3, num2: 4 });<br><br>// Listen for message from child process<br>compute.on(&#39;message&#39;, (sum) =&gt; {<br>    console.log(`Sum is: ${sum}`);  // Outputs: &#39;Sum is: 7&#39;<br>});</pre><pre>process.on(&#39;message&#39;, (message) =&gt; {<br>    const sum = message.num1 + message.num2;<br>    process.send(sum);<br>});</pre><p><strong>The Bottom Line</strong></p><p>Yes, Node.js was built to shine in dealing with I/O-bound tasks. Still, with worker threads, Node.js Addons, or a microservices architecture, you can use Node.js effectively for CPU-intensive tasks. While it might not be the most traditional choice for such tasks, it’s certainly possible and can provide a range of benefits, such as a unified language for both frontend and backend and the power of the vast npm ecosystem.</p><p>When it comes to developing software, there are always trade-offs to consider. While Node.js might not be the most efficient option for CPU-bound tasks, the convenience</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=942a8bda4084" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MAC OS - SSH to Github, HTTP’s Connection in localhost and Custom domain, Certificates…]]></title>
            <link>https://medium.com/@yogi-dev/mac-os-ssh-to-github-https-connection-in-localhost-and-custom-domain-certificates-2e605bdf6ea2?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e605bdf6ea2</guid>
            <category><![CDATA[httpscertificate]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 10:25:01 GMT</pubDate>
            <atom:updated>2021-08-08T10:25:01.323Z</atom:updated>
            <content:encoded><![CDATA[<h3>MAC OS - SSH to Github, HTTP’s Connection in localhost and Custom domain, Certificates, LetsEncryption</h3><p>Hey people, Let do some stuff related to OpenSSH and HTTPS connections</p><h3>1. Connecting to GitHub with SSH</h3><p>You can connect to GitHub using the Secure Shell Protocol (SSH), which provides a secure channel over an unsecured network.</p><p>Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username and personal access token at each visit.</p><p><strong>Steps to follow:</strong></p><ol><li>ssh-keygen -&gt;this will generate public and private keys inside ~/.ssh/</li><li>navigate to ~/.ssh/ and you will find id_rsa and id_rsa.pub files</li><li>id_rsa has a private key and id_rsa.pub has a public key</li><li>copy id_rsa.pub key go to Your Github Account-&gt;Settings-&gt;SSH-&gt; Add new SSH keyand paste your public key there</li><li>Now you are connected to your GitHub account via SSH, and you don’t have to type your username and password at each visit.</li></ol><p>6. You can also check your know_hosts inside ~/.ssh/know_hosts</p><h3>2. Setup HTTPS on localhost — Certificates</h3><ol><li>Make a my-localhost-ssl folder in your home directory</li><li>we need to create a self-signed key and certificate -&gt;sudo openssl genrsa -out ~/my-localhost-ssl/localhost.key 2048</li><li>sudo openssl req -new -x509 -key ~/my-localhost-ssl/localhost.key -out ~/my-localhost-ssl/localhost.crt -days 3650 -subj /CN=localhost</li><li>Add these keys to the Keychain.app -&gt; sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/my-localhost-ssl/localhost.crt</li></ol><h3>3. Setup HTTPS on your own Custom domain — Nginx — Certificates</h3><p>We will use <strong>lets encryption </strong>for this</p><ol><li>brew install letsencrypt</li><li>Make sure your Nginx server is not running sudo nginx -s stop</li><li>sudo certbot certonly --standalone</li><li>It will ask your custom domain in this step — enter it for eg: nginxtest.ddns.test</li><li>Your certificate will be saved at /etc/letsencryt/live/nginxtest.ddns.test/fullchain.pem</li><li>Your key will be saved at /etc/letsencryt/live/nginxtest.ddns.test/private.pem</li><li>Add this path in your Nginx config file as shown in the below image</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2_hMZ5PMPXJUSiUVyyYjZg.png" /></figure><h3>4. Make your site available to the public</h3><ol><li>Get your public ID Address, basically your router address -&gt; google search ip</li><li>Go to your Router settings-&gt;Port Forwarding</li><li>Add rules for 80:80 and 443:443</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*EBJFrflGxqQL_aIjTAcrRw.png" /></figure><p>4. Now this will forward everything that goes from your public IP on port 80 or 443 <strong>TO </strong>your MacBook which is listening on port 80(http) or 443(https)</p><p>Refer to Section 5 to create your <strong>DNS Record</strong></p><h3>5. Create DNS Record</h3><ol><li>Open noip.com It is a free service — You are free to choose any</li><li>Add custom domain and create an entry as shown in the image below</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*Ny-ruU2zmDmPFTTgnKePnA.png" /></figure><h3>Bonus:</h3><p>What is .pem, .pub, .key, .cert files???</p><p>Refer to -&gt; <a href="https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file">https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file</a> for details explanintion</p><p>Stay Safe and Happing Learning!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e605bdf6ea2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding CORS and Misconception of CORS Browser Extensions and Hacks]]></title>
            <link>https://medium.com/@yogi-dev/understanding-cors-and-misconception-of-cors-browser-extensions-aa71912c1872?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa71912c1872</guid>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[cors]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Thu, 29 Jul 2021 18:08:19 GMT</pubDate>
            <atom:updated>2021-07-29T18:09:34.827Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey People, Today we will try to understand CORS and misunderstandings about Cors browser extensions.</p><p>The main motive of this article is to highlight the misconception people have about cors browser extensions. The intention of this article is not to teach you CORS in depth</p><p><strong>What is CORS?</strong></p><p><strong>Cross-origin resource sharing (CORS)</strong> is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.</p><p>By default, all browsers blocks Cross-origin-resource-sharing</p><p>If client any of <strong>[protocal]:[domain]:[port]</strong> is different from the server any of <strong>[protocal]:[domain]:[port]</strong> then it is against the cors policy and browsers will by default block all requests.</p><p><strong>Note</strong>: “CORS is only a browser mechanism”. If you try to access resources from the different domains using <strong>other servers</strong> or <strong>terminals</strong> then the CORS restriction does not apply and you will be freely able to access resources.</p><p>Ok, Now I believe things are pretty clear about CORS, So let try it live.</p><p>I have Setup a <strong>NodeJS Server</strong> locally, I have set it up on <a href="http://www.localhost:7777">http://www.localhost:7777</a> and it is running and accepts incoming requests</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YSdApKXgwQrI37di1xU8cw.png" /><figcaption>NodeJS Server</figcaption></figure><p>Now start the server</p><p><strong>Note: Now there are no cors set up for it on the server-side</strong></p><p>Now go to <a href="http://www.google.com">www.google.com</a> and try to fetch resources from <a href="http://www.localhost:7777">http://www.localhost:7777</a></p><p>you will see cors error — &gt; because the browser is blocking different domain resource sharing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8l21ptWU3RFsYH5tUwRplQ.png" /></figure><p>Now, How can we solve this problem?</p><p>There are 2 ways of doing this</p><ol><li>Use browser extension for cors <a href="https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en">https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en</a> . It will add a header in response for <strong>Access-Control-Allow-Origin: true </strong>therefore browser will allow sharing of resources.</li></ol><p>2. Add cors on the server as middleware</p><pre>app.use(cors());   <br>OR<br>app.use(cors({origin:&quot;*&quot;}))</pre><p>It will basically allow resource sharing for all origin</p><p>But what if you want to give access to a specific domain only, then</p><pre>app.use(cors({origin: [&quot;https://www.google.com&quot;, &quot;https://www.bing.com&quot;]}));</pre><p>Now only <a href="https://www.google.com">https://www.google.com</a> and <a href="https://www.google.com">https://www.bing.com</a> is allowed to access the resource from <a href="http://www.localhost:7777">http://www.localhost:7777</a></p><p><strong>Now Coming to the interesting part</strong></p><p><strong>Important to NOTE</strong>: It is clear that if we add specific origin to the cors then those domains <strong>only</strong> be allowed by default, <strong>BUT BUT BUT </strong>at the same time if you use <strong>cors chrome extension</strong> then it will allow for all domains even though only 2 specific domains are mentions.</p><p>Anyone can easily get resources from your API using the CORS chrome extension even though you have configured for a specific domain, then how do we overcome this problem? See the code below,</p><p>Code below will not allow other domains to access resources even if they use CORS browser extensions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eEE6AkzOFvKxrDt-pQOFPA.png" /></figure><p>Now this will only allow requests from https://www.google.com <a href="https://www.bing.com">https://www.bing.com</a> even if you use any chrome cors extension</p><p><strong>So The misconception here is that — &gt; </strong>I have come across many people who think and believe that if there is any cors issue coming then just using a cors browser extensions will solve the issue, which is not true we just saw in the above example where we were using whitelist domain and throwing an error if the domain does not match the one which server wants to allow</p><p><strong>If the server is handling cors by allowing specific domains and throwing errors for all other domains then browser extensions for cors will not help in any way.</strong></p><p>So now, you will say, OK Mann I understood it, but then How do we deal with it then?</p><p>Yes, we can do this using <strong>proxy-server</strong> because as I said before in the article that cors restriction is only put by browser by default, so instead of sending a request directly from the browser to the server, we will send that request to the proxy server first where we will have cors allowed for all origin, and then let that proxy-server hit the other server for getting the resource.</p><p>I have created a <strong>node proxy-server</strong> for anyone to use, you can find it here -&gt; <a href="https://www.github.com/yogain123/proxy-server"><strong>https://www.github.com/yogain123/proxy-server</strong></a></p><p>It is very easy to set up and use.</p><p>Star and Contribute to the Repo to make it more mature.</p><p>Say Safe and Happy Learning !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa71912c1872" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consistent Hashing, A Reliable Algorithm to scale your System]]></title>
            <link>https://medium.com/@yogi-dev/consistent-hashing-a-reliable-algorithm-to-scale-your-system-fb5145acc700?source=rss-85dbd9b5e21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb5145acc700</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[consistent-hashing]]></category>
            <category><![CDATA[scaling-microservices]]></category>
            <dc:creator><![CDATA[Yogendra Saxena]]></dc:creator>
            <pubDate>Sat, 21 Mar 2020 08:08:40 GMT</pubDate>
            <atom:updated>2020-04-25T05:16:27.343Z</atom:updated>
            <content:encoded><![CDATA[<p>So the Topic is what is <strong>Consistent Hashing</strong>? So before going deep into it lets discuss why we need it and where we need it.</p><p>Let&#39;s say you created an <strong>Algorithm</strong> and your Algorithm is super awesome and you want it to reach to multiple people, you put your algorithm on a cloud-like <strong>AWS</strong>, now let say initially only a few people know about it, but now it has become so popular that multiple requests have started coming to your server to get the most out of it, How do you deal with it?</p><p>You can <strong>Scale</strong> your system.</p><p>What does scaling means?</p><p><strong>Scaling here means able to handle a lot of requests/load.</strong></p><p>How do we do that?</p><p>There are 2 ways of doing it.</p><ol><li>Verticale Scaling</li><li>Horizontal Scaling</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BoOS3AD_Skc51zF_aQb6mg.jpeg" /><figcaption>Vertical Vs Horizontal Scaling</figcaption></figure><p>Here we will focus on Horizontal scaling, but let me tell you the difference between both.</p><p><strong>Horizontal Scaling</strong>: Scaling your System horizontally, means adding more and more servers and putting your Algorithm in all servers.</p><p><strong>Vertical Scaling</strong>: Scaling your system Vertically, means getting one single Big super powerful machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HS0mhGRyCt8_7wP4WYwLMw.jpeg" /><figcaption>Horizontal Scaling</figcaption></figure><p>What is the best solution?</p><p><strong>Taking the best out of both the world.</strong></p><p>Means getting the bigger and better machine and scale horizontally if the load is very high.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*bdPGQY0NHIAThXIQwgumlg.png" /><figcaption>Scaling</figcaption></figure><p>So now we understood what is scaling.</p><p>Now let&#39;s look deep into <strong>Horizontal Scaling</strong></p><p>We add more and more servers horizontally here, but the issue is how do we deal with sending a request or balancing the load among servers.</p><p>There are many ways of doing that:</p><ol><li>Round Robin</li><li>Weighted Round Robin</li><li><strong>Consistence Hashing</strong></li></ol><p>We will specifically look into <strong>Consistent Hashing</strong> because it is the main hero of our article.</p><p>Now let&#39;s look into a scenario where we are not using Consistency hashing and then the problem we face because of that.</p><p>Exactly what is <strong>Hashing</strong> here.</p><p>Let me explain to you.</p><p>When a request comes to a server (usually a request is some unique id), that request is passed through our <strong>Hash Function</strong>, now the result we get is numeric, we take <strong>Mod</strong> of that number to the <strong>Number of Servers</strong> we have, Let look into an example</p><pre>H(R1) =&gt; 1232</pre><pre>1232 % 5 = 2</pre><p>Here Our Hash function is H(), our Request id is R1, we pass our Request R1 to the hash function and we get 1232, then we mode it with 5, <strong>Let say we have 5 servers</strong></p><pre>1231 % 5 = 1<br>4454 % 5= 4<br>125 % 5 = 0<br>123435 % 5 = 0</pre><p>Now we can create a <strong>Hash Table</strong> where we map requested keys and values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*n3LRid5elV0rq4iHnp_T1Q.png" /><figcaption>hashing</figcaption></figure><p>There could be some problem in this like, getting data in the same address for example 125,123435, etc, we can solve it by using <strong>Chaining(Linked List), Probing, making a good Hash Function</strong> and whatnot (that&#39;s not the main point of the topic, you can google it).</p><p>Now let say if the above design is been used for Horizontal Scaling then what problem we can face?</p><p>Now let say everything happens as explained above then if any of the <strong>Servers Goes Down</strong>, <strong>or you plan to add a few More Server</strong>, then what could be the scenario and how it will <strong>bamboozle</strong> you <strong>Cache System.</strong></p><p><strong>For example, if one server goes down, Now the number of servers you have is 4.</strong></p><p>Now the Scenario is :</p><pre>1231 % 4= 3<br>4454 % 4= 2<br>125 % 4 = 1<br>123435 % 4= 3</pre><p>Now your all request is going to totally different Servers, Why this is a problem?</p><p>You might think if it is going to a different server then let it go, Right?</p><p><strong>No, the server caches its data for that id</strong>, if some client request is been served by the server, that server caches it as that client was always requesting data from the same server, but now with the change in the number of servers, the case is not same anymore.</p><p>Because of this, all client request is bamboozled and <strong>All cached data is dumped or useless.</strong></p><p><strong>How we can overcome it?</strong></p><p>Yes, <strong>Consistent Hashing</strong> is a solution, How?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*V0Qno1Wt4ocp0sSwsi-QBQ.png" /><figcaption>Consistence Hashing</figcaption></figure><p>All the Server are in a <strong>Circular Clockwise Direction</strong>, whenever a request comes, An Immediate clockwise Directed server will be responsible for serving the request( See Above Image)</p><pre>Robert is servered by server 10.10.10.2.11211</pre><pre>Josph is servered by server 10.10.10.1.11211</pre><p>so on so forth.</p><p>Now If one server is removed let say server 10.10.10.2.11211 is removed, then Robet will be served by its immediate Clockwise Server which is 10.10.10.1.11211, <strong>this way it is not messing with all server but only messing with the immediate clockwise server.</strong></p><p>This was the fundamental of Consistence Hashing, but there is a lot more to learn about it, like adding <strong>Virtual Servers</strong> to reduce the mess much more.</p><p>So now we can define a <strong>Consistent Hashing </strong>is a distributed <strong>hashing</strong> scheme that operates independently of the number of servers or objects in a distributed <strong>hash</strong> table by assigning them a position on an abstract circle, or <strong>hash</strong> ring. This allows servers and objects to scale without affecting the overall system.</p><p>I would highly recommend reading more about it using more resources to get more insights on it and try to understand the Pie Diagram above.</p><p>This was a <strong>high-level Architecture</strong> Overview of Consistent Hashing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ABVVkyNwI6hx4oRpJLud4A.gif" /></figure><p>I would also recommend you to check a product by <strong>Netflix</strong>,<strong> Chaos Monkey</strong> which is responsible for intentionally going to Netflix production on working days and messes with the Servers.</p><p>It removes or adds servers, just to check if their system is <strong>Resilient</strong> enough for handling this situation if occurred originally.</p><p>Happing Learning :)</p><p><a href="http://github.com/yogain123">yogain123 - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb5145acc700" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>