<?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[Devtimeblog]]></title><description><![CDATA[Devtimeblog]]></description><link>https://devtimeblog.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 01 Sep 2026 02:26:14 GMT</lastBuildDate><atom:link href="https://devtimeblog.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[The significance of union and intersection types in Typescript.]]></title><description><![CDATA[In Typescript, we have free access to multiple types in one type by Union or Intersection. However, there is a big difference between union and intersection types. Here is a glimpse of both types, including examples :
Union Type
Let's say I have two ...]]></description><link>https://devtimeblog.hashnode.dev/the-significance-of-union-and-intersection-types-in-typescript</link><guid isPermaLink="true">https://devtimeblog.hashnode.dev/the-significance-of-union-and-intersection-types-in-typescript</guid><category><![CDATA[TypeScript]]></category><dc:creator><![CDATA[MD.Tajkier Haque Raiyan]]></dc:creator><pubDate>Tue, 07 May 2024 17:57:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1715104591426/d443a458-f4f8-481e-86ab-83423a2374a4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Typescript, we have free access to multiple types in one type by Union or Intersection. However, there is a big difference between union and intersection types. Here is a glimpse of both types, including examples :</p>
<h3 id="heading-union-type">Union Type</h3>
<p>Let's say I have two types of users: <strong>Admin</strong> and <strong>Saller.</strong></p>
<pre><code class="lang-typescript"><span class="hljs-keyword">type</span> TAdmin = {
  name: <span class="hljs-built_in">string</span>;
  email: <span class="hljs-built_in">string</span>;
  permissions: <span class="hljs-string">"manager"</span> | <span class="hljs-string">"reporter"</span> | <span class="hljs-string">"contentManager"</span>;
  role: <span class="hljs-string">"admin"</span>;
};

<span class="hljs-keyword">type</span> TSeller = {
  name: <span class="hljs-built_in">string</span>;
  email: <span class="hljs-built_in">string</span>;
  img?: <span class="hljs-built_in">string</span> | <span class="hljs-literal">null</span>;
  role: <span class="hljs-string">"seller"</span>;
};
<span class="hljs-comment">// This is a normal UserData</span>
<span class="hljs-keyword">const</span> apiSellerUserObject: TAdmin | TSeller = {
  name: <span class="hljs-string">"Kim Soo Hyun"</span>,
  email: <span class="hljs-string">"kim@gmail.com"</span>,
  img: <span class="hljs-literal">null</span>,
  role: <span class="hljs-string">"seller"</span>,
};

<span class="hljs-comment">// This is a admin UserData</span>
<span class="hljs-keyword">const</span> apiAdminUserObject: TAdmin | TSeller = {
  name: <span class="hljs-string">"Kim Soo Hyun"</span>,
  email: <span class="hljs-string">"kim@gmail.com"</span>,
  role: <span class="hljs-string">"admin"</span>,
  permissions: <span class="hljs-string">"manager"</span>,
};
</code></pre>
<p>In the above example, both are the types of users, and I imagine I don't know which user is coming from the API request. Because of that, I will give my object data type, whether it is seller or Admin. I will check it after the API request finishes. It's works like the javascript <strong><em>OR</em> [||] operator.</strong> In this kind of scenario, Union types are convenient. The main benefit of using it is that I can easily use Union when I'm not sure both types can be set. Shortly speaking, it will just check if one of the type conditions is true, then it will work fine.</p>
<h3 id="heading-intersection-type">Intersection Type</h3>
<p>Let's say I wanted to make a new type using the above example's <strong>Admin</strong> type. In the latest type, I need both the Admin and new properties. And combine them into a single new type called <strong>SuperAdmin.</strong> Take a look</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">type</span> TAdmin = {
  name: <span class="hljs-built_in">string</span>;
  email: <span class="hljs-built_in">string</span>;
  permission: <span class="hljs-string">"manager"</span> | <span class="hljs-string">"reporter"</span> | <span class="hljs-string">"contentManager"</span>;
  role: <span class="hljs-string">"seller"</span> | <span class="hljs-string">"admin"</span>;
};

<span class="hljs-keyword">type</span> SuperAdmin = Omit&lt;TAdmin, <span class="hljs-string">"permission"</span>&gt; &amp; {
  contactInfo: <span class="hljs-built_in">string</span>;
  isNidVerified: <span class="hljs-built_in">boolean</span>;
  permission: <span class="hljs-string">"transactionManagement"</span> | <span class="hljs-string">"ControlUser"</span>;
};

