<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tanzim Chowdhury on Medium]]></title>
        <description><![CDATA[Stories by Tanzim Chowdhury on Medium]]></description>
        <link>https://medium.com/@tanzim3421?source=rss-a8974385c683------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nTmqsYarmS6wOOkQX6W0nQ.jpeg</url>
            <title>Stories by Tanzim Chowdhury on Medium</title>
            <link>https://medium.com/@tanzim3421?source=rss-a8974385c683------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:33:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanzim3421/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Next.js: App Router vs Pages Router — What You Need to Know (202]]></title>
            <link>https://medium.com/@tanzim3421/next-js-app-router-vs-pages-router-what-you-need-to-know-202-69a885ccaa56?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/69a885ccaa56</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nextjs-13]]></category>
            <category><![CDATA[nextjs-app-router]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Thu, 24 Oct 2024 17:56:41 GMT</pubDate>
            <atom:updated>2024-10-24T17:56:41.863Z</atom:updated>
            <content:encoded><![CDATA[<h3>Next.js: App Router vs Pages Router — What You Need to Know (2024)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YjP4yBLrl1Wy6yluaU5ToQ.png" /></figure><p>As developers, one of the first challenges we face when building web apps is figuring out how users will move between different pages or screens. If you’ve been working with <strong>Next.js</strong>, you’ve probably heard of two main approaches: the <strong>Pages Router</strong> and the newer <strong>App Router</strong>. I remember when I first encountered these options — it was a bit confusing, but once I understood the difference, everything clicked.</p><p>In this article, I’ll break down the key differences between the <strong>Pages Router</strong> (which you may already be familiar with) and the newer <strong>App Router</strong>. Whether you’re just starting out with Next.js or looking to expand your knowledge, I’ll explain things in a way that’s easy to follow. Let’s get into it!</p><h3>1. The Pages Router: The Old Reliable</h3><p>Before Next.js introduced the App Router, we all relied on the Pages Router for building our applications. If you’re coming from a traditional React background, it’s basically like using React Router, but built into Next.js to handle things automatically for you.</p><p>Here’s how it works:</p><ul><li><strong>File-based routing</strong>: All you need to do is create a .js or .ts file in the pages directory, and Next.js will turn that file into a page. For example, if you create pages/about.js, that automatically becomes the /about page. No extra setup required!</li><li><strong>Server-side rendering (SSR)</strong>: If you need to fetch data on the server (e.g., from an API), you can use getServerSideProps or getStaticProps inside your page files. It’s a powerful feature for improving performance and SEO without much effort.</li></ul><p><strong>Why it’s great for beginners</strong>:</p><ul><li><strong>Simple setup</strong>: You don’t need to worry about folder structure or complex routing setups — Next.js handles it for you.</li><li><strong>Stable</strong>: Pages Router has been around for a while and is super reliable.</li></ul><p><strong>Where it falls short</strong>:</p><ul><li><strong>Limited flexibility</strong>: As your app grows, you might find that handling more complex layouts and deeply nested routes can be tricky.</li></ul><h3>2. The App Router: The New Kid on the Block</h3><p>Next.js introduced the <strong>App Router</strong> in version 13 to give developers more control and flexibility. Instead of the older file-based system, the App Router uses <strong>folders</strong> to define routes and introduces more advanced features, like <strong>nested layouts</strong>.</p><p>Think of it like this: Instead of each file representing a single page, the App Router lets you define routes through folders, making it easier to manage large applications as they grow.</p><ul><li><strong>Folder-based routing</strong>: Routes are defined by folders inside the app directory. So, if you create app/about/page.js, that becomes the /about route.</li><li><strong>Nested layouts</strong>: This is a game-changer for organizing your app’s structure. You can create layouts that are shared across multiple routes, making it super easy to manage consistent designs and structures across your app.</li></ul><p><strong>Why it’s awesome</strong>:</p><ul><li><strong>Better for complex projects</strong>: If you’re building something more advanced, the App Router is designed to handle things like reusable layouts and deeply nested pages.</li><li><strong>Cleaner data fetching</strong>: Data fetching is done through async components, which feels more intuitive compared to the older getServerSideProps methods.</li></ul><h3>3. Server-Side Data Fetching: Pages Router vs App Router</h3><p>One of the key differences between the <strong>App Router</strong> and the <strong>Pages Router</strong> is how they handle <strong>server-side data fetching</strong>.</p><p>In the <strong>App Router</strong>, all data fetching is <strong>server-side by default</strong>, which simplifies the process of fetching data on the server before rendering the page. Meanwhile, in the <strong>Pages Router</strong>, you have to use special functions like getServerSideProps to fetch data on the server.</p><p>Let’s take a look at how this works with some code examples.</p><h4>App Router: Server-Side Data Fetching</h4><p>In the <strong>App Router</strong>, you can fetch data directly inside an <strong>async component</strong>. The data is fetched server-side by default, and it’s ready before the page is rendered:</p><pre>// app/posts/page.js<br>export default async function PostsPage() {<br>  const res = await fetch(&#39;https://jsonplaceholder.typicode.com/posts&#39;);<br>  const posts = await res.json();<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Posts&lt;/h1&gt;<br>      &lt;ul&gt;<br>        {posts.map((post) =&gt; (<br>          &lt;li key={post.id}&gt;{post.title}&lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Here’s what’s happening:</p><ul><li><strong>Async components</strong>: You can fetch data directly within the component itself, as it supports async/await.</li><li><strong>Server-side fetching by default</strong>: The data is always fetched server-side, ensuring the HTML is rendered with the data when sent to the client.</li></ul><h4>Pages Router: Server-Side Data Fetching</h4><p>In the <strong>Pages Router</strong>, you need to define a special function like getServerSideProps to fetch data server-side. Here’s how the same example would work:</p><pre>// pages/posts.js<br>export default function PostsPage({ posts }) {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Posts&lt;/h1&gt;<br>      &lt;ul&gt;<br>        {posts.map((post) =&gt; (<br>          &lt;li key={post.id}&gt;{post.title}&lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export async function getServerSideProps() {<br>  const res = await fetch(&#39;https://jsonplaceholder.typicode.com/posts&#39;);<br>  const posts = await res.json();<br><br>  return {<br>    props: {<br>      posts,<br>    },<br>  };<br>}</pre><p>Here’s how it works:</p><ul><li><strong>getServerSideProps</strong>: This function is used to fetch data server-side in the Pages Router. The data is passed as <strong>props</strong> to the page component.</li><li><strong>Separation of concerns</strong>: You have to keep the data-fetching logic outside of the component, which can make it feel more detached.</li></ul><h4>Which One Should You Use for Data Fetching?</h4><ul><li>If you prefer having <strong>cleaner, simpler code</strong> with all your data-fetching handled in the component itself, the <strong>App Router</strong> is a great choice.</li><li>If you need more flexibility, such as mixing <strong>client-side fetching</strong> with <strong>server-side fetching</strong>, or prefer the structure of keeping your data logic separate from the component, the <strong>Pages Router</strong> might be more comfortable for you.</li></ul><h3>3. Side-by-Side Comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOCGOanpcushn5-1JO2oAw.png" /></figure><h3>4. Which One Should You Use?</h3><p>For those of you who are just starting out or building small-to-medium projects, the <strong>Pages Router</strong> might be all you need. It’s easy to understand and works great out of the box.</p><p>However, if you’re looking to build a more complex app that requires a lot of reusable layouts and components, the <strong>App Router</strong> is definitely the better option. Even though it has a steeper learning curve, it’s designed to handle larger applications more gracefully.</p><h3>Conclusion</h3><p>Next.js has evolved to offer two great options for routing, depending on the complexity of your project. If you’re working on something simple or just want to get started quickly, go with the <strong>Pages Router</strong>. If you’re building something that’s going to grow and scale, the <strong>App Router</strong> will give you the tools to keep things organized and flexible.</p><p>Whichever you choose, the beauty of Next.js is that it makes routing (and your life) easier!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69a885ccaa56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Practical Guide to Cross-Browser Automation and Debugging with Playwright]]></title>
            <link>https://medium.com/@tanzim3421/a-practical-guide-to-cross-browser-automation-and-debugging-with-playwright-fddc7b6ee1da?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/fddc7b6ee1da</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <category><![CDATA[testing-framework]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Fri, 04 Oct 2024 05:47:37 GMT</pubDate>
            <atom:updated>2024-10-04T05:47:37.220Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*1aQ9ki7tVGg9edYFJJnM-g.png" /></figure><p>In today’s fast-paced development world, automated testing plays a critical role in ensuring the reliability of web applications. With tools like Playwright, developers can test across multiple browsers and devices effortlessly. In this article, I’ll share my recent experience building a cross-browser automated test suite using Playwright, exploring advanced features, performance testing, and key debugging techniques. Whether you’re just getting started or looking to take your automation to the next level, this guide will have something for you.</p><h3>Why Playwright for Cross-Browser Testing?</h3><p>Playwright offers an edge in automated testing because it can handle multiple browsers, such as Chromium, Firefox, and WebKit, in a single API. It also simplifies working with modern web applications by handling complex scenarios like waiting for network events, headless testing, and parallel execution. Its ability to test on different platforms seamlessly is why it stands out from the competition.</p><p>In my case, I wanted to ensure my automated tests could catch potential browser-specific issues early, making Playwright an obvious choice.</p><h3>Setting Up Your Playwright Environment</h3><p>To get started, you first need to install Playwright:</p><pre>npm install @playwright/test</pre><p>Once installed, you can create a test file and begin writing your first test. Below is a simple example of how to set up a test environment and open a page:</p><pre>const { test, expect } = require(&#39;@playwright/test&#39;);<br><br>test(&#39;Basic test&#39;, async ({ page }) =&gt; {<br>  await page.goto(&#39;https://news.ycombinator.com/&#39;);<br>  const title = await page.title();<br>  expect(title).toBe(&#39;Hacker News&#39;);<br>});</pre><p>This small script validates that the Hacker News homepage loads correctly and that the title is as expected. It’s a simple starting point, but from here, the possibilities grow.</p><h3>Extracting Web Data with Playwright</h3><p>In one of my more intricate projects, I needed to scrape article titles, URLs, and their corresponding timestamps from Hacker News. Playwright provided the capability to interact directly with the DOM and extract data using the $$eval function. Below are the functions I developed to extract article information and timestamps.</p><p><strong>Function to Extract Articles:</strong></p><pre>const { chromium } = require(&#39;playwright&#39;);<br><br>async function getArticlesFromPage(page) {<br>  return await page.$$eval(&#39;span.titleline a&#39;, (links) =&gt; {<br>    return links.map(link =&gt; ({<br>      title: link.textContent.trim(),<br>      href: link.href<br>    }));<br>  });<br>}<br><br>async function getTimestampsFromPage(page) {<br>  return await page.$$eval(&#39;span.age&#39;, (ages) =&gt;<br>    ages.map(age =&gt; new Date(age.title).getTime())<br>  );<br>}</pre><p>Function to Extract Timestamps:</p><pre>async function getTimestampsFromPage(page) {<br>  return await page.$$eval(&#39;span.age&#39;, (ages) =&gt;<br>    ages.map(age =&gt; new Date(age.title).getTime())<br>  );<br>}</pre><p>These functions allow you to extract relevant data from any given page. I later used them to automate the collection of 100 articles.</p><p>These functions allowed me to scrape relevant data from the Hacker News homepage. By separating the concerns — one function for articles, another for timestamps — the code remains modular and easy to maintain. I later expanded these functions to scrape up to 100 articles, ensuring that I collected enough data for testing purposes.</p><h3>Advanced Features for Robust Testing</h3><h4>Cross-Browser Automation:</h4><p>One of Playwright’s standout features is its ability to test across multiple browsers. To fully leverage this, I wrote tests that ran in parallel across Chromium, Firefox, and WebKit browsers. Here’s a look at how this was achieved:</p><pre>test.describe.parallel(&#39;Cross-Browser Testing&#39;, () =&gt; {<br>  [&#39;chromium&#39;, &#39;firefox&#39;, &#39;webkit&#39;].forEach((browserType) =&gt; {<br>    test(`Testing on ${browserType}`, async ({ browser }) =&gt; {<br>      const browserInstance = await browserType.newPage();<br>      await browserInstance.goto(&quot;https://news.ycombinator.com/&quot;);<br>      // Perform assertions or actions...<br>      await browserInstance.close();<br>    });<br>  });<br>});</pre><p>With this approach, I could ensure that my application worked consistently across multiple browsers without needing to write separate tests for each. Cross-browser testing is essential, especially for applications that need to perform reliably on a variety of user devices.</p><h4>Debugging and Error Handling:</h4><p>While writing tests, failures are inevitable, and debugging them is crucial. Playwright offers integration with Chrome DevTools for debugging purposes. However, I went a step further by using Playwright’s event listeners to capture errors directly from the browser console:</p><pre>page.on(&#39;console&#39;, msg =&gt; {<br>  if (msg.type() === &#39;error&#39;) {<br>    console.log(`Error: &quot;${msg.text()}&quot;`);<br>  }<br>});</pre><p>This allowed me to trace JavaScript errors in the web page during test execution, making it easier to pinpoint and resolve issues as they occurred.</p><h3>Performance Considerations in Web Scraping</h3><p>While scraping web data, one challenge I encountered was ensuring that all network activity completed before moving to the next step. For instance, if the page wasn’t fully loaded, my script could potentially miss extracting some articles. To address this, I used Playwright’s page.waitForLoadState(&#39;networkidle&#39;) method to ensure the page was fully loaded before continuing:</p><pre>await Promise.all([<br>  page.click(&#39;a.morelink&#39;),<br>  page.waitForLoadState(&#39;networkidle&#39;)<br>]);</pre><p>This optimization prevented premature interactions with the page, improving both the accuracy of the data and the efficiency of the scraping process.</p><h3>Creating Visual Reports for Your Test Suite</h3><p>Visual reports play a vital role in ensuring that the test suite runs smoothly and that issues are easily identifiable. Playwright allows you to capture screenshots of the current state of the page during testing. For example, here’s how I captured a screenshot of a page during test execution:</p><pre>await page.screenshot({ path: &#39;screenshot.png&#39; });</pre><p>In addition, Playwright supports generating detailed reports, allowing for a comprehensive view of the test runs. By integrating these tools, you can generate reports that provide insight into which tests passed, failed, or were skipped.</p><h3>Going Beyond Automation: Manual QA Insights</h3><p>While automation is powerful, it cannot cover every edge case. During my project, I also manually tested the user experience of the Hacker News website. This allowed me to ensure that every link worked correctly, that articles were displayed properly, and that the overall interface remained intuitive.</p><p>This balance between manual and automated testing leads to a more complete quality assurance process.</p><h3>Conclusion: Taking Your Automation to the Next Level</h3><p>Playwright is an incredibly versatile tool for testing web applications across multiple browsers and platforms. By leveraging its advanced features — such as cross-browser automation, debugging with DevTools, and parallel execution — you can build a robust test suite that ensures your web applications are performant, reliable, and scalable.</p><p>If you’re looking to improve your automated testing efforts, Playwright is a powerful tool that can help you achieve those goals. By incorporating the tips shared in this article, you can take your testing to the next level and deliver high-quality software every time.</p><h3>About the Author</h3><p>I’m a software engineer with over 3 years of experience, passionate about building scalable and secure applications. When I’m not coding, I enjoy writing tech articles, helping developers solve problems on Stack Overflow, and taking on challenging projects to expand my knowledge. I believe in continuous learning, and I’m always exploring new tools and technologies to enhance my development and testing skills. Playwright has been one of those exciting tools that helped me push my automation expertise to the next level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fddc7b6ee1da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Server-Side Rendering (SSR), Static Site Generation (SSG), and Client-Side Rendering…]]></title>
            <link>https://medium.com/@tanzim3421/understanding-server-side-rendering-ssr-static-site-generation-ssg-and-client-side-rendering-2e3958aeed8b?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e3958aeed8b</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[static-site-generator]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[client-side-rendering]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Mon, 29 Jul 2024 17:03:39 GMT</pubDate>
            <atom:updated>2024-07-29T17:03:39.341Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Server-Side Rendering (SSR), Static Site Generation (SSG), and Client-Side Rendering (CSR)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byDukOtSxldXPIg28r_Qhg.png" /></figure><p>Hey there! If you’re anything like me, you know that in our fast-paced digital world, making sure our web applications perform well and rank high on search engines is a top priority. Over the years, I’ve come across three powerful techniques that have truly transformed the way I build and optimize web apps: Server-Side Rendering (SSR), Static Site Generation (SSG), and Client-Side Rendering (CSR). Whether you’re a seasoned developer or just dipping your toes into the world of web development, understanding these techniques can significantly boost your app’s performance and user experience. Let’s dive in!</p><h4>What is Client-Side Rendering (CSR)?</h4><p>Client-Side Rendering (CSR) is a technique where the rendering of web pages happens in the client’s browser using JavaScript. When a user requests a page, the server sends a minimal HTML file along with JavaScript files. The browser then executes the JavaScript to build the HTML and render the page.</p><p>Benefits of CSR:</p><p><strong>Rich Interactivity:</strong></p><ul><li>CSR allows for highly interactive user interfaces, making applications feel more dynamic and responsive.</li></ul><p><strong>Efficient Data Loading:</strong></p><ul><li>Data can be fetched asynchronously, enabling smooth updates without reloading the entire page.</li></ul><p><strong>Improved User Experience:</strong></p><ul><li>Users can interact with the application immediately while data is being loaded in the background.</li></ul><p>Drawbacks of CSR:</p><p><strong>Initial Load Time:</strong></p><ul><li>The initial load time can be slow since the browser has to download and execute JavaScript before rendering the content.</li></ul><p><strong>SEO Challenges:</strong></p><ul><li>Search engines may struggle to index content that is rendered on the client side, potentially affecting SEO.</li></ul><p><strong>Complexity:</strong></p><ul><li>Managing state and asynchronous data loading can add complexity to the application.</li></ul><h4>What is Server-Side Rendering (SSR)?</h4><p>Server-Side Rendering (SSR) is a technique where web pages are rendered on the server rather than the client’s browser. When a user requests a page, the server generates the complete HTML for the page and sends it to the client’s browser. This approach contrasts with CSR.</p><p>Benefits of SSR:</p><p><strong>Improved Performance:</strong></p><ul><li>SSR can lead to faster initial load times because the browser receives a fully-rendered HTML page, reducing the time spent on executing JavaScript.</li></ul><p><strong>Enhanced SEO:</strong></p><ul><li>Search engines can easily crawl and index the pre-rendered HTML content, improving the website’s visibility and ranking.</li></ul><p><strong>Better User Experience:</strong></p><ul><li>Users see the content faster since the page doesn’t rely solely on JavaScript to build the content.</li></ul><p>Real-World Example:</p><p>At one of my previous companies, we implemented SSR for an API Developer Portal built with React. By rendering the pages on the server, we ensured that users experienced minimal load times and search engines effectively indexed our documentation, enhancing our overall SEO.</p><h4>What is Static Site Generation (SSG)?</h4><p>Static Site Generation (SSG) is the process of generating static HTML files for each page of a web application at build time. These static files are then served to users, offering a middle ground between traditional static sites and dynamic applications.</p><p>Benefits of SSG:</p><p><strong>Blazing Fast Performance:</strong></p><ul><li>Static files can be served quickly from a Content Delivery Network (CDN), leading to rapid load times.</li></ul><p><strong>Scalability:</strong></p><ul><li>Static files are easy to scale and distribute across servers, making them ideal for handling high traffic.</li></ul><p><strong>Enhanced Security:</strong></p><ul><li>With no server-side code execution on each request, the attack surface is significantly reduced.</li></ul><p>Real-World Example:</p><p>In the same API Developer Portal project, we used SSG for parts of our site that didn’t require frequent updates. By generating static files at build time, we ensured fast load times and reduced the load on our servers, providing a smooth and efficient user experience.</p><h4>Combining SSR, SSG, and CSR:</h4><p>Many modern frameworks, such as Next.js for React, allow developers to combine SSR, SSG, and CSR within a single application. This hybrid approach lets you choose the best rendering method based on the specific needs of each page. For example, you can use SSR for dynamic pages that change frequently, SSG for static pages like documentation or blogs, and CSR for highly interactive pages.</p><h4>Frameworks to Explore:</h4><p><strong>Next.js (React):</strong></p><ul><li>Next.js offers seamless support for SSR, SSG, and CSR, making it a popular choice among React developers.</li></ul><p><strong>Nuxt.js (Vue.js):</strong></p><ul><li>Nuxt.js provides similar capabilities for Vue.js applications, allowing developers to leverage SSR, SSG, and CSR easily.</li></ul><p><strong>Gatsby (React):</strong></p><ul><li>Gatsby specializes in SSG, enabling developers to build ultra-fast static sites with React.</li></ul><h4>Conclusion:</h4><p>Server-Side Rendering (SSR), Static Site Generation (SSG), and Client-Side Rendering (CSR) each offer unique advantages that can greatly enhance the performance, SEO, and user experience of your web applications. By understanding and leveraging these techniques, you can create faster, more scalable, and SEO-friendly websites.</p><h3>About the Author:</h3><p>I’m Tanzim Chowdhury, a software engineer with a passion for backend development and web optimization. With over 3 years of experience in the industry, I’ve had the opportunity to work on various projects that utilize SSR, SSG, and CSR to deliver high-performance web applications. Connect with me on <a href="https://www.linkedin.com/">LinkedIn</a> or check out my portfolio at <a href="https://www.tanzimcode.dev/">TanzimCode.dev</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e3958aeed8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big O Notation Made Easy: A Simple Guide to Writing Efficient Code in 2024]]></title>
            <link>https://medium.com/@tanzim3421/big-o-notation-made-easy-a-simple-guide-to-writing-efficient-code-in-2024-b385a5158a0e?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/b385a5158a0e</guid>
            <category><![CDATA[big-o-notation]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[efficient-coding]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Sat, 27 Jul 2024 16:29:36 GMT</pubDate>
            <atom:updated>2024-07-27T18:22:04.883Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RvyLs4TfHTRPdHs75mLLVQ.jpeg" /></figure><h3>What is Good Code?</h3><p>As a software engineer, I often judge code by two main qualities: readability and scalability.</p><p><strong>Readability</strong> means that your code is easy to understand. Imagine picking up a book written in a clear and simple language — you can easily follow the story. Similarly, readable code allows other developers (and future you) to quickly grasp what the code does. This includes using meaningful variable names, writing comments, and keeping the code clean and organized.</p><p><strong>Scalability</strong> means that your code can handle growth efficiently. As your application gets more users or processes more data, scalable code ensures that it continues to perform well without major changes.</p><h3>Understanding Big O Notation</h3><p>When we talk about the efficiency of our code, especially as it scales, we use a concept called Big O notation. Big O notation helps us understand how the performance of an algorithm changes as the size of the input data grows.</p><h3>Practical Example: Finding Nemo</h3><p>Let’s break this down with a simple example.</p><pre>const everyone = [&#39;dory&#39;, &#39;bruce&#39;, &#39;marlin&#39;, &#39;nemo&#39;, &#39;gill&#39;, &#39;bloat&#39;, &#39;nigel&#39;, &#39;squirt&#39;, &#39;darla&#39;, &#39;hank&#39;];<br>const large = new Array(100000).fill(&quot;nemo&quot;);<br><br>function findNemo(array) {<br>  let t0 = performance.now();<br>  for (let i = 0; i &lt; array.length; i++) {<br>    if (array[i] === &#39;nemo&#39;) {<br>      console.log(&#39;Found NEMO!&#39;);<br>    }<br>  }<br>  let t1 = performance.now();<br>  console.log(&#39;Call to find Nemo took &#39; + (t1 - t0) + &#39; milliseconds&#39;);<br>}<br><br>findNemo(everyone);</pre><p>Imagine we have an array of characters from Finding Nemo, and we want to find “Nemo” in the array. The findNemo function goes through each element of the array and prints &quot;Found NEMO!&quot; when it finds the correct one.</p><p>Running this function with a small array might take just a few milliseconds on your computer. However, if you run it on a different computer or with a larger array, the time taken can vary due to differences in hardware and other factors.</p><h3>Measuring Code Efficiency</h3><p>So, how do we measure the efficiency of code in a way that is consistent, regardless of hardware or programming language differences? This is where Big O notation comes in. It’s a way of describing how the runtime of an algorithm changes as the size of the input data grows, providing a universal language for discussing performance.</p><h3>Time Complexity</h3><p>Let’s look at some common Big O notations using our example:</p><p><strong>O(1) — Constant Time:</strong> The runtime doesn’t change regardless of the input size. For example, accessing the first element in the array.</p><pre>function getFirstElement(arr) {<br>  return arr[0];<br>}</pre><p><strong>O(n) — Linear Time:</strong> The runtime increases linearly with the input size. Our findNemo function is an example of this.</p><pre>function findNemo(array) {<br>  for (let i = 0; i &lt; array.length; i++) {<br>    if (array[i] === &#39;nemo&#39;) {<br>      console.log(&#39;Found NEMO!&#39;);<br>    }<br>  }<br>}</pre><ul><li>If the array has 10 elements, the function might take 10 milliseconds. If the array has 100,000 elements, it might take much longer, increasing linearly with the size of the array.</li></ul><p><strong>O(n²) — Quadratic Time:</strong> The runtime increases quadratically with the input size. For example, a function with nested loops.</p><pre>function printPairs(arr) {<br>  for (let i = 0; i &lt; arr.length; i++) {<br>    for (let j = 0; j &lt; arr.length; j++) {<br>      console.log(arr[i], arr[j]);<br>    }<br>  }<br>}</pre><ul><li>Let’s break it down: If you have an array of 10 elements, your function will need to perform 10 * 10 = 100 operations. If the array size grows to 100 elements, the function will perform 100 * 100 = 10,000 operations. This means that the time it takes to run the function grows much faster as the input size increases.</li></ul><p><strong>O(log n) — Logarithmic Time:</strong> The runtime increases logarithmically with the input size. For example, a binary search.</p><pre>function binarySearch(arr, target) {<br>  let left = 0;<br>  let right = arr.length - 1;<br>  while (left &lt;= right) {<br>    const mid = Math.floor((left + right) / 2);<br>    if (arr[mid] === target) return mid;<br>    else if (arr[mid] &lt; target) left = mid + 1;<br>    else right = mid - 1;<br>  }<br>  return -1;<br>}</pre><ul><li>Imagine you have a sorted array of 1,000,000 elements, and you’re looking for a specific element. With binary search, you don’t look through each element one by one. Instead, you repeatedly divide the array in half, drastically reducing the number of elements you need to check. In the worst case, this means you only need about 20 checks (logarithm base 2 of 1,000,000 is approximately 20).</li></ul><p><strong>O(n log n) — Linearithmic Time:</strong> The runtime increases linearly multiplied by the logarithm of the input size. For example, efficient sorting algorithms like Merge Sort and Quick Sort.</p><pre>function mergeSort(arr) {<br>  if (arr.length &lt;= 1) return arr;<br>  const mid = Math.floor(arr.length / 2);<br>  const left = mergeSort(arr.slice(0, mid));<br>  const right = mergeSort(arr.slice(mid));<br>  return merge(left, right);<br>}<br><br>function merge(left, right) {<br>  let result = [], leftIndex = 0, rightIndex = 0;<br>  while (leftIndex &lt; left.length &amp;&amp; rightIndex &lt; right.length) {<br>    if (left[leftIndex] &lt; right[rightIndex]) result.push(left[leftIndex++]);<br>    else result.push(right[rightIndex++]);<br>  }<br>  return result.concat(left.slice(leftIndex)).concat(right.slice(rightIndex));<br>}</pre><ul><li>If you have an array of 1,000 elements, an O(n log n) algorithm like merge sort will perform about 10,000 operations (1,000 * log(1,000)). If the array size grows to 10,000 elements, the algorithm will perform about 40,000 operations (10,000 * log(10,000)). This means that the algorithm is efficient, even for large input sizes, and scales well compared to quadratic algorithms.</li></ul><h3>Space Complexity: Understanding the Memory Footprint</h3><p>When we talk about how fast an algorithm is, we often focus on time complexity — how quickly it runs. But there’s another side to this coin: space complexity. Space complexity is all about how much memory an algorithm needs to run. Just like with time, it’s crucial to know how an algorithm’s memory requirements grow as the size of the input increases.</p><h4>Why Does Space Complexity Matter?</h4><p>Knowing about space complexity helps you write more efficient code, especially when working with large datasets or when memory is limited. An algorithm with high space complexity might be too “greedy” for memory, which could slow down your application or even cause it to crash.</p><p>By keeping an eye on both time and space complexity, you can create algorithms that are not only fast but also memory-friendly.</p><h4>Breaking Down Space Complexity</h4><ol><li><strong>Auxiliary Space</strong>: This is the extra memory an algorithm uses, not counting the memory needed to hold the input data. For instance, if your algorithm is using extra variables or stack space for recursion, that’s auxiliary space.</li><li><strong>Total Space</strong>: This combines both the auxiliary space and the space needed for the input itself. So, if an algorithm needs extra space to work with data plus the space to hold that data, that’s the total space it requires.</li><li><strong>Big O Notation for Space Complexity</strong>: We use Big O notation to express space complexity just like we do for time complexity. It helps us understand how memory usage grows with the input size. Some common notations are:</li></ol><ul><li><strong>O(1)</strong>: Constant space — no matter how big your input gets, the memory needed stays the same. For example, swapping two numbers requires the same amount of space.</li><li><strong>O(n)</strong>: Linear space — memory grows directly with the input size. If you’re creating a new list that’s as big as your input, you’re looking at O(n) space complexity.</li><li><strong>O(n²)</strong>: Quadratic space — memory usage grows with the square of the input size. For instance, a 2D matrix used in some algorithms might need O(n²) space.</li></ul><h3>The Trade-Off Between Space and Time Complexity</h3><p>When designing algorithms, there’s often a trade-off between space and time complexity. Improving one aspect can impact the other:</p><ul><li><strong>Time vs. Space</strong>: Sometimes, algorithms that run faster (lower time complexity) may use more memory (higher space complexity). For instance, an algorithm that precomputes results to speed up future queries may require additional memory.</li><li><strong>Balancing Act</strong>: In practice, you might need to balance between the two. For example, a quick but memory-intensive solution might be ideal for applications with ample memory but strict performance requirements. Conversely, a memory-efficient but slower algorithm may be better for environments with limited resources.</li></ul><h3>Conclusion</h3><p>Understanding Big O notation helps developers write more efficient code, especially for applications that need to handle large amounts of data or high traffic. By analyzing the time and space complexity of different algorithms, you can make informed decisions about which algorithms are best suited for your needs.</p><p>In conclusion, while readability and scalability are key components of good code, understanding and applying Big O notation ensures that your code can efficiently handle growth, making it both maintainable and high-performing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b385a5158a0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Buy a Domain and Connect It to Your Heroku App in 2024]]></title>
            <link>https://medium.com/@tanzim3421/how-to-buy-a-domain-and-connect-it-to-your-heroku-app-in-2024-f926c1f34c89?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/f926c1f34c89</guid>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[domain-registration]]></category>
            <category><![CDATA[dns-configuration]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Mon, 22 Jul 2024 21:43:22 GMT</pubDate>
            <atom:updated>2024-07-22T21:43:22.359Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*C2nYXFoWcH0HHxlSJfnBhA.jpeg" /></figure><p>Having a custom domain for your web projects not only adds a professional touch but also makes it easier for users to find and remember your site. When I first decided to buy a domain for my portfolio, <a href="https://tanzimcode.dev/">TanzimCode.dev</a>, I realized how much more credible and polished it made my online presence. In this guide, I’ll walk you through the process of buying a domain from Porkbun and connecting it to your Heroku app, so you can give your projects the same boost.</p><h3>How to Buy a Domain and Connect It to Your Heroku App in 2024</h3><p>Having a custom domain for your web projects not only adds a professional touch but also makes it easier for users to find and remember your site. When I first decided to buy a domain for my portfolio, TanzimCode.dev, I realized how much more credible and polished it made my online presence. In this guide, I’ll walk you through the process of buying a domain from Porkbun and connecting it to your Heroku app, so you can give your projects the same boost.</p><h3>Buying a Domain from Porkbun</h3><h4>Choosing a Domain Name</h4><p>The first step in establishing your online identity is choosing the right domain name. It should be unique, memorable, and reflective of your brand or project. When brainstorming ideas for my domain, I used tools like LeanDomainSearch and Namecheap to find inspiration. Eventually, I settled on TanzimCode.dev because it combines my name with what I do — coding!</p><h4>Registering Your Domain with Porkbun</h4><p>Once you’ve settled on the perfect domain name, the next step is to register it. I chose Porkbun for its affordable pricing and easy-to-use interface. Here’s how you can register your domain:</p><ol><li><strong>Search for Your Domain</strong>: Go to <a href="https://porkbun.com/">Porkbun</a> and enter your chosen domain name in the search bar.</li><li><strong>Select and Checkout</strong>: If your domain is available, add it to your cart and proceed to checkout. Make sure to review any additional services like domain privacy protection.</li><li><strong>Complete the Purchase</strong>: Enter your details, complete the payment, and you now own your domain!</li></ol><p>Porkbun offers a lot of benefits, including a free SSL certificate, which is essential for securing your site with HTTPS. This was a huge plus for me because it saved me time and money compared to other registrars.</p><h3>Connecting Your Domain to Heroku</h3><p>After registering your domain, the next step is to connect it to your Heroku app. Here’s how I did it:</p><p><strong>Add Custom Domain in Heroku</strong></p><ul><li>Log in to your Heroku account, go to your app, and navigate to the “Settings” tab. Under “Domains and certificates,” click on “Add domain” and enter your custom domain. Heroku will then provide a DNS target.</li></ul><p><strong>Set Up DNS Records in Porkbun</strong>:</p><ul><li>Log in to your Porkbun account and navigate to the “Domain Management” section.</li><li>Find your domain and click on “Edit” to manage DNS records.</li></ul><p><strong>Add an</strong> <strong>ALIAS Record</strong>:</p><ul><li><strong>Name</strong>: Enter the DNS target provided by Heroku</li><li><strong>Host</strong>: Leave this field blank.</li></ul><h4>Enabling SSL on Heroku</h4><ol><li><strong>Enable SSL</strong>: After setting up the DNS records, go back to the Heroku dashboard. In the “Settings” tab of your app, click on “Configure SSL” and enable the SSL. Heroku handles the SSL certificate configuration automatically.</li></ol><p>It took about 10 minutes for my site to be up and running with the custom domain and SSL enabled. Seeing my site live on <a href="https://tanzimcode.dev/">TanzimCode.dev</a> was an exciting moment that made all the effort worthwhile.</p><h3>Conclusion</h3><p>Setting up a custom domain for your Heroku app is a straightforward process that can significantly enhance your project’s professional appearance. By following these steps, you can easily buy a domain from Porkbun and connect it to your Heroku app.</p><p>If you want to know more about deploying to Heroku, you can refer to my other article about <a href="https://medium.com/@tanzim3421/automate-ci-cd-2024-seamlessly-deploy-your-node-js-application-to-heroku-using-github-actions-df160134609f">CI/CD with Git and Heroku</a>. Don’t hesitate to reach out if you have any questions or run into issues — I’d love to hear about your experiences and help where I can.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f926c1f34c89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate CI/CD 2024: Seamlessly Deploy Your Node.js Application to Heroku Using GitHub Actions]]></title>
            <link>https://medium.com/@tanzim3421/automate-ci-cd-2024-seamlessly-deploy-your-node-js-application-to-heroku-using-github-actions-df160134609f?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/df160134609f</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Fri, 12 Jul 2024 19:08:42 GMT</pubDate>
            <atom:updated>2024-07-12T19:08:42.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*cSsyFgrqylrRkhPWzHbujw.jpeg" /></figure><h3>Introduction</h3><p>Hey there, fellow engineers! In this tutorial, I’ll walk you through automating the Continuous Integration and Continuous Deployment (CI/CD) process for your Node.js applications using GitHub Actions. By the end of this guide, you’ll have a streamlined workflow that automatically deploys your application to Heroku whenever you push changes to your GitHub repository.</p><p><strong>Why CI/CD Matters to Me</strong></p><p>As someone deeply passionate about creating efficient workflows, automating CI/CD has been a game-changer in my development journey. It not only saves time but also ensures that every code change goes through a standardized testing and deployment process, boosting overall project reliability.</p><h3>Prerequisites</h3><p>Before we get started, make sure you have:</p><ol><li>A GitHub account.</li><li>A Node.js application repository on GitHub.</li></ol><h3>Step 1: Setting Up Your Node.js Application</h3><p>Let’s start by setting up a basic Node.js application. We’ll include a server.js file and set up a Procfile for Heroku:</p><ul><li><strong>Initialize a new Node.js project:</strong></li></ul><pre>mkdir my-app <br>cd my-app <br>npm init -y</pre><ul><li><strong>Install Express and create </strong><strong>server.js:</strong></li></ul><pre>npm install express</pre><ul><li><strong>Create </strong><strong>server.js file:</strong></li></ul><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const PORT = process.env.PORT || 3000;<br><br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&#39;Hello World!&#39;);<br>});<br><br>app.listen(PORT, () =&gt; {<br>  console.log(`Server started on port ${PORT}`);<br>});</pre><ul><li><strong>Update </strong><strong>package.json to include a start script:</strong></li></ul><pre>{<br>  &quot;name&quot;: &quot;my-app&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;A simple Node.js app&quot;,<br>  &quot;main&quot;: &quot;server.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;node server.js&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;express&quot;: &quot;^4.17.1&quot;<br>  }<br>}</pre><ul><li><strong>Create a </strong><strong>Procfile file:</strong></li></ul><pre>web: npm start</pre><h3>Step 2: Verify Application Setup Locally</h3><p>After setting up your Node.js application, it’s crucial to ensure everything works locally before automating deployment.</p><ul><li><strong>Start the Server:</strong> Open a terminal in your project directory and run:</li></ul><pre>npm start</pre><p>This command starts your Node.js server locally using the server.js file.</p><ul><li><strong>Open in Browser:</strong> Open your web browser and go to http://localhost:3000/. You should see &quot;Hello World!&quot; displayed, confirming that your local server is running correctly.</li><li><strong>Stop the Server:</strong> Press Ctrl + C in the terminal to stop the local server.</li></ul><h3>Step 3: Setting Up GitHub Actions</h3><p>Now, let’s automate the deployment process using GitHub Actions. We’ll create a workflow file that triggers deployment to Heroku on each push to the main branch.</p><ul><li>Create a workflow file .github/workflows/deploy.yml in your repository with the following content:</li></ul><pre>name: Deploy to Heroku<br><br>on:<br>  push:<br>    branches:<br>      - main<br><br>jobs:<br>    deploy:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v3<br>        with:<br>          fetch-depth: 0<br>          <br>      - name: Set up Node.js<br>        uses: actions/setup-node@v3<br>        with:<br>          node-version: &#39;16&#39;<br><br>      - name: Install dependencies<br>        run: npm install<br><br>      - name: Deploy to Heroku<br>        env:<br>          HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}<br>        run: |<br>          # Authenticate to Heroku<br>          echo $HEROKU_API_KEY | heroku auth:token<br>          <br>          # Verify authentication<br>          heroku auth:whoami<br>          <br>          # Add Heroku remote<br>          git remote add heroku https://heroku:$HEROKU_API_KEY@git.heroku.com/node-ci-cd.git<br>          <br>          # Push to Heroku<br>          git push heroku main</pre><p>Replace your-app-name with your actual Heroku app name. If you have tests for your application, replace npm test with your actual test command. If not, you can remove the step “Test application”.</p><h3>Step 4: Testing Your CI/CD Pipeline</h3><p>Before moving on, let’s commit our changes and trigger the GitHub Actions workflow to verify our setup:</p><pre>git add .<br>git commit -m &quot;Set up CI/CD pipeline&quot;<br>git push origin main</pre><p>Monitor the workflow:</p><ul><li><strong>Monitor Progress:</strong> Go to the “Actions” tab in your GitHub repository to monitor the progress of your workflow.</li><li><strong>Verify Deployment:</strong> Once completed, check your Heroku app to verify that it is running correctly.</li></ul><h3>Step 5: Verify Application Running Remotely (on Heroku)</h3><p>Once deployed, let’s ensure our application is running smoothly on Heroku by accessing its URL</p><ul><li><strong>Access the Deployed Application:</strong> After deployment, open your web browser and go to your Heroku app’s URL (e.g., https://your-app-name.herokuapp.com/). Ensure that you see &quot;Hello World!&quot; or the expected output, confirming that your application is running correctly on Heroku.</li><li><strong>View Logs (Optional):</strong> You can view the logs on the Heroku Dashboard or using the Heroku CLI to troubleshoot any issues that may arise.</li></ul><h3>Troubleshooting Common Issues</h3><p>Throughout this process, I’ll also cover common issues you might encounter and their solutions, ensuring a smooth deployment experience</p><p><strong>Issue: Heroku deployment fails with authentication errors.</strong></p><ul><li><strong>Solution:</strong> Ensure that your Heroku API key ($HEROKU_API_KEY) is correctly configured as a secret in your GitHub repository settings. Verify that the Heroku remote URL (git.heroku.com/your-app-name.git) is correctly set in your deployment step.</li></ul><p><strong>Issue: Application fails to start on Heroku (Boot timeout error).</strong></p><ul><li><strong>Solution:</strong> Check the Heroku logs (heroku logs --tail) for any errors during application startup. Ensure that your Procfile and package.json are correctly configured to start your application.</li></ul><p><strong>Issue: GitHub Actions workflow does not trigger on push to </strong><strong>main branch</strong></p><ul><li><strong>Solution:</strong> Verify your workflow file location (.github/workflows/deploy.yml) and the branch name (main) specified in the on section of the workflow file.</li></ul><h3>Conclusion</h3><p>By following these steps, you’ve successfully automated the CI/CD process for your Node.js application using GitHub Actions, empowering you to focus more on coding and less on manual deployment tasks. Feel free to experiment further with additional features or scaling your application as needed.</p><p>Happy coding!</p><p><strong>About Me</strong></p><p>Hi, I’m Tanzim, a passionate software developer with over two years of experience in back-end API services, authentication and authorization, SSO, and third-party API integration. I enjoy exploring new technologies and finding efficient ways to streamline development processes. When I’m not coding, you can find me working on personal projects, writing articles, or experimenting with new frameworks and tools. Connect with me on <a href="https://www.linkedin.com/in/tanzim-i/">LinkedIn</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df160134609f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Hashing: The Backbone of Data Integrity and Security 2024]]></title>
            <link>https://medium.com/@tanzim3421/understanding-hashing-the-backbone-of-data-integrity-and-security-92e6e5fcdee3?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/92e6e5fcdee3</guid>
            <category><![CDATA[hashing-algorithm]]></category>
            <category><![CDATA[hashing]]></category>
            <category><![CDATA[data-integrity]]></category>
            <category><![CDATA[password-hashing]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 05:01:57 GMT</pubDate>
            <atom:updated>2024-07-20T21:45:39.501Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N6K8cxiqWpFIkqQFoQsGBQ.jpeg" /></figure><p>I’ve spent a good portion of my career diving into the world of software development and data security. Today, I want to share with you something that I believe is a cornerstone of our digital lives: hashing. Let’s break down what hashing is, why it’s important, and how it impacts our daily tech interactions in a way that’s easy to grasp and apply.</p><h4>What is Hashing?</h4><p>Hashing is like creating a unique, short summary of a big file — a document, a picture, or even code. It converts this file into a fixed-size string of characters, often called a digest, that uniquely identifies the data.</p><p><strong>Example:</strong></p><p>Let’s say we have the phrase “Hello, world!”. Using a hash function like MD5, it gets transformed into a string of characters.</p><pre>Input: &quot;Hello, world!&quot;<br>MD5 Hash: 6cd3556deb0da54bca060b4c39479839</pre><p>Try it yourself! You can use an online hash generator or a command line tool like md5sum to see how different inputs generate unique hashes. Before we dive into hashing algorithms and it’s practical usage, let’s first look at what makes a good hash algorithm.</p><h4>Requirements for a Good Hashing Algorithm</h4><ul><li><strong>Deterministic:</strong> The same input always produces the same hash. <br>–Imagine identifying a person by their fingerprint. You need to be sure that every time you look at that fingerprint, it’s exactly the same. The same goes for hashing; consistency is key.</li><li><strong>Fast Computation:</strong> Generates hash values quickly and efficiently.<br>– Think of it like brewing coffee. You want your coffee fast but still good. In the tech world, speed matters, especially when you need to hash data frequently, like when verifying passwords or checking file integrity.</li><li><strong>Pre-image Resistance:</strong> Hard to reverse-engineer the original input from its hash.<br>- Imagine you see a delicious cake (the hash) but can’t figure out the secret recipe (the original data). This keeps your data safe because even if someone gets the hash, they can’t reverse-engineer it to get the original data.</li><li><strong>Avalanche Effect:</strong> Small input changes produce significantly different hashes.<br>- Think of it like throwing a small pebble into a calm pond and causing a big splash. This ensures that even small differences in input create vastly different hashes, making it harder for attackers to guess the original data.</li><li><strong>Collision Resistance:</strong> Nearly impossible for two different inputs to produce the same hash.<br>- Imagine if two different people had identical fingerprints. That would be confusing and problematic! In hashing, preventing collisions ensures that each unique input has a unique hash.</li><li><strong>Second Pre-image Resistance:</strong> Difficult to find another input with the same hash as a given input.<br>- This is like ensuring that once you’ve locked a door with a unique key (hash), no other key (input) can open it. This adds an extra layer of security.</li><li><strong>Fixed Output Length:</strong> Hash value is the same length regardless of input size.<br>- Think of it like having a fixed-size ID card that fits perfectly in your wallet, regardless of the person’s name length. This consistency is crucial for many applications, like digital signatures and checksums.</li></ul><h4>My Journey with Hash Functions</h4><p>When I first started exploring data integrity, I encountered various hash functions like MD5, SHA-1, and SHA-256. Each had its own strengths and weaknesses:</p><ul><li><strong>MD5:</strong> Fast but not secure against advanced attacks.</li><li><strong>SHA-1:</strong> More secure than MD5 but still has vulnerabilities.</li><li><strong>SHA-256:</strong> Part of the SHA-2 family, offering strong security and commonly used today.</li></ul><p>I remember using md5sum on my Linux machine to verify file integrity for the first time. It was like magic seeing a simple command ensure that my downloaded file was exactly what it was supposed to be.</p><p><strong>Example:</strong></p><p>Let’s hash another phrase, “Goodbye, world!” using SHA-256.</p><pre>Input: &quot;Goodbye, world!&quot;<br>SHA-256 Hash: f0a6c1ff918bbd68eabe1edc5f73a47c0e17627ff1e5bb4f44a0fb5082c43dbf</pre><p>Notice how the hash value is completely different from the previous example, demonstrating the avalanche effect.</p><h4>Applications of Hashing</h4><p>Hashing has practical, real-world applications:</p><ul><li><strong>Data Integrity:</strong> Verifying downloaded files haven’t been tampered with.<br>- When you download a file and see a hash value provided, it’s there for you to verify that the file hasn’t been tampered with.</li><li><strong>Password Storage:</strong> Systems store hashed passwords for security.<br>- Instead of storing passwords directly (which is dangerous), systems store the hash of the password. When you log in, the system hashes your input and compares it to the stored hash.</li><li><strong>Digital Signatures:</strong> Verifying the authenticity and integrity of messages and documents.<br>- Hashing is a crucial part of creating digital signatures that verify the authenticity and integrity of messages and documents.</li></ul><h4>Conclusion</h4><p>Hashing is essential for ensuring data integrity and security. Whether securing passwords, verifying file integrity, or enabling blockchain technology, understanding and using hashing effectively is crucial. Dive deeper into resources and start implementing hashing in your projects today!</p><p>I’d love to hear your thoughts and experiences with hashing. Drop a comment below or reach out — let’s continue this conversation!</p><h4>Further Reading and Resources</h4><ul><li><a href="https://csrc.nist.gov/publications/detail/sp/800-107/rev-1/final">NIST’s Guide to Hash Functions</a></li><li><a href="https://www.geeksforgeeks.org/hash-functions-and-list-types-of-hash-functions/">Understanding Hash Functions by GeeksforGeeks</a></li><li><a href="https://www.freecodecamp.org/news/md5-vs-sha-1-vs-sha-2-which-is-the-most-secure-encryption-hash-and-how-to-check-them/">The Basics of MD5, SHA-1, and SHA-256</a></li></ul><h3>About Me</h3><p>I’m Tanzim, a software developer with a passion for data security and integrity. Over the years, I’ve delved into various aspects of software development, focusing on creating secure and reliable systems. You can find more of my work and musings on my <a href="https://medium.com/@tanzim3421/about">Medium profile</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92e6e5fcdee3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Elasticsearch and Kibana on Windows: A step-by-step guide 2024]]></title>
            <link>https://medium.com/@tanzim3421/setting-up-elasticsearch-and-kibana-on-windows-a-step-by-step-guide-5b8368e2dc77?source=rss-a8974385c683------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b8368e2dc77</guid>
            <category><![CDATA[kibana]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Tanzim Chowdhury]]></dc:creator>
            <pubDate>Sun, 07 Jul 2024 08:31:37 GMT</pubDate>
            <atom:updated>2024-07-20T21:45:22.610Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nvl3SOvnmHVvQEcVVlYuew.jpeg" /></figure><p>Hi there! I’m Tanzim, a passionate tech enthusiast who loves diving into technologies. Today, I want to walk you through the process of setting up Elasticsearch and Kibana on a Windows machine. Whether you’re a developer, a data analyst, or just someone curious about these powerful tools, I’ve got you covered. Let’s get started!</p><h3>Prerequisites</h3><p>Before we begin, make sure you have the following:</p><ul><li>A Windows 10 or later version.</li><li>Java 11 or later installed (Even though Elasticsearch needs it, it should come bundled with it’s own JDK).</li><li>Basic knowledge of using the windows terminal (command prompt)</li></ul><h3>Step 1: Install Elasticsearch</h3><h3>1.1 Download Elasticsearch</h3><ul><li>Head over to the <a href="https://www.elastic.co/downloads/elasticsearch">Elasticsearch download page</a></li><li>Download the latest Windows ZIP file</li></ul><h3>1.2 Extract and Start Elasticsearch</h3><ul><li>Extract the ZIP file to a folder, like C:\Elasticsearch</li><li>Open Command Prompt as Administrator</li><li>Go to the bin directory of your Elasticsearch folder.</li><li>Run elasticsearch.bat to start Elasticsearch</li></ul><pre>cd C:\Elasticsearch\bin<br>elasticsearch.bat</pre><p>Please note that it will take some time for the elastic server to start and run. Once it’s successfully completes, you should see something similar printed in your terminal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_eYnpiltMX6llc2TcwLzKw.png" /></figure><p>Here, you should notice 3 important things.</p><ul><li>The auto generated password for the default user “elastic”</li><li>The self signed CA certificate</li><li>A <strong>temporary token</strong> which you will need to use with Kibana for configuration. Notice that this token is temporary and will be valid for only 30 mins. If it expires, you will need to generate a new one.</li></ul><p>Please copy the whole information as you will need all of these in just a moment.</p><p>To verify Elasticsearch is up and running, use this curl command</p><pre>curl -k -X GET &quot;https://localhost:9200/&quot; -u elastic:your_password</pre><p>Replace your_password with the password which Elasticsearch just provided for you. You should get a successful JSON response like this:</p><pre>{<br>  &quot;name&quot; : &quot;your-node-name&quot;,<br>  &quot;cluster_name&quot; : &quot;elasticsearch&quot;,<br>  &quot;cluster_uuid&quot; : &quot;your-cluster-uuid&quot;,<br>  &quot;version&quot; : {<br>    &quot;number&quot; : &quot;8.x.x&quot;,<br>    &quot;build_flavor&quot; : &quot;default&quot;,<br>    &quot;build_type&quot; : &quot;zip&quot;,<br>    &quot;build_hash&quot; : &quot;your-build-hash&quot;,<br>    &quot;build_date&quot; : &quot;your-build-date&quot;,<br>    &quot;build_snapshot&quot; : false,<br>    &quot;lucene_version&quot; : &quot;8.x.x&quot;,<br>    &quot;minimum_wire_compatibility_version&quot; : &quot;7.x.x&quot;,<br>    &quot;minimum_index_compatibility_version&quot; : &quot;7.x.x&quot;<br>  },<br>  &quot;tagline&quot; : &quot;You Know, for Search&quot;<br>}</pre><h3>Step 2: Install Kibana</h3><h3>2.1 Download Kibana</h3><ul><li>Head over to the <a href="https://www.elastic.co/downloads/kibana">Kibana download page</a></li><li>Download the latest Windows ZIP file</li></ul><h3>2.2 Extract and Configure Kibana</h3><ul><li>Extract the ZIP file to a folder, like C:\Kibana</li><li>Open the config folder inside the extracted directory</li><li>Open the file kibana.yml</li></ul><p>Now, we are going to make a few changes to this file. Assuming you did all the steps above for Elasticsearch correctly, let’s go through setting some defaults.</p><p>First, we will need to change the host. Keep searching the file until you come across:</p><pre>#elasticsearch.hosts: [&quot;http://localhost:9200&quot;]</pre><p>Uncomment this by removing the # sign, and then change http to https.</p><pre>elasticsearch.hosts: [&quot;https://localhost:9200&quot;]</pre><p>Next, find:</p><pre>#elasticsearch.ssl.certificateAuthorities: [&quot;/path/to/your/CA.pem&quot;]<br>#elasticsearch.ssl.verificationMode: full</pre><p>Here, we need to specify the path for the certificate file generated by Elasticsearch. In the extracted Elasticsearch folder, go to config -&gt; certs. There you will find a file ending in .crt; that&#39;s the certificate file.</p><p>Copy the file’s full path and paste it as a value for the elasticsearch.ssl.certificateAuthorities. Please note that Windows paths use backslashes \, but for the configuration file you need to replace them with forward slashes /. Set the verificationModeto none.</p><pre>elasticsearch.ssl.certificateAuthorities: [&quot;C:/Users/…/elasticsearch-8.14.2/config/certs/http_ca.crt&quot;]<br>elasticsearch.ssl.verificationMode: none</pre><p>Now, before we go to the last part of the Kibana configuration, we will need to generate a token for the service account “elastic/kibana”. What is a service account? It’s an account specifically for integration with external services that connect to Elasticsearch (Kibana, for example). You can learn more about service accounts <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/service-accounts.html">here</a>.</p><p>To generate this, open a new terminal and paste this code:</p><pre>curl -k -X POST &quot;https://localhost:9200/_security/service/elastic/kibana/credential/token/token1?pretty&quot; -u elastic:your_password</pre><p>Remember to replace your_password with your Elasticsearch password that was generated.</p><p>Once you successfully make that REST call, you should get a token. Copy that. Now search the kibana.yml file again until you find:</p><pre># elasticsearch.serviceAccountToken: &quot;my_token&quot;</pre><p>Replace my_token with the value you just copied. Now save this file and close it.</p><h3>Step 3: Start Kibana and Connect to Elasticsearch</h3><ul><li>Open a new terminal</li><li>Navigate to the bin directory of your Kibana folder</li><li>Run elasticsearch.bat to start Kibana</li></ul><pre>cd C:\Kibana\bin<br>kibana.bat</pre><p>If all goes well, you should be given a local host URL in your terminal. Click on it and it direct you to the Kibana homepage which is usually <a href="http://localhost:5601/">http://localhost:5601/</a> . If all goes well, you should come across this page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BTSaBIhBdatS_215VdI0w.png" /></figure><p>The enrollment token is the <strong>temporary token </strong>which you copied in step 1.2. Paste it in and click on <strong>Configure Elastic. </strong>And that’s it, you have both Elasticsearch and Kibana up and running.</p><p>In the next article, we will look at the architecture of Elasticsearch and perform some basic REST API CRUD operations using our GUI, Kibana. So stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b8368e2dc77" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>