{
    "version": "https://jsonfeed.org/version/1",
    "title": "Sarvesh Mishra | Lead Platform Engineer",
    "home_page_url": "https://sarvesh.xyz",
    "description": "Sarvesh Mishra's Blog",
    "icon": "https://sarvesh.xyz/images/logo.webp",
    "author": {
        "name": "Sarvesh Mishra",
        "url": "https://sarvesh.xyz"
    },
    "items": [
        {
            "id": "https://sarvesh.xyz/blog/A-Step-by-Step-Guide-to-Saving-AWS-Costs-by-Uploading-Public-Docker-Images",
            "content_html": "<p>In the world of containerized applications, Docker Hub is a popular choice for storing and sharing Docker images. While Docker Hub is a convenient option, it may not be the most cost-effective choice if you&#39;re deploying containers in Amazon Web Services (AWS). AWS charges for data transfer between regions and services, and pulling Docker Hub images into AWS regions can add up to significant costs over time. For more info, you can check here <a href=\"https://aws.amazon.com/blogs/containers/understanding-data-transfer-costs-for-aws-container-services/\" target=\"_blank\">See How AWS Calculate Data Transfer Cost</a></p>\n<p>A smarter approach is to store your Docker Hub images in Amazon Elastic Container Registry (ECR), an AWS-managed Docker container registry. By doing so, you can significantly reduce data transfer costs when deploying containers on AWS services like Amazon Elastic Kubernetes Service (EKS) or Amazon Elastic Container Service (ECS). In this blog post, we&#39;ll walk you through the steps to achieve this cost-saving strategy.</p>\n<h2>Why Move Docker Hub Images to ECR?</h2>\n<p>Before we dive into the &quot;how,&quot; let&#39;s understand the &quot;why.&quot; Here are some compelling reasons to move your Docker Hub images to Amazon ECR:</p>\n<ol>\n<li><p><strong>Reduced Data Transfer Costs</strong>: AWS services typically don&#39;t incur data transfer charges when pulling images from ECR repositories within the same AWS region.</p>\n</li>\n<li><p><strong>Improved Latency</strong>: Storing images in ECR ensures faster container deployments since the images are located closer to your AWS resources.</p>\n</li>\n<li><p><strong>Increased Control</strong>: You have full control over image versions, access policies, and security in your ECR repository.</p>\n</li>\n</ol>\n<p>Now, let&#39;s get started with the steps to migrate your Docker Hub images to ECR.</p>\n<h2>Step 1: Create an ECR Repository</h2>\n<p>Begin by creating a new ECR repository. You can do this through the AWS Management Console, AWS CLI, or an Infrastructure-as-Code (IaC) tool like AWS CloudFormation or Terraform. Here&#39;s an example using the AWS CLI:</p>\n<pre><code class=\"language-bash\">aws ecr create-repository --repository-name my-docker-repo\n</code></pre>\n<p>Replace <code>my-docker-repo</code> with a name that reflects the content of your Docker images.</p>\n<h2>Step 2: Login to Docker Hub</h2>\n<p>Use the <code>docker login</code> command to log in to your Docker Hub account. You&#39;ll need this to pull images from Docker Hub.</p>\n<pre><code class=\"language-bash\">docker login\n</code></pre>\n<h2>Step 3: Pull the Docker Hub Image</h2>\n<p>Pull the Docker Hub image you want to migrate into your local environment.</p>\n<pre><code class=\"language-bash\">docker pull dockerhubusername/imagename:tag\n</code></pre>\n<p>Replace <code>dockerhubusername</code>, <code>imagename</code>, and <code>tag</code> with your Docker Hub image details.</p>\n<h2>Step 4: Tag the Docker Image for ECR</h2>\n<p>Tag the Docker image with the ECR repository URI. Replace <code>account-id</code>, <code>my-docker-repo</code>, and <code>my-tag</code> with your AWS account ID, ECR repository name, and desired tag. Here&#39;s an example:</p>\n<pre><code class=\"language-bash\">docker tag dockerhubusername/imagename:tag account-id.dkr.ecr.region.amazonaws.com/my-docker-repo:my-tag\n</code></pre>\n<h2>Step 5: Push the Image to ECR</h2>\n<p>Push the Docker image to your ECR repository.</p>\n<pre><code class=\"language-bash\">docker push account-id.dkr.ecr.region.amazonaws.com/my-docker-repo:my-tag\n</code></pre>\n<h2>Step 6: Use ECR Image in Your AWS Services</h2>\n<p>Update your AWS services (EKS, ECS, etc.) to use the image from your ECR repository. Replace references to the Docker Hub image with the ECR image URI.</p>\n<h2>Step 7: Clean Up</h2>\n<p>You can now remove the local Docker image since it&#39;s already pushed to ECR.</p>\n<pre><code class=\"language-bash\">docker rmi dockerhubusername/imagename:tag\n</code></pre>\n<p>By following these steps, you&#39;ve successfully migrated your Docker Hub image to Amazon ECR, saving data transfer costs and improving the efficiency of your container deployments.</p>\n<p>Remember to set up appropriate IAM roles and permissions to allow your AWS services to access your ECR repository. Additionally, consider automating this process in your CI/CD pipeline for seamless image updates and deployments.</p>\n<blockquote>\n<p>In conclusion, optimizing your container workflows in AWS is not just about functionality; it&#39;s also about cost-efficiency. By moving your Docker Hub images to Amazon ECR, you can enjoy the benefits of AWS-managed container repositories while reducing data transfer costs.</p>\n</blockquote>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/A-Step-by-Step-Guide-to-Saving-AWS-Costs-by-Uploading-Public-Docker-Images",
            "title": "A Step-by-Step Guide to Saving AWS Costs by Uploading Public Docker Images to Private ECR",
            "summary": "Docker is a powerful tool that has revolutionized the way applications are deployed and managed. In this blog post we'll see how we can save AWS Data Transfer cost by saving public image on ECR",
            "image": "https://sarvesh.xyz/images/docker.jpg",
            "date_modified": "2023-09-22T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/Flutter-Basics-Understanding-Widgets-State-and-Navigation",
            "content_html": "<h3><strong>Part 3: Flutter Basics – Understanding Widgets, State, and Navigation</strong></h3>\n<h4><strong>Introduction</strong></h4>\n<p>Now that you’ve set up Flutter and created your first app, it’s time to dive deeper into the core concepts that make Flutter powerful. In this blog, we’ll cover <strong>widgets, state management, and navigation</strong>.</p>\n<h4><strong>1. Understanding Widgets</strong></h4>\n<p>Everything in Flutter is a <strong>widget</strong>. Flutter has two main types of widgets:</p>\n<ul>\n<li><strong>StatelessWidget</strong> – Doesn’t change over time (e.g., <code>Text</code>, <code>Image</code>).</li>\n<li><strong>StatefulWidget</strong> – Changes dynamically (e.g., buttons, animations).</li>\n</ul>\n<p>Example of a simple <code>StatelessWidget</code>:</p>\n<pre><code class=\"language-dart\">import &#39;package:flutter/material.dart&#39;;\n\nvoid main() {\n  runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        appBar: AppBar(title: Text(&quot;Hello Flutter&quot;)),\n        body: Center(child: Text(&quot;Welcome to Flutter!&quot;)),\n      ),\n    );\n  }\n}\n</code></pre>\n<h4><strong>2. Managing State in Flutter</strong></h4>\n<p>State management is crucial for dynamic apps. The most common way to manage state is using <code>StatefulWidget</code>.</p>\n<p>Example of a simple <code>StatefulWidget</code>:</p>\n<pre><code class=\"language-dart\">import &#39;package:flutter/material.dart&#39;;\n\nvoid main() {\n  runApp(MyApp());\n}\n\nclass MyApp extends StatefulWidget {\n  @override\n  _MyAppState createState() =&gt; _MyAppState();\n}\n\nclass _MyAppState extends State&lt;MyApp&gt; {\n  int counter = 0;\n\n  void incrementCounter() {\n    setState(() {\n      counter++;\n    });\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        appBar: AppBar(title: Text(&quot;State Management&quot;)),\n        body: Center(\n          child: Column(\n            mainAxisAlignment: MainAxisAlignment.center,\n            children: [\n              Text(&quot;Counter: $counter&quot;, style: TextStyle(fontSize: 24)),\n              ElevatedButton(\n                onPressed: incrementCounter,\n                child: Text(&quot;Increase Counter&quot;),\n              ),\n            ],\n          ),\n        ),\n      ),\n    );\n  }\n}\n</code></pre>\n<h4><strong>3. Navigation Between Screens</strong></h4>\n<p>In Flutter, you use the <code>Navigator</code> to switch between screens.</p>\n<p>Example:</p>\n<pre><code class=\"language-dart\">Navigator.push(\n  context,\n  MaterialPageRoute(builder: (context) =&gt; SecondScreen()),\n);\n</code></pre>\n<h4><strong>Final Thoughts</strong></h4>\n<p>Understanding widgets, state, and navigation is fundamental in Flutter. These concepts will help you build more interactive and feature-rich applications. In the next post, we’ll explore advanced Flutter topics like animations, API calls, and database integration.</p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/Flutter-Basics-Understanding-Widgets-State-and-Navigation",
            "title": "Flutter Basics – Understanding Widgets, State, and Navigation",
            "summary": "Flutter has emerged as one of the most popular frameworks for building mobile applications. Developed by Google, it allows developers to create cross-platform apps with a single codebase.",
            "image": "https://sarvesh.xyz/images/flutter.svg",
            "date_modified": "2025-03-12T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/Getting-Started-with-Flutter-Step-by-Step-Guide",
            "content_html": "<h3><strong>Part 2: Getting Started with Flutter – Step-by-Step Guide</strong></h3>\n<h4><strong>Introduction</strong></h4>\n<p>Now that you know why Flutter is a great choice for mobile app development, let’s dive into setting up your Flutter development environment and creating your first Flutter app.</p>\n<h4><strong>Step 1: Install Flutter</strong></h4>\n<p>Before you can start developing with Flutter, you need to install the Flutter SDK on your machine.</p>\n<ol>\n<li><p><strong>Download Flutter SDK</strong></p>\n<ul>\n<li>Visit the <a href=\"https://flutter.dev/docs/get-started/install\">Flutter official website</a> and download the SDK for your operating system (Windows, macOS, or Linux).</li>\n</ul>\n</li>\n<li><p><strong>Extract the Files</strong></p>\n<ul>\n<li>Extract the downloaded file to a suitable location (e.g., <code>C:\\flutter</code> on Windows or <code>~/flutter</code> on macOS/Linux).</li>\n</ul>\n</li>\n<li><p><strong>Add Flutter to the System Path</strong></p>\n<ul>\n<li>On Windows: Add <code>C:\\flutter\\bin</code> to your system <code>PATH</code>.</li>\n<li>On macOS/Linux: Add <code>export PATH=&quot;$PATH:</code>pwd<code>/flutter/bin&quot;</code> to your <code>~/.bashrc</code> or <code>~/.zshrc</code>.</li>\n</ul>\n</li>\n</ol>\n<h4><strong>Step 2: Install an IDE</strong></h4>\n<p>To write and debug Flutter applications, you need an Integrated Development Environment (IDE). The most popular choices are:</p>\n<ul>\n<li><strong>Android Studio</strong> (Recommended for full Android support)</li>\n<li><strong>Visual Studio Code</strong> (Lightweight and fast)</li>\n</ul>\n<p>After installing your IDE, install the Flutter and Dart plugins.</p>\n<h4><strong>Step 3: Verify the Installation</strong></h4>\n<p>Run the following command in your terminal to check if Flutter is installed correctly:</p>\n<pre><code class=\"language-bash\">flutter doctor\n</code></pre>\n<p>This command checks for missing dependencies and provides instructions to fix any issues.</p>\n<h4><strong>Step 4: Create Your First Flutter App</strong></h4>\n<p>Run the following command to create a new Flutter project:</p>\n<pre><code class=\"language-bash\">flutter create my_first_app\n</code></pre>\n<p>Navigate to the project folder:</p>\n<pre><code class=\"language-bash\">cd my_first_app\n</code></pre>\n<p>To run your app on an emulator or a connected device, use:</p>\n<pre><code class=\"language-bash\">flutter run\n</code></pre>\n<h4><strong>Step 5: Understanding the Project Structure</strong></h4>\n<p>A Flutter project contains several important folders:</p>\n<ul>\n<li><code>lib/</code> – The main directory where your Dart code lives.</li>\n<li><code>pubspec.yaml</code> – The configuration file for dependencies and assets.</li>\n<li><code>android/ &amp; ios/</code> – Platform-specific files for Android and iOS.</li>\n</ul>\n<h4><strong>Final Thoughts</strong></h4>\n<p>Congratulations! You&#39;ve successfully set up Flutter and created your first app. In the next blog post, we’ll cover some fundamental concepts in Flutter, such as widgets, state management, and navigation.</p>\n<p>Lets move to the next part <a href=\"/blog/Flutter-Basics-Understanding-Widgets-State-and-Navigation\"> Getting-Started-with-Flutter-Step-by-Step-Guide</a></p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/Getting-Started-with-Flutter-Step-by-Step-Guide",
            "title": "Getting Started with Flutter – Step-by-Step Guide",
            "summary": "Flutter has emerged as one of the most popular frameworks for building mobile applications. Developed by Google, it allows developers to create cross-platform apps with a single codebase.",
            "image": "https://sarvesh.xyz/images/flutter.svg",
            "date_modified": "2025-03-06T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/How-to-add-large-files-on-github",
            "content_html": "<p>In the realm of software development, version control systems like Git have become indispensable tools. They allow developers to collaborate seamlessly, track changes, and manage code effectively. However, Git wasn&#39;t initially designed to handle large files efficiently. This limitation can be problematic for projects that involve multimedia assets, large datasets, or binaries.</p>\n<p>Enter Git LFS (Large File Storage), a solution tailored specifically for managing large files within Git repositories. In this article, we&#39;ll delve into what Git LFS is, its benefits, and how to use it to streamline large file management effortlessly.</p>\n<h3>Understanding Git LFS</h3>\n<p>Git LFS extends Git by replacing large files with text pointers while storing the actual file content in a separate storage. This decoupling mechanism ensures that Git repositories remain lightweight and performant, even when dealing with sizable assets. Instead of storing large files directly within the repository, Git LFS manages them externally.</p>\n<h3>Benefits of Git LFS</h3>\n<ol>\n<li><p><strong>Efficient Version Control</strong>: By storing large files outside the Git repository, Git LFS prevents repositories from becoming bloated. This helps maintain a smooth version control experience, even for projects with substantial assets.</p>\n</li>\n<li><p><strong>Improved Performance</strong>: Since Git LFS only stores text pointers in the repository, cloning and fetching operations become significantly faster. Developers can access the files they need without unnecessary delays, enhancing productivity.</p>\n</li>\n<li><p><strong>Reduced Storage Costs</strong>: Large files can consume considerable disk space within a repository. Git LFS reduces storage overhead by storing these files in a separate location, potentially saving costs for organizations hosting repositories.</p>\n</li>\n<li><p><strong>Streamlined Collaboration</strong>: Git LFS facilitates collaboration on projects involving large files by ensuring that team members can clone and work with repositories efficiently. This is particularly advantageous for distributed teams working on multimedia-rich applications or data-intensive projects.</p>\n</li>\n</ol>\n<h3>Getting Started with Git LFS</h3>\n<p>Now that we understand the benefits of Git LFS, let&#39;s explore how to incorporate it into our workflow:</p>\n<h4>Installation</h4>\n<p>Before using Git LFS, you&#39;ll need to install it on your system. Most package managers provide straightforward ways to install Git LFS <a href=\"https://git-lfs.com/\">Download Here</a>, then can run below commands:</p>\n<h4>Initializing Git LFS in a Repository</h4>\n<p>Once Git LFS is installed, navigate to your Git repository and run the following command to initialize Git LFS:</p>\n<pre><code class=\"language-bash\">git lfs install\n</code></pre>\n<p>This command configures Git LFS for the current repository, enabling it to track large files.</p>\n<h4>Tracking Large Files</h4>\n<p>To start tracking large files with Git LFS, use the <code>git lfs track</code> command followed by the file patterns you want to track. For example:</p>\n<pre><code class=\"language-bash\">git lfs track &quot;*.psd&quot;\n</code></pre>\n<p>This command instructs Git LFS to track all PSD files in the repository.</p>\n<h4>Committing and Pushing Changes</h4>\n<p>After tracking large files, commit your changes as usual:</p>\n<pre><code class=\"language-bash\">git add .\ngit commit -m &quot;Add large files&quot;\n</code></pre>\n<p>Then, push your changes to the remote repository:</p>\n<pre><code class=\"language-bash\">git push origin main\n</code></pre>\n<h4>Cloning a Repository with Git LFS</h4>\n<p>When cloning a repository that uses Git LFS, ensure that Git LFS is installed on your system. Git LFS will automatically download the large files referenced in the repository, allowing you to work with them seamlessly.</p>\n<h3>Conclusion</h3>\n<p>Git LFS addresses the challenges associated with managing large files in Git repositories, offering a scalable and efficient solution for version controlling multimedia assets, datasets, and binaries. By decoupling large files from the repository itself, Git LFS streamlines collaboration, enhances performance, and reduces storage overhead.</p>\n<p>Whether you&#39;re working on a multimedia-rich application, a data-intensive project, or any other scenario requiring version control of large files, Git LFS empowers you to manage your assets with ease, ensuring that your Git workflows remain smooth and productive.</p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/How-to-add-large-files-on-github",
            "title": "How to store large files on GitHub? What is Git LFS? ",
            "summary": "Discover how Git LFS (Large File Storage) revolutionizes version control by efficiently managing large files in Git repositories. Learn the benefits, installation steps, and best practices to streamline collaboration and boost productivity in multimedia-rich projects.",
            "image": "https://sarvesh.xyz/images/github.png",
            "date_modified": "2024-04-14T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/Kubernetes-The-Future-of-Cloud-Computing",
            "content_html": "<p>In the world of modern software development and deployment, Kubernetes has emerged as a powerhouse that is changing the way we manage and scale applications. Whether you are a seasoned developer or a newcomer to the tech world, understanding Kubernetes is essential to stay competitive and efficient. In this blog post, we&#39;ll dive deep into what Kubernetes is, how it works, and why it has become a cornerstone of contemporary application infrastructure.</p>\n<h3>What is Kubernetes?</h3>\n<p><a href=\"https://sarvesh.xyz/tags/kubernetes\">Kubernetes</a>, often abbreviated as K8s (K-eight-s), is an open-source container orchestration platform designed to automate and streamline the deployment, scaling, and management of containerized applications. It was originally developed by Google but is now maintained by the Cloud Native Computing Foundation (CNCF), a testament to its widespread adoption and community support.</p>\n<h3>Containers and Kubernetes</h3>\n<p>To truly grasp the essence of Kubernetes, we need to start with the concept of containers. <a href=\"https://sarvesh.xyz/tags/docker\">Containers</a> are lightweight, standalone, and executable packages that include everything needed to run a piece of software, including the code, runtime, libraries, and system tools. They ensure that applications run consistently across different environments, making them an ideal solution for modern software development.</p>\n<p>Kubernetes takes the power of containers to the next level by offering a unified framework for container orchestration. It can manage multiple containers, distributed across a cluster of machines, making it possible to deploy, scale, and maintain applications with ease.</p>\n<h3>Key Features of Kubernetes</h3>\n<ol>\n<li><p><strong>Automated Scaling</strong>: Kubernetes allows you to define rules and policies for automatically scaling your applications based on demand. You can scale horizontally by adding more containers or vertically by adjusting the resources allocated to each container.</p>\n</li>\n<li><p><strong>Load Balancing</strong>: It automatically distributes incoming traffic to containers, ensuring efficient resource utilization and fault tolerance.</p>\n</li>\n<li><p><strong>Self-Healing</strong>: Kubernetes continually monitors the health of containers and can restart or replace them if they fail. This feature contributes to the high availability and reliability of applications.</p>\n</li>\n<li><p><strong>Rolling Deployments</strong>: Updating applications in Kubernetes is a breeze. It enables rolling deployments, which gradually replace old containers with new ones, reducing the risk of downtime.</p>\n</li>\n<li><p><strong>Configuration Management</strong>: Kubernetes provides tools for storing and managing configuration data separately from the application code, enhancing security and portability.</p>\n</li>\n<li><p><strong>Storage Orchestration</strong>: It offers storage solutions for containers, enabling you to manage data in a consistent and scalable way.</p>\n</li>\n<li><p><strong>Declarative Approach</strong>: You define the desired state of your application, and Kubernetes makes it happen. This declarative approach simplifies management and reduces the risk of configuration drift.</p>\n</li>\n</ol>\n<h3>Why Kubernetes?</h3>\n<ol>\n<li><p><strong>Scalability</strong>: Kubernetes is capable of managing applications that range from a single container to thousands of containers running across a vast cluster of machines. This scalability makes it suitable for both small startups and large enterprises.</p>\n</li>\n<li><p><strong>Portability</strong>: Kubernetes abstracts away the underlying infrastructure, making your applications easily portable across different cloud providers or on-premises data centers.</p>\n</li>\n<li><p><strong>Resource Efficiency</strong>: It optimizes resource utilization by packing containers onto machines efficiently and enabling you to set resource limits and quotas.</p>\n</li>\n<li><p><strong>Community Support</strong>: With a large and active community, Kubernetes enjoys ongoing development and support, with a vast ecosystem of tools and resources.</p>\n</li>\n<li><p><strong>Standardization</strong>: Kubernetes has emerged as a de facto standard for container orchestration, ensuring compatibility and consistency across various platforms.</p>\n</li>\n</ol>\n<p>Conclusion</p>\n<blockquote>\n<p>Kubernetes has revolutionized the way we deploy, manage, and scale applications in a containerized world. Its flexibility, automation capabilities, and extensive community support have made it the go-to solution for organizations of all sizes. Whether you&#39;re working on a small personal project or managing a massive enterprise application, understanding Kubernetes is essential for modern software development. So, don&#39;t wait – start exploring Kubernetes and unlock its full potential for your applications.</p>\n</blockquote>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/Kubernetes-The-Future-of-Cloud-Computing",
            "title": "Kubernetes: The Future of Cloud Computing",
            "summary": "Kubernetes (K8s) is a powerful open-source container orchestration platform, enabling automated deployment and management of containerized applications. Discover how K8s streamlines application scaling, improves reliability, and enhances resource efficiency.",
            "image": "https://sarvesh.xyz/images/kubernetes.png",
            "date_modified": "2023-10-11T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/Mastering-Docker-Multi-platform-Image-Building",
            "content_html": "<p>In the rapidly evolving world of containerization, building Docker images that can run on multiple platforms is essential. Whether you&#39;re targeting ARM, x86, or any other architecture, Docker provides powerful tools to make this process seamless. In this blog post, we&#39;ll explore Docker Multi-platform image building, comparing the native way and the Qemu way. Let&#39;s dive in!</p>\n<h2>What is Docker Multi-platform Building?</h2>\n<p>Docker Multi-platform building allows you to create Docker images that can run on different CPU architectures. This is particularly useful for deploying applications across various environments, such as cloud servers, IoT devices, and edge computing platforms.</p>\n<h2>Native Way</h2>\n<p>The native way of building Docker images for multiple platforms leverages Docker&#39;s buildx and buildkit features. For this you need two machines one for amd build and another for arm build. You have to build amd image on amd machines and arm image on arm machine.</p>\n<h3>Key Concepts</h3>\n<h4>Docker Buildx</h4>\n<p>Buildx is an extended build command for Docker, providing full support for multi-platform builds and other advanced features. It uses the BuildKit backend.</p>\n<h4>Docker BuildKit</h4>\n<p>BuildKit is a modern backend for building Docker images. It offers performance improvements, cache management, and multistage builds.</p>\n<h3>Steps to Build Multi-platform Images Natively</h3>\n<ol>\n<li><p><strong>Install Docker Buildx:</strong></p>\n<pre><code class=\"language-bash\">docker buildx create --use\n</code></pre>\n</li>\n<li><p><strong>Set Up a Builder Instance:</strong></p>\n<pre><code class=\"language-bash\">docker buildx create --name mybuilder --use\n</code></pre>\n</li>\n<li><p><strong>Inspect the Builder:</strong></p>\n<pre><code class=\"language-bash\">docker buildx inspect --bootstrap\n</code></pre>\n</li>\n<li><p><strong>Build and Push Image from both machines:</strong></p>\n<pre><code class=\"language-bash\">docker buildx build -t myimage:latest --push .\n</code></pre>\n</li>\n<li><p><strong>Create Image manifest to support multi-platform:</strong></p>\n<pre><code class=\"language-bash\">ECR_URL=xxxxxxxx.dkr.ecr.ap-south-1.amazonaws.com\nREPOSITORY=dotnet-build\nTAG=dotnet-8.0-multi-platform\nTAG_AMD=dotnet-8.0-amd\nTAG_ARM=dotnet-8.0-arm\ndocker manifest create $ECR_URL/$REPOSITORY:$TAG $ECR_URL/$REPOSITORY:$TAG_AMD $ECR_URL/$REPOSITORY:$TAG_ARM\ndocker manifest annotate $ECR_URL/$REPOSITORY:$TAG $ECR_URL/$REPOSITORY:$TAG_AMD --os linux --arch amd64\ndocker manifest annotate $ECR_URL/$REPOSITORY:$TAG $ECR_URL/$REPOSITORY:$TAG_ARM --os linux --arch arm64\ndocker manifest inspect $ECR_URL/$REPOSITORY:$TAG\n</code></pre>\n</li>\n</ol>\n<h3>Advantages</h3>\n<ol>\n<li><strong>Performance:</strong> Native builds are faster as they use the host&#39;s architecture.</li>\n<li><strong>Integration:</strong> Seamlessly integrates with Docker&#39;s ecosystem.</li>\n<li><strong>Simplicity:</strong> Easy to set up and use with existing Docker commands.</li>\n</ol>\n<h3>Disadvantages</h3>\n<ol>\n<li><strong>Architecture Limitation:</strong> Requires access to physical or virtual machines for each target architecture.</li>\n</ol>\n<h2>Qemu Way</h2>\n<p>Qemu is an open-source machine emulator and virtualizer. It allows you to emulate different CPU architectures, enabling Multi-platform builds on a single host machine.</p>\n<h3>Key Concepts</h3>\n<h4>Qemu</h4>\n<p>Qemu emulates the target architecture, allowing you to run and build software for different platforms.</p>\n<h3>Steps to Build Multi-platform Images Using Qemu</h3>\n<ol>\n<li><p><strong>Install Qemu:</strong></p>\n<pre><code class=\"language-bash\">sudo apt-get install qemu-user-static\n</code></pre>\n</li>\n<li><p><strong>Register Qemu in Docker:</strong></p>\n<pre><code class=\"language-bash\">docker run --rm --privileged multiarch/qemu-user-static --reset -p yes\n</code></pre>\n</li>\n<li><p><strong>Set Up Buildx:</strong></p>\n<pre><code class=\"language-bash\">docker buildx create --name mybuilder --use\ndocker buildx inspect --bootstrap\n</code></pre>\n</li>\n<li><p><strong>Build and Push Multi-platform Image:</strong></p>\n<pre><code class=\"language-bash\">docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest --push .\n</code></pre>\n</li>\n</ol>\n<h3>Advantages</h3>\n<ol>\n<li><strong>Flexibility:</strong> Build for multiple architectures on a single host.</li>\n<li><strong>Cost-Effective:</strong> No need for separate machines for each architecture.</li>\n<li><strong>Accessibility:</strong> Easier to set up for personal and small-scale projects.</li>\n</ol>\n<h3>Disadvantages</h3>\n<ol>\n<li><strong>Performance:</strong> Slower builds due to emulation overhead.</li>\n<li><strong>Complexity:</strong> Requires additional setup and configuration.</li>\n<li><strong>Potential Compatibility Issues:</strong> Some software may not run as expected in an emulated environment.</li>\n</ol>\n<h2>Conclusion</h2>\n<blockquote>\n<p>Building Docker images for multiple platforms is crucial in today&#39;s diverse computing landscape. Both the native way and the Qemu way offer unique advantages and challenges. The native method provides superior performance and integration but requires access to different architectures. On the other hand, the Qemu way offers flexibility and cost-effectiveness, making it suitable for various use cases. Choose the method that best fits your needs and start building Multi-platform Docker images with confidence.</p>\n</blockquote>\n<h5>Happy Dockerizing! 🐋 See you in the next post. Don&#39;t forget to comment your thoughts on this post. Share knowledge with others…</h5>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n<hr>\n<p>I hope you find this guide helpful! Let me know if there&#39;s anything else you need.</p>\n",
            "url": "https://sarvesh.xyz/blog/Mastering-Docker-Multi-platform-Image-Building",
            "title": "Mastering Docker Multi-platform Image Building: Native Way vs. Qemu Way",
            "summary": "Explore Docker Multi-platform image building techniques: native method and Qemu emulation. Learn the differences, advantages, and how to get started.",
            "image": "https://sarvesh.xyz/images/docker-Multi-platform.png",
            "date_modified": "2025-02-25T17:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/Why-You-Should-Learn-Flutter-for-App-Development",
            "content_html": "<h3><strong>Part 1: Why You Should Learn Flutter for App Development</strong></h3>\n<h4><strong>Introduction</strong></h4>\n<p>Flutter has emerged as one of the most popular frameworks for building mobile applications. Developed by Google, it allows developers to create cross-platform apps with a single codebase. Whether you&#39;re a beginner in app development or an experienced developer looking to expand your skills, Flutter offers a fast, efficient, and flexible approach to building high-quality applications.</p>\n<p>In this blog post, we’ll explore why Flutter is an excellent choice for mobile development and how it can benefit you.</p>\n<h4><strong>What is Flutter?</strong></h4>\n<p>Flutter is an open-source UI software development kit (SDK) created by Google. It enables developers to build natively compiled applications for mobile, web, and desktop from a single codebase. It uses the Dart programming language and comes with a rich set of pre-built widgets that allow for a smooth UI/UX experience.</p>\n<h4><strong>Why Choose Flutter?</strong></h4>\n<ol>\n<li><p><strong>Cross-Platform Development</strong>\nWith Flutter, you write one codebase and deploy it on multiple platforms, including Android, iOS, web, and desktop. This reduces development time and effort.</p>\n</li>\n<li><p><strong>Hot Reload for Faster Development</strong>\nOne of Flutter’s standout features is <strong>hot reload</strong>, which allows developers to see changes in real-time without restarting the app. This speeds up debugging and UI refinements.</p>\n</li>\n<li><p><strong>Beautiful UI with Widgets</strong>\nFlutter provides customizable widgets, enabling developers to create stunning and highly responsive user interfaces. Whether you’re aiming for a material design or a custom UI, Flutter makes it seamless.</p>\n</li>\n<li><p><strong>Performance Comparable to Native Apps</strong>\nUnlike other cross-platform frameworks that rely on web views, Flutter compiles directly to native ARM code, resulting in faster performance and smooth animations.</p>\n</li>\n<li><p><strong>Growing Community and Support</strong>\nGoogle actively maintains Flutter, and it has a growing community of developers worldwide. With extensive documentation, tutorials, and third-party plugins, learning and using Flutter is easier than ever.</p>\n</li>\n</ol>\n<h4><strong>Who Should Learn Flutter?</strong></h4>\n<p>Flutter is great for:</p>\n<ul>\n<li><strong>Beginners</strong> who want to start with mobile app development.</li>\n<li><strong>Web developers</strong> looking to transition into mobile development.</li>\n<li><strong>Businesses &amp; startups</strong> that want cost-effective cross-platform solutions.</li>\n<li><strong>Freelancers</strong> who want to expand their services and increase opportunities.</li>\n</ul>\n<h4><strong>Final Thoughts</strong></h4>\n<p>Flutter is a game-changer in mobile app development. Whether you’re a beginner or an experienced developer, learning Flutter can significantly boost your productivity and career prospects. In our next blog post, we’ll guide you through getting started with Flutter step by step.</p>\n<p>Lets move to the next part <a href=\"/blog/Getting-Started-with-Flutter-Step-by-Step-Guide\"> Getting-Started-with-Flutter-Step-by-Step-Guide</a></p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/Why-You-Should-Learn-Flutter-for-App-Development",
            "title": "Why You Should Learn Flutter for App Development",
            "summary": "Flutter has emerged as one of the most popular frameworks for building mobile applications. Developed by Google, it allows developers to create cross-platform apps with a single codebase.",
            "image": "https://sarvesh.xyz/images/flutter.svg",
            "date_modified": "2025-03-01T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/docker-basic-commands-cheatsheet",
            "content_html": "<p>Docker has become an indispensable tool in the world of software development and deployment. It enables developers to create, deploy, and run applications in lightweight, portable containers. Whether you&#39;re a seasoned Docker user or just getting started, having a cheat sheet of basic Docker commands can be incredibly helpful. In this guide, we&#39;ll provide you with a handy Docker command cheat sheet to keep at your fingertips.</p>\n<h2>Prerequisites</h2>\n<p>Before you dive into Docker commands, make sure you have Docker installed on your system. You can download and install Docker from the <a href=\"https://www.docker.com/get-started\">official Docker website</a>.</p>\n<h2>Docker Basics</h2>\n<h4>1. Check Docker Version</h4>\n<p>To verify that Docker is installed and see its version:</p>\n<pre><code class=\"language-bash\">docker --version\n</code></pre>\n<h4>2. Display Docker Info</h4>\n<p>For detailed information about your Docker installation:</p>\n<pre><code class=\"language-bash\">docker info\n</code></pre>\n<h4>3. List Running Containers</h4>\n<p>To see the list of running containers:</p>\n<pre><code class=\"language-bash\">docker ps\n</code></pre>\n<h4>4. List All Containers</h4>\n<p>To see all containers, including stopped ones:</p>\n<pre><code class=\"language-bash\">docker ps -a\n</code></pre>\n<h4>5. Pull Docker Image</h4>\n<p>To download a Docker image from a registry (e.g., Docker Hub):</p>\n<pre><code class=\"language-bash\">docker pull &lt;image_name&gt;\n</code></pre>\n<h4>6. Search for Docker Images</h4>\n<p>To search for Docker images on Docker Hub:</p>\n<pre><code class=\"language-bash\">docker search &lt;image_name&gt;\n</code></pre>\n<h4>7. Run a Docker Container</h4>\n<p>To start a container based on an image:</p>\n<pre><code class=\"language-bash\">docker run &lt;image_name&gt;\n</code></pre>\n<p>Add the -d flag to run the container in detached mode.</p>\n<h4>8. Stop a Running Container</h4>\n<p>To stop a running container gracefully:</p>\n<pre><code class=\"language-bash\">docker stop &lt;container_id&gt;\n</code></pre>\n<h4>9. Remove a Container</h4>\n<p>To remove a stopped container:</p>\n<pre><code class=\"language-bash\">docker rm &lt;container_id&gt;\n</code></pre>\n<h4>10. Remove an Image</h4>\n<p>To remove a Docker image:</p>\n<pre><code class=\"language-bash\">docker rmi &lt;image_name&gt;\n</code></pre>\n<h4>11. List Docker Images</h4>\n<p>To list all locally available Docker images:</p>\n<pre><code class=\"language-bash\">docker images\n</code></pre>\n<h4>12. Display Container Logs</h4>\n<p>To view the logs of a running container:</p>\n<pre><code class=\"language-bash\">docker logs &lt;container_id&gt;\n</code></pre>\n<h4>13. Execute Commands Inside a Container</h4>\n<p>To run a command inside a running container:</p>\n<pre><code class=\"language-bash\">docker exec -it &lt;container_id&gt; &lt;command&gt;\n</code></pre>\n<h4>14. Copy Files To/From a Container</h4>\n<p>To copy files to/from a container:</p>\n<pre><code class=\"language-bash\">docker cp &lt;file&gt; &lt;container_id&gt;:&lt;destination_path&gt;\n</code></pre>\n<h4>15. Inspect Container/Network/Volume</h4>\n<p>To view detailed information about a container/network/volume:</p>\n<pre><code class=\"language-bash\">docker inspect &lt;container_id&gt;/&lt;network_name&gt;/&lt;volume_name&gt;\n</code></pre>\n<h4>Conclusion</h4>\n<blockquote>\n<p>This Docker command cheat sheet provides a quick reference to essential Docker commands that every developer should be familiar with. Docker simplifies the process of building, deploying, and scaling applications, making it a valuable tool for modern software development.</p>\n</blockquote>\n<Notice type=\"note\">\nRemember that this is just the tip of the iceberg when it comes to Docker's capabilities. As you become more experienced with Docker, you'll discover many more advanced commands and features to enhance your containerization workflow. Docker's official documentation is a fantastic resource to explore those advanced topics further.\n</Notice>\n\n<h5>Happy Dockerizing! 🐋 See you in next post. Don&#39;t forget to comment your thoughts for this post. Share knowledge with others...</h5>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/docker-basic-commands-cheatsheet",
            "title": "Basic Docker Commands CheatSheet",
            "summary": "Docker is a powerful tool that has revolutionized the way applications are deployed and managed. This Docker command cheat sheet provides a quick reference to essential Docker commands that every developer should be familiar with.",
            "image": "https://sarvesh.xyz/images/docker.jpg",
            "date_modified": "2023-09-13T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/from-dockerfile-to-docker-compose-a-comprehensive-guide",
            "content_html": "<p>Containerization has revolutionized the way we develop, deploy, and manage applications. Docker has been at the forefront of this containerization movement, simplifying the process of packaging an application and its dependencies into a single, portable container. Two essential tools in the Docker ecosystem are Dockerfile and Docker Compose, each serving a distinct purpose. In this blog post, we&#39;ll delve into the differences between Dockerfile and Docker Compose, and how they complement each other.</p>\n<h3>Dockerfile: Building Container Images</h3>\n<p>A Dockerfile is like a blueprint for creating Docker container images. It contains a set of instructions that specify how to build an image. Here are some key points about Dockerfiles:</p>\n<ol>\n<li><p><strong>Definition</strong>: A Dockerfile is a text file with a set of instructions and configurations for building a Docker image.</p>\n</li>\n<li><p><strong>Purpose</strong>: Dockerfiles are used to define the environment and dependencies required for running a single containerized application.</p>\n</li>\n<li><p><strong>Structure</strong>: A Dockerfile typically starts with a base image, followed by instructions to install dependencies, copy application code, configure settings, and define the entry point.</p>\n</li>\n<li><p><strong>Reproducibility</strong>: Dockerfiles ensure the reproducibility of container builds. By sharing the Dockerfile, anyone can recreate the same container image with the exact same environment.</p>\n</li>\n<li><p><strong>Example</strong>: Here&#39;s a simple Dockerfile for a Node.js application:</p>\n</li>\n</ol>\n<pre><code class=\"language-Dockerfile\"># Use an official Node.js runtime as the base image\nFROM node:14\n\n# Set the working directory in the container\nWORKDIR /app\n\n# Copy package.json and package-lock.json to the working directory\nCOPY package*.json ./\n\n# Install application dependencies\nRUN npm install\n\n# Copy the rest of the application code\nCOPY . .\n\n# Specify the command to run the application\nCMD [&quot;node&quot;, &quot;app.js&quot;]\n</code></pre>\n<p>For more content related to Dockerfile you can check here, <a href=\"https://sarvesh.xyz/tags/docker\">blog posts on Docker</a></p>\n<h3>Docker Compose: Managing Multi-Container Applications</h3>\n<p>Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to manage complex applications consisting of multiple services with different dependencies. Here are some key points about Docker Compose:</p>\n<ol>\n<li><p><strong>Definition</strong>: Docker Compose uses a YAML file (typically named <code>docker-compose.yml</code>) to define services, their configurations, and their interconnections.</p>\n</li>\n<li><p><strong>Purpose</strong>: Docker Compose is designed for managing the orchestration of multi-container applications. It simplifies the process of running multiple containers that work together.</p>\n</li>\n<li><p><strong>Structure</strong>: A <code>docker-compose.yml</code> file specifies services, their base images, build instructions (if needed), environment variables, ports, and volumes.</p>\n</li>\n<li><p><strong>Orchestration</strong>: Docker Compose handles the entire lifecycle of multiple containers, including creating, starting, stopping, and removing them. It ensures that containers can communicate with each other easily.</p>\n</li>\n<li><p><strong>Example</strong>: Below is an example <code>docker-compose.yml</code> file for a web application with a Node.js backend and a PostgreSQL database:</p>\n</li>\n</ol>\n<pre><code class=\"language-yaml\">version: &quot;3&quot;\nservices:\n  web:\n    build: ./web\n    ports:\n      - &quot;80:3000&quot;\n    depends_on:\n      - db\n  db:\n    image: postgres:13\n    environment:\n      POSTGRES_PASSWORD: mysecretpassword\n</code></pre>\n<h3>Key Differences</h3>\n<p>Now that we&#39;ve covered the basics of Dockerfile and Docker Compose, let&#39;s highlight the key differences between them:</p>\n<ol>\n<li><p><strong>Scope</strong>: Dockerfile is used to define a single container image, while Docker Compose is used to manage multiple containers that form an application.</p>\n</li>\n<li><p><strong>Purpose</strong>: Dockerfile defines how a single container image is built, while Docker Compose orchestrates the deployment of multiple containers, handling their dependencies and interactions.</p>\n</li>\n<li><p><strong>Structure</strong>: Dockerfile is a text file with build instructions, while Docker Compose uses a YAML file to define services, networks, and volumes.</p>\n</li>\n<li><p><strong>Usage</strong>: Dockerfile is typically used during the development and build phase of an application, whereas Docker Compose is used to manage the deployment and runtime configuration.</p>\n</li>\n<li><p><strong>Reproducibility</strong>: Dockerfile ensures that a single container image can be reproduced accurately. Docker Compose ensures that an entire multi-container application can be deployed consistently.</p>\n</li>\n</ol>\n<p>Conclusion</p>\n<blockquote>\n<p>In summary, Dockerfile and Docker Compose are complementary tools in the Docker ecosystem. Dockerfile is used to build single container images, while Docker Compose is used to define and manage multi-container applications. Understanding when and how to use each tool is crucial for effectively containerizing and orchestrating your applications. By leveraging both Dockerfile and Docker Compose, you can simplify the development and deployment of containerized applications, making it easier to harness the full potential of containerization technology.</p>\n</blockquote>\n<h5>Happy Dockerizing! 🐋 See you in the next post. Don&#39;t forget to comment your thoughts on this post. Share knowledge with others…</h5>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/from-dockerfile-to-docker-compose-a-comprehensive-guide",
            "title": "From Dockerfile to Docker Compose: A Comprehensive Guide in Containerization",
            "summary": "Docker is a powerful tool that has revolutionized the way applications are deployed and managed. In this blog post we will learn about how docker compose is  use to build multiple app in single file.",
            "image": "https://sarvesh.xyz/images/whale-docker.gif",
            "date_modified": "2023-09-24T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/google-idx-new-vs-code-editor-in-cloud",
            "content_html": "<h3><strong>Introduction</strong></h3>\n<p>The landscape of software development is constantly evolving, and the introduction of <strong>Google IDX</strong> and <strong>VS Code in the Cloud</strong> brings unprecedented flexibility to developers. These tools allow for seamless cloud-based coding, supporting popular frameworks like <strong>Flutter, Next.js, and Astro</strong> without requiring complex local setups.</p>\n<p>In this guide, we’ll explore how <strong>Google IDX</strong> and <strong>VS Code Cloud</strong> revolutionize development, their key features, and how you can leverage them for efficient coding.</p>\n<hr>\n<h2><strong>What is Google IDX?</strong></h2>\n<p><strong><a href=\"https://idx.google.com/\">Google IDX</a></strong> is Google’s next-generation cloud-based IDE designed for modern web and app development. Built on <strong>Code OSS (VS Code&#39;s open-source foundation)</strong>, Google IDX integrates seamlessly with <strong>Google Cloud, Firebase, and AI-powered coding assistance</strong>.</p>\n<h3><strong>Key Features of Google IDX:</strong></h3>\n<ol>\n<li><p><strong>AI-Powered Coding Assistance</strong></p>\n<ul>\n<li>Google IDX comes with <strong>built-in AI coding suggestions</strong>, making development faster and smarter.</li>\n</ul>\n</li>\n<li><p><strong>Cloud-Based Development</strong></p>\n<ul>\n<li>No need for local setups – develop directly in the cloud with seamless <strong>containerized environments</strong>.</li>\n</ul>\n</li>\n<li><p><strong>Supports Multiple Frameworks</strong></p>\n<ul>\n<li>Native support for <strong>Flutter, Next.js, Astro, Angular, Vue.js, and more</strong>.</li>\n</ul>\n</li>\n<li><p><strong>Google Cloud Integration</strong></p>\n<ul>\n<li>Deploy directly to <strong>Google Cloud Functions, Firebase Hosting, or Kubernetes</strong>.</li>\n</ul>\n</li>\n<li><p><strong>Real-Time Collaboration</strong></p>\n<ul>\n<li>Similar to <strong>Google Docs</strong>, IDX allows multiple developers to collaborate on a project in real-time.</li>\n</ul>\n</li>\n<li><p><strong>Built-in Terminal and Debugging Tools</strong></p>\n<ul>\n<li>Run commands, debug applications, and manage dependencies seamlessly from the browser.</li>\n</ul>\n</li>\n</ol>\n<h2><strong>Getting Started with Google IDX</strong></h2>\n<ol>\n<li><p><strong>Sign Up &amp; Create a Workspace</strong></p>\n<ul>\n<li>Visit <a href=\"https://idx.google.com/\">Google IDX</a> and sign in with your Google account.</li>\n<li>Create a new workspace for your project.</li>\n</ul>\n</li>\n<li><p><strong>Select Your Tech Stack</strong></p>\n<ul>\n<li>Choose from <strong>Flutter, Next.js, Astro, Node.js, or any other framework</strong>.</li>\n</ul>\n</li>\n<li><p><strong>Develop in the Cloud</strong></p>\n<ul>\n<li>Start coding in the browser with built-in GitHub integration and AI-powered suggestions.</li>\n</ul>\n</li>\n<li><p><strong>Deploy in One Click</strong></p>\n<ul>\n<li>Deploy your application to Google Cloud, Firebase, or any preferred platform.</li>\n</ul>\n</li>\n</ol>\n<hr>\n<h2><strong>VS Code in the Cloud – A Game Changer</strong></h2>\n<p><a href=\"https://vscode.dev/\">VS Code Cloud</a> brings <strong>Microsoft’s powerful Visual Studio Code</strong> to the cloud, allowing developers to write, test, and deploy applications from any device.</p>\n<h3><strong>Why Use VS Code Cloud?</strong></h3>\n<ul>\n<li><strong>No Installation Required:</strong> Run VS Code directly in your browser.</li>\n<li><strong>GitHub &amp; Azure Integration:</strong> Seamlessly connect with repositories.</li>\n<li><strong>Supports Remote Development:</strong> Work on <strong>server-hosted environments</strong>.</li>\n<li><strong>Same Extensions as Desktop VS Code:</strong> Use all your favorite extensions.</li>\n</ul>\n<h3><strong>Best Use Cases for VS Code Cloud</strong></h3>\n<ul>\n<li><strong>Flutter Development:</strong><ul>\n<li>Install Flutter SDK in a remote container and build <strong>cross-platform mobile apps</strong>.</li>\n</ul>\n</li>\n<li><strong>Next.js &amp; Astro Development:</strong><ul>\n<li>Run modern <strong>SSR and SSG web applications</strong>.</li>\n</ul>\n</li>\n<li><strong>AI-Powered Development:</strong><ul>\n<li>Use <strong>GitHub Copilot</strong> or <strong>AI-based extensions</strong> for auto-suggestions.</li>\n</ul>\n</li>\n</ul>\n<h2><strong>Google IDX vs. VS Code Cloud – Which One Should You Use?</strong></h2>\n<table>\n<thead>\n<tr>\n<th>Feature</th>\n<th>Google IDX</th>\n<th>VS Code Cloud</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>AI Assistance</td>\n<td>✅ Built-in</td>\n<td>✅ Extensions</td>\n</tr>\n<tr>\n<td>Cloud Hosting</td>\n<td>✅ Google Cloud, Firebase</td>\n<td>❌ Requires manual setup</td>\n</tr>\n<tr>\n<td>Framework Support</td>\n<td>✅ Flutter, Next.js, Astro, Vue, etc.</td>\n<td>✅ Supports all via extensions</td>\n</tr>\n<tr>\n<td>Real-Time Collaboration</td>\n<td>✅ Yes</td>\n<td>❌ Limited</td>\n</tr>\n<tr>\n<td>GitHub Integration</td>\n<td>✅ Yes</td>\n<td>✅ Yes</td>\n</tr>\n<tr>\n<td>Extensions</td>\n<td>❌ Limited</td>\n<td>✅ Full VS Code Marketplace</td>\n</tr>\n<tr>\n<td>Debugging</td>\n<td>✅ Cloud-native tools</td>\n<td>✅ Desktop-like experience</td>\n</tr>\n</tbody></table>\n<hr>\n<h2><strong>Final Thoughts</strong></h2>\n<p>Google IDX and VS Code Cloud are transforming the development workflow. While <strong>Google IDX</strong> is an excellent choice for developers deeply integrated with <strong>Google Cloud, Firebase, and AI-driven coding</strong>, <strong>VS Code Cloud</strong> provides flexibility with its rich extension marketplace and compatibility with multiple platforms.</p>\n<p>If you&#39;re working with <strong>Flutter, Next.js, or Astro</strong>, these cloud IDEs can significantly improve your productivity.</p>\n<hr>\n<h2><strong>Let’s Connect!</strong></h2>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\">Twitter</a></li>\n<li><a href=\"https://linktr.ee/sarveshmishra\">Linktree</a></li>\n</ul>\n<p>Stay tuned for our next deep dive into <strong>AI-powered development environments</strong> and <strong>cloud-native coding best practices</strong>!</p>\n",
            "url": "https://sarvesh.xyz/blog/google-idx-new-vs-code-editor-in-cloud",
            "title": "Exploring Google’s New IDX and Advanced Cloud-Based Development with VS Code",
            "summary": "Google's new IDX and the cloud-based VS Code are revolutionizing development. Learn how these tools enhance Flutter, Next.js, Astro, and more.",
            "image": "https://sarvesh.xyz/images/google-idx.png",
            "date_modified": "2025-03-25T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/how-to-create-a-simple-server-with-python-flask",
            "content_html": "<p>Flask is one of the popular and simple-to-learn frameworks of Python to build a full-stack web app.</p>\n<p>This tutorial is the first part of the complete full-stack web app, we are going to build using Flask Framework.</p>\n<h4>Prerequisite:</h4>\n<p>Python must be installed version greater than 3.7 (i.e requirement of Flask)</p>\n<p>This tutorial is created on Ubuntu but you can run similar commands on macOS or Windows OS.</p>\n<p>Know some basics of Python language.</p>\n<p>Let&#39;s Start:</p>\n<p>Step 1. Create a folder and open it in VS Code.</p>\n<pre><code class=\"language-bash\">mkdir my-flask-app\ncd my-flask-app\ncode .\n</code></pre>\n<p>Step 2. Create a requirements.txt file.</p>\n<p>(For Python Beginner: requirements.txt or any txt file we use in Python to write on which package this project is dependent, for example here we are going to depend on the Flask package for this project, and we use this file to download those packages for the first time we start the project)</p>\n<pre><code class=\"language-bash\">touch requirements.txt\n</code></pre>\n<p>Now open this file in VS Code and add the below line</p>\n<pre><code class=\"language-txt\">flask==2.1.1\n</code></pre>\n<p>Step 3. Now create a file app.py and add the below code.</p>\n<pre><code class=\"language-python\">#app.py\n\n# importing Flask from flask package\nfrom flask import Flask\n\n# creating app from the Flask\napp = Flask(__name__)\n\n# creating base route with .route(&quot;/&quot;) and returning a p tag with Hello World\n@app.route(&quot;/&quot;)\ndef hello_world()   return &quot;&lt;p&gt;Hello, World!&lt;/p&gt;&quot;\n\n# this is to start a server on local host with port 5001\nif __name__ == &quot;__main__&quot;:\n    app.run(host=&quot;0.0.0.0&quot;, debug=True, port=5001)\n</code></pre>\n<p>Step 4: Now open a terminal and run (You can use a virtual environment if you know that already in Python otherwise, a simple command will also do the same thing)</p>\n<pre><code class=\"language-bash\">pip install -r requirements.txt\npython app.py run\n</code></pre>\n<p>Now open your browser and visit localhost:5001 and you&#39;ll see &quot;Hello World!&quot;</p>\n<p>This is the first part, in the next part we will see how to create multiple routes and render HTML pages.</p>\n<p>Thank you, and see you in the next post.</p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/how-to-create-a-simple-server-with-python-flask",
            "title": "How to create a simple server with Python Flask?",
            "summary": "Create a web server with Python using Flask web framework with simple steps. This tutorial is about creating web server with Python.",
            "image": "https://sarvesh.xyz/images/python-and-flask.gif",
            "date_modified": "2022-12-22T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/how-to-inspect-the-docker-image",
            "content_html": "<p>When it comes to Microservice architecture, the docker image is like the soul of the system. It is essential to understand the purpose of a docker image and what it contains so that you can use the right image for your needs. Whether you&#39;re browsing Docker Hub or working with legacy code, you&#39;ll encounter various types of docker images with different sizes. In my recent migration project, I had to inspect docker images carefully to ensure a smooth migration without any errors. But how do you know what&#39;s inside a docker image? Let&#39;s take a deep dive into the world of docker images...</p>\n<ol>\n<li><p><strong>Pull the Docker Image</strong>: If you haven&#39;t already, you need to pull the Docker image you want to inspect. You can do this using the <strong>docker pull</strong> command. If you are new to docker you can read basics of the docker <a href=\"https://sarvesh.xyz/blog/what-is-docker-and-its-use-case\">here</a> and basic docker commands <a href=\"https://sarvesh.xyz/blog/docker-basic-commands-cheatsheet\">here</a> For example:</p>\n<pre><code class=\"language-bash\">docker pull &lt;image_name&gt;:&lt;tag&gt;\n</code></pre>\n<p>Replace <code>&lt;image_name&gt;</code> with the name of the Docker image and <code>&lt;tag&gt;</code> with the specific version or tag you want to pull.</p>\n</li>\n<li><p><strong>Create a Temporary Container</strong>: You can create a temporary Docker container from the image you just pulled. This container will be used for inspection. Use the <code>docker run</code> command:</p>\n<pre><code class=\"language-bash\">docker run -it --name temp_container &lt;image_name&gt;:&lt;tag&gt; /bin/bash\n</code></pre>\n<p>Replace <code>&lt;image_name&gt;</code> and <code>&lt;tag&gt;</code> with the same image and tag you pulled earlier. The <code>--name</code> option assigns a name to the container, and <code>/bin/bash</code> starts an interactive shell within the container.</p>\n</li>\n<li><p><strong>Inspect the Container</strong>: Now that you have a shell inside the container, you can use standard Linux commands to inspect its contents. For example:</p>\n<ul>\n<li>To list installed packages and their versions (on Debian-based systems, like Ubuntu), you can use:</li>\n</ul>\n<pre><code class=\"language-bash\">dpkg -l\n</code></pre>\n<ul>\n<li>To list installed packages and their versions (on Red Hat-based systems, like CentOS), you can use:</li>\n</ul>\n<pre><code class=\"language-bash\">rpm -qa\n</code></pre>\n<ul>\n<li>To examine the file system, navigate to the root directory and use standard file system commands like <code>ls</code>, <code>cd</code>, and <code>cat</code> to inspect files and directories.</li>\n</ul>\n</li>\n<li><p><strong>Exit the Container</strong>: Once you&#39;ve finished inspecting the container, you can exit the interactive shell:</p>\n<pre><code class=\"language-bash\">exit\n</code></pre>\n</li>\n<li><p><strong>Cleanup</strong>: To remove the temporary container, you can use the <code>docker rm</code> command:</p>\n<pre><code class=\"language-bash\">docker rm temp_container\n</code></pre>\n</li>\n</ol>\n<p>After examining the contents of the Docker image, which includes package versions and other details, it&#39;s important to note that the commands for inspecting packages may differ based on the Linux distribution used in the Docker image (for example, Debian, Ubuntu, CentOS, etc.). To ensure accuracy, use the appropriate package manager (<code>dpkg</code> for Debian-based or <code>rpm</code> for Red Hat-based) and modify the commands accordingly.</p>\n<h5>Happy Dockerizing! 🐋 See you in next post. Don&#39;t forget to comment your thoughts for this post. Share knowledge with others...</h5>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/how-to-inspect-the-docker-image",
            "title": "How to inspect the docker image?",
            "summary": "Docker is a powerful tool that has revolutionized the way applications are deployed and managed. This Docker image inspection is the need of developer to know what is the inside of any docker image",
            "image": "https://sarvesh.xyz/images/docker.jpg",
            "date_modified": "2023-09-18T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/how-to-install-apache-spark-on-ubuntu",
            "content_html": "<p>This tutorial is for Ubuntu Users. For Windows users, you can directly install Apache Spark from the below link and start it directly on Powershell.</p>\n<p>Download the latest Spark from Apache Website <a href=\"https://spark.apache.org/downloads.html\">https://spark.apache.org/downloads.html</a></p>\n<p>Open the download folder in the terminal and run the below command to extract.</p>\n<p><code>tar xvf spark-3.3.1-bin-hadoop3.tgz</code></p>\n<p>Now move the extracted folder to /opt/spark</p>\n<p><code>sudo mv spark-3.3.1-bin-hadoop3/ /opt/spark</code></p>\n<p>Add path to .bashrc file</p>\n<p><code>export SPARK_HOME=/opt/spark export PATH=$PATH:$SPARK_HOME/bin:$SPARK_HOM/sbin</code></p>\n<p>and refresh source</p>\n<p><code>source ~/.bashrc</code></p>\n<p>Now you will be able to run all spark commands from the terminal.</p>\n<p>For example, To start the spark server with master and worker-run the below command and then enter jps and open <a href=\"http://localhost:8080\">http://localhost:8080</a> to see the spark GUI</p>\n<p><code>start-all.sh</code></p>\n<p>To run spark-shell REPL directly in the terminal run the below command</p>\n<p><code>spark-shell</code></p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/how-to-install-apache-spark-on-ubuntu",
            "title": "How to install Apache Spark on Ubuntu?",
            "summary": "Learn how to install Apache Spark on Ubuntu with this step-by-step guide. Configure paths, set up Spark, and run basic commands for data processing.",
            "image": "https://sarvesh.xyz/images/Apache-Spark.webp",
            "date_modified": "2022-12-20T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/how-to-open-vs-code-live-server-extension-web-page-on-mobile",
            "content_html": "<p>Hello guys, today I am going to write about a very productive topic if you have started learning as a Web developer and using one of our favorite Code editors as a VS Code.</p>\n<p>So, if you have ever written HTML code and wanted to see HTML magic on your browser you have used Live Server extension once in a lifetime…</p>\n<p>And this extension makes a frontend developer way more productive. But many developers don’t know how to see the same webpage on mobile because today’s web world follows a mobile-first approach to website development.</p>\n<p>So, by default Live server only enables the server for your PC not for your mobile. But there is an inside setting that let you enable this, and you can see the same page on mobile too.</p>\n<p>Prerequisite: Both PC and Mobile are on the same network.</p>\n<p>Let’s Start:</p>\n<p>Step 1:</p>\n<p>Just enable USE LOCAL IP inside the setting.json file of VS Code.</p>\n<p>&quot;liveServer.settings.useLocalIp&quot;: true\nHow can you do this?</p>\n<p>Follow Steps:</p>\n<p>Click on settings and open settings.</p>\n<p><img src=\"/images/vs-code-setting.webp\" alt=\"image\">\nClick on this little file icon to access the settings.json file.</p>\n<p><img src=\"/images/vs-code-setting-file.webp\" alt=\"image\">\nAnd you’ll have a setting JSON file just paste this line at the end and you’re done.</p>\n<p>&quot;liveServer.settings.useLocalIp&quot;: true\nNow next time when you use the live server it will open with your local IP and you can access this page by typing the same address in your mobile browser.</p>\n<p>Example Video check on my YouTube channel:</p>\n<Youtube id=\"fUuuesnwzhE\" title=\"Play:Youtube\"/>\n\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/how-to-open-vs-code-live-server-extension-web-page-on-mobile",
            "title": "How to open VS Code Live Server Extension web page on Mobile?",
            "summary": "Learn how to open VS Code Live Server Extension web page on your mobile device. A step-by-step guide for web developers using VS Code.",
            "image": "https://sarvesh.xyz/images/Vs-code.gif",
            "date_modified": "2022-12-20T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/kubernetes-vs-hashicorp-nomad",
            "content_html": "<p>In the world of modern application deployment, container orchestration has become a critical component. As organizations scale their infrastructure, the need to manage, deploy, and scale applications efficiently has led to the rise of powerful orchestration tools. Two of the most prominent names in this space are <strong>Kubernetes</strong> and <strong>HashiCorp Nomad</strong>.</p>\n<p>While both tools aim to automate the deployment, scaling, and management of containerized applications, they approach the problem with different philosophies and architectures. This article provides a comprehensive comparison to help you decide which tool best fits your needs.</p>\n<h2>Section 1: Overview of Each Tool</h2>\n<h3>Kubernetes</h3>\n<p><strong>History and Background:</strong>\nKubernetes, often abbreviated as K8s, was originally developed by Google based on their internal cluster management system, Borg. It was open-sourced in 2014 and is now maintained by the Cloud Native Computing Foundation (CNCF).</p>\n<p><strong>Core Architecture:</strong>\nKubernetes is a robust, feature-rich platform designed for container orchestration. Its architecture consists of a control plane and worker nodes. Key components include:</p>\n<ul>\n<li><strong>Nodes:</strong> The machines (virtual or physical) that run the applications.</li>\n<li><strong>Pods:</strong> The smallest deployable units created and managed by Kubernetes, which can contain one or more containers.</li>\n<li><strong>Services:</strong> An abstract way to expose an application running on a set of Pods as a network service.</li>\n</ul>\n<p><strong>Adoption:</strong>\nKubernetes has become the de facto standard for container orchestration, with widespread adoption across the industry, from startups to Fortune 500 companies.</p>\n<h3>HashiCorp Nomad</h3>\n<p><strong>History and Background:</strong>\nNomad was developed by HashiCorp and released in 2015. It is designed to be a simple, flexible, and easy-to-use orchestrator that integrates seamlessly with other HashiCorp tools like Consul and Vault.</p>\n<p><strong>Core Architecture:</strong>\nNomad focuses on simplicity. It runs as a single binary that can act as both a client and a server. Unlike Kubernetes, which focuses primarily on containers, Nomad is a general-purpose scheduler that can manage non-containerized applications, virtual machines, and batch jobs alongside Docker containers.</p>\n<p><strong>Adoption:</strong>\nWhile not as ubiquitous as Kubernetes, Nomad has a loyal following and is used by major organizations like Roblox, Cloudflare, and Pandora, particularly those who value simplicity and operational ease.</p>\n<h2>Section 2: Use Cases</h2>\n<h3>Kubernetes Use Cases</h3>\n<ul>\n<li><strong>Large-scale Microservices:</strong> Kubernetes excels in managing complex microservices architectures with hundreds or thousands of services.</li>\n<li><strong>Stateful Applications:</strong> With robust storage orchestration, K8s is suitable for running databases and other stateful workloads.</li>\n<li><strong>Multi-Cloud &amp; Hybrid Cloud:</strong> Its consistent API allows for deployment across various cloud providers and on-premise data centers.</li>\n<li><strong>Complex CI/CD:</strong> Ideally suited for environments requiring intricate continuous integration and deployment pipelines.</li>\n</ul>\n<h3>HashiCorp Nomad Use Cases</h3>\n<ul>\n<li><strong>Simple Scheduling:</strong> Perfect for teams that need to schedule batch jobs, long-running services, or cron jobs without the overhead of K8s.</li>\n<li><strong>Mixed Workloads:</strong> Unique ability to orchestrate legacy applications (Java JARs, static binaries) alongside Docker containers.</li>\n<li><strong>Fast Deployment:</strong> Ideal for companies that need to get up and running quickly with minimal operational complexity.</li>\n<li><strong>HashiCorp Ecosystem:</strong> Best for organizations already heavily invested in Consul for service mesh/discovery and Vault for secrets management.</li>\n</ul>\n<h2>Section 3: Consumer Base</h2>\n<p><strong>Target Audience:</strong></p>\n<ul>\n<li><strong>Kubernetes:</strong> Generally targets larger engineering teams with dedicated DevOps resources. It requires a significant investment in learning and maintenance but offers unparalleled power and configurability.</li>\n<li><strong>Nomad:</strong> Appeals to smaller to medium-sized teams, or large enterprises that want to reduce operational complexity. It is favored by platform teams that want to build a &quot;Golden Path&quot; without managing the complexity of Kubernetes clusters.</li>\n</ul>\n<p><strong>Case Studies:</strong></p>\n<ul>\n<li><strong>Kubernetes:</strong> Used by companies like <strong>Spotify</strong> and <strong>Airbnb</strong> to manage massive scale. Challenges often include the &quot;complexity tax&quot; where managing the cluster itself becomes a full-time job.</li>\n<li><strong>Nomad:</strong> Used by <strong>Roblox</strong> to schedule containerized and non-containerized workloads at a massive scale. The challenge addressed was the need for a unified scheduler that didn&#39;t force a complete rewrite of legacy applications into containers immediately.</li>\n</ul>\n<h2>Section 4: When to Switch from One to Another</h2>\n<h3>Moving to Kubernetes</h3>\n<p>You might consider switching to Kubernetes if:</p>\n<ul>\n<li>You need a vast ecosystem of third-party tools (Helm charts, Operators).</li>\n<li>Your team is growing, and you need the granular control and standardization K8s provides.</li>\n<li>You are running purely containerized, cloud-native applications.</li>\n</ul>\n<h3>Moving to Nomad</h3>\n<p>You might consider switching to Nomad if:</p>\n<ul>\n<li>Kubernetes complexity is slowing down your development cycles.</li>\n<li>You need to manage legacy applications that are difficult to containerize.</li>\n<li>You want a single binary deployment that is easy to upgrade and manage.</li>\n<li>You are experiencing resource overhead issues with K8s control planes.</li>\n</ul>\n<h2>Section 5: Benefits and Limitations</h2>\n<h3>Kubernetes</h3>\n<p><strong>Benefits:</strong></p>\n<ul>\n<li><strong>Rich Ecosystem:</strong> Thousands of integrations, tools, and managed services (EKS, GKE, AKS).</li>\n<li><strong>Community Support:</strong> Massive community means you can find a solution to almost any problem.</li>\n<li><strong>Standardization:</strong> Becoming the &quot;operating system&quot; of the cloud.</li>\n</ul>\n<p><strong>Limitations:</strong></p>\n<ul>\n<li><strong>Steep Learning Curve:</strong> Concepts like Pods, Ingress, PV/PVCs, and RBAC take time to master.</li>\n<li><strong>Complexity:</strong> Setting up and maintaining a production-grade cluster &quot;the hard way&quot; is difficult.</li>\n</ul>\n<h3>HashiCorp Nomad</h3>\n<p><strong>Benefits:</strong></p>\n<ul>\n<li><strong>Simplicity:</strong> Single binary, easy to understand job specifications (HCL).</li>\n<li><strong>Flexibility:</strong> Runs containers, binaries, Java, and more.</li>\n<li><strong>Lightweight:</strong> Low resource footprint compared to K8s.</li>\n</ul>\n<p><strong>Limitations:</strong></p>\n<ul>\n<li><strong>Smaller Ecosystem:</strong> Fewer third-party tools and Helm-like package managers.</li>\n<li><strong>Feature Parity:</strong> Some advanced features found in K8s (like advanced networking or autoscaling nuances) might require more manual setup or integration with Consul.</li>\n</ul>\n<h2>Comparison Video</h2>\n<p>For a visual breakdown of the differences, check out this excellent comparison by DevOps Directive:</p>\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/eyATBivtrMA\" title=\"Kubernetes vs Nomad\" frameBorder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowFullScreen></iframe>\n\n<h2>Conclusion</h2>\n<p>Choosing between Kubernetes and HashiCorp Nomad isn&#39;t about finding the &quot;best&quot; tool, but finding the right tool for your specific constraints and goals.</p>\n<ul>\n<li>Choose <strong>Kubernetes</strong> if you want the industry standard, have a team dedicated to platform engineering, and are building complex, cloud-native microservices.</li>\n<li>Choose <strong>HashiCorp Nomad</strong> if you value simplicity, need to run mixed workloads (legacy + containers), and want to minimize operational overhead.</li>\n</ul>\n<p>Before making a decision, evaluate your team&#39;s expertise, your application requirements, and your long-term infrastructure roadmap.</p>\n<p><strong>Resources:</strong></p>\n<ul>\n<li><a href=\"https://kubernetes.io/docs/home/\">Kubernetes Documentation</a></li>\n<li><a href=\"https://developer.hashicorp.com/nomad/docs\">Nomad Documentation</a></li>\n</ul>\n<h3>Let&#39;s Connect</h3>\n<p>We’d love to hear your experiences! Have you used Kubernetes or Nomad? Which one do you prefer and why? Share your thoughts in the comments below.</p>\n",
            "url": "https://sarvesh.xyz/blog/kubernetes-vs-hashicorp-nomad",
            "title": "Kubernetes vs. HashiCorp Nomad: A Comprehensive Comparison",
            "summary": "A comprehensive comparison of Kubernetes and HashiCorp Nomad, covering architecture, use cases, benefits, and limitations to help you choose the best orchestration tool.",
            "image": "https://sarvesh.xyz/images/kubernetes-vs-nomad.png",
            "date_modified": "2025-11-23T00:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/mastering-dsa-in-go-from-basics-to-advanced-patterns",
            "content_html": "<h2>Introduction</h2>\n<p>Go has rapidly become the language of choice for building robust, scalable backend infrastructure. But beyond building microservices and orchestrating containers, Go is an exceptionally powerful language for learning and applying Data Structures &amp; Algorithms (DSA). Its simplicity, combined with a pragmatic standard library, makes it a formidable tool for both competitive programming and technical interviews.</p>\n<p>One of Go&#39;s greatest strengths in DSA is its readable, self-documenting syntax. You spend less time deciphering complex language features and more time focusing on the underlying algorithmic logic. Built-in primitives like slices, maps, and goroutines map naturally to real-world DSA use cases, providing a smooth transition from theoretical concepts to practical implementation.</p>\n<p>Furthermore, Go&#39;s strong standard library—specifically packages like <code>sort</code>, <code>container/heap</code>, and <code>container/list</code>—reduces the boilerplate often required in other systems languages. Static typing catches edge cases and bugs early in the compilation process, meaning fewer runtime surprises during crucial moments like coding contests or high-pressure FAANG-style interviews.</p>\n<p>Uniquely, Go&#39;s lightweight goroutines and channels unlock concurrent algorithm design that is cumbersome or downright impossible in many other languages. Given that Go is widely used in massive backend infrastructure projects like Docker and Kubernetes, mastering DSA in Go translates directly to writing better, more efficient production code. If you are a developer looking to sharpen your algorithmic thinking while leveling up your Go skills, you are in the right place.</p>\n<hr>\n<h2>SECTION 1 — Getting Started with Go for DSA</h2>\n<p>Before diving into complex structures, setting up an efficient Go workspace and understanding its unique idioms is crucial for a smooth DSA practice experience.</p>\n<h3>Setting Up Your Go Workspace</h3>\n<p>A clean workspace allows you to switch between problems quickly. Initialize a new Go module for your DSA practice:</p>\n<pre><code class=\"language-bash\">mkdir go-dsa &amp;&amp; cd go-dsa\ngo mod init github.com/yourusername/go-dsa\n</code></pre>\n<p>Organize your folder structure by topic (e.g., <code>arrays/</code>, <code>trees/</code>, <code>graphs/</code>). This keeps your code modular and makes it easy to review past solutions. Creating a shared <code>utils/</code> package for common helper functions is also a great practice.</p>\n<h3>Essential Go Idioms for DSA</h3>\n<p>Go&#39;s design choices heavily influence how you write algorithms. Understanding these idioms is non-negotiable:</p>\n<ul>\n<li><strong>Zero Values:</strong> Go guarantees that uninitialized variables are given a useful &quot;zero value&quot; (e.g., <code>0</code> for ints, <code>&quot;&quot;</code> for strings, <code>nil</code> for pointers, slices, and maps). This eliminates a whole class of uninitialized variable bugs.</li>\n<li><strong>Slices vs. Arrays:</strong> In Go, arrays have a fixed size determined at compile time. Slices are dynamically sized, flexible views into the elements of an array. You will almost exclusively use slices for DSA.</li>\n<li><strong><code>make()</code> and <code>append()</code>:</strong> Use <code>make()</code> to pre-allocate slices and maps when you know the capacity beforehand. This prevents expensive reallocation operations. Use <code>append()</code> to dynamically add elements to a slice.</li>\n</ul>\n<h3>Efficient Input Reading</h3>\n<p>For competitive programming, standard <code>fmt.Scan</code> can be too slow for large inputs. Instead, use <code>bufio.Scanner</code> to read input efficiently.</p>\n<pre><code class=\"language-go\">package main\n\nimport (\n    &quot;bufio&quot;\n    &quot;fmt&quot;\n    &quot;os&quot;\n    &quot;strconv&quot;\n    &quot;strings&quot;\n)\n\n// Time Complexity: O(N) where N is the number of integers\n// Space Complexity: O(N) to store the input strings before parsing\nfunc main() {\n    scanner := bufio.NewScanner(os.Stdin)\n    // Increase buffer capacity for very long lines\n    const maxCapacity = 1024 * 1024\n    buf := make([]byte, maxCapacity)\n    scanner.Buffer(buf, maxCapacity)\n\n    if scanner.Scan() {\n        line := scanner.Text()\n        parts := strings.Fields(line)\n        sum := 0\n        for _, p := range parts {\n            num, _ := strconv.Atoi(p)\n            sum += num\n        }\n        fmt.Println(sum)\n    }\n}\n</code></pre>\n<h3>Writing Reusable Utility Functions</h3>\n<p>Writing utility functions like <code>min</code>, <code>max</code>, and <code>abs</code> is a rite of passage in Go. While Go 1.21+ introduced built-in <code>min</code> and <code>max</code> functions, it&#39;s still useful to know how to write them, especially if you are stuck on an older version.</p>\n<pre><code class=\"language-go\">// Pre Go 1.21 generic implementation\nfunc Min[T constraints.Ordered](a, b T) T {\n    if a &lt; b {\n        return a\n    }\n    return b\n}\n\nfunc Abs(x int) int {\n    if x &lt; 0 {\n        return -x\n    }\n    return x\n}\n</code></pre>\n<h3>Testing Your Solutions</h3>\n<p>Go&#39;s built-in <code>testing</code> package is fantastic for validating DSA solutions. Create a file ending in <code>_test.go</code> and write table-driven tests to cover edge cases thoroughly.</p>\n<pre><code class=\"language-go\">// two_sum_test.go\nfunc TestTwoSum(t *testing.T) {\n    tests := []struct {\n        nums   []int\n        target int\n        want   []int\n    }{\n        {[]int{2, 7, 11, 15}, 9, []int{0, 1}},\n        {[]int{3, 2, 4}, 6, []int{1, 2}},\n    }\n\n    for _, tt := range tests {\n        got := TwoSum(tt.nums, tt.target)\n        if !reflect.DeepEqual(got, tt.want) {\n            t.Errorf(&quot;TwoSum(%v, %d) = %v; want %v&quot;, tt.nums, tt.target, got, tt.want)\n        }\n    }\n}\n</code></pre>\n<hr>\n<h2>SECTION 2 — Core Data Structures in Go</h2>\n<p>Mastering core data structures is the foundation of any algorithmic journey. Let&#39;s look at how to implement them idiomatically in Go.</p>\n<h3>Arrays &amp; Slices</h3>\n<p>While arrays are fixed-size values in Go, slices are references to a contiguous segment of an array. A slice is essentially a struct containing a pointer to the underlying array, a length, and a capacity.</p>\n<p><strong>2D Slices:</strong> Go doesn&#39;t have true multi-dimensional arrays. Instead, you create a slice of slices.</p>\n<pre><code class=\"language-go\">// Rotating a matrix by 90 degrees clockwise\n// Time Complexity: O(N^2) where N is the dimension of the matrix\n// Space Complexity: O(1) in-place modification\nfunc rotate(matrix [][]int) {\n    n := len(matrix)\n    // Transpose\n    for i := 0; i &lt; n; i++ {\n        for j := i; j &lt; n; j++ {\n            matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]\n        }\n    }\n    // Reverse rows\n    for i := 0; i &lt; n; i++ {\n        for j, k := 0, n-1; j &lt; k; j, k = j+1, k-1 {\n            matrix[i][j], matrix[i][k] = matrix[i][k], matrix[i][j]\n        }\n    }\n}\n</code></pre>\n<h3>Strings</h3>\n<p>In Go, a string is a read-only slice of bytes. To iterate over Unicode characters, you must iterate over <code>rune</code>s (alias for <code>int32</code>).</p>\n<p>For O(1) amortized string concatenation, always use <code>strings.Builder</code>. Avoid the <code>+</code> operator in loops, as strings are immutable and it will trigger O(N^2) memory allocations.</p>\n<pre><code class=\"language-go\">import &quot;strings&quot;\n\n// Time Complexity: O(N) where N is the length of the words slice\n// Space Complexity: O(N) for the resulting string\nfunc buildSentence(words []string) string {\n    var builder strings.Builder\n    for i, word := range words {\n        builder.WriteString(word)\n        if i &lt; len(words)-1 {\n            builder.WriteByte(&#39; &#39;)\n        }\n    }\n    return builder.String()\n}\n</code></pre>\n<h3>Linked Lists</h3>\n<p>You can implement singly and doubly linked lists easily using structs. Alternatively, Go provides a built-in doubly linked list in the <code>container/list</code> package.</p>\n<pre><code class=\"language-go\">// Singly Linked List Node\ntype ListNode struct {\n    Val  int\n    Next *ListNode\n}\n\n// Reversing a linked list\n// Time Complexity: O(N)\n// Space Complexity: O(1)\nfunc reverseList(head *ListNode) *ListNode {\n    var prev *ListNode\n    curr := head\n    for curr != nil {\n        next := curr.Next\n        curr.Next = prev\n        prev = curr\n        curr = next\n    }\n    return prev\n}\n</code></pre>\n<h3>Stacks &amp; Queues</h3>\n<p>Slices are perfect for implementing stacks and queues. A stack pushes and pops from the end of the slice. A queue pushes to the end and pops from the beginning (though popping from the front of a slice is O(N)).</p>\n<p><strong>Queue using Two Stacks</strong></p>\n<p>A queue can be implemented using two stacks (slices). Push operations go to the <code>in</code> stack. For pop operations, if the <code>out</code> stack is empty, we transfer all elements from <code>in</code> to <code>out</code>, reversing their order.</p>\n<pre><code class=\"language-go\">// Queue using Two Stacks\n// Time Complexity: O(1) amortized for push/pop\n// Space Complexity: O(N)\ntype MyQueue struct {\n    in  []int\n    out []int\n}\n\nfunc (q *MyQueue) Push(x int) {\n    q.in = append(q.in, x)\n}\n\nfunc (q *MyQueue) Pop() int {\n    if len(q.out) == 0 {\n        for len(q.in) &gt; 0 {\n            q.out = append(q.out, q.in[len(q.in)-1])\n            q.in = q.in[:len(q.in)-1]\n        }\n    }\n    res := q.out[len(q.out)-1]\n    q.out = q.out[:len(q.out)-1]\n    return res\n}\n</code></pre>\n<p><strong>Monotonic Stack Pattern:</strong> Useful for finding the &quot;next greater element&quot;.</p>\n<pre><code class=\"language-go\">// Next Greater Element using a Monotonic Stack\n// Time Complexity: O(N)\n// Space Complexity: O(N)\nfunc nextGreaterElement(nums []int) []int {\n    res := make([]int, len(nums))\n    for i := range res {\n        res[i] = -1\n    }\n    stack := []int{} // stores indices\n\n    for i, num := range nums {\n        for len(stack) &gt; 0 &amp;&amp; nums[stack[len(stack)-1]] &lt; num {\n            idx := stack[len(stack)-1]\n            stack = stack[:len(stack)-1] // Pop\n            res[idx] = num\n        }\n        stack = append(stack, i) // Push\n    }\n    return res\n}\n</code></pre>\n<h3>Hash Maps &amp; Sets</h3>\n<p>Go provides built-in maps (<code>map[K]V</code>). A crucial &quot;gotcha&quot; is that writing to a <code>nil</code> map causes a panic; always initialize with <code>make()</code>.</p>\n<p>Go doesn&#39;t have a built-in Set, but you can idiomatically create one using <code>map[T]struct{}</code>. An empty struct consumes zero bytes of memory.</p>\n<pre><code class=\"language-go\">// Frequency Counting Pattern\n// Time Complexity: O(N)\n// Space Complexity: O(N)\nfunc hasDuplicate(nums []int) bool {\n    seen := make(map[int]struct{})\n    for _, num := range nums {\n        if _, exists := seen[num]; exists {\n            return true\n        }\n        seen[num] = struct{}{}\n    }\n    return false\n}\n</code></pre>\n<h3>Heaps / Priority Queues</h3>\n<p>To implement a heap, define a type that satisfies the <code>heap.Interface</code> from the <code>container/heap</code> package. This requires implementing <code>Len()</code>, <code>Less()</code>, <code>Swap()</code>, <code>Push()</code>, and <code>Pop()</code>.</p>\n<pre><code class=\"language-go\">import &quot;container/heap&quot;\n\n// An IntHeap is a min-heap of ints.\ntype IntHeap []int\n\nfunc (h IntHeap) Len() int           { return len(h) }\nfunc (h IntHeap) Less(i, j int) bool { return h[i] &lt; h[j] }\nfunc (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }\n\nfunc (h *IntHeap) Push(x interface{}) {\n    *h = append(*h, x.(int))\n}\n\nfunc (h *IntHeap) Pop() interface{} {\n    old := *h\n    n := len(old)\n    x := old[n-1]\n    *h = old[0 : n-1]\n    return x\n}\n\n// Top K Elements\n// Time Complexity: O(N log K)\n// Space Complexity: O(K)\nfunc findKthLargest(nums []int, k int) int {\n    h := &amp;IntHeap{}\n    heap.Init(h)\n    for _, num := range nums {\n        heap.Push(h, num)\n        if h.Len() &gt; k {\n            heap.Pop(h)\n        }\n    }\n    return heap.Pop(h).(int)\n}\n</code></pre>\n<hr>\n<h2>SECTION 3 — Algorithms and Patterns</h2>\n<p>Recognizing patterns is the key to solving complex algorithmic problems. Let&#39;s explore essential patterns implemented in Go.</p>\n<h3>Sorting</h3>\n<p>Go&#39;s <code>sort</code> package is highly optimized. Use <code>sort.Ints()</code>, <code>sort.Strings()</code>, or <code>sort.Slice()</code> for custom comparators.</p>\n<table>\n<thead>\n<tr>\n<th align=\"left\">Algorithm</th>\n<th align=\"left\">Best Time</th>\n<th align=\"left\">Avg Time</th>\n<th align=\"left\">Worst Time</th>\n<th align=\"left\">Space</th>\n</tr>\n</thead>\n<tbody><tr>\n<td align=\"left\">Merge Sort</td>\n<td align=\"left\">O(N log N)</td>\n<td align=\"left\">O(N log N)</td>\n<td align=\"left\">O(N log N)</td>\n<td align=\"left\">O(N)</td>\n</tr>\n<tr>\n<td align=\"left\">Quick Sort</td>\n<td align=\"left\">O(N log N)</td>\n<td align=\"left\">O(N log N)</td>\n<td align=\"left\">O(N^2)</td>\n<td align=\"left\">O(log N)</td>\n</tr>\n<tr>\n<td align=\"left\">Counting Sort</td>\n<td align=\"left\">O(N + K)</td>\n<td align=\"left\">O(N + K)</td>\n<td align=\"left\">O(N + K)</td>\n<td align=\"left\">O(K)</td>\n</tr>\n</tbody></table>\n<pre><code class=\"language-go\">import &quot;sort&quot;\n\ntype Person struct {\n    Name string\n    Age  int\n}\n\n// Time Complexity: O(N log N)\n// Space Complexity: O(log N) or O(N) depending on sort implementation\nfunc sortByAge(people []Person) {\n    sort.Slice(people, func(i, j int) bool {\n        return people[i].Age &lt; people[j].Age\n    })\n}\n</code></pre>\n<h3>Searching</h3>\n<p>For binary search, <code>sort.SearchInts</code> is available, but manually implementing it provides more flexibility, especially for the &quot;Binary Search on Answer&quot; pattern.</p>\n<pre><code class=\"language-go\">// Minimum Days to Complete Tasks (Binary Search on Answer)\n// Time Complexity: O(N log M) where M is the search space\n// Space Complexity: O(1)\nfunc minDays(weights []int, days int) int {\n    left, right := 0, 0\n    for _, w := range weights {\n        if w &gt; left {\n            left = w\n        }\n        right += w\n    }\n\n    for left &lt; right {\n        mid := left + (right-left)/2\n        if canFinish(weights, days, mid) {\n            right = mid\n        } else {\n            left = mid + 1\n        }\n    }\n    return left\n}\n\nfunc canFinish(weights []int, days, capacity int) bool {\n    daysNeeded, currentLoad := 1, 0\n    for _, w := range weights {\n        if currentLoad+w &gt; capacity {\n            daysNeeded++\n            currentLoad = w\n        } else {\n            currentLoad += w\n        }\n    }\n    return daysNeeded &lt;= days\n}\n</code></pre>\n<h3>Two Pointers</h3>\n<p>The Two Pointers pattern is elegant for traversing arrays or strings from both ends.</p>\n<pre><code class=\"language-go\">// 3Sum\n// Time Complexity: O(N^2)\n// Space Complexity: O(1) or O(N) depending on sort\nimport &quot;sort&quot;\n\nfunc threeSum(nums []int) [][]int {\n    sort.Ints(nums)\n    var res [][]int\n    for i := 0; i &lt; len(nums)-2; i++ {\n        if i &gt; 0 &amp;&amp; nums[i] == nums[i-1] {\n            continue // skip duplicates\n        }\n        left, right := i+1, len(nums)-1\n        for left &lt; right {\n            sum := nums[i] + nums[left] + nums[right]\n            if sum == 0 {\n                res = append(res, []int{nums[i], nums[left], nums[right]})\n                left++\n                right--\n                for left &lt; right &amp;&amp; nums[left] == nums[left-1] {\n                    left++\n                }\n                for left &lt; right &amp;&amp; nums[right] == nums[right+1] {\n                    right--\n                }\n            } else if sum &lt; 0 {\n                left++\n            } else {\n                right--\n            }\n        }\n    }\n    return res\n}\n</code></pre>\n<pre><code class=\"language-go\">// Container With Most Water\n// Time Complexity: O(N)\n// Space Complexity: O(1)\nfunc maxArea(height []int) int {\n    left, right := 0, len(height)-1\n    maxWater := 0\n\n    for left &lt; right {\n        h := height[left]\n        if height[right] &lt; h {\n            h = height[right]\n        }\n\n        area := h * (right - left)\n        if area &gt; maxWater {\n            maxWater = area\n        }\n\n        if height[left] &lt; height[right] {\n            left++\n        } else {\n            right--\n        }\n    }\n    return maxWater\n}\n</code></pre>\n<h3>Sliding Window</h3>\n<p>Sliding Window is indispensable for subarray problems.</p>\n<pre><code class=\"language-go\">// Maximum Sum Subarray of Size K (Fixed Window)\n// Time Complexity: O(N)\n// Space Complexity: O(1)\nfunc maxSumSubarray(arr []int, k int) int {\n    if len(arr) &lt; k {\n        return 0\n    }\n    windowSum, maxSum := 0, 0\n    for i := 0; i &lt; k; i++ {\n        windowSum += arr[i]\n    }\n    maxSum = windowSum\n\n    for i := k; i &lt; len(arr); i++ {\n        windowSum += arr[i] - arr[i-k]\n        if windowSum &gt; maxSum {\n            maxSum = windowSum\n        }\n    }\n    return maxSum\n}\n</code></pre>\n<h3>Prefix Sum &amp; Difference Array</h3>\n<p>Prefix sums allow O(1) range queries after O(N) preprocessing. Difference arrays allow O(1) range updates.</p>\n<pre><code class=\"language-go\">// Prefix Sum for Range Queries\n// Time Complexity: O(N) preprocessing, O(1) query\n// Space Complexity: O(N)\ntype NumArray struct {\n    prefix []int\n}\n\nfunc Constructor(nums []int) NumArray {\n    prefix := make([]int, len(nums)+1)\n    for i := 0; i &lt; len(nums); i++ {\n        prefix[i+1] = prefix[i] + nums[i]\n    }\n    return NumArray{prefix}\n}\n\nfunc (this *NumArray) SumRange(left int, right int) int {\n    return this.prefix[right+1] - this.prefix[left]\n}\n</code></pre>\n<h3>Recursion &amp; Backtracking</h3>\n<p>When dealing with deep recursion in Go, keep an eye on stack memory. Goroutines start with a small stack (2KB), which grows dynamically.</p>\n<pre><code class=\"language-go\">// Generate Subsets (Backtracking)\n// Time Complexity: O(N * 2^N)\n// Space Complexity: O(N) for recursion stack\nfunc subsets(nums []int) [][]int {\n    var res [][]int\n    var backtrack func(start int, current []int)\n\n    backtrack = func(start int, current []int) {\n        temp := make([]int, len(current))\n        copy(temp, current)\n        res = append(res, temp)\n\n        for i := start; i &lt; len(nums); i++ {\n            current = append(current, nums[i])\n            backtrack(i+1, current)\n            current = current[:len(current)-1]\n        }\n    }\n\n    backtrack(0, []int{})\n    return res\n}\n</code></pre>\n<hr>\n<h2>SECTION 4 — Graph Algorithms</h2>\n<p>Graphs are ubiquitous in tech interviews and backend systems. Go&#39;s maps and slices handle them beautifully.</p>\n<h3>Representation</h3>\n<p>Adjacency lists are the go-to representation. Use <code>[][]int</code> if node values are sequential integers <code>0</code> to <code>N-1</code>, or <code>map[int][]int</code> for arbitrary identifiers.</p>\n<h3>Traversal: BFS and DFS</h3>\n<p>BFS uses a queue, while DFS uses recursion (call stack) or an explicit stack.</p>\n<pre><code class=\"language-go\">// BFS Traversal\n// Time Complexity: O(V + E)\n// Space Complexity: O(V)\nfunc bfs(adjList [][]int, start int) []int {\n    visited := make(map[int]bool)\n    queue := []int{start}\n    visited[start] = true\n    var res []int\n\n    for len(queue) &gt; 0 {\n        node := queue[0]\n        queue = queue[1:] // Dequeue\n        res = append(res, node)\n\n        for _, neighbor := range adjList[node] {\n            if !visited[neighbor] {\n                visited[neighbor] = true\n                queue = append(queue, neighbor)\n            }\n        }\n    }\n    return res\n}\n</code></pre>\n<pre><code class=\"language-go\">// Detecting Cycles in Undirected Graph (DFS)\n// Time Complexity: O(V + E)\n// Space Complexity: O(V)\nfunc hasCycle(n int, edges [][]int) bool {\n    adj := make([][]int, n)\n    for _, e := range edges {\n        adj[e[0]] = append(adj[e[0]], e[1])\n        adj[e[1]] = append(adj[e[1]], e[0])\n    }\n    visited := make([]bool, n)\n\n    var dfs func(u, parent int) bool\n    dfs = func(u, parent int) bool {\n        visited[u] = true\n        for _, v := range adj[u] {\n            if !visited[v] {\n                if dfs(v, u) {\n                    return true\n                }\n            } else if v != parent {\n                return true // Cycle detected\n            }\n        }\n        return false\n    }\n\n    for i := 0; i &lt; n; i++ {\n        if !visited[i] &amp;&amp; dfs(i, -1) {\n            return true\n        }\n    }\n    return false\n}\n</code></pre>\n<h3>Shortest Path: Dijkstra&#39;s Algorithm &amp; Bellman-Ford</h3>\n<p>Dijkstra finds the shortest path from a source to all other nodes with non-negative weights, leveraging <code>container/heap</code>. For graphs with negative weights, Bellman-Ford is necessary.</p>\n<pre><code class=\"language-go\">// Bellman-Ford Algorithm\n// Time Complexity: O(V * E)\n// Space Complexity: O(V)\nfunc bellmanFord(n int, edges [][]int, src int) []int {\n    dist := make([]int, n)\n    for i := range dist {\n        dist[i] = 1e9\n    }\n    dist[src] = 0\n\n    // Relax all edges V-1 times\n    for i := 0; i &lt; n-1; i++ {\n        for _, e := range edges {\n            u, v, w := e[0], e[1], e[2]\n            if dist[u] != 1e9 &amp;&amp; dist[u]+w &lt; dist[v] {\n                dist[v] = dist[u] + w\n            }\n        }\n    }\n    // Optional: 1 more relaxation to detect negative weight cycles\n    return dist\n}\n</code></pre>\n<p>Here is a Dijkstra implementation in Go:</p>\n<pre><code class=\"language-go\">import &quot;container/heap&quot;\n\ntype Item struct {\n    node, dist, index int\n}\n\ntype PQ []*Item\n\nfunc (pq PQ) Len() int           { return len(pq) }\nfunc (pq PQ) Less(i, j int) bool { return pq[i].dist &lt; pq[j].dist }\nfunc (pq PQ) Swap(i, j int) {\n    pq[i], pq[j] = pq[j], pq[i]\n    pq[i].index = i\n    pq[j].index = j\n}\nfunc (pq *PQ) Push(x interface{}) {\n    n := len(*pq)\n    item := x.(*Item)\n    item.index = n\n    *pq = append(*pq, item)\n}\nfunc (pq *PQ) Pop() interface{} {\n    old := *pq\n    n := len(old)\n    item := old[n-1]\n    old[n-1] = nil\n    item.index = -1\n    *pq = old[0 : n-1]\n    return item\n}\n\n// Dijkstra&#39;s Algorithm\n// Time Complexity: O((V + E) log V)\n// Space Complexity: O(V)\nfunc dijkstra(n int, edges [][]int, src int) []int {\n    adj := make(map[int][][2]int) // node -&gt; [neighbor, weight]\n    for _, e := range edges {\n        u, v, w := e[0], e[1], e[2]\n        adj[u] = append(adj[u], [2]int{v, w})\n    }\n\n    dist := make([]int, n)\n    for i := range dist {\n        dist[i] = 1e9 // Infinity\n    }\n    dist[src] = 0\n\n    pq := make(PQ, 0)\n    heap.Init(&amp;pq)\n    heap.Push(&amp;pq, &amp;Item{node: src, dist: 0})\n\n    for pq.Len() &gt; 0 {\n        curr := heap.Pop(&amp;pq).(*Item)\n        u := curr.node\n        d := curr.dist\n\n        if d &gt; dist[u] {\n            continue\n        }\n\n        for _, neighbor := range adj[u] {\n            v, weight := neighbor[0], neighbor[1]\n            if dist[u]+weight &lt; dist[v] {\n                dist[v] = dist[u] + weight\n                heap.Push(&amp;pq, &amp;Item{node: v, dist: dist[v]})\n            }\n        }\n    }\n    return dist\n}\n</code></pre>\n<h3>Advanced Graphs</h3>\n<p>Topological sort is vital for dependency resolution (Kahn&#39;s algorithm). Union-Find (Disjoint Set Union) is essential for connectivity queries and Minimum Spanning Trees (Kruskal&#39;s).</p>\n<hr>\n<h2>SECTION 5 — Dynamic Programming in Go</h2>\n<p>Dynamic Programming involves breaking down problems into overlapping subproblems and applying optimal substructure.</p>\n<h3>The DP Mindset</h3>\n<p>You can approach DP top-down (Memoization) or bottom-up (Tabulation).</p>\n<h3>2D DP Template and Optimization</h3>\n<p>Often, 2D DP can be optimized to 1D space if the current state only depends on the immediately previous row.</p>\n<pre><code class=\"language-go\">// 0/1 Knapsack (Space Optimized Tabulation)\n// Time Complexity: O(N * W) where N is items, W is capacity\n// Space Complexity: O(W)\nfunc knapsack(weights []int, values []int, W int) int {\n    dp := make([]int, W+1)\n\n    for i := 0; i &lt; len(weights); i++ {\n        // Iterate backwards to avoid using the same item multiple times\n        for w := W; w &gt;= weights[i]; w-- {\n            if dp[w-weights[i]]+values[i] &gt; dp[w] {\n                dp[w] = dp[w-weights[i]] + values[i]\n            }\n        }\n    }\n    return dp[W]\n}\n</code></pre>\n<p>To identify a DP problem, look for clues asking for the &quot;minimum&quot;, &quot;maximum&quot;, &quot;longest&quot;, &quot;shortest&quot;, or &quot;number of ways&quot; to achieve something, combined with constraints that suggest making sequential decisions. If you can break the problem down into smaller instances of the same problem (optimal substructure) and you find yourself computing the same subproblems repeatedly (overlapping subproblems), it&#39;s highly likely a DP problem. (Note: other canonical problems like Matrix Chain Multiplication also fall under advanced DP patterns but are usually solved via similar tabular or memoized approaches).</p>\n<h3>Key DP Patterns and Implementations</h3>\n<p>Here are canonical DP problems implemented in Go, progressing from basic to advanced.</p>\n<p><strong>1. Fibonacci Numbers:</strong> A classic introductory DP problem. We optimize space from O(N) down to O(1) by only keeping track of the previous two states.</p>\n<pre><code class=\"language-go\">// Fibonacci (Space Optimized Tabulation)\n// Time Complexity: O(N)\n// Space Complexity: O(1)\nfunc fib(n int) int {\n    if n &lt;= 1 {\n        return n\n    }\n    prev2, prev1 := 0, 1\n    for i := 2; i &lt;= n; i++ {\n        curr := prev1 + prev2\n        prev2 = prev1\n        prev1 = curr\n    }\n    return prev1\n}\n</code></pre>\n<pre><code class=\"language-go\">// Longest Common Subsequence\n// Time Complexity: O(N * M)\n// Space Complexity: O(N * M)\nfunc longestCommonSubsequence(text1 string, text2 string) int {\n    n, m := len(text1), len(text2)\n    dp := make([][]int, n+1)\n    for i := range dp {\n        dp[i] = make([]int, m+1)\n    }\n\n    for i := 1; i &lt;= n; i++ {\n        for j := 1; j &lt;= m; j++ {\n            if text1[i-1] == text2[j-1] {\n                dp[i][j] = dp[i-1][j-1] + 1\n            } else {\n                if dp[i-1][j] &gt; dp[i][j-1] {\n                    dp[i][j] = dp[i-1][j]\n                } else {\n                    dp[i][j] = dp[i][j-1]\n                }\n            }\n        }\n    }\n    return dp[n][m]\n}\n</code></pre>\n<pre><code class=\"language-go\">// Longest Increasing Subsequence (with Binary Search)\n// Time Complexity: O(N log N)\n// Space Complexity: O(N)\nimport &quot;sort&quot;\n\nfunc lengthOfLIS(nums []int) int {\n    tails := []int{}\n    for _, x := range nums {\n        idx := sort.SearchInts(tails, x)\n        if idx == len(tails) {\n            tails = append(tails, x)\n        } else {\n            tails[idx] = x\n        }\n    }\n    return len(tails)\n}\n</code></pre>\n<pre><code class=\"language-go\">// Coin Change\n// Time Complexity: O(N * amount)\n// Space Complexity: O(amount)\nfunc coinChange(coins []int, amount int) int {\n    dp := make([]int, amount+1)\n    for i := 1; i &lt;= amount; i++ {\n        dp[i] = amount + 1\n    }\n    dp[0] = 0\n\n    for i := 1; i &lt;= amount; i++ {\n        for _, coin := range coins {\n            if i-coin &gt;= 0 &amp;&amp; dp[i-coin]+1 &lt; dp[i] {\n                dp[i] = dp[i-coin] + 1\n            }\n        }\n    }\n\n    if dp[amount] &gt; amount {\n        return -1\n    }\n    return dp[amount]\n}\n</code></pre>\n<pre><code class=\"language-go\">// Palindrome Partitioning (Partition DP / Backtracking with Memoization)\n// Time Complexity: O(N * 2^N)\n// Space Complexity: O(N) for recursion stack\nfunc partition(s string) [][]string {\n    var res [][]string\n    var path []string\n\n    isPalindrome := func(str string) bool {\n        l, r := 0, len(str)-1\n        for l &lt; r {\n            if str[l] != str[r] {\n                return false\n            }\n            l++\n            r--\n        }\n        return true\n    }\n\n    var dfs func(start int)\n    dfs = func(start int) {\n        if start == len(s) {\n            temp := make([]string, len(path))\n            copy(temp, path)\n            res = append(res, temp)\n            return\n        }\n        for i := start; i &lt; len(s); i++ {\n            if isPalindrome(s[start : i+1]) {\n                path = append(path, s[start:i+1])\n                dfs(i + 1)\n                path = path[:len(path)-1]\n            }\n        }\n    }\n\n    dfs(0)\n    return res\n}\n</code></pre>\n<hr>\n<h2>SECTION 6 — Concurrency and DSA</h2>\n<p>Go truly shines in its concurrency primitives. While rarely tested in standard DSA interviews, concurrent algorithm design is a critical skill for senior engineers.</p>\n<h3>Why Concurrency Matters in DSA</h3>\n<p>Algorithms like parallel merge sort, parallel graph traversal, or MapReduce patterns drastically reduce execution time on massive datasets by utilizing multiple cores.</p>\n<h3>Concurrent BFS / Parallel Graph Traversal</h3>\n<p>For massive graphs, standard BFS can be slow. We can parallelize traversal layer by layer using goroutines and <code>sync.WaitGroup</code>.</p>\n<pre><code class=\"language-go\">// Concurrent BFS (Layer by Layer)\n// Time Complexity: O(V + E)\n// Space Complexity: O(V)\nfunc concurrentBFS(start int, adjList map[int][]int) {\n    visited := sync.Map{}\n    visited.Store(start, true)\n\n    currentLayer := []int{start}\n\n    for len(currentLayer) &gt; 0 {\n        var wg sync.WaitGroup\n        var mu sync.Mutex\n        var nextLayer []int\n\n        for _, node := range currentLayer {\n            wg.Add(1)\n            go func(u int) {\n                defer wg.Done()\n                for _, v := range adjList[u] {\n                    if _, seen := visited.LoadOrStore(v, true); !seen {\n                        mu.Lock()\n                        nextLayer = append(nextLayer, v)\n                        mu.Unlock()\n                    }\n                }\n            }(node)\n        }\n        wg.Wait() // Wait for entire layer to finish\n        currentLayer = nextLayer\n    }\n}\n</code></pre>\n<h3>Mutex-Safe Data Structures</h3>\n<p>To build thread-safe structures, wrap standard slice operations in a <code>sync.Mutex</code>.</p>\n<pre><code class=\"language-go\">// Thread-Safe Queue\n// Time Complexity: O(1) for both Enqueue and Dequeue\n// Space Complexity: O(N)\ntype SafeQueue struct {\n    items []int\n    mu    sync.Mutex\n}\n\nfunc (q *SafeQueue) Enqueue(item int) {\n    q.mu.Lock()\n    defer q.mu.Unlock()\n    q.items = append(q.items, item)\n}\n\nfunc (q *SafeQueue) Dequeue() (int, bool) {\n    q.mu.Lock()\n    defer q.mu.Unlock()\n    if len(q.items) == 0 {\n        return 0, false\n    }\n    item := q.items[0]\n    q.items = q.items[1:]\n    return item, true\n}\n</code></pre>\n<h3>Concurrent Word Frequency Counter</h3>\n<p>Using goroutines, wait groups, and channels allows us to process data pipelines efficiently.</p>\n<pre><code class=\"language-go\">package main\n\nimport (\n    &quot;fmt&quot;\n    &quot;strings&quot;\n    &quot;sync&quot;\n)\n\n// Time Complexity: O(N) overall processing, split across workers\n// Space Complexity: O(U) where U is the number of unique words\nfunc concurrentWordCount(texts []string) map[string]int {\n    var wg sync.WaitGroup\n    wordChan := make(chan string, 100)\n    counts := make(map[string]int)\n\n    // Mutex to protect map writes\n    var mu sync.Mutex\n\n    // Worker Goroutines\n    workerCount := 4\n    for i := 0; i &lt; workerCount; i++ {\n        wg.Add(1)\n        go func() {\n            defer wg.Done()\n            for word := range wordChan {\n                mu.Lock()\n                counts[word]++\n                mu.Unlock()\n            }\n        }()\n    }\n\n    // Producer\n    for _, text := range texts {\n        words := strings.Fields(text)\n        for _, w := range words {\n            wordChan &lt;- strings.ToLower(w)\n        }\n    }\n    close(wordChan)\n\n    // Wait for all workers to finish\n    wg.Wait()\n    return counts\n}\n</code></pre>\n<p>Mutexes (<code>sync.Mutex</code>) are essential for thread-safe data structures. For highly concurrent reads/writes on maps, <code>sync.Map</code> provides optimized performance.</p>\n<hr>\n<h2>SECTION 7 — Practice Tips</h2>\n<p>Mastering DSA requires structured, consistent practice.</p>\n<ul>\n<li><strong>Recommended Progression:</strong> Arrays → Strings → Linked Lists → Stacks/Queues → Trees → Graphs → Dynamic Programming. Don&#39;t rush; build a solid foundation.</li>\n<li><strong>Where to Practice:</strong> LeetCode perfectly supports Go. Codeforces and AtCoder are excellent for pushing your limits.</li>\n<li><strong>Go-Specific Tooling:</strong> Always validate the performance of your implementations. Use <code>go test -bench</code> to benchmark different approaches and <code>pprof</code> to profile CPU and memory usage of complex algorithms.</li>\n<li><strong>Reading List:</strong> While &quot;Introduction to Algorithms&quot; (CLRS) provides theory, studying the source code of Go&#39;s standard library (e.g., <code>sort.go</code>) offers incredible insights into production-grade algorithm implementation.</li>\n</ul>\n<p>Go&#39;s strict yet simple syntax means you spend less time fighting language idiosyncrasies and more time thinking deeply about the problem at hand. Happy coding!</p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target=\"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target=\"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target=\"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target=\"_blank\">Twitter</a></li>\n<li><a href=\"https://linktr.ee/sarveshmishra\" target=\"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/mastering-dsa-in-go-from-basics-to-advanced-patterns",
            "title": "Mastering DSA in Go: From Basics to Advanced Patterns",
            "summary": "A comprehensive, developer-friendly guide to mastering Data Structures and Algorithms in Go. Learn core structures, advanced patterns, graph algorithms, DP, and concurrency.",
            "image": "https://sarvesh.xyz/images/golang.png",
            "date_modified": "2026-05-07T00:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/mastering-dsa-in-python-from-basics-to-advanced-patterns",
            "content_html": "<h2>INTRODUCTION</h2>\n<p>Python has firmly established itself as one of the best languages for learning, applying, and mastering Data Structures and Algorithms (DSA). For developers and engineers aiming to crack technical interviews at top-tier companies, Python’s clean, pseudocode-like syntax is an absolute game-changer. It allows you to focus your cognitive energy on the logic and structure of the algorithm itself, rather than getting bogged down by the verbose language-specific boilerplate found in languages like Java or C++. When you are trying to implement a complex graph traversal under time pressure, fewer lines of code directly translate to fewer opportunities for syntax errors.</p>\n<p>Beyond its elegant syntax, Python ships with a rich set of highly optimized, battle-tested built-in data structures. Lists, dictionaries, sets, and tuples are available right out of the box, implemented in C, and highly optimized for everyday use cases. When standard structures fall short, Python&#39;s standard library steps in. The <code>collections</code> module provides specialized container datatypes like <code>deque</code>, <code>Counter</code>, and <code>defaultdict</code> that eliminate the need to manually implement these structures. Need a heap? The <code>heapq</code> module has you covered. Need binary search? The <code>bisect</code> module is ready. This means you have an entire DSA toolkit available without installing any third-party libraries.</p>\n<p>Furthermore, Python&#39;s feature set—including list comprehensions, generator expressions, and advanced slicing—makes array manipulation incredibly elegant and concise. The dynamic typing system paired with an interactive REPL (Read-Eval-Print Loop) creates a workflow that is perfect for visualizing, prototyping, and debugging algorithms iteratively. You can instantly test an edge case for your dynamic programming solution without waiting for a compilation step.</p>\n<p>Finally, Python is the dominant language in the fields of Machine Learning, Artificial Intelligence, and Data Engineering. The algorithmic problem-solving skills and data manipulation patterns you build while practicing DSA in Python will transfer directly into building real-world, high-performance data pipelines and AI models. Moreover, it is universally accepted on every major competitive programming platform and in almost every FAANG interview setting. Mastering DSA in Python is not just an academic exercise; it is an investment in your practical engineering toolkit.</p>\n<hr>\n<h2>SECTION 1 — Getting Started with Python for DSA</h2>\n<h3>Setting Up a Python DSA Workspace</h3>\n<p>Setting up an effective workspace is the crucial first step for focused algorithm practice. I highly recommend organizing your practice repository logically. Create a dedicated directory structured by topic—such as <code>arrays/</code>, <code>strings/</code>, <code>graphs/</code>, <code>dp/</code>, and <code>trees/</code>. Inside each directory, maintain an <code>__init__.py</code> if you wish to share code across files, and create a <code>utils.py</code> file in the root for shared helper functions (like a function that converts an array into a linked list for easy testing). Use a virtual environment to manage any external packages like <code>pytest</code> or <code>jupyter</code> to keep your environment clean.</p>\n<p>Regarding the Python version, stick to Python 3.10 or newer. Python 3.10 introduced structural pattern matching (<code>match</code> statements), which can be quite elegant for certain parsers or state machine implementations. Even better, use Python 3.12 or newer to take advantage of the significant performance improvements made to the underlying CPython interpreter.</p>\n<h3>Reading Input Efficiently</h3>\n<p>When dealing with competitive programming platforms (like Codeforces or HackerRank) or processing massive datasets, standard I/O functions can become a severe bottleneck. The standard <code>input()</code> function in Python strips trailing whitespace and adds overhead that can lead to Time Limit Exceeded (TLE) errors. Instead, the idiomatic approach is to use <code>sys.stdin.readline</code>. It reads the entire line including the newline character, and it is significantly faster.</p>\n<pre><code class=\"language-python\">import sys\n\n# Efficiently read multiple integers from a single line\n# Time Complexity: O(N) where N is the number of integers read\n# Space Complexity: O(N) to store the resulting list\ninput_line = sys.stdin.readline()\nif input_line:\n    # Use map to apply int() to every split string element\n    numbers = list(map(int, input_line.split()))\n    print(sum(numbers))\n</code></pre>\n<h3>Writing Reusable Utility Snippets</h3>\n<p>Creating reusable utility snippets will save you precious minutes during interviews or timed contests. A very common pattern is initializing variables to infinity for graph algorithms (like Dijkstra&#39;s) or dynamic programming problems. Using <code>INF = float(&#39;inf&#39;)</code> is the standard approach.</p>\n<p>For top-down dynamic programming, Python’s <code>functools</code> module provides the absolute killer feature: memoization decorators. Using <code>@functools.lru_cache(None)</code> or the newer, simpler <code>@cache</code> decorator (available from Python 3.9+) automatically caches the results of function calls based on their arguments. This eliminates the need to manually pass around and update memoization dictionaries or 2D arrays, turning complex recursive solutions into optimized DP solutions with a single line of code.</p>\n<h3>Testing and Visualization</h3>\n<p>To ensure your solutions are robust, leverage Python&#39;s built-in <code>unittest</code> module or the more flexible third-party <code>pytest</code> framework. Using parameterized testing allows you to feed multiple test cases (including edge cases) into your solution function automatically. For algorithm visualization, step-by-step debugging, and exploring data structures, Jupyter notebooks and the interactive Python REPL are invaluable tools. You can print the state of your variables at each iteration, which drastically speeds up the debugging process.</p>\n<hr>\n<h2>SECTION 2 — Core Data Structures in Python</h2>\n<h3>Data Structure Comparison</h3>\n<p>Before diving deep, let&#39;s look at a quick comparison of linear data structures in Python to understand when to use what:</p>\n<table>\n<thead>\n<tr>\n<th>Structure</th>\n<th>Append (End)</th>\n<th>Pop (End)</th>\n<th>Insert (Front)</th>\n<th>Pop (Front)</th>\n<th>Indexed Access</th>\n<th>Primary Use Case</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><strong>List</strong></td>\n<td>O(1) amortized</td>\n<td>O(1)</td>\n<td>O(n)</td>\n<td>O(n)</td>\n<td>O(1)</td>\n<td>Dynamic Arrays, Stacks</td>\n</tr>\n<tr>\n<td><strong>Deque</strong></td>\n<td>O(1)</td>\n<td>O(1)</td>\n<td>O(1)</td>\n<td>O(1)</td>\n<td>O(n)</td>\n<td>Queues, Sliding Windows</td>\n</tr>\n<tr>\n<td><strong>Array</strong> (<code>array.array</code>)</td>\n<td>O(1) amortized</td>\n<td>O(1)</td>\n<td>O(n)</td>\n<td>O(n)</td>\n<td>O(1)</td>\n<td>Memory-efficient primitives</td>\n</tr>\n</tbody></table>\n<h3>Lists (Dynamic Arrays)</h3>\n<p>Python&#39;s built-in <code>list</code> is not a traditional linked list; it is a dynamic array implemented in C. It relies on a strategy of over-allocation. When the array fills up, Python allocates a larger block of memory and copies the elements over. This guarantees an amortized O(1) append time.</p>\n<p>Lists are incredibly versatile. You can use slicing tricks to reverse arrays (<code>arr[::-1]</code>), rotate elements, or extract sublists. However, slicing creates shallow copies, requiring O(k) time where k is the slice length. Lists make perfect Stacks (using <code>append()</code> and <code>pop()</code>), but they are terrible Queues. Removing from the front of a list (<code>pop(0)</code>) requires shifting every subsequent element left by one index, which is an O(n) operation.</p>\n<pre><code class=\"language-python\"># Reversing and Rotating using Slicing\n# Time: O(n) for slice creation, Space: O(n) for new list\narr = [1, 2, 3, 4, 5]\nreversed_arr = arr[::-1]       # [5, 4, 3, 2, 1]\nrotate_left = arr[1:] + arr[:1] # [2, 3, 4, 5, 1]\n\n# 2D List Initialization (Beware of shallow copies!)\n# Time: O(rows * cols), Space: O(rows * cols)\nrows, cols = 3, 3\ngrid = [[0 for _ in range(cols)] for _ in range(rows)]\n</code></pre>\n<h3>Strings</h3>\n<p>Strings in Python are immutable. Every time you modify a string, Python allocates memory for a completely new string object. This is why using the <code>+=</code> operator inside a loop to build a string results in quadratic O(n²) time complexity—the entire string is copied repeatedly.</p>\n<p>The idiomatic, highly optimized pattern for string building is to append characters to a list and use <code>&#39;&#39;.join()</code>. This operates in linear O(n) time. String slicing is also prevalent for palindrome checks, and <code>collections.Counter</code> is the go-to tool for anagram detection.</p>\n<pre><code class=\"language-python\">from collections import Counter\n\n# O(n) String Building\n# Time: O(n), Space: O(n)\nparts = [&#39;A&#39;, &#39;l&#39;, &#39;g&#39;, &#39;o&#39;, &#39;r&#39;, &#39;i&#39;, &#39;t&#39;, &#39;h&#39;, &#39;m&#39;]\nresult = &#39;&#39;.join(parts)\n\n# Anagram Check using Counter\n# Time: O(n), Space: O(n) to store frequencies\ndef is_anagram(s1: str, s2: str) -&gt; bool:\n    return Counter(s1) == Counter(s2)\n</code></pre>\n<h3>Linked Lists</h3>\n<p>Python doesn&#39;t have a built-in Linked List type, but implementing singly or doubly linked lists using custom classes is straightforward. In practice, if you merely need O(1) insertions and deletions at both ends without custom node pointers, <code>collections.deque</code> acts as a highly optimized, thread-safe, doubly linked list under the hood.</p>\n<p>For algorithm problems specifically asking for Linked Lists, the most critical pattern is the fast/slow pointer technique (Floyd’s Cycle Detection), used to find cycles or the middle node.</p>\n<pre><code class=\"language-python\">class ListNode:\n    def __init__(self, val=0, next=None):\n        self.val = val\n        self.next = next\n\n# Floyd&#39;s Cycle Detection (Fast/Slow Pointers)\n# Time: O(n), Space: O(1)\ndef has_cycle(head: ListNode) -&gt; bool:\n    slow, fast = head, head\n    while fast and fast.next:\n        slow = slow.next\n        fast = fast.next.next\n        if slow == fast:\n            return True # Cycle detected\n    return False\n</code></pre>\n<h3>Stacks &amp; Queues</h3>\n<p>As established, a Python <code>list</code> is your stack. Use <code>append()</code> to push and <code>pop()</code> to pop. For queues, always import <code>collections.deque</code> and use <code>append()</code> to enqueue and <code>popleft()</code> to dequeue (both O(1)). Python also has a <code>queue.Queue</code> module, but this is designed for thread-safe communication in concurrent programming and introduces unnecessary overhead for standard DSA problems.</p>\n<p>The Monotonic Stack is an advanced pattern where elements in the stack remain entirely in increasing or decreasing order. It is perfectly suited for &quot;Next Greater Element&quot; problems.</p>\n<pre><code class=\"language-python\"># Monotonic Stack for Next Greater Element\n# Time: O(n) since each element is pushed and popped at most once\n# Space: O(n) to store the stack and result array\ndef next_greater_element(nums):\n    res = [-1] * len(nums)\n    stack = [] # stores indices\n    for i, num in enumerate(nums):\n        while stack and nums[stack[-1]] &lt; num:\n            idx = stack.pop()\n            res[idx] = num\n        stack.append(i)\n    return res\n</code></pre>\n<h3>Hash Maps &amp; Sets</h3>\n<p>Python’s <code>dict</code> is a robust hash table implementation. Since Python 3.7, dictionaries are guaranteed to maintain insertion order. To avoid verbose <code>if key not in dict</code> checks, use <code>collections.defaultdict</code>. It automatically initializes missing keys with a default factory (like <code>int</code> for 0, or <code>list</code> for an empty list), making it ideal for frequency maps and graph adjacency lists.</p>\n<p>Sets in Python (<code>set</code>) are hash maps without values. They support rapid O(1) membership testing and mathematical operations like union (<code>|</code>), intersection (<code>&amp;</code>), and difference (<code>-</code>), which are often the key to elegant solutions in array deduplication problems.</p>\n<pre><code class=\"language-python\">from collections import defaultdict\n\n# Using defaultdict for graph adjacency list\n# Time: O(V + E) to build graph, Space: O(V + E)\nedges = [(1, 2), (1, 3), (2, 4)]\ngraph = defaultdict(list)\nfor u, v in edges:\n    graph[u].append(v)\n    graph[v].append(u) # For undirected graphs\n\n# Set Operations\n# Time: O(min(len(s1), len(s2))) for intersection, Space: O(min(len(s1), len(s2)))\ns1, s2 = {1, 2, 3}, {2, 3, 4}\nintersection = s1 &amp; s2 # {2, 3}\n</code></pre>\n<h3>Heaps / Priority Queues</h3>\n<p>The <code>heapq</code> module provides functions to manipulate standard lists as binary min-heaps. Pushing (<code>heappush</code>) and popping (<code>heappop</code>) operate in O(log n) time. To create a max-heap, Python does not have a built-in flag; instead, the standard trick is to negate numeric values before pushing them, and negate them again upon popping.</p>\n<p>For finding the largest or smallest elements without fully sorting, use <code>heapq.nlargest()</code> or <code>heapq.nsmallest()</code>. For complex data, you can push tuples onto the heap following the <code>(priority, value)</code> pattern. Python compares tuples element by element.</p>\n<pre><code class=\"language-python\">import heapq\n\n# Max-heap trick and K Closest Points to Origin\n# Time: O(N log K), Space: O(K)\ndef k_closest(points, k):\n    max_heap = []\n    for x, y in points:\n        dist = -(x*x + y*y) # Negate for max-heap behavior\n        if len(max_heap) == k:\n            heapq.heappushpop(max_heap, (dist, x, y))\n        else:\n            heapq.heappush(max_heap, (dist, x, y))\n\n    return [[x, y] for _, x, y in max_heap]\n</code></pre>\n<h3>Deque &amp; Monotonic Deque</h3>\n<p>A Deque (Double Ended Queue) can be initialized with a maximum length (<code>deque(maxlen=k)</code>). When the queue reaches <code>maxlen</code>, appending to one end automatically discards the item at the opposite end. This is a very niche but useful feature for sliding windows.</p>\n<p>More complex is the Monotonic Deque, often used to find the maximum in a sliding window efficiently.</p>\n<pre><code class=\"language-python\">from collections import deque\n\n# Sliding Window Maximum using Monotonic Deque\n# Time: O(n) because each element is added/removed to deque at most once\n# Space: O(k) for the deque\ndef max_sliding_window(nums, k):\n    q = deque() # Stores indices, values monotonically decreasing\n    res = []\n    for i, n in enumerate(nums):\n        # Remove elements smaller than current element\n        while q and nums[q[-1]] &lt; n:\n            q.pop()\n        q.append(i)\n\n        # Remove elements outside the window\n        if q[0] == i - k:\n            q.popleft()\n\n        # Add to result once window reaches size k\n        if i &gt;= k - 1:\n            res.append(nums[q[0]])\n    return res\n</code></pre>\n<hr>\n<h2>SECTION 3 — Algorithms and Patterns</h2>\n<h3>Sorting</h3>\n<p>Python offers two primary ways to sort: <code>list.sort()</code> (which sorts the array in-place and returns <code>None</code>) and <code>sorted()</code> (which takes an iterable and returns a new sorted list). Both methods are incredibly fast because they use Timsort, a hybrid algorithm derived from merge sort and insertion sort. Timsort is stable and optimized to find and leverage existing ordered runs in real-world data, often achieving better than O(n log n) time on partially sorted lists.</p>\n<p>For custom sorting criteria, pass a lambda function to the <code>key</code> parameter. If you need complex comparison logic that depends on comparing two elements (like in Java&#39;s Comparator), use <code>functools.cmp_to_key</code>.</p>\n<p>For bounded ranges (e.g., sorting ages or test scores), Counting Sort or Bucket Sort provide O(n) time complexity by trading off memory.</p>\n<pre><code class=\"language-python\">from functools import cmp_to_key\n\n# Custom Sort using cmp_to_key\n# Time: O(n log n), Space: O(n) for sorted array\ndef custom_compare(x, y):\n    # Sort by absolute value, then descending\n    if abs(x) != abs(y):\n        return abs(x) - abs(y)\n    return y - x\n\narr = [-5, 2, -2, 5, 1]\nsorted_arr = sorted(arr, key=cmp_to_key(custom_compare))\n# Result: [2, -2, 5, -5, 1] based on custom logic\n</code></pre>\n<h3>Searching</h3>\n<p>Binary search operates in O(log n) time. While you can implement it manually, the <code>bisect</code> module is faster and less prone to off-by-one errors. <code>bisect.bisect_left</code> finds the first suitable insertion point to maintain sorted order, effectively finding the first occurrence of a value. <code>bisect.bisect_right</code> finds the insertion point after identical elements.</p>\n<p>When manual implementation is necessary—such as the &quot;Binary Search on Answer&quot; pattern where you search over a range of possible solutions (e.g., minimum days, minimum capacity)—a standard template helps avoid infinite loops.</p>\n<pre><code class=\"language-python\"># Manual Binary Search Template (Binary Search on Answer)\n# Time: O(N log(Max_Capacity)), Space: O(1)\ndef shipWithinDays(weights, days):\n    left, right = max(weights), sum(weights)\n\n    def can_ship(capacity):\n        ships, curr = 1, 0\n        for w in weights:\n            if curr + w &gt; capacity:\n                ships += 1\n                curr = 0\n            curr += w\n        return ships &lt;= days\n\n    ans = right\n    while left &lt;= right:\n        mid = (left + right) // 2\n        if can_ship(mid):\n            ans = mid\n            right = mid - 1 # Try to find a smaller capacity\n        else:\n            left = mid + 1  # Capacity too small, increase it\n    return ans\n</code></pre>\n<h3>Two Pointers</h3>\n<p>The two-pointer technique is a classic for arrays and strings. Python’s tuple packing and unpacking make pointer updates exceptionally clean, allowing you to swap values or increment/decrement simultaneously without temporary variables. The pattern is famously used in problems like &quot;Container With Most Water&quot; and &quot;3Sum&quot;.</p>\n<pre><code class=\"language-python\"># 3Sum using Sorting and Two Pointers\n# Time: O(n^2), Space: O(n) for sorting (Timsort)\ndef three_sum(nums):\n    nums.sort()\n    res = []\n    for i, a in enumerate(nums):\n        if i &gt; 0 and a == nums[i - 1]:\n            continue # Skip duplicates\n        l, r = i + 1, len(nums) - 1\n        while l &lt; r:\n            three_sum = a + nums[l] + nums[r]\n            if three_sum &gt; 0:\n                r -= 1\n            elif three_sum &lt; 0:\n                l += 1\n            else:\n                res.append([a, nums[l], nums[r]])\n                l += 1\n                while nums[l] == nums[l - 1] and l &lt; r:\n                    l += 1\n    return res\n</code></pre>\n<h3>Sliding Window</h3>\n<p>Sliding window problems process contiguous subsegments. A fixed window aggregates data over a set length, while a variable window expands and shrinks based on a specific condition. Python&#39;s <code>defaultdict</code> or <code>Counter</code> are often used to track the state inside the window.</p>\n<pre><code class=\"language-python\"># Variable Sliding Window: Longest Substring with At Most K Distinct Characters\n# Time: O(n), Space: O(k)\ndef length_of_longest_substring_k_distinct(s, k):\n    window_counts = {}\n    left, max_len = 0, 0\n\n    for right, char in enumerate(s):\n        window_counts[char] = window_counts.get(char, 0) + 1\n\n        while len(window_counts) &gt; k:\n            left_char = s[left]\n            window_counts[left_char] -= 1\n            if window_counts[left_char] == 0:\n                del window_counts[left_char]\n            left += 1\n\n        max_len = max(max_len, right - left + 1)\n\n    return max_len\n</code></pre>\n<h3>Prefix Sum &amp; Difference Array</h3>\n<p>Prefix sums allow O(1) range sum queries after an O(n) pre-computation pass. <code>itertools.accumulate</code> makes generating these arrays trivial. A Difference Array is a related pattern used when you need to apply numerous range updates (e.g., add <code>val</code> to indices <code>i</code> through <code>j</code>) in O(1) time. You update <code>diff[i] += val</code> and <code>diff[j+1] -= val</code>, and eventually reconstruct the final array by computing the prefix sum of the difference array. 2D prefix sums follow a similar logic for matrix subgrid queries.</p>\n<h3>Recursion &amp; Backtracking</h3>\n<p>Python makes recursive backtracking highly intuitive. The general pattern involves making a choice, recursing, and then undoing the choice (backtracking). Always be aware of Python&#39;s default recursion limit (usually 1000). If you expect deeper recursion, call <code>sys.setrecursionlimit(10**6)</code>.</p>\n<p>For standard combinatorial problems, the standard library offers shortcuts. <code>itertools.permutations</code> and <code>itertools.combinations</code> can often replace dozens of lines of manual backtracking code in an interview context, though you should be prepared to write them from scratch if asked.</p>\n<h3>Greedy Algorithms</h3>\n<p>Greedy algorithms make the locally optimal choice at each step, hoping it leads to a global optimum. Problems like &quot;Activity Selection&quot; or &quot;Interval Scheduling&quot; are canonical greedy problems. The solution almost always involves using <code>sorted()</code> with a custom <code>key</code> to establish a specific processing order, followed by a linear scan. Other classic greedy problems include the &quot;Jump Game&quot; and &quot;Gas Station&quot; scenarios.</p>\n<hr>\n<h2>SECTION 4 — Graph Algorithms</h2>\n<h3>Representation</h3>\n<p>The most common and efficient way to represent a graph in Python is the Adjacency List. Using <code>collections.defaultdict(list)</code> handles missing keys gracefully. If the graph requires unique edges, <code>defaultdict(set)</code> is preferable. For weighted graphs, the list holds tuples representing <code>(neighbor_node, edge_weight)</code>.</p>\n<p>Edge lists (a simple list of <code>[u, v, weight]</code> arrays) are used primarily for algorithms like Kruskal&#39;s or Bellman-Ford. Adjacency matrices (a 2D array) are mostly reserved for dense graphs or specifically for the Floyd-Warshall algorithm.</p>\n<h3>Traversal</h3>\n<p>Breadth-First Search (BFS) explores graphs level by level. It must be implemented iteratively using <code>collections.deque</code>. Depth-First Search (DFS) explores as deep as possible and is typically implemented using recursion.</p>\n<p>Cycle detection in directed graphs utilizes a three-color DFS marking states as <code>0</code> (unvisited), <code>1</code> (visiting/in current path stack), and <code>2</code> (fully visited). If a DFS traversal encounters a node marked <code>1</code>, a back-edge exists, indicating a cycle. In undirected graphs, cycles can be found via simple DFS keeping track of the parent node, or by utilizing a Union-Find data structure.</p>\n<h3>Shortest Path</h3>\n<p>Dijkstra’s algorithm finds the shortest path from a source to all other nodes in a graph with non-negative edge weights. Python&#39;s <code>heapq</code> module is exceptionally well-suited for managing the required priority queue.</p>\n<pre><code class=\"language-python\">import heapq\nfrom collections import defaultdict\n\n# Dijkstra&#39;s Algorithm\n# Time: O((V + E) log V), Space: O(V + E)\ndef dijkstra(n, edges, start):\n    graph = defaultdict(list)\n    for u, v, w in edges:\n        graph[u].append((v, w))\n\n    distances = {i: float(&#39;inf&#39;) for i in range(n)}\n    distances[start] = 0\n    # Priority Queue stores tuples of (current_distance, node)\n    pq = [(0, start)]\n\n    while pq:\n        curr_dist, u = heapq.heappop(pq)\n\n        # Optimization: skip if we&#39;ve already found a shorter path\n        if curr_dist &gt; distances[u]:\n            continue\n\n        for v, weight in graph[u]:\n            dist = curr_dist + weight\n            if dist &lt; distances[v]:\n                distances[v] = dist\n                heapq.heappush(pq, (dist, v))\n\n    return distances\n</code></pre>\n<p>For graphs containing negative edge weights, Bellman-Ford algorithm is required. It iteratively relaxes all edges V-1 times. An additional V-th relaxation pass detects negative weight cycles. Floyd-Warshall handles all-pairs shortest paths using dynamic programming, operating in O(V³) time. In data science applications with massive graphs, libraries like <code>numpy</code> or <code>scipy.sparse.csgraph</code> execute these algorithms much faster than native Python loops.</p>\n<h3>Advanced Algorithms</h3>\n<ul>\n<li><strong>Topological Sort:</strong> Essential for scheduling tasks with dependencies. Kahn’s algorithm uses BFS tracking node in-degrees, while the DFS approach collects nodes in a post-order traversal and reverses the final list.</li>\n<li><strong>Union-Find (Disjoint Set Union):</strong> A beautiful data structure for tracking connected components. Implementing path compression and union by rank yields nearly O(1) operations (Inverse Ackermann function time).</li>\n<li><strong>Minimum Spanning Tree:</strong> Prim&#39;s algorithm expands a tree greedily using a min-heap (<code>heapq</code>). Kruskal&#39;s algorithm sorts all edges and connects them using Union-Find to avoid creating cycles.</li>\n<li><strong>Multi-source BFS:</strong> A variation where the queue is initialized with multiple starting nodes (e.g., the Rotting Oranges problem or 0-1 Matrix distance). This evaluates the shortest path from <em>any</em> of the sources simultaneously.</li>\n</ul>\n<hr>\n<h2>SECTION 5 — Dynamic Programming in Python</h2>\n<p>Dynamic Programming (DP) is often the most feared topic in technical interviews, but Python’s features drastically reduce the friction of implementing DP solutions. The DP mindset requires identifying overlapping subproblems and an optimal substructure.</p>\n<h3>Top-Down Memoization with <code>@cache</code></h3>\n<p>Top-down DP (Memoization) is where Python genuinely feels like cheating. Instead of manually creating dictionaries to store previously calculated states, you define a purely recursive function and add the <code>@cache</code> decorator (or <code>@functools.lru_cache(None)</code> for older Python versions). Python automatically handles caching the return values based on the function arguments. This collapses 20 lines of state-management boilerplate into exactly two lines.</p>\n<pre><code class=\"language-python\">from functools import cache\n\n# Fibonacci with @cache\n# Time: O(n), Space: O(n) due to recursion stack and cache\n@cache\ndef fib(n):\n    if n &lt;= 1:\n        return n\n    return fib(n-1) + fib(n-2)\n</code></pre>\n<h3>Bottom-Up Tabulation and Space Optimization</h3>\n<p>While <code>@cache</code> is immensely elegant, deep recursion can hit Python&#39;s recursion limit, and caching function overhead can consume significant memory. Bottom-up tabulation constructs the answer iteratively using an array. When the current state only depends on a few previous states, you can heavily optimize the space complexity.</p>\n<pre><code class=\"language-python\"># 2D DP Tabulation Template with Space Optimization Pattern\n# e.g., computing a grid where current row depends only on the previous row\n# Time: O(n * m), Space: O(m) where m is the number of columns\ndef dp_space_optimized(grid):\n    rows, cols = len(grid), len(grid[0])\n    prev_row = [0] * cols\n\n    for r in range(rows):\n        curr_row = [0] * cols\n        for c in range(cols):\n            # Calculate current state based on previous row and previous columns\n            up = prev_row[c]\n            left = curr_row[c-1] if c &gt; 0 else 0\n            curr_row[c] = grid[r][c] + max(up, left)\n        prev_row = curr_row\n\n    return prev_row[-1]\n</code></pre>\n<h3>Canonical DP Problem Implementations</h3>\n<p>To truly master DP, you must understand the canonical problems. Here are standard, idiomatic Python solutions for the core DP archetypes.</p>\n<h4>0/1 Knapsack Problem</h4>\n<p>The classic problem of choosing items to maximize value without exceeding capacity.</p>\n<pre><code class=\"language-python\"># 0/1 Knapsack (Bottom-Up Tabulation)\n# Time: O(N * W), Space: O(W) using space optimization\ndef knapsack(values, weights, W):\n    n = len(values)\n    dp = [0] * (W + 1)\n\n    for i in range(n):\n        # Traverse backwards to prevent using the same item multiple times\n        for w in range(W, weights[i] - 1, -1):\n            dp[w] = max(dp[w], dp[w - weights[i]] + values[i])\n\n    return dp[W]\n</code></pre>\n<h4>Longest Common Subsequence (LCS)</h4>\n<p>Comparing two strings to find the longest subsequence present in both.</p>\n<pre><code class=\"language-python\"># Longest Common Subsequence (Top-Down with @cache)\n# Time: O(m * n), Space: O(m * n)\n@cache\ndef lcs(i, j, s1, s2):\n    if i == len(s1) or j == len(s2):\n        return 0\n    if s1[i] == s2[j]:\n        return 1 + lcs(i + 1, j + 1, s1, s2)\n    return max(lcs(i + 1, j, s1, s2), lcs(i, j + 1, s1, s2))\n\n# Call with: lcs(0, 0, text1, text2)\n</code></pre>\n<h4>Longest Increasing Subsequence (LIS)</h4>\n<p>Finding the longest strictly increasing subsequence. The optimal solution uses binary search (<code>bisect</code>) alongside DP to achieve O(n log n) time.</p>\n<pre><code class=\"language-python\">import bisect\n\n# Longest Increasing Subsequence\n# Time: O(n log n), Space: O(n)\ndef lengthOfLIS(nums):\n    sub = []\n    for num in nums:\n        # Find index where num should be inserted to maintain sorted order\n        idx = bisect.bisect_left(sub, num)\n        if idx == len(sub):\n            sub.append(num) # New largest element, extend subsequence\n        else:\n            sub[idx] = num  # Overwrite to maintain smallest possible ending elements\n    return len(sub)\n</code></pre>\n<h4>Coin Change</h4>\n<p>Finding the minimum number of coins to make a specific amount.</p>\n<pre><code class=\"language-python\"># Coin Change (Bottom-Up)\n# Time: O(amount * n), Space: O(amount)\ndef coinChange(coins, amount):\n    # Initialize array with infinity\n    dp = [float(&#39;inf&#39;)] * (amount + 1)\n    dp[0] = 0\n\n    for a in range(1, amount + 1):\n        for c in coins:\n            if a - c &gt;= 0:\n                dp[a] = min(dp[a], 1 + dp[a - c])\n\n    return dp[amount] if dp[amount] != float(&#39;inf&#39;) else -1\n</code></pre>\n<h4>Edit Distance</h4>\n<p>The minimum operations (insert, delete, replace) required to convert one string to another.</p>\n<pre><code class=\"language-python\"># Edit Distance (Top-Down)\n# Time: O(m * n), Space: O(m * n)\n@cache\ndef minDistance(word1: str, word2: str) -&gt; int:\n    def dp(i, j):\n        if i == len(word1): return len(word2) - j\n        if j == len(word2): return len(word1) - i\n\n        if word1[i] == word2[j]:\n            return dp(i + 1, j + 1)\n\n        insert = dp(i, j + 1)\n        delete = dp(i + 1, j)\n        replace = dp(i + 1, j + 1)\n\n        return 1 + min(insert, delete, replace)\n\n    return dp(0, 0)\n</code></pre>\n<h4>Partition DP and Bitmask DP</h4>\n<ul>\n<li><strong>Partition DP:</strong> Used in problems like &quot;Burst Balloons&quot; or &quot;Palindrome Partitioning&quot;. You iterate over possible split points to divide the array into independent subproblems. The pattern generally involves a 3-loop structure (length of subarray, start index, split point) yielding O(n³) time.</li>\n<li><strong>Bitmask DP:</strong> Used when the state involves subsets of a small array (e.g., Travelling Salesman Problem). Integers act as bitmasks representing state (e.g., <code>101</code> indicates items 0 and 2 are visited). Bitwise operations (<code>&amp;</code>, <code>|</code>, <code>^</code>, <code>&lt;&lt;</code>) update the state rapidly. Mentioning this pattern in an interview shows advanced algorithmic maturity.</li>\n</ul>\n<hr>\n<h2>SECTION 6 — Python-Specific Power Features for DSA</h2>\n<p>Python features several modules and syntactic capabilities that provide an &quot;unfair advantage&quot; in both implementation speed and code clarity. Utilizing these correctly signals to an interviewer that you are a proficient, experienced Python developer.</p>\n<h3><code>collections</code> Deep Dive</h3>\n<p>The <code>collections.Counter</code> class goes beyond simple frequency maps. It supports direct multiset arithmetic. You can add two Counters together, subtract them, or find their intersection.</p>\n<p><code>collections.OrderedDict</code> retains the insertion order of elements. While standard dictionaries also do this in modern Python, <code>OrderedDict</code> provides the <code>.move_to_end()</code> and <code>.popitem(last=False)</code> methods. This makes implementing complex structures like an LRU Cache almost trivial, achievable in roughly 10 lines of code.</p>\n<p>Furthermore, <code>deque</code> comes with a <code>rotate(n)</code> method, which cyclically shifts the queue elements to the right or left, an incredibly useful feature for circular buffer or rotation problems.</p>\n<pre><code class=\"language-python\">from collections import OrderedDict\n\n# LRU Cache from scratch using OrderedDict\n# Time: O(1) for both get and put operations\n# Space: O(capacity) to store the cache map\nclass LRUCache:\n    def __init__(self, capacity: int):\n        self.cache = OrderedDict()\n        self.capacity = capacity\n\n    def get(self, key: int) -&gt; int:\n        if key not in self.cache:\n            return -1\n        # Mark as recently used by moving to end\n        self.cache.move_to_end(key)\n        return self.cache[key]\n\n    def put(self, key: int, value: int) -&gt; None:\n        if key in self.cache:\n            self.cache.move_to_end(key)\n        self.cache[key] = value\n        # Evict least recently used (first item) if over capacity\n        if len(self.cache) &gt; self.capacity:\n            self.cache.popitem(last=False)\n</code></pre>\n<h3><code>itertools</code> for Combinatorics and Iteration</h3>\n<p>The <code>itertools</code> module handles complex iteration logic elegantly. The combinatoric generators—<code>permutations</code>, <code>combinations</code>, and <code>combinations_with_replacement</code>—are life-savers during interviews. <code>itertools.groupby</code> handles run-length encoding logic smoothly. For multi-dimensional iteration or flattening structures, tools like <code>chain</code>, <code>islice</code>, and <code>product</code> prevent the need for deeply nested <code>for</code> loops.</p>\n<h3><code>functools</code> for Algorithm Design</h3>\n<p>Aside from caching and custom sorting keys, <code>functools.reduce</code> applies a function of two arguments cumulatively to the items of a sequence, from left to right. This is excellent for fold operations, such as calculating the total product of an array or chaining XOR operations over a sequence.</p>\n<h3>Comprehensions as Algorithm Tools</h3>\n<p>Python comprehensions are more than syntactic sugar; they are highly optimized C-level loops. Nested list comprehensions can transpose or rotate matrices in a single line. Dictionary comprehensions can invert frequency maps effortlessly. Generator expressions yield items one at a time, providing memory-efficient processing for massive inputs where a full list comprehension would cause a memory exception.</p>\n<pre><code class=\"language-python\"># Matrix Transposition in one line\n# Time: O(rows * cols), Space: O(rows * cols)\nmatrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\ntransposed = [[matrix[r][c] for r in range(len(matrix))] for c in range(len(matrix[0]))]\n</code></pre>\n<h3><code>bisect</code> Module Patterns</h3>\n<p>Beyond basic binary search, the <code>bisect</code> module is the engine behind coordinate compression algorithms. It is used alongside sorted arrays of unique values to efficiently map sparse coordinate ranges to dense indices. Furthermore, it plays a vital role in manually maintaining sorted properties dynamically as elements stream into a structure.</p>\n<hr>\n<h2>SECTION 7 — Practice Tips</h2>\n<p>Mastering DSA requires structured, consistent, and deliberate practice. Randomly solving problems will yield diminishing returns.</p>\n<p>First, follow a logical progression path. Do not jump into Graph algorithms before mastering base structures. A proven roadmap is: Arrays → Strings → Linked Lists → Stacks &amp; Queues → Trees → Heaps → Graphs → Dynamic Programming → Advanced Patterns.</p>\n<p>When deciding where to practice, LeetCode remains the gold standard because Python is treated as a first-class language there, and the community discussion solutions are primarily written in Python. Use structured roadmaps like NeetCode&#39;s 150 to guide your problem selection. Other excellent platforms include HackerRank for fundamentals and Codeforces or AtCoder if you wish to dive into the intensely competitive, math-heavy programming sphere.</p>\n<p>During interviews, lean into Python&#39;s strengths but understand the tradeoffs. Knowing when to use <code>@cache</code> versus writing a manual DP array demonstrates strong engineering judgment. Avoid using a <code>list</code> as a queue at all costs—interviewers look for candidates who instinctively reach for <code>collections.deque</code>. Show off your knowledge of built-ins; leveraging <code>Counter</code>, <code>bisect</code>, and <code>heapq</code> signals that you have significant practical experience with the language.</p>\n<p>If you encounter performance bottlenecks locally, profile your Python solutions. Use the <code>timeit</code> module for micro-benchmarks and <code>cProfile</code> for broader application profiling. Understanding the overhead of the CPython interpreter (and the GIL) will help you write faster loops and avoid unnecessary memory allocations.</p>\n<p>For further reading, &quot;The Algorithm Design Manual&quot; by Steven Skiena provides the best theoretical foundation. Pair that by reading through the official Python documentation for the <code>collections</code>, <code>itertools</code>, and <code>heapq</code> modules—you will be surprised by how many built-in capabilities you haven&#39;t discovered yet.</p>\n<p>Ultimately, Python&#39;s greatest strength is that it minimizes the friction between your brain and the compiler. It lets you express the core algorithmic idea first. You can write the logic almost as fast as you can think it, verify the correctness, and then optimize it later. That’s exactly how technical problem-solving should feel. Keep practicing, trust the process, and let Python do the heavy lifting.</p>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target=\"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target=\"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target=\"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target=\"_blank\">Twitter</a></li>\n<li><a href=\"https://linktr.ee/sarveshmishra\" target=\"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/mastering-dsa-in-python-from-basics-to-advanced-patterns",
            "title": "Mastering DSA in Python: From Basics to Advanced Patterns",
            "summary": "A comprehensive, developer-friendly guide to mastering Data Structures and Algorithms in Python. Learn idiomatic patterns, complexities, and advanced techniques.",
            "image": "https://sarvesh.xyz/images/python.png",
            "date_modified": "2026-06-10T17:28:30.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/oops-concept-in-simple-english",
            "content_html": "<p>OOP is a way of writing computer programs that makes it easier to manage and organize your code. Let&#39;s break down some key OOP concepts:</p>\n<h3>1. <strong>Class</strong>:</h3>\n<p>Think of a class as a blueprint or a template. It defines the characteristics and behaviors that objects created from it will have. For example, if you have a &quot;Car&quot; class, it describes what a car should have (e.g., wheels, color, brand) and what it can do (e.g., drive, honk).</p>\n<h3>2. <strong>Object</strong>:</h3>\n<p>An object is like a real-world instance of a class. Using our &quot;Car&quot; example, if you create a specific car called &quot;MyCar,&quot; it&#39;s an object of the &quot;Car&quot; class. MyCar will have its unique characteristics and can perform actions specific to it.</p>\n<h3>3. <strong>Attributes/Properties</strong>:</h3>\n<p>These are like the characteristics or features of an object. In our car example, attributes could be things like the car&#39;s color, number of wheels, or brand.</p>\n<h3>4. <strong>Methods</strong>:</h3>\n<p>Methods are the actions or functions that an object can perform. Sticking with cars, methods could be &quot;start the engine,&quot; &quot;stop,&quot; or &quot;change gears.&quot;</p>\n<h3>5. <strong>Inheritance</strong>:</h3>\n<p>Imagine you have different types of cars, like sports cars and SUVs. Inheritance allows you to create a new class (e.g., &quot;SportsCar&quot;) based on an existing class (e.g., &quot;Car&quot;). The new class inherits all the attributes and methods of the parent class but can also have its unique features. It&#39;s like saying a sports car is still a car but with some extras.</p>\n<h3>6. <strong>Encapsulation</strong>:</h3>\n<p>Think of encapsulation as putting things in a box. In OOP, you hide the inner workings of an object from the outside world. You provide a clear interface (methods) to interact with the object, but you don&#39;t need to know all the details of how it works inside. For instance, you don&#39;t need to understand how the engine of a car works to drive it; you just need to use the pedals and steering wheel.</p>\n<h3>7. <strong>Polymorphism</strong>:</h3>\n<p>Polymorphism means that different objects can respond to the same method in their own unique way. Back to cars, if you have a &quot;start&quot; method, it behaves differently for a sports car and an SUV, but you can use the same method to start both of them.</p>\n<h3>8. <strong>Abstraction</strong>:</h3>\n<p>Abstraction is like simplifying something complex. It lets you focus on the essential details while hiding the non-essential ones. In OOP, you create abstract classes that define a general idea of something, like &quot;Vehicle,&quot; without specifying every detail. Then, you create concrete classes like &quot;Car&quot; and &quot;Truck&quot; that fill in the specifics.</p>\n<blockquote>\n<p>In essence, OOP helps you organize your code by breaking it into smaller, manageable pieces (objects and classes) that represent real-world concepts, making it easier to understand, maintain, and extend your programs.</p>\n</blockquote>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/oops-concept-in-simple-english",
            "title": "OOPS Concept in Simple English with Examples",
            "summary": "OOPs concept is the pillar of any computer science and programming world. In this bloa we learn basic of OOPS concept like Inheritance, Encapsulation, Polymorphism and Abstraction",
            "image": "https://sarvesh.xyz/images/oops.jpg",
            "date_modified": "2023-09-15T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/unlocking-potential-with-notebookllm",
            "content_html": "<p><strong>Introduction:</strong></p>\n<p>In the rapidly evolving landscape of Artificial Intelligence, Google&#39;s NotebookLLM stands out as a unique tool designed to be your personalized AI research assistant and collaborator. Unlike general-purpose chatbots that pull information from the vast open web, NotebookLLM is &quot;grounded&quot; in the specific documents and sources you upload. This means it becomes an expert in <em>your</em> data—whether that&#39;s a collection of PDFs, Google Docs, Slides, web URLs, or even audio files—providing accurate summaries, insights, and answers with inline citations.</p>\n<p>One of its most groundbreaking features is the <strong>Audio Overview</strong>, which can transform your dense documents into engaging, podcast-style discussions between two AI hosts. This allows users to consume complex information on the go. Additionally, NotebookLLM ensures data privacy, as your personal data is not used to train the model.</p>\n<p>This comprehensive guide explores how professionals across various fields—Product Managers, Developers, Students, Data Scientists, and Business Analysts—can leverage NotebookLLM to streamline workflows, enhance decision-making, and unlock new potential.</p>\n<hr>\n<h2>1. Product Managers: Enhancing Decision-Making and Collaboration</h2>\n<p>Product Managers (PMs) often juggle vast amounts of qualitative and quantitative data, from user interviews to market reports. NotebookLLM serves as a centralized intelligence hub that can synthesize this information into actionable strategies.</p>\n<h3>Use Case 1: Market Research Analysis</h3>\n<p>PMs can upload dozens of market research reports, competitor analysis whitepapers, and customer survey results into a single notebook. NotebookLLM can then identify emerging trends, common customer pain points, and gaps in the market across all these sources simultaneously.</p>\n<ul>\n<li><strong>Example:</strong> A PM at a fintech startup uploads 20 recent articles on &quot;Gen Z banking habits&quot; and transcripts from 10 user interviews. They ask NotebookLLM to &quot;Identify the top 3 requested features mentioned by users under 25 and cross-reference them with competitor offerings.&quot; The tool provides a summarized list with citations pointing directly to the specific interview or article where the insight was found.</li>\n</ul>\n<h3>Use Case 2: Roadmap Planning and Communication</h3>\n<p>Communicating the &quot;why&quot; behind a roadmap is often as important as the roadmap itself. PMs can use NotebookLLM to draft PRDs (Product Requirement Documents) or generate FAQs for stakeholders by referencing internal strategy documents and meeting notes.</p>\n<ul>\n<li><strong>Example:</strong> Before a quarterly planning meeting, a PM uploads the team’s OKRs, last quarter&#39;s retrospective notes, and the backlog CSV. They ask NotebookLLM to &quot;Generate a draft roadmap narrative that aligns our backlog items with our Q3 OKRs.&quot; They also generate an <strong>Audio Overview</strong> of the roadmap strategy to share with the sales team, allowing them to listen to the rationale during their commute.</li>\n</ul>\n<hr>\n<h2>2. Developers: Streamlining Code Development and Management</h2>\n<p>While developers have many AI coding assistants, NotebookLLM shines in managing the <em>knowledge</em> surrounding the code—documentation, architecture decisions, and legacy context.</p>\n<h3>Use Case 1: Knowledge Management and Onboarding</h3>\n<p>onboarding new developers to a legacy codebase can be daunting. By creating a notebook containing technical specifications, architecture diagrams, and post-mortem reports, teams can create an interactive knowledge base.</p>\n<ul>\n<li><strong>Example:</strong> A lead developer creates an &quot;Onboarding Notebook&quot; containing the project&#39;s <code>README.md</code>, API documentation, and past incident reports. A new hire can ask, &quot;How does the authentication flow handle token refresh failures?&quot; NotebookLLM answers based <em>strictly</em> on the uploaded documentation, reducing the risk of hallucinated architectural advice and saving the senior developer&#39;s time.</li>\n</ul>\n<h3>Use Case 2: Debugging Assistance and Log Analysis</h3>\n<p>Developers can upload error logs, stack traces, and relevant code snippets to get contextual debugging help. Because NotebookLLM can process multiple files, it can correlate errors in a log file with specific function definitions in the code.</p>\n<ul>\n<li><strong>Example:</strong> A backend engineer encounters a cryptic 500 error in production. They upload the server logs from the time of the crash along with the source code for the relevant microservices. They ask, &quot;Trace the request ID <code>req-12345</code> through the logs and identify which service threw the exception.&quot; NotebookLLM helps pinpoint that a database timeout in the <code>User_Service</code> caused a cascading failure in the <code>Order_Service</code>.</li>\n</ul>\n<hr>\n<h2>3. Students: Enhancing Learning and Study Practices</h2>\n<p>For students, NotebookLLM acts as an on-demand tutor and study partner that knows exactly what is in their syllabus.</p>\n<h3>Use Case 1: Note-Taking, Organization, and Study Guides</h3>\n<p>Students can upload lecture slides, textbook PDFs, and their own handwritten class notes. NotebookLLM can synthesize these materials to create comprehensive study guides, flashcards, and timelines.</p>\n<ul>\n<li><strong>Example:</strong> A history student uploads five PDF chapters about the French Revolution and their lecture notes. They ask NotebookLLM to &quot;Create a chronological timeline of key events between 1789 and 1799, highlighting the major political figures involved.&quot; They then use the &quot;Suggested Actions&quot; to automatically generate a Glossary of terms and a Briefing Doc for exam review.</li>\n</ul>\n<h3>Use Case 2: Collaborative Projects and Synthesis</h3>\n<p>Group projects often struggle with unifying different research paths. NotebookLLM allows multiple students to contribute sources to a shared notebook, ensuring everyone is working from the same knowledge base.</p>\n<ul>\n<li><strong>Example:</strong> A group of biology students is working on a paper about climate change&#39;s effect on coral reefs. Each student uploads their assigned research papers to a shared notebook. They use the <strong>Audio Overview</strong> feature to generate a &quot;podcast&quot; discussion of all their combined research. Listening to this conversation helps them identify contradictions in their findings and find a unique angle for their final presentation.</li>\n</ul>\n<hr>\n<h2>4. Data Scientists: Analyzing and Visualizing Data Effectively</h2>\n<p>Data Scientists can use NotebookLLM to bridge the gap between technical data analysis and business context, ensuring their models align with organizational goals.</p>\n<h3>Use Case 1: Reproducible Analysis Workflows</h3>\n<p>Documenting the &quot;why&quot; behind data cleaning and feature selection steps is crucial for reproducibility. Data scientists can upload their Jupyter Notebooks (converted to text/PDF) and research papers to maintain a &quot;lab notebook&quot; of their experiments.</p>\n<ul>\n<li><strong>Example:</strong> A data scientist is experimenting with different machine learning models for customer churn prediction. They upload their experiment logs and the original project brief. They use NotebookLLM to draft a &quot;Methodology&quot; section for their final report, asking it to explain <em>why</em> Random Forest was chosen over Logistic Regression based on the comparative results in the uploaded logs.</li>\n</ul>\n<h3>Use Case 2: Literature Review and Model Development</h3>\n<p>Staying updated with the latest research is a core part of a data scientist&#39;s job. NotebookLLM helps quickly distill complex academic papers.</p>\n<ul>\n<li><strong>Example:</strong> A researcher uploads 15 technical PDFs about &quot;Transformer Architectures in Time Series Forecasting.&quot; They ask NotebookLLM to &quot;Summarize the pros and cons of each architecture specifically for high-frequency trading data.&quot; The tool provides a comparative table, allowing the data scientist to quickly select the most promising models to prototype.</li>\n</ul>\n<hr>\n<h2>5. Business Analysts: Gaining Insights from Data</h2>\n<p>Business Analysts (BAs) act as the bridge between IT and business stakeholders. NotebookLLM helps them translate technical requirements into business value and vice versa.</p>\n<h3>Use Case 1: Reporting and Dashboards</h3>\n<p>BAs can use NotebookLLM to synthesize quarterly reports by combining quantitative data exports (CSV/Sheets) with qualitative emails and meeting notes.</p>\n<ul>\n<li><strong>Example:</strong> A BA needs to explain a dip in Q2 sales. They upload the Q2 sales spreadsheet and a folder of email correspondence from regional sales leads. They ask NotebookLLM, &quot;Correlate the weeks with the lowest sales numbers to the challenges mentioned in the sales team&#39;s emails.&quot; The tool highlights that the sales dip coincided with a reported supply chain outage mentioned in emails from the APAC region.</li>\n</ul>\n<h3>Use Case 2: Data-Driven Decision Making</h3>\n<p>NotebookLLM assists in visualizing key metrics to aid decision-making. It helps in translating complex data into actionable insights for non-technical stakeholders.</p>\n<ul>\n<li><strong>Example:</strong> A BA is preparing a presentation for the board. They upload the company&#39;s annual financial report and industry benchmark reports. They ask NotebookLLM to &quot;Create a script for a 5-minute presentation highlighting our performance vs. the industry average, focusing on EBITDA margins.&quot; They use the generated script as a baseline and refine it for the final meeting.</li>\n</ul>\n<hr>\n<h2>Conclusion</h2>\n<p>NotebookLLM is more than just another AI tool; it is a paradigm shift in how we interact with information. By grounding its intelligence in <em>your</em> trusted sources, it eliminates the noise of the open web and provides tailored, citation-backed insights. Whether you are a Product Manager strategizing a roadmap, a Developer debugging legacy code, a Student preparing for finals, or an Analyst making sense of disparate data points, NotebookLLM adapts to your workflow.</p>\n<p>We encourage you to start small: upload a few documents related to your current project and explore the &quot;Audio Overview&quot; or ask a few complex questions. You might find that your new favorite coworker is the one that lives in your notebook.</p>\n<h2>Watch in Action</h2>\n<p>To truly understand the power of NotebookLLM, especially its Audio Overview feature, check out this in-depth video by Tiago Forte:</p>\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/-Nl6hz2nYFA\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>\n\n<h2><strong>Let’s Connect!</strong></h2>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\">Twitter</a></li>\n<li><a href=\"https://linktr.ee/sarveshmishra\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/unlocking-potential-with-notebookllm",
            "title": "Unlocking Potential with NotebookLLM: A Comprehensive Guide to Use Cases for Various Roles",
            "summary": "Discover how NotebookLLM can revolutionize workflows for Product Managers, Developers, Students, Data Scientists, and Business Analysts. Explore use cases and unlock your potential.",
            "image": "https://sarvesh.xyz/images/notebookllm-banner.jpg",
            "date_modified": "2025-12-11T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/what-are-micro-service-and-monolithic-architecture",
            "content_html": "<p><b>Introduction:</b> In the world of software development, architecture plays a crucial role in determining the scalability, maintainability, and flexibility of an application. Two popular architectural approaches that have gained significant attention in recent years are micro-services and monoliths. In this blog post, we will delve into the characteristics, benefits, and challenges of each architecture.</p>\n<h3>I. Monolithic Architecture</h3>\n<p>Monolithic architecture refers to a traditional approach where an entire application is built as a single, self-contained unit. In this model, all the components, functionalities, and services of the application are tightly coupled and deployed together.</p>\n<h4>Characteristics</h4>\n<p>Monolithic applications are typically built using a single codebase, with all functionalities and services combined into a single deployment unit.</p>\n<p>The architecture relies on a single technology stack and database.</p>\n<p>The components within a monolith communicate through in-process method calls or shared libraries.\nDevelopment, testing, and deployment of the entire application are done as a whole.</p>\n<h6>Benefits:</h6>\n<p>Simplicity: Monolithic architecture is relatively straightforward to develop and deploy, especially for smaller projects.</p>\n<p>Performance: Since all components reside within the same process, there is minimal overhead in communication, resulting in efficient performance.</p>\n<p>Easier development: Developers can easily understand the entire codebase and make changes as required.</p>\n<h6>Challenges:</h6>\n<p>Scalability: Scaling a monolithic application can be challenging, as the entire application needs to be replicated instead of scaling specific modules.</p>\n<p>Maintainability: As the application grows, the codebase becomes more complex and harder to maintain. A single change may require re-deploying the entire monolith.</p>\n<p>Technology lock-in: The choice of a specific technology stack is made at the outset, making it difficult to adopt new technologies.</p>\n<h3>II. Microservices Architecture</h3>\n<p>Microservices architecture, on the other hand, follows a modular approach where an application is decomposed into a collection of smaller, loosely coupled services. Each service represents a specific business capability and can be independently developed, deployed, and scaled.</p>\n<h4>Characteristics</h4>\n<p>Microservices are small, autonomous services that communicate with each other through lightweight protocols like HTTP or message queues.</p>\n<p>Each service is responsible for a specific business capability and can be developed, deployed, and scaled independently.</p>\n<p>Services can be implemented using different technologies, databases, and programming languages as per the specific requirements.</p>\n<p>Communication between services is typically achieved through APIs (Application Programming Interfaces).</p>\n<h6>Benefits:</h6>\n<p>Scalability: Microservices offer excellent scalability by allowing individual services to be scaled independently based on demand.</p>\n<p>Flexibility: Different services can use different technologies, enabling teams to choose the most suitable tools for each service.</p>\n<p>Maintainability: Since services are decoupled, making changes to one service does not require redeploying the entire application.</p>\n<p>Fault isolation: If one service fails, it doesn’t affect the entire system, ensuring higher fault tolerance.</p>\n<h6>Challenges:</h6>\n<p>Distributed complexity: Microservices architecture introduces distributed system complexities like network communication, service discovery, and data consistency.</p>\n<p>Operational overhead: Maintaining and managing multiple services requires additional effort for deployment, monitoring, and debugging.</p>\n<p>Service coordination: Services need to coordinate and handle inter-service communication effectively.</p>\n<h6>Conclusion</h6>\n<blockquote>\n<p>Microservice architecture and monolithic architecture are two different approaches to application development. Each approach has its own advantages and disadvantages. The best approach for a particular application will depend on the specific needs of the application.</p>\n</blockquote>\n<Notice type=\"note\">\nPlease share which architecture you use or prefer in the comment box. Thank you for your time. See you with a new post soon. Share with love.\n</Notice>\n\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/what-are-micro-service-and-monolithic-architecture",
            "title": "What are Micro-service and Monolithic Architecture?",
            "summary": "Docker is a powerful tool that has revolutionized the way applications are deployed and managed. It is an open-source platform that allows developers to build, package, and deploy applications in a consistent and efficient manner. In this blog post, we will explore Docker and its uses Docker uses a lightweight virtualization approach to package applications",
            "image": "https://sarvesh.xyz/images/kubernetes.webp",
            "date_modified": "2023-05-14T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/what-is-docker-and-its-use-case",
            "content_html": "<p>Docker is a powerful tool that has revolutionized the way applications are deployed and managed. It is an open-source platform that allows developers to build, package, and deploy applications in a consistent and efficient manner. In this blog post, we will explore Docker and its uses</p>\n<p>Docker uses a lightweight virtualization approach to package applications and their dependencies into a container. Unlike traditional virtual machines, Docker containers share the host operating system kernel, which makes them much more lightweight and efficient. This means that Docker containers can be spun up and down very quickly, making them ideal for use in cloud environments</p>\n<p>Docker containers provide application isolation, which means that applications can be run in their own containers without interfering with other applications or the host operating system. This also makes it easy to move applications between different environments, such as development, testing, and production.</p>\n<p>Docker provides a simple and consistent way to package and deploy applications. Developers can package their application and its dependencies into a Docker image, which can be easily deployed to any environment that supports Docker. This makes it easy to deploy applications to the cloud or on-premises, and also simplifies the management of applications in production</p>\n<h4>How Does Docker Work?</h4>\n<p>At its core, Docker employs containerization technology using the concept of images and containers. Let’s take a closer look at each:</p>\n<p><b>Docker Images:</b> A Docker image is a read-only template or blueprint used to create Docker containers. It includes the necessary dependencies, libraries, and binaries required for an application to run. Images are lightweight and can be easily shared, version-controlled, and distributed across different environments.</p>\n<p><b>Docker Containers:</b> A Docker container is an instance of an image that can be executed, allowing applications to run in an isolated and consistent environment. Containers are portable, ensuring that an application works seamlessly on any system where Docker is installed, regardless of the underlying infrastructure.</p>\n<h4>Key Benefits of Using Docker</h4>\n<p><b>Consistency:</b> Docker ensures consistency across different environments by providing a standardized runtime environment for applications. Developers can build and test applications on their local machines and confidently deploy them in different production environments without worrying about compatibility issues.</p>\n<p><b>Scalability:</b> Docker’s container-based approach enables effortless scalability. With Docker, it is easy to spin up multiple containers, each running an instance of the application, and distribute the load across various containers. This flexibility empowers organizations to scale their applications based on demand, ensuring optimal performance.</p>\n<p><b>Efficiency:</b> Docker promotes efficient resource utilization by eliminating the need for separate virtual machines for each application. Containers share the host machine’s operating system kernel, resulting in faster startup times and reduced memory footprint. This streamlined approach allows for denser application deployment on a single host machine.</p>\n<p><b>Dependency Management:</b> Docker simplifies dependency management by encapsulating all required dependencies within the container image. This eliminates conflicts between different versions of libraries or packages and ensures that the application runs consistently across various environments.</p>\n<p><b>Continuous Integration and Deployment (CI/CD):</b> Docker seamlessly integrates with CI/CD pipelines, making it easier to automate the software development lifecycle. By using Docker, development teams can package applications into containers, test them, and deploy them to production environments more efficiently, resulting in faster time-to-market.</p>\n<blockquote>\n<p>In conclusion, Docker is a powerful tool that has revolutionized the way applications are deployed and managed. Its lightweight virtualization approach, application isolation, and simplified deployment and management make it an ideal choice for modern application development. Whether you are developing cloud-native applications or managing legacy applications, Docker can help streamline your development and operations processes.</p>\n</blockquote>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/what-is-docker-and-its-use-case",
            "title": "What is Docker and its use case?",
            "summary": "Docker is a powerful tool that has revolutionized the way applications are deployed and managed. It is an open-source platform that allows developers to build, package, and deploy applications in a consistent and efficient manner. In this blog post, we will explore Docker and its uses Docker uses a lightweight virtualization approach to package applications",
            "image": "https://sarvesh.xyz/images/whale-docker.gif",
            "date_modified": "2023-05-17T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/what-is-the-docker-multi-stage-build",
            "content_html": "<p>Although Docker eliminates the need for dependencies on the client system, inefficient building of the image can result in a heavy image size. Many developers are unaware of this feature, leading to high data transfer costs for their organization. In this blog, I will demonstrate how to use Docker&#39;s multi-stage build to comprehensively build and reduce the image size.</p>\n<p>By utilizing Docker multi-stage builds, you can create more efficient and simplified container images by consolidating multiple build stages into one Docker file. This feature was introduced in Docker 17.05 and is particularly useful for applications that require build processes or dependencies that are not necessary for the final runtime image.\nHere&#39;s how Docker multi-stage builds work:</p>\n<h4>Multiple Build Stages:</h4>\n<p>You define multiple build stages in your Dockerfile, each with its own base image and set of instructions. Each stage is like a separate container image during the build process.</p>\n<h4>Copy Artifacts:</h4>\n<p>You can copy files or artifacts from one build stage to another using the COPY <code>--from=&lt;stage&gt;</code> instruction. This allows you to selectively include only the necessary files in the final image.</p>\n<h4>Reduce Image Size:</h4>\n<p>By using multi-stage builds, you can avoid including build tools, development dependencies, and intermediate files in the final container image. This results in smaller and more efficient images that are easier to distribute and deploy.</p>\n<Notice type=\"tip\">\nIf you're new to Docker, start by reading these posts before continuing.\n</Notice>\n\n<ul>\n<li><a href=\"https://sarvesh.xyz/blog/what-is-docker-and-its-use-case\">What is Docker and its use case?</a></li>\n<li><a href=\"https://sarvesh.xyz/blog/docker-basic-commands-cheatsheet\">Basic Docker Commands CheatSheet</a></li>\n<li><a href=\"https://sarvesh.xyz/blog/how-to-inspect-the-docker-image\">How to inspect the docker image?</a></li>\n</ul>\n<p>Here&#39;s how you can effectively use multi-stage builds in Docker:</p>\n<ol>\n<li><p><strong>Create a Dockerfile with Multiple Stages:</strong></p>\n<p>To use multi-stage builds, create a Dockerfile that defines multiple stages. Each stage represents a step in the build process and can have its own base image and set of instructions.</p>\n<pre><code class=\"language-Dockerfile\"># Stage 1: Build the application\nFROM node:14 AS builder\nWORKDIR /app\nCOPY package.json package-lock.json ./\nRUN npm install\nCOPY . .\nRUN npm run build\n\n# Stage 2: Create the production image\nFROM nginx:alpine\nCOPY --from=builder /app/build /usr/share/nginx/html\nEXPOSE 80\nCMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]\n</code></pre>\n<p>In this example, there are two stages: one for building a Node.js application and another for creating an Nginx-based production image.</p>\n</li>\n<li><p><strong>Use Different Base Images:</strong></p>\n<p>Each stage can use a different base image that is suitable for the specific task. In the example above, the first stage uses a Node.js base image for building the application, and the second stage uses an Nginx base image for the production image.</p>\n</li>\n<li><p><strong>Copy Artifacts Between Stages:</strong></p>\n<p>To copy artifacts (e.g., compiled code or static files) from one stage to another, use the <code>COPY --from</code> instruction, as shown in the example. This allows you to keep only the necessary files in the final image.</p>\n</li>\n<li><p><strong>Keep Only What&#39;s Necessary:</strong></p>\n<p>In the final stage, include only the necessary files and dependencies needed to run your application. This helps reduce the size of the container image and minimize security risks.</p>\n</li>\n<li><p><strong>Build the Docker Image:</strong></p>\n<p>To build the Docker image, use the <code>docker build</code> command with the <code>-t</code> flag to specify a tag for the image. For example:</p>\n<pre><code class=\"language-bash\">docker build -t myapp:v1 .\n</code></pre>\n</li>\n<li><p><strong>Run the Docker Container:</strong></p>\n<p>Once the image is built, you can run a container from it:</p>\n<pre><code class=\"language-bash\">docker run -p 8080:80 myapp:v1\n</code></pre>\n<p>This will start your application in a container.</p>\n</li>\n</ol>\n<blockquote>\n<p>Using multi-stage builds helps create more efficient and smaller Docker images, making them easier to distribute and deploy. It&#39;s particularly useful for building applications that require compilation or build steps, as it allows you to keep only the necessary artifacts in the final image while discarding build tools and intermediate files.</p>\n</blockquote>\n<Notice type=\"note\">\nDocker does not have a built-in concept of \"stages\" in the same way as some other containerization or build systems like multi-stage builds in Docker can help you create smaller and more efficient container images by reducing the image size and minimizing the number of dependencies.\n</Notice>\n\n<h5>Happy Dockerizing! 🐋 See you in next post. Don&#39;t forget to comment your thoughts for this post. Share knowledge with others...</h5>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/what-is-the-docker-multi-stage-build",
            "title": "What is the docker multi-stage build?",
            "summary": "Docker is a powerful tool that has revolutionized the way applications are deployed and managed. By utilizing Docker multi-stage builds, you can create more efficient and simplified container images by consolidating multiple build stages into one Docker file.",
            "image": "https://sarvesh.xyz/images/docker.jpg",
            "date_modified": "2023-09-19T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        },
        {
            "id": "https://sarvesh.xyz/blog/what-is-the-docker-swarm",
            "content_html": "<p>In the world of containerization and microservices, managing and scaling containers efficiently has become a critical task. Docker Swarm, a native clustering and orchestration solution for Docker containers, provides a seamless way to tackle this challenge. In this blog post, we will delve into the world of Docker Swarm, exploring its core concepts, benefits, and how to get started.</p>\n<h2>What is Docker Swarm?</h2>\n<p>Docker Swarm is a native container orchestration tool provided by Docker that allows you to manage a cluster of Docker nodes as a single virtual system. It simplifies the deployment, scaling, and management of containerized applications by providing a unified interface and a set of powerful features.</p>\n<h2>Key Concepts</h2>\n<p>Before diving into the details, let&#39;s understand some key concepts of Docker Swarm:</p>\n<h3>Node</h3>\n<p>A node is an individual Docker engine that participates in the Swarm cluster. Nodes can be either manager nodes or worker nodes. Manager nodes are responsible for managing the cluster, while worker nodes run containers.</p>\n<h3>Service</h3>\n<p>A service is a definition for the tasks to execute on the worker nodes. It specifies which Docker image to use, how many replicas of the service should run, and various other configuration options.</p>\n<h3>Task</h3>\n<p>A task is a running instance of a service on a worker node. Docker Swarm schedules and manages tasks to ensure the desired number of replicas are running.</p>\n<h3>Stack</h3>\n<p>A stack is a collection of services that make up an application. Docker Compose files can be used to define stacks, making it easy to manage multi-service applications.</p>\n<h2>Benefits of Docker Swarm</h2>\n<p>Now that we have a basic understanding of Docker Swarm, let&#39;s explore the benefits it offers:</p>\n<ol>\n<li><p><strong>Ease of Use</strong>: Docker Swarm is known for its simplicity. If you are already familiar with Docker, the learning curve is minimal. You can set up a Swarm cluster and deploy services within minutes.</p>\n</li>\n<li><p><strong>High Availability</strong>: Docker Swarm ensures high availability by distributing services across multiple nodes. In case a node fails, Swarm reschedules tasks on healthy nodes, minimizing downtime.</p>\n</li>\n<li><p><strong>Load Balancing</strong>: Swarm provides built-in load balancing for services. It intelligently routes traffic to containers, distributing the load evenly.</p>\n</li>\n<li><p><strong>Horizontal Scaling</strong>: Scaling your applications up or down is effortless with Docker Swarm. You can easily adjust the number of service replicas to meet changing demands.</p>\n</li>\n<li><p><strong>Security</strong>: Docker Swarm provides security features such as mutual TLS (mTLS) encryption for node-to-node communication, making your cluster more secure.</p>\n</li>\n<li><p><strong>Integration with Docker Tools</strong>: Swarm seamlessly integrates with other Docker tools like Docker Compose, making it easy to define and deploy multi-container applications.</p>\n</li>\n</ol>\n<h2>Getting Started with Docker Swarm</h2>\n<p>Now that you&#39;re excited about Docker Swarm, let&#39;s get started with a basic setup:</p>\n<h3>Prerequisites</h3>\n<ol>\n<li>Docker Engine installed on all nodes you want to include in the Swarm.</li>\n<li>A network connection between the nodes.</li>\n<li>Port 2377 (Swarm management) and port 7946/udp (overlay network) should be open between the nodes.</li>\n</ol>\n<h3>Initialize a Swarm</h3>\n<p>On a node that you want to designate as a manager, run the following command to initialize a Swarm:</p>\n<pre><code>docker swarm init --advertise-addr &lt;MANAGER-IP&gt;\n</code></pre>\n<p>Replace <code>&lt;MANAGER-IP&gt;</code> with the IP address of the manager node.</p>\n<h3>Join Worker Nodes</h3>\n<p>On worker nodes, run the command provided by the <code>docker swarm init</code> command on the manager node to join the Swarm.</p>\n<h3>Deploy a Service</h3>\n<p>You can deploy a service using the <code>docker service create</code> command. For example:</p>\n<pre><code>docker service create --replicas 3 --name my-web-app -p 80:80 my-web-app-image\n</code></pre>\n<p>This command deploys a service named <code>my-web-app</code> with three replicas, exposing port 80.</p>\n<h3>Scale a Service</h3>\n<p>To scale a service up or down, use the following command:</p>\n<pre><code>docker service scale my-web-app=5\n</code></pre>\n<p>This scales the <code>my-web-app</code> service to five replicas.</p>\n<h2>Conclusion</h2>\n<blockquote>\n<p>Docker Swarm simplifies container orchestration and management, making it accessible to developers and operations teams alike. With its ease of use, high availability, and scalability features, Docker Swarm is a powerful tool for building and deploying containerized applications. Whether you are running a small project or managing a large-scale microservices architecture, Docker Swarm is worth considering as your container orchestration solution. Start experimenting with Docker Swarm today and unlock the potential of containerization in your infrastructure.</p>\n</blockquote>\n<h5>Happy Dockerizing! 🐋 See you in the next post. Don&#39;t forget to comment your thoughts on this post. Share knowledge with others…</h5>\n<p>Let&#39;s Connect on:</p>\n<ul>\n<li><a href=\"https://www.linkedin.com/in/sarveshm\" target = \"_blank\">LinkedIn</a></li>\n<li><a href=\"https://www.github.com/sarveshmishra\" target = \"_blank\">GitHub</a></li>\n<li><a href=\"https://substack.com/@sarveshmishra\" target = \"_blank\">Substack</a></li>\n<li><a href=\"https://twitter.com/sarveshworld\" target = \"_blank\">Twitter</a></li>\n<li><a href=\" https://linktr.ee/sarveshmishra\" target = \"_blank\">Linktree</a></li>\n</ul>\n",
            "url": "https://sarvesh.xyz/blog/what-is-the-docker-swarm",
            "title": "A Comprehensive Guide to Docker Swarm: Orchestrate Your Containers with Ease",
            "summary": "Docker Swarm: A native clustering and orchestration solution for Docker containers. Learn how Docker Swarm simplifies container deployment and scaling for seamless application management.",
            "image": "https://sarvesh.xyz/images/docker.jpg",
            "date_modified": "2023-10-08T05:00:00.000Z",
            "author": {
                "name": "Sarvesh Mishra"
            }
        }
    ]
}