<span class="hljs-comment">// This is a super normal UserData</span>
<span class="hljs-keyword">const</span> apuSuperAdminObject: SuperAdmin = {
  name: <span class="hljs-string">"Kim Soo Hyun"</span>,
  email: <span class="hljs-string">"kim@gmail.com"</span>,
  role: <span class="hljs-string">"admin"</span>,
  contactInfo: <span class="hljs-string">"01908279809"</span>,
  isNidVerified: <span class="hljs-literal">true</span>,
  permission: <span class="hljs-string">"transactionManagement"</span>,
};
</code></pre>
<p>Here, you need to add some extra property in that <strong>superAdminObject</strong>. Because those two properties are also required, you cannot miss that extra property, as I said, using the intersection operator (&amp;). That's how I can force users consistently to have those in the property in Super Admin. It works like a Javascript AND (&amp;&amp;) operator in which both conditions must be fulfilled. Here is the main benefit of this intersection type. I can take an existing type, modify it on top of a new one, and make it a different one.</p>
<p><strong><em>Lastly</em></strong>, both types are very handy and useful. Just know when to use what. You can choose the intersection Type when you want both types to meet your condition. Use Union to meet just one condition of those types for your object.</p>
]]></content:encoded></item><item><title><![CDATA[Docker Beginner to Advanced Concepts Part - 1]]></title><description><![CDATA[Note*: I'm using Yarn, so don't be confused if I said somewhere npm; both are the same package managers for Node JS. You don't need to learn it. Just follow the blog to understand some important fundamentals of the docker.*
What is Docker?
Docker is ...]]></description><link>https://devtimeblog.hashnode.dev/docker-beginner-to-advanced-concepts-part-1</link><guid isPermaLink="true">https://devtimeblog.hashnode.dev/docker-beginner-to-advanced-concepts-part-1</guid><category><![CDATA[Docker]]></category><category><![CDATA[docker images]]></category><category><![CDATA[docker container]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[MD.Tajkier Haque Raiyan]]></dc:creator><pubDate>Mon, 15 Apr 2024 07:39:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1712472601365/157a7a49-8b7a-470c-ad07-7c091f1aff82.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong><em>Note</em></strong>*: I'm using Yarn, so don't be confused if I said somewhere npm; both are the same package managers for Node JS. You don't need to learn it. Just follow the blog to understand some important fundamentals of the docker.*</p>
<h3 id="heading-what-is-docker">What is Docker?</h3>
<p>Docker is a container technology tool for creating and managing containers. If you're wondering what a container is, think of it as a package of code that includes all your project dependencies and libraries needed to run that code. Picture a picnic basket where you carry all the necessary items for a picnic and can share them with your friends.</p>
<h3 id="heading-images-vs-container">Images vs Container</h3>
<p>Images are the blueprints of your project, holding all your packages and dependencies. <strong>For example</strong>, they contain your Node.js environment and all your code. On the other hand, a container takes a copy of that Image and runs it in an isolated environment, such as your Node.js server. The exciting part is you can run multiple containers using the same Image, and they will always work the same until you change the Image.</p>
<h3 id="heading-types-of-images">Types of Images</h3>
<p>We have two types of images: <strong><mark>pre-built existing images</mark></strong> from the <a target="_blank" href="https://hub.docker.com/">Docker Hub</a> and another type is a <strong><mark>pre-built image on top of your custom image</mark></strong>.</p>
<h3 id="heading-lets-see-an-example">Let's see an example.</h3>
<p><em>Here is my Folder Structure</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1713168712323/f7e842d8-e9a2-414e-a5f6-4239e9f5595f.png" alt /></p>
<p>I'm using Node.js. To follow along, pull it from here. First, create a <strong>Dockerfile</strong> at the root of your project.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1712501993899/bf6b12b4-164c-49e9-b6bd-c1ee13c797bb.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p><strong>FROM:</strong> is used for a top-level pre-built image upon your custom: Os <strong><mark>(Linux Distro) </mark></strong> or <strong><mark>Any runtime (Node.js)</mark>.</strong> You can find anything on the Docker hub.</p>
</li>
<li><p><strong>WORKDIR</strong>: Here, you can locate your Image folder, where all the code should be copied from your machine to the Image. Because your local machine file system and image file system are different, I have copied my files to the **/app** directory of the Image in the example.</p>
</li>
<li><p><strong>COPY:</strong> This command lets you copy a file from your local machine to the Image. I have done this for the second time because of Docker Image Layer-based Architecture, which I will discuss in this section.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1712502804622/564a4064-04de-47df-95eb-1f91fcbcf26e.png" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>RUN:</strong> Here, you can specify which command you must run when the Image is being built.</p>
</li>
<li><p><strong>EXPOSE:</strong> It exposes a port from your container. But it is optional. You can easily do this by adding a flag on the command line. We will talk about it later in this section.</p>
</li>
<li><p><strong>CMD:</strong> This command allows you to specify which command you must run after creating an Image. For example, you can use this command to create a container from that Image and run something after building the container.</p>
</li>
</ol>
<h3 id="heading-understanding-image-layers">Understanding Image Layers</h3>
<p>The Docker image works on a layer-based Architecture. First, after listing all the commands in the <strong>Dockerfile</strong>, you execute them individually when you run the <strong>[docker build .]</strong> command. This will build your Image one by one using the command layers you have given in the <strong>Dockerfile</strong>. In the <strong>Dockerfile, you have a command called [COPY. /app], which copies and pastes your local files into the image file system.</strong> Which is different from your local file system. By running that copy command, Docker will remember and cache your files until your local file changes and you rebuild the Image. Then, it will run other listed commands that need to be run after this copy command, which will also be cached.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1713165585545/92339b3a-c2b2-4894-90e8-9026159d1d25.png" alt class="image--center mx-auto" /></p>
<p>The above picture shows when I built the Image for the second time without changing my files. Instead, it will use the cache. It won't take as long as it took when I was building it for the first time. Here is a fun part: if I have to change something in my code and rebuild it, although I have only changed one file in the code base, it will re-run all the commands listed after copying my files because it knows something has changed. So the catch is if you wanted to optimise your commands, let's say you don't want to run npm install all the time because you haven't made any changes on the package.json file. You need to copy your package.json file before running the install commands. Then, you can copy all your other files from the code base, and then it won't run when you have just changed something in the code because You haven't installed any packages. Therefore, it comes from the cache. Here is an example :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1713166358757/725e206c-6573-41b4-a330-198ec591a55e.png" alt class="image--center mx-auto" /></p>
<p><strong>The next part is coming soon...</strong></p>
]]></content:encoded></item><item><title><![CDATA[Linked List 101 - Introductions]]></title><description><![CDATA[What is a Linked list?
A linked list is a data structure or, as you can say, a collection of nodes connected to each other. It's a very popular and efficient Data Structure. There are two types of Linked lists: singly and Doubly. Today, we will see a...]]></description><link>https://devtimeblog.hashnode.dev/linked-list-101-introductions</link><guid isPermaLink="true">https://devtimeblog.hashnode.dev/linked-list-101-introductions</guid><category><![CDATA[#linkedlists]]></category><category><![CDATA[linked list, singly linked list]]></category><category><![CDATA[linked-list-101]]></category><category><![CDATA[linkedlist-101]]></category><dc:creator><![CDATA[MD.Tajkier Haque Raiyan]]></dc:creator><pubDate>Fri, 03 Feb 2023 14:04:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1675429141666/855efca2-f094-4b05-82ba-a58f41143e28.avif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-is-a-linked-list"><em>What is a Linked list</em>?</h3>
<p>A linked list is a data structure or, as you can say, a collection of nodes connected to each other. It's a very popular and efficient Data Structure. There are two types of Linked lists: singly and Doubly. Today, we will see a basic overview of the Linked list. Let's get started.</p>
<hr />
<h3 id="heading-what-is-a-pointer"><em>What is a Pointer?</em></h3>
<p>Now you might be thinking, what is a pointer? Don't worry. I will explain. So first of all, you need a basic knowledge of memory and how computers store our data. When we declare an Array, it will allocate memory contiguously, which means one by one. But this is different in a hashtable and Linked list. In a Linked List, data is stored in various locations, not contiguously. By using the Pointer, we caPointer our Data addresses. Input</p>
<p>integer strings take different memory spaces, so we need to store them in something. Here comes pointers. A pointer can store the address easily. For example, I declared a variable and stored it as an Integer so it would go to my memory space and take 1 - 3 bytes. Now I know the starting address and need to store the end address. That's why we need pointers. I know It's quite a boring explanation, by the way. It's the core of pointers.</p>
<hr />
<h2 id="heading-pointers-in-linked-list">Pointers in Linked List</h2>
<p>So now we know what a pointer is, we can go on to the Linked List pointer. It is the same as what I have told you in <strong>what is a Pointers</strong> section. Pointers are the heart of Linked List. Linked means Everything is connected. By the way, here is the catch: Is Everything associated with a pointer? The Pointer is noPointerut, just pointing to its next or previous nodes. <strong>Node</strong> means you can think of an object with the key of value and a next or previous key with a value of its previous or next node. That's it for now. I will explain it briefly after I dive into Singly and Double Linked Lists.</p>
<p><strong>Next Part is coming soon....</strong></p>
]]></content:encoded></item></channel></rss>