<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dev Journey]]></title><description><![CDATA[Dev Journey]]></description><link>https://blog.atchyutn.com</link><generator>RSS for Node</generator><lastBuildDate>Thu, 21 May 2026 14:37:00 GMT</lastBuildDate><atom:link href="https://blog.atchyutn.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[The Digital Transformation Imperative: Why Your Business Can't Afford to Ignore Digital Solutions]]></title><description><![CDATA[August 4, 2024
Welcome to The AN-Swer Series! I’m Atchyut Nagabhairava, and today we’re diving into a crucial topic: why your business needs to embrace digital solutions right now. If you’re a CEO or business leader still on the fence about digital t...]]></description><link>https://blog.atchyutn.com/digital-solutions</link><guid isPermaLink="true">https://blog.atchyutn.com/digital-solutions</guid><dc:creator><![CDATA[Atchyut Nagabhairava]]></dc:creator><pubDate>Sat, 03 Aug 2024 21:07:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1722718736054/54231264-a026-42bf-8ba9-38b3b7eae382.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>August 4, 2024</p>
<p>Welcome to <strong>The AN-Swer Series</strong>! I’m Atchyut Nagabhairava, and today we’re diving into a crucial topic: why your business needs to embrace digital solutions right now. If you’re a CEO or business leader still on the fence about digital transformation, this article is for you.</p>
<h2 id="heading-1-from-old-school-to-high-tech-the-evolution-of-business-efficiency">1. From Old-School to High-Tech: The Evolution of Business Efficiency</h2>
<p>Remember when businesses relied on stacks of paperwork and endless manual processes? Sounds exhausting, right? Fast forward to today, and digital solutions are here to save the day. Take <strong>Therapy Genius</strong>, my AI-powered web application. This tool is a game-changer for therapy centers, automating tedious tasks and freeing up time for what really matters—providing top-notch care.</p>
<h2 id="heading-2-the-hidden-costs-of-sticking-with-the-status-quo">2. The Hidden Costs of Sticking with the Status Quo</h2>
<p>Ever wondered what you’re really losing by sticking with manual processes? It’s more than just a few extra hours each week. For instance, one of my clients was juggling customer data manually, leading to costly errors and missed sales. By switching to a custom digital solution, we cut down on mistakes and boosted their sales. The results? A more efficient operation and happier customers.</p>
<h2 id="heading-3-the-magic-of-digital-solutions-why-theyre-worth-every-penny">3. The Magic of Digital Solutions: Why They’re Worth Every Penny</h2>
<ul>
<li><p><strong>Boosting Productivity:</strong> Digital tools aren’t just cool—they make your life easier. For example, using Tailwind CSS and Next.js in my projects has sped up development and made it smoother than ever. Imagine cutting your project time in half!</p>
</li>
<li><p><strong>Smart Decisions with Data:</strong> With digital solutions, you don’t have to guess. Data analytics gives you real-time insights, so you can make smart, informed decisions. It’s like having a crystal ball for your business.</p>
</li>
<li><p><strong>Scalability and Flexibility:</strong> Digital tools grow with you. Whether you’re adding new features or scaling up, these solutions adapt to your needs. It’s like having a business partner that’s always in your corner.</p>
</li>
</ul>
<h2 id="heading-4-busting-myths-digital-solutions-arent-as-scary-as-they-sound">4. Busting Myths: Digital Solutions Aren’t as Scary as They Sound</h2>
<ul>
<li><p><strong>High Costs? Think Again:</strong> Yes, there’s an upfront investment, but the long-term gains are huge. Automating tasks saves time and money—money you can invest back into your business.</p>
</li>
<li><p><strong>Too Complicated? Not Anymore:</strong> Modern digital tools are designed to be user-friendly. With intuitive interfaces and plenty of support, getting started is easier than ever. My use of frameworks like DaisyUI and AcentricityUI, NextJS, OpenAI proves that cutting-edge tech can be accessible.</p>
</li>
</ul>
<h2 id="heading-5-custom-solutions-tailored-just-for-you">5. Custom Solutions: Tailored Just for You</h2>
<p>One-size-fits-all doesn’t cut it in business. Custom solutions address your unique challenges. For instance, I developed a leads management portal that allowed a client to efficiently track, search, and contact leads. This tailored solution provided them with a significant advantage, streamlining their processes and boosting their sales effectiveness.</p>
<h2 id="heading-6-your-roadmap-to-digital-transformation">6. Your Roadmap to Digital Transformation</h2>
<ul>
<li><p><strong>Start with a Plan:</strong> Assess where you’re at and where you want to go. A solid plan makes all the difference.</p>
</li>
<li><p><strong>Implement and Support:</strong> The journey doesn’t end with implementation. Ongoing support ensures everything runs smoothly and efficiently.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Digital solutions aren’t just a trend—they’re a necessity for staying ahead. They offer incredible benefits, from increased efficiency to smarter decision-making. If you’re curious about how digital transformation can work for your business, let’s chat. I’m here to share insights and help you navigate this exciting journey.</p>
<h2 id="heading-call-to-action">Call to Action</h2>
<p>Ready to see how digital solutions can transform your business? Reach out to me, and let’s explore how these technologies can take your business to the next level.</p>
<ul>
<li><p><strong>Name:</strong> Atchyut Nagabhairava</p>
</li>
<li><p><strong>Email:</strong> <a target="_blank" href="mailto:atchyutnagabhairava@gmail.com">atchyutnagabhairava@gmail.com</a></p>
</li>
<li><p><strong>LinkedIn:</strong> <a target="_blank" href="http://linkedin.com/in/atchyutn">linkedin.com/in/atchyutn</a></p>
</li>
<li><p><strong>GitHub:</strong> <a target="_blank" href="http://github.com/atchyutn">github.com/atchyutn</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Revolutionizing Therapy with AI: A Journey from Challenge to Innovation]]></title><description><![CDATA[Hey there! I'm excited to share a project that's been keeping me up at night (in a good way!) for the Hashnode 'AI for Tomorrow' Hackathon. It's a story of friendship, problem-solving, and how AI might just revolutionize therapy for kids having ADHD ...]]></description><link>https://blog.atchyutn.com/therapy-genius</link><guid isPermaLink="true">https://blog.atchyutn.com/therapy-genius</guid><category><![CDATA[ #PaperworkRevolution]]></category><category><![CDATA[AIForTomorrow]]></category><category><![CDATA[AI]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[therapy]]></category><category><![CDATA[innovation]]></category><category><![CDATA[TechForGood]]></category><category><![CDATA[neurodivergent]]></category><category><![CDATA[ADHD]]></category><category><![CDATA[Autism]]></category><dc:creator><![CDATA[Atchyut Nagabhairava]]></dc:creator><pubDate>Thu, 25 Jul 2024 07:31:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1721890546096/94b8a747-d380-4d38-9f5a-908a63aac312.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey there! I'm excited to share a project that's been keeping me up at night (in a good way!) for the <strong>Hashnode 'AI for Tomorrow' Hackathon</strong>. It's a story of friendship, problem-solving, and how AI might just revolutionize therapy for kids having ADHD and Autism. Buckle up!</p>
<h3 id="heading-useful-links"><strong>Useful Links</strong></h3>
<p><strong>Sneak-Peak:</strong> <a target="_blank" href="https://therapygenius.tech/"><strong>Therapy Genius is Live here 🚀</strong></a></p>
<p><strong>Github Link:</strong><a target="_blank" href="https://github.com/atchyutn/Therapy-Genius"><strong>https://github.com/atchyutn/Therapy-Genius</strong></a></p>
<h3 id="heading-introduction-when-coffee-talks-lead-to-tech-breakthroughs"><strong>Introduction: When Coffee Talks Lead to Tech Breakthroughs</strong></h3>
<p>You know how some of the best ideas come from casual conversations? Well, grab a virtual coffee and let me tell you about one that's changing the game for kids with ADHD and autism. As a developer, I'm always on the lookout for real-world problems to solve. Little did I know that my next big project would come from a chat with a friend who runs a therapy center.</p>
<p>One day, I was sitting in a cafe with my friend Rita <em>(changed name for privacy)</em>, who runs a therapy center for kids. As we sipped our coffee, Rita started talking about her work. She looked tired and a bit stressed and she said</p>
<blockquote>
<p>"You wouldn't believe how much time I spend writing reports, I became a therapist to help kids, not to be stuck doing paperwork all day!"</p>
</blockquote>
<p>I curiously asked to explain me in detail, Listening to my friend's experiences in her center, I learned about the significant challenges they're facing. I'll try my best to explain what I understood.</p>
<h3 id="heading-the-challenge-neurodiversity-in-a-nutshell">The Challenge: Neurodiversity in a Nutshell</h3>
<p>Before we dive into the problem &amp; solution, let's talk about the elephant in the room. ADHD and autism aren't just buzzwords – they're part of the daily reality for many families worldwide. ADHD(Attention Deficit Hyperactivity Disorder) involves difficulties with focus, hyperactivity, and impulsivity, making daily tasks and interactions challenging for affected children. Autism Spectrum Disorder (ASD) affects how a person communicates and interacts with others, often leading to repetitive behaviors and a strong preference for routines.</p>
<h3 id="heading-the-problems-too-much-paperwork-not-enough-time">The Problems: Too Much Paperwork, Not Enough Time</h3>
<p>From my conversation with my friend, I learned how these conditions require tailored, individualized therapy to truly make a difference. However, designing personalized activities presents following problems for therapy centers.</p>
<ol>
<li><p>Therapists spend too much time writing and not enough time with kids</p>
</li>
<li><p>Potential for errors (nobody's perfect, especially at 2 AM right?)</p>
</li>
<li><p>Different therapists might write reports in different ways, which will be confusing for parents.</p>
</li>
<li><p>Textbook based activities without creativity, which miss the core concept of personalised therapy.</p>
</li>
</ol>
<h3 id="heading-our-solution-using-ai-to-help">Our Solution: Using AI to Help</h3>
<p>Considering Rita's problems, I'm excited to use technology to make a difference by creating a digital solution. As part of Hashnode's 'AI for Tomorrow' Hackathon, we developed an AI-powered web app that helps therapists to generate personalised reports on the fly.</p>
<p>Our system is like a smart assistant for therapists. It takes information about each child (like their age, gender, type of therapy and goals to achieve) and quickly creates personalized therapy activities, which can be edit or printed post generation. This means:</p>
<ol>
<li><p>Giving therapists their time back (maybe now they can finally finish that Netflix series)</p>
</li>
<li><p>Ensuring consistency across therapists (no more "grape progress" typos)</p>
</li>
<li><p>Making therapy more engaging for kids (who said learning can't be fun?)</p>
</li>
<li><p>Helping parents understand the therapy activities and help their kids reach their full potential (world, watch out for these future superstars)</p>
</li>
</ol>
<h3 id="heading-how-we-built-it-our-tech-tools-the-secret-sauce">How We Built It: Our Tech Tools, the Secret Sauce</h3>
<p>As per my understanding the therapits are not tech savy and don't have time to explore the app pages, We decided to keep it as simple and viable. For that, I used following tech stack.</p>
<ul>
<li><p><strong>Next.js</strong>: Because it helps building single-page applications, so therapists don’t have to play hide-and-seek with their screens. Plus, its server-side rendering (SSR) helps in making API calls to therapy assistant.</p>
</li>
<li><p><strong>TailwindCSS &amp; DaisyUI</strong>: Because even AI assistants need to look good and responsiveness with less efforts</p>
</li>
<li><p><strong>Lottie Animations</strong>: Giving our UI more style to get that "Wow!" feeling on first impression.</p>
</li>
<li><p><strong>OpenAI Assistant API</strong>: The brains of the operation, generating activities so personalized, as if it already knew them. All this is possible, thanks to her previous reports that were feeded helping the assistant understand the pattern and give reliable suggestions.</p>
</li>
</ul>
<h3 id="heading-impact-and-future-scope-to-infinity-and-beyond">Impact and Future Scope: To Infinity and Beyond!</h3>
<p>We're not just saving trees here (though the forests thank us). But wait, there's more! Future plans for this app are so exciting, they'll make your neurons dance:</p>
<ol>
<li><p><strong>Machine Learning Magic</strong>: Our AI will get smarter over time, like a fine wine but without the hangover</p>
</li>
<li><p><strong>Telehealth Integration</strong>: Because therapy should be accessible, even if you're in your seven seas away.</p>
</li>
<li><p><strong>Activities &amp; Mood Tracker:</strong> It's like having a therapy detective on the case -helping therapists and parents figure out which activities are making a difference and which ones are just making kids' moods do the cha-cha.</p>
</li>
</ol>
<h3 id="heading-be-a-guinea-pig-but-way-cooler-try-our-preview">Be a Guinea Pig (But Way Cooler): Try Our Preview!</h3>
<p>Okay, we promise no lab coats or maze-running required! Want to see our AI in action and feel like a tech superhero at the same time? We've got just the thing for you!</p>
<p><a target="_blank" href="https://therapygenius.tech/"><strong>🚀 Click here to test drive our preview version! 🚀</strong></a></p>
<h3 id="heading-conclusion-the-future-is-bright-and-paperwork-free">Conclusion: The Future is Bright (and Paperwork-Free)</h3>
<p>As we gear up to release this platform to the public, we're buzzing with excitement. We're not just creating software; we're crafting a future where every child, regardless of how their amazing brain is wired, has the chance to shine brighter than a supernova.</p>
<p>So here's to a future where therapists can focus on changing lives instead of fighting with spell-check, where kids enjoy therapy more than ice cream (okay, maybe that's a stretch), and where AI and human creativity join forces to make the world a better place.</p>
<p>Thank you for joining us on this wild ride. Together, we're not just thinking outside the box; we're building a whole new box – one that's filled with hope, innovation, and maybe a few robots (the friendly kind, of course).</p>
<p>Stay tuned, keep innovating, and remember: in the world of therapy, the only paperwork we want to see is the kind kids use for origami!</p>
<hr />
<h3 id="heading-how-you-can-jump-in-and-tinker-or-save-the-day">How You Can Jump In and Tinker (or Save the Day)</h3>
<p>Yes, you can totally contribute! We promise it's easier than convincing a cat to take a bath. Just follow these steps, and you’ll be helping to make therapy tech more awesome in no time.Creating and Customizing the OpenAI Assistant</p>
<p>Before diving into the technical setup, let's explore how to create and customize an OpenAI Assistant, which is the core of our solution. This assistant will generate personalized therapy activities for children with ADHD and autism.</p>
<h4 id="heading-steps-to-create-and-customize-the-openai-assistant">Steps to Create and Customize the OpenAI Assistant:</h4>
<ol>
<li><p><strong>Create an OpenAI Account</strong>: If you haven't already, sign up at <a target="_blank" href="https://openai.com/">OpenAI</a>.</p>
</li>
<li><p><strong>Access the API</strong>: Navigate to the API section and create a new API key.</p>
</li>
<li><p><strong>Create a New Assistant</strong>:</p>
<ul>
<li><p>Go to the <a target="_blank" href="https://platform.openai.com/playground">OpenAI Playground</a>.</p>
</li>
<li><p>Click on "Create new assistant" and give it a name (e.g., "Therapy Activity Generator").</p>
</li>
</ul>
</li>
<li><p><strong>Customize the Assistant</strong>:</p>
<ul>
<li><p>Set the model to GPT-4 or the latest available.</p>
</li>
<li><p>In the system message, provide context about generating therapy activities. For example:</p>
<pre><code class="lang-plaintext">  You are an AI assistant specialized in creating personalized therapy activities for children with ADHD and autism. Generate activities based on the child's age, specific condition, and therapy goals.
</code></pre>
</li>
</ul>
</li>
<li><p><strong>Feed Data to the Assistant</strong>:</p>
<ul>
<li><p>Upload sample therapy reports or activity descriptions to help the AI understand the format and content.</p>
</li>
<li><p>You can do this by using the <code>files</code> parameter when creating the assistant via the API.</p>
</li>
</ul>
</li>
<li><p><strong>Customize for Report Format</strong>:</p>
<ul>
<li><p>In the system message, specify the desired report format. For example:</p>
<pre><code class="lang-plaintext">  Generate activities in the following format:
  Activity Name:
  Objective:
  Materials Needed:
  Task:
</code></pre>
</li>
</ul>
</li>
<li><p><strong>Save and Get Assistant ID</strong>:</p>
<ul>
<li>After creating and customizing your assistant, save it and note down the Assistant ID.</li>
</ul>
</li>
<li><p><strong>Use in Your App</strong>:</p>
<ul>
<li><p>Create a <code>.env.local</code> file in your project root.</p>
</li>
<li><p>Add your OpenAI API key and Assistant ID:</p>
<pre><code class="lang-plaintext">  OPENAI_API_KEY=your_api_key_here
  OPENAI_ASSISTANT_ID=your_assistant_id_here
</code></pre>
</li>
</ul>
</li>
</ol>
<p>This setup ensures that your assistant is ready to generate personalized therapy activities based on the unique needs of each child.</p>
<hr />
<h3 id="heading-setting-up-the-nextjs-project-locally">Setting Up the Next.js Project Locally</h3>
<p>To get started with the Therapy Genius project, follow these steps to set up the project locally on your machine.</p>
<h4 id="heading-steps-to-set-up-the-project">Steps to Set Up the Project:</h4>
<ol>
<li><p><strong>Clone the Repository</strong>:</p>
<pre><code class="lang-bash"> git <span class="hljs-built_in">clone</span> https://github.com/atchyutn/Therapy-Genius.git
 <span class="hljs-built_in">cd</span> Therapy-Genius
</code></pre>
</li>
<li><p><strong>Install Dependencies</strong>:</p>
<pre><code class="lang-bash"> npm install
 <span class="hljs-comment"># or</span>
 yarn install
</code></pre>
</li>
<li><p><strong>Set Up Environment Variables</strong>:</p>
<ul>
<li><p>Create a <code>.env.local</code> file in the project root.</p>
</li>
<li><p>Add your OpenAI API key and Assistant ID:</p>
<pre><code class="lang-plaintext">  OPENAI_API_KEY=your_api_key_here
  OPENAI_ASSISTANT_ID=your_assistant_id_here
</code></pre>
</li>
</ul>
</li>
<li><p><strong>Run the Development Server</strong>:</p>
<pre><code class="lang-bash"> npm run dev
 <span class="hljs-comment"># or</span>
 yarn dev
 <span class="hljs-comment"># or</span>
 pnpm dev
 <span class="hljs-comment"># or</span>
 bun dev
</code></pre>
</li>
<li><p><strong>Open in Browser</strong>:</p>
<ul>
<li>Open <a target="_blank" href="http://localhost:3000">http://localhost:3000</a> with your browser to see the result.</li>
</ul>
</li>
<li><p><strong>Start Editing</strong>:</p>
<ul>
<li>You can start editing the page by modifying <code>app/page.tsx</code>. The page auto-updates as you edit the file.</li>
</ul>
</li>
</ol>
<p>This setup allows you to run and develop the Therapy Genius project locally, making it easy to contribute and customize the app.</p>
<hr />
<h3 id="heading-screenshot">Screenshot 👇🏻</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1721864477950/d4cef0a0-3aa0-4185-a387-6d7fa7940baa.jpeg" alt class="image--center mx-auto" /></p>
<p>#AIForTomorrow #AI #MachineLearning #Therapy #Innovation #TechForGood #Neurodivergence #ADHD #Autism #PaperworkRevolution</p>
]]></content:encoded></item><item><title><![CDATA[Understanding the Differences: Subsets, Subarrays, and Subsequences in Data Structures]]></title><description><![CDATA[In the world of data structures and algorithms, understanding the nuances between similar-sounding terms is crucial. Today, we're diving into three such terms: subsets, subarrays, and subsequences. While they might seem interchangeable at first glanc...]]></description><link>https://blog.atchyutn.com/understanding-the-differences-subsets-subarrays-and-subsequences-in-data-structures</link><guid isPermaLink="true">https://blog.atchyutn.com/understanding-the-differences-subsets-subarrays-and-subsequences-in-data-structures</guid><category><![CDATA[ Problem Solving Techniques]]></category><category><![CDATA[Combinatorial Algorithms]]></category><category><![CDATA[Algorithmic Strategies]]></category><category><![CDATA[datastructure]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[Programming concepts]]></category><category><![CDATA[Coding Fundamentals]]></category><category><![CDATA[backtracking]]></category><category><![CDATA[array manipulation in java]]></category><dc:creator><![CDATA[Atchyut Nagabhairava]]></dc:creator><pubDate>Tue, 19 Dec 2023 05:42:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702964391378/92a30557-a299-4b70-968c-ea678f20c0ba.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the world of data structures and algorithms, understanding the nuances between similar-sounding terms is crucial. Today, we're diving into three such terms: subsets, subarrays, and subsequences. While they might seem interchangeable at first glance, each has distinct characteristics that set them apart. Let's explore these differences and understand when and how each concept is used in algorithm design.</p>
<h2 id="heading-what-is-a-subset"><strong>What is a Subset?</strong></h2>
<p>A subset is perhaps the most general of the three concepts. It refers to any possible combination of elements from a given array. Crucially, the order of elements in a subset is not important, and a subset can include any number of elements from the original array, including none at all.</p>
<h3 id="heading-characteristics-of-subsets"><strong>Characteristics of Subsets:</strong></h3>
<ul>
<li><p><strong>Combination of Elements</strong>: Can include any element from the array.</p>
</li>
<li><p><strong>Order Irrelevant</strong>: The arrangement of elements doesn't matter.</p>
</li>
<li><p><strong>Total Possibilities</strong>: For an array with <code>N</code> elements, there are 2�2<em>N</em> possible subsets.</p>
</li>
</ul>
<h3 id="heading-example"><strong>Example:</strong></h3>
<p>Given an array <code>[1, 2, 3]</code>, the subsets include <code>[1, 2, 3]</code>, <code>[1, 2]</code>, <code>[1, 3]</code>, <code>[2, 3]</code>, <code>[1]</code>, <code>[2]</code>, <code>[3]</code>, and <code>[]</code>.</p>
<h2 id="heading-what-is-a-subarray"><strong>What is a Subarray?</strong></h2>
<p>A subarray, in contrast, is a more specific concept. It refers to a contiguous segment of the original array. This means the elements in a subarray must appear in unbroken sequence in the array.</p>
<h3 id="heading-characteristics-of-subarrays"><strong>Characteristics of Subarrays:</strong></h3>
<ul>
<li><p><strong>Contiguity</strong>: Elements must be adjacent in the original array.</p>
</li>
<li><p><strong>Preserved Order</strong>: The order of elements in a subarray is the same as in the original array.</p>
</li>
<li><p><strong>Specific Subset</strong>: Every subarray is a subset, but not every subset is a subarray.</p>
</li>
</ul>
<h3 id="heading-example-1"><strong>Example:</strong></h3>
<p>In the array <code>[3, 2, 1, 9, 6, 8]</code>, <code>[2, 1, 9]</code> is a subarray, but <code>[3, 1, 8]</code> is not since the elements are not contiguous.</p>
<h2 id="heading-what-is-a-subsequence"><strong>What is a Subsequence?</strong></h2>
<p>A subsequence strikes a balance between subsets and subarrays. It involves elements from the array in the same order as they appear, but, unlike subarrays, the elements don't have to be contiguous.</p>
<h3 id="heading-characteristics-of-subsequences"><strong>Characteristics of Subsequences:</strong></h3>
<ul>
<li><p><strong>Order Preserved</strong>: Elements maintain their original order from the array.</p>
</li>
<li><p><strong>Non-Contiguous</strong>: Elements need not be adjacent.</p>
</li>
<li><p><strong>Generalized Subset</strong>: Every subsequence is a subset, and every subarray is a subsequence.</p>
</li>
</ul>
<h3 id="heading-example-2"><strong>Example:</strong></h3>
<p>For the array <code>[3, 2, 1, 9, 6, 8]</code>, <code>[3, 1, 6]</code> is a subsequence. It preserves the order of the elements as they appear in the array but skips some elements.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In summary, while subsets, subarrays, and subsequences may seem similar, they have distinct properties that are crucial in different algorithmic contexts. Subsets offer the most freedom, subarrays require contiguous elements, and subsequences keep the order of elements without the contiguity constraint. Recognizing these differences is key in solving various problems in computer science, particularly in the realm of backtracking algorithms and combinatorial problems.</p>
<p>Understanding these fundamental concepts not only helps in algorithm design but also in comprehending the underlying principles of data structures and problem-solving strategies. So, the next time you come across these terms, remember their unique characteristics and applications!</p>
]]></content:encoded></item><item><title><![CDATA[Creating a Reusable Snackbar Component in Next.js]]></title><description><![CDATA[Notifications and alerts are an essential part of user interaction in web applications. They inform users about successes, errors, and other significant events. Material-UI’s Snackbar component is a popular choice for displaying these brief messages....]]></description><link>https://blog.atchyutn.com/snackbar-component-in-nextjs</link><guid isPermaLink="true">https://blog.atchyutn.com/snackbar-component-in-nextjs</guid><category><![CDATA[Notification System,]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[React]]></category><category><![CDATA[coding]]></category><category><![CDATA[software development]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[ReactHooks]]></category><category><![CDATA[ui components]]></category><category><![CDATA[React context]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[User Interface]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[snackbar]]></category><category><![CDATA[material ui]]></category><dc:creator><![CDATA[Atchyut Nagabhairava]]></dc:creator><pubDate>Tue, 19 Dec 2023 05:29:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701424232935/9246e84b-43b4-4bcf-934e-b2d2c9aa5563.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Notifications and alerts are an essential part of user interaction in web applications. They inform users about successes, errors, and other significant events. Material-UI’s Snackbar component is a popular choice for displaying these brief messages. In this post, we’ll explore how to create a reusable Snackbar component in a Next.js application using React context and hooks.</p>
<h2 id="heading-why-use-a-context-for-snackbar"><strong>Why Use a Context for Snackbar?</strong></h2>
<p>In complex applications, you often need to trigger notifications from many different components. Passing down props or callbacks through multiple layers of components can get messy. A more elegant solution is to use a React context. This allows any component in your application to easily display a notification without prop drilling.</p>
<h2 id="heading-setting-up-the-snackbar-context"><strong>Setting Up the Snackbar Context</strong></h2>
<p>First, we create a new context for the Snackbar in a separate file (<code>SnackbarContext.js</code>):</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { createContext, useContext, useState, useCallback } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> SnackbarContext = createContext();

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> useSnackbar = <span class="hljs-function">() =&gt;</span> useContext(SnackbarContext);

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> SnackbarProvider = <span class="hljs-function">(<span class="hljs-params">{ children }</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> [snackPack, setSnackPack] = useState([]);

  <span class="hljs-keyword">const</span> addSnackbar = useCallback(<span class="hljs-function">(<span class="hljs-params">message, severity = <span class="hljs-string">'info'</span></span>) =&gt;</span> {
    setSnackPack(<span class="hljs-function">(<span class="hljs-params">prev</span>) =&gt;</span> [...prev, { message, severity, <span class="hljs-attr">key</span>: <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>().getTime() }]);
  }, []);

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">SnackbarContext.Provider</span> <span class="hljs-attr">value</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">addSnackbar</span> }}&gt;</span>
      {children}
      {/* Snackbar Component will be added here */}
    <span class="hljs-tag">&lt;/<span class="hljs-name">SnackbarContext.Provider</span>&gt;</span></span>
  );
};
</code></pre>
<p>This <code>SnackbarProvider</code> component will wrap our application, providing the <code>addSnackbar</code> function through context to any child component.</p>
<h2 id="heading-creating-the-reusable-snackbar-component"><strong>Creating the Reusable Snackbar Component</strong></h2>
<p>Within the <code>SnackbarProvider</code>, we include the reusable Snackbar component that listens to the <code>snackPack</code> state:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { Alert, Snackbar } <span class="hljs-keyword">from</span> <span class="hljs-string">'@mui/material'</span>;

