<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Shubhainder Singh</title>
    <description>The latest articles on Forem by Shubhainder Singh (@shubhainder_singh).</description>
    <link>https://forem.com/shubhainder_singh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2526080%2Fea8623b6-26a0-4f64-84fe-7e529eec9988.JPG</url>
      <title>Forem: Shubhainder Singh</title>
      <link>https://forem.com/shubhainder_singh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shubhainder_singh"/>
    <language>en</language>
    <item>
      <title>Why DSA is Essential for Every Developer (Frontend, Backend, or Full Stack)</title>
      <dc:creator>Shubhainder Singh</dc:creator>
      <pubDate>Wed, 26 Feb 2025 07:31:46 +0000</pubDate>
      <link>https://forem.com/shubhainder_singh/why-dsa-is-essential-for-every-developer-frontend-backend-or-full-stack-2h9b</link>
      <guid>https://forem.com/shubhainder_singh/why-dsa-is-essential-for-every-developer-frontend-backend-or-full-stack-2h9b</guid>
      <description>&lt;h2&gt;
  
  
  "DSA is just for interviews!" — The Biggest Lie Ever
&lt;/h2&gt;

&lt;p&gt;If you think Data Structures and Algorithms (DSA) are only useful for cracking FAANG interviews, you’re missing the bigger picture. DSA is like knowing how to navigate rush-hour traffic efficiently—sure, you can get by without it, but wouldn’t you rather take the fastest, smoothest route? Just like Uber optimizes ride matching or Netflix ensures your favorite shows load instantly, DSA helps you write efficient, scalable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  DSA = Problem-Solving Superpower
&lt;/h2&gt;

&lt;p&gt;At its core, DSA teaches you how to think critically and optimize solutions. Writing code is easy, but writing efficient code that scales is what makes a good developer.&lt;/p&gt;

&lt;p&gt;Example: Imagine you’re working at Amazon. Your task is to show personalized product recommendations in milliseconds. You could brute-force it by looping through a million items, or you could use HashMaps or Trees to make retrieval fast. Your algorithm just saved Black Friday sales.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don’t Just Learn DSA, Apply It
&lt;/h2&gt;

&lt;p&gt;Most people treat DSA like a checklist—Leetcode grind, interview, forget everything. But real magic happens when you apply it in real projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Start Studying DSA
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start from the basics&lt;/strong&gt; – If you’re new, begin with understanding what DSA is, what algorithms are, and the basic data structures (arrays, linked lists, stacks, queues). Learn basic math concepts needed for DSA, such as logarithms and complexity analysis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solve questions immediately&lt;/strong&gt; – Don’t wait to finish a course. Read the problem properly, break it down step by step, and write your approach before jumping to solutions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explain the problem to yourself&lt;/strong&gt; – Try to come up with a brute force solution first, then refine it by optimizing step by step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implement DSA in projects&lt;/strong&gt; – Use DSA concepts in your personal or work projects to see real-world applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read other people’s code&lt;/strong&gt; – Learning from experienced developers helps you understand better approaches and improves your problem-solving mindset.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  DSA = Your Secret Weapon as a Developer
&lt;/h2&gt;

&lt;p&gt;You don’t need to be a competitive coder, but mastering basic DSA concepts will make you a better developer. It’s not about interviews—it’s about writing clean, fast, and scalable code. You wouldn’t build a skyscraper without a solid foundation, so why build software without understanding how to handle data properly?&lt;/p&gt;

&lt;p&gt;Stop seeing DSA as a chore—start using it as your toolkit to level up your skills.&lt;/p&gt;




&lt;p&gt;Share you DSA journey or insights in the comments!&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>programming</category>
      <category>softwareengineering</category>
      <category>problemsolving</category>
    </item>
    <item>
      <title>Debugging Strategies: Real-World Scenarios and Solutions</title>
      <dc:creator>Shubhainder Singh</dc:creator>
      <pubDate>Wed, 19 Feb 2025 06:51:22 +0000</pubDate>
      <link>https://forem.com/shubhainder_singh/debugging-strategies-real-world-scenarios-and-solutions-4kj7</link>
      <guid>https://forem.com/shubhainder_singh/debugging-strategies-real-world-scenarios-and-solutions-4kj7</guid>
      <description>&lt;h2&gt;
  
  
  Debugging Like a Pro: Strategies to Fix Bugs Faster
&lt;/h2&gt;

&lt;p&gt;Let’s be real: debugging is a core part of being a developer. Some days, you’re a genius fixing things in seconds; other days, you’re staring at an error for hours only to realize you misspelled a variable. Debugging isn’t just about fixing code; it’s about problem-solving, staying patient, and sometimes just taking a break before the screen starts mocking you.&lt;/p&gt;

&lt;p&gt;Today, we’re diving into battle-tested debugging strategies, real-world examples, and how to stay (relatively) sane while hunting down bugs.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Read the Error Message (No, Seriously!)
&lt;/h2&gt;