<span class="hljs-comment">// ... inside SnackbarProvider component</span>

{snackPack.map(<span class="hljs-function">(<span class="hljs-params">snack, index</span>) =&gt;</span> (
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Snackbar</span>
    <span class="hljs-attr">key</span>=<span class="hljs-string">{snack.key}</span>
    <span class="hljs-attr">open</span>
    <span class="hljs-attr">autoHideDuration</span>=<span class="hljs-string">{6000}</span>
    <span class="hljs-attr">onClose</span>=<span class="hljs-string">{()</span> =&gt;</span> {
      setSnackPack((prev) =&gt; prev.filter((item) =&gt; item.key !== snack.key));
    }}
    anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
  &gt;
    <span class="hljs-tag">&lt;<span class="hljs-name">Alert</span> <span class="hljs-attr">onClose</span>=<span class="hljs-string">{()</span> =&gt;</span> {
      setSnackPack((prev) =&gt; prev.filter((item) =&gt; item.key !== snack.key));
    }} severity={snack.severity} sx={{ width: '100%' }}&gt;
      {snack.message}
    <span class="hljs-tag">&lt;/<span class="hljs-name">Alert</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">Snackbar</span>&gt;</span></span>
))}
</code></pre>
<p>Each message in the <code>snackPack</code> array is displayed as a Snackbar. We use the <code>key</code> property to uniquely identify each message, which is helpful for dismissing messages correctly.</p>
<h2 id="heading-integrating-snackbarprovider-in-your-application"><strong>Integrating SnackbarProvider in Your Application</strong></h2>
<p>In your Next.js <code>_app.js</code> file, wrap your application with the <code>SnackbarProvider</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { SnackbarProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'../path/to/SnackbarContext'</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyApp</span>(<span class="hljs-params">{ Component, pageProps }</span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">SnackbarProvider</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Component</span> {<span class="hljs-attr">...pageProps</span>} /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">SnackbarProvider</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> MyApp;
</code></pre>
<h2 id="heading-using-the-usesnackbar-hook"><strong>Using the useSnackbar Hook</strong></h2>
<p>Anywhere in your application, you can now use the <code>useSnackbar</code> hook to trigger Snackbar messages:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { useSnackbar } <span class="hljs-keyword">from</span> <span class="hljs-string">'../path/to/SnackbarContext'</span>;

<span class="hljs-keyword">const</span> MyComponent = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> { addSnackbar } = useSnackbar();

  <span class="hljs-keyword">const</span> handleAction = <span class="hljs-function">() =&gt;</span> {
    addSnackbar(<span class="hljs-string">'This action was successful!'</span>, <span class="hljs-string">'success'</span>);
  };

  <span class="hljs-keyword">return</span> (
    <span class="hljs-comment">// Your component JSX</span>
  );
};
</code></pre>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>This approach simplifies the process of displaying notifications in a Next.js application. By using a context provider, we can avoid prop drilling and make our notification system more maintainable and elegant.</p>
<p>The reusable Snackbar component makes it easy to display consistent and attractive notifications across the entire application, enhancing the user experience.</p>
]]></content:encoded></item></channel></rss>