&lt;p&gt;The first rule of debugging? Read the error message. Yes, it sounds obvious, but too many developers (my past self included) immediately panic instead of actually reading what the system is trying to say.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;Ever seen this in Python?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nb"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;NoneType&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="nb"&gt;object&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;subscriptable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt; You’re trying to access an index of something that doesn’t exist. Somewhere in your code, you assumed a variable was a list or dictionary, but it’s actually &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Print your variables, use a debugger, and trace where that &lt;code&gt;None&lt;/code&gt; is sneaking in.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Explain It to a Rubber Duck (Or Anything That Listens)
&lt;/h2&gt;

&lt;p&gt;Ever tried explaining your problem to someone and suddenly realized the mistake? That’s called rubber duck debugging. It works because explaining your thought process forces you to see gaps in your logic. If you don’t have a teammate, talk to a rubber duck, yourself (recommended), a pet, or even a plant. They won’t judge (probably).&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;Once, I spent hours debugging a function that wasn’t returning the right value. When I explained it to a friend, I realized I was modifying the wrong variable the entire time. &lt;strong&gt;Facepalm moment.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. The Binary Search Method: Cut the Problem in Half
&lt;/h2&gt;

&lt;p&gt;If you’re dealing with a large chunk of code, don’t try to debug everything at once. Instead, comment out half and check if the bug still exists. Keep narrowing it down until you isolate the issue. It’s like binary search, but for debugging pain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;A button click wasn’t working in my React app. Instead of checking every function, I commented out different parts of the handler until I found the culprit—a state mutation inside a &lt;code&gt;useEffect&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Print Statements vs. Debugger: Use Both Wisely
&lt;/h2&gt;

&lt;p&gt;Some developers swear by &lt;code&gt;console.log()&lt;/code&gt;, others by proper debuggers. The truth? Both are useful, depending on the situation.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Print statements&lt;/strong&gt; (&lt;code&gt;console.log&lt;/code&gt;, &lt;code&gt;print&lt;/code&gt;, &lt;code&gt;fmt.Println&lt;/code&gt;) are great for quick checks.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;A debugger&lt;/strong&gt; lets you pause execution and inspect variables in real-time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;While debugging a Next.js API route, I first used &lt;code&gt;console.log()&lt;/code&gt; to check if the request body was parsed correctly. Once I needed deeper insights, I switched to the VS Code debugger to step through function calls.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Git Is Your Time Machine
&lt;/h2&gt;

&lt;p&gt;If a bug appeared out of nowhere, check your Git history. Sometimes, past-you made a mistake, and present-you is suffering the consequences.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;A colleague once spent hours fixing a broken feature, only to realize they had deleted an important line of code in their last commit. &lt;code&gt;git blame&lt;/code&gt; showed exactly when (and who) made the change. A quick rollback, and boom—problem solved.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Google Like a Pro
&lt;/h2&gt;

&lt;p&gt;Knowing how to Google is an underrated skill. The more specific your search, the faster you’ll find a solution.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Bad:&lt;/strong&gt; "React not working"&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Good:&lt;/strong&gt; "React useEffect not triggering on state update with async function"&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;Once, I had a weird PostgreSQL bug. Instead of searching blindly, I copied the exact error message into Google. Turns out, I was using an outdated database version missing a key feature. One Stack Overflow thread later, problem solved.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Walk Away (Yes, That’s a Strategy)
&lt;/h2&gt;

&lt;p&gt;If you’ve been debugging for hours with no progress, take a break. Your brain keeps working in the background, and sometimes the solution pops into your head when you least expect it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;I once spent an entire afternoon debugging a test failure. Frustrated, I grabbed coffee. When I came back, I instantly saw the issue—a missing mock dependency. Could’ve saved myself hours if I had just stepped away earlier.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Bugs are inevitable, but they don’t have to be nightmares. The best developers aren’t the ones who never introduce bugs (&lt;strong&gt;that’s impossible&lt;/strong&gt;), but the ones who can track them down efficiently. Stay patient, use the right tools, and don’t be afraid to ask for help.&lt;/p&gt;

&lt;p&gt;Oh, and always keep a rubber duck handy. You never know when you’ll need it. 🦆&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy debugging!&lt;/strong&gt; 🐛🔍🚀&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>programming</category>
      <category>softwareengineering</category>
      <category>learning</category>
    </item>
    <item>
      <title>Upload to S3</title>
      <dc:creator>Shubhainder Singh</dc:creator>
      <pubDate>Thu, 05 Dec 2024 06:09:26 +0000</pubDate>
      <link>https://forem.com/shubhainder_singh/upload-to-s3-33gh</link>
      <guid>https://forem.com/shubhainder_singh/upload-to-s3-33gh</guid>
      <description>&lt;p&gt;Hello Devs! 👋&lt;/p&gt;

&lt;p&gt;If you've ever wanted to integrate file uploads directly into your Next.js app, this post is for you! We'll walk through how to upload files to AWS S3 using the AWS SDK (nextjs + AWS S3 + clerk auth). Whether you're building an image gallery, document manager, or any app that deals with file storage, S3 is a great choice.&lt;/p&gt;

&lt;p&gt;Let’s dive in! 🏊‍♂️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why S3?&lt;/strong&gt; 🤔&lt;br&gt;
Amazon S3 (Simple Storage Service) is a scalable, durable, and secure file storage solution. It's great for:&lt;/p&gt;

&lt;p&gt;Storing user uploads (images, PDFs, etc.)&lt;br&gt;
 Backing up important data&lt;br&gt;
 Serving static assets (like images or videos)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up Your Project&lt;/strong&gt; 🛠️&lt;/p&gt;
&lt;h5&gt;
  
  
  Prerequisites
&lt;/h5&gt;

&lt;p&gt;Make sure you have:&lt;/p&gt;

&lt;p&gt;A Next.js app &lt;br&gt;
  An AWS account&lt;br&gt;
  AWS credentials with permissions to access S3 (comment if you need a &lt;br&gt;
  post on how to access S3)&lt;/p&gt;
&lt;h5&gt;
  
  
  Install AWS SDK
&lt;/h5&gt;

&lt;p&gt;First, install the AWS SDK in your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @aws-sdk/client-s3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Backend Setup: API Routes for Uploading Files *&lt;/em&gt;📡&lt;/p&gt;

&lt;p&gt;File: app/api/upload/route.ts&lt;/p&gt;

&lt;p&gt;This API route will handle file uploads.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NextRequest, NextResponse } from 'next/server';
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';

const s3Client = new S3Client({ region: process.env.AWS_S3_REGION });

export async function POST(request: NextRequest) {
  try {
    const formData = await request.formData();
    const file = formData.get('file') as File;

    if (!file) {
      return NextResponse.json({ error: 'No file uploaded' }, { status: 400 });
    }

    const bytes = await file.arrayBuffer();
    const buffer = Buffer.from(bytes);

    const uploadParams = {
      Bucket: process.env.AWS_S3_BUCKET_NAME!,
      Key: `uploads/${Date.now()}-${file.name}`,
      Body: buffer,
      ContentType: file.type,
    };

    await s3Client.send(new PutObjectCommand(uploadParams));

    return NextResponse.json({ success: true });
  } catch (error) {
    return NextResponse.json({ error: 'Upload failed', details: error }, { status: 500 });
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Frontend Setup: File Upload UI *&lt;/em&gt;📤&lt;/p&gt;

&lt;p&gt;Create a simple upload form in your Next.js app.&lt;/p&gt;

&lt;p&gt;File: components/Upload.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react';

export default function Upload() {
  const [file, setFile] = useState&amp;lt;File | null&amp;gt;(null);
  const [message, setMessage] = useState('');

  const handleSubmit = async (e: React.FormEvent) =&amp;gt; {
    e.preventDefault();
    if (!file) return;

    const formData = new FormData();
    formData.append('file', file);

    const res = await fetch('/api/upload', {
      method: 'POST',
      body: formData,
    });

    if (res.ok) {
      setMessage('File uploaded successfully!');
    } else {
      setMessage('Failed to upload file.');
    }
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;input type="file" onChange={(e) =&amp;gt; setFile(e.target.files?.[0] || null)} /&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Upload&amp;lt;/button&amp;gt;
      {message &amp;amp;&amp;amp; &amp;lt;p&amp;gt;{message}&amp;lt;/p&amp;gt;}
    &amp;lt;/form&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Testing Your Setup&lt;/strong&gt; 🧪&lt;br&gt;
Start your Next.js app:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Navigate to your upload form.&lt;br&gt;
Select a file and hit Upload.&lt;br&gt;
Head over to your S3 bucket and confirm the file is there!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus: Listing Files from S3&lt;/strong&gt; 📜&lt;br&gt;
Want to display uploaded files? Here’s how:&lt;/p&gt;

&lt;p&gt;File: app/api/files/route.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { S3Client, ListObjectsV2Command } from '@aws-sdk/client-s3';
import { NextResponse } from 'next/server';

const s3Client = new S3Client({ region: process.env.AWS_S3_REGION });

export async function GET() {
  try {
    const command = new ListObjectsV2Command({
      Bucket: process.env.AWS_S3_BUCKET_NAME!,
    });

    const response = await s3Client.send(command);
    const files = response.Contents?.map((file) =&amp;gt; ({
      name: file.Key,
      size: file.Size,
      lastModified: file.LastModified,
    }));

    return NextResponse.json({ files });
  } catch (error) {
    return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 });
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Wrapping Up&lt;/strong&gt; 🎁&lt;br&gt;
And that’s it! You’ve now integrated file uploads to S3 in your Next.js app. This setup is production-ready, scalable, and easy to extend. Do you have ideas for improvements? Fork the project and share your contributions!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Shubhainder/upload-to-s3" rel="noopener noreferrer"&gt;Github repository&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let me know if this was helpful, and feel free to drop your thoughts or questions below. Happy coding!&lt;/em&gt; 💻✨&lt;/p&gt;

</description>
      <category>programming</category>
      <category>aws</category>
      <category>nextjs</category>
      <category>clerk</category>
    </item>
  </channel>
</rss>
