<?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: Kaustubh Joshi</title>
    <description>The latest articles on Forem by Kaustubh Joshi (@elpidaguy).</description>
    <link>https://forem.com/elpidaguy</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%2F662386%2F6a883e1e-42f3-415d-b0c2-775b480e5c5a.jpeg</url>
      <title>Forem: Kaustubh Joshi</title>
      <link>https://forem.com/elpidaguy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/elpidaguy"/>
    <language>en</language>
    <item>
      <title>Kubuntu might be the revive potion you are looking for your old laptop 🐦‍🔥</title>
      <dc:creator>Kaustubh Joshi</dc:creator>
      <pubDate>Mon, 16 Jun 2025 15:42:53 +0000</pubDate>
      <link>https://forem.com/elpidaguy/kubuntu-might-be-the-revive-potion-you-are-looking-for-your-old-laptop-8fk</link>
      <guid>https://forem.com/elpidaguy/kubuntu-might-be-the-revive-potion-you-are-looking-for-your-old-laptop-8fk</guid>
      <description>&lt;h3&gt;
  
  
  🤓 Introduction
&lt;/h3&gt;

&lt;p&gt;I have a HP laptop I bought in year 2016. It had the top specs a mid-range gaming laptop can have at that point.&lt;br&gt;
Over the period of 9 strong years, I noticed that the performance of my laptop degraded slowly. And all this time I was blaming my old hardware for occasional hangs and slow response time.&lt;/p&gt;

&lt;p&gt;Many users like me often attribute this as an hardware failure, but the real issue is (most of the time) the operating system, which in my case was Windows.&lt;/p&gt;

&lt;p&gt;In addition to that, Microsoft has randomly dropped the bomb, that Windows 10 will be out of support starting Oct 25, and many of these old hardware cannot run official Windows 11 image.&lt;/p&gt;

&lt;p&gt;This is the perfect opportunity to explore some Linux based distros.&lt;br&gt;
In this post, I will share my experience and try to convince you to start using Kubuntu.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎱 Why Kubuntu?
&lt;/h2&gt;

&lt;p&gt;These reasons are coming from my personal experience, let's see why I like Kubuntu.&lt;/p&gt;

&lt;h3&gt;
  
  
  ⛷️ Performance Boost: My Old Laptop Runs 80% Faster now
&lt;/h3&gt;

&lt;p&gt;I started noticing the performance boost immediately after I installed Kubuntu.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First thing first, the boot time to load the OS reduced to around 9 seconds, which is super fast.&lt;/li&gt;
&lt;li&gt;The animations were crisp, fast and beautiful, and the apps like Libre Office, VLC and Firefox, loaded in a blink of an eye.&lt;/li&gt;
&lt;li&gt;I also attached external accessories like Keyboard, Mouse and external Monitor with HDMI and I did not find any lag or issues.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🏡 Gnome vs KDE? Why I preferred KDE?
&lt;/h3&gt;

&lt;p&gt;In very layman terms, Gnome and KDE are the softwares which runs on the top of your operating system session layer, which decides how your GUI will look like.&lt;br&gt;
This means, using Gnome on Ubuntu will look nothing like using KDE on Ubuntu (without tweaks of course).&lt;br&gt;
Personally after using both for more than a year, I can vouch for KDE, as it is more Modern looking and gives more premium feel.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Customizability:&lt;/strong&gt; You can change anything to your liking if you spend some time searching stable plugins. I usually prefer custom apps over the inbuilt ones, like for an example 'Kitty' for Terminal &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; KDE Plasma is very lightweight and super fast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aesthetic:&lt;/strong&gt; With few settings, even without the external apps, you can make your desktop look like MacOS, and it's really fun to try different KDE settings.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🥾 Live Boot Mode
&lt;/h3&gt;

&lt;p&gt;Just like any other Linux distro, you can quickly make a bootable USB with Kubuntu ISO image and run the OS without installing it onto your drive.&lt;br&gt;
All the KDE settings, customization and installations are available in the live boot options.&lt;br&gt;
So, if you are unsure if you really want to switch, you can give the Live Boot Mode a try.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I recommend doing this before clean install as with Live boot mode, you will get an idea of how the OS will run on your hardware, how is the performance and early detection of driver issues, if any.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  👨🏻‍💻 Clean Install
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backup Your Data:&lt;/strong&gt; Make sure your important files are backed up in an external storage device, as installing any OS will wipe your disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create a Bootable USB:&lt;/strong&gt; Download and run &lt;a href="https://etcher.balena.io/" rel="noopener noreferrer"&gt;balenaEtcher&lt;/a&gt; and create a bootable USB drive with the Kubuntu ISO.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boot from USB:&lt;/strong&gt; Restart your computer and boot from the USB drive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Select "Install Kubuntu":&lt;/strong&gt; Select Install Kubuntu option instead of Live Mode to open the installer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partitioning:&lt;/strong&gt; I prefer selecting defaults if this option sounds confusing, but only and only do this, if your data is already backed up somewhere else.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Follow Installation Prompts:&lt;/strong&gt; Set your timezone, keyboard layout, and create a user account, and voila, your Kubuntu will be ready to use.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  ⚠️ Risks: Driver Issues and App Compatibility
&lt;/h3&gt;

&lt;p&gt;When you try to switch from one OS to another, there are always some potential risks involved. And these experiences may ruin your entire day or rather week, if they appear out of nowhere as a surprise.&lt;br&gt;
Being an open-source software which is free to use, there are few things which you should be aware of for Kubuntu:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Driver issues:&lt;/strong&gt; Some laptops and their hardware may not have supporting drivers for the latest version of Kubuntu. You can always use community built drivers, if they are available, but at your own risk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application compatibility:&lt;/strong&gt; I might be making a stupid point here, but many of the Mac and Windows application may not have Linux supported distributions like MS Office and Adobe. Many of these already has open source alternatives, but they always has a small learning curve involved. Also, you can also try tools like Wine or alternatives which can run your Windows apps on Linux.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other random issues I faced:&lt;/strong&gt; It might be because of something I did wrong (it always is), but I also faced a random crash of Touch-pad and mouse cursor in my Kubuntu. Just putting it here if anyone faces the same in the future.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🥧 Other Stable Distros for Windows Users
&lt;/h2&gt;

&lt;p&gt;I understand you are a long Windows or Mac User and you want stability more than speed and aesthetics. Fear not, here are some more stable and windows looking Linux Distros you can try:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linux Mint:&lt;/strong&gt; Known for its ease of use and Windows-like interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zorin OS:&lt;/strong&gt; Designed to make the transition from Windows to Linux easier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elementary OS:&lt;/strong&gt; Focuses on a clean and simple user experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have some time in your hand, explore these options with Live mode and choose for yourself.&lt;/p&gt;




&lt;h2&gt;
  
  
  🗓️ Conclusion
&lt;/h2&gt;

&lt;p&gt;With Windows 10 going away, this is the right time to explore the world of FOSS. And Kubuntu could definitely be your gateway to it.&lt;br&gt;
It is fast, modern, easily customizable, huge community support and FREE.&lt;br&gt;
By installing it on your old laptop, you will pour the life into it for many years to come.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Feel free to leave a comment on your similar experiences of switching to Kubuntu or any other Linux distro.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🔗 Useful Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kubuntu.org/getkubuntu/" rel="noopener noreferrer"&gt;Get Kubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://etcher.balena.io/" rel="noopener noreferrer"&gt;Boot Media Creator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discourse.ubuntu.com/c/flavors/kubuntu/187" rel="noopener noreferrer"&gt;Official Community&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/unixporn/comments/3iy3wd/stupid_question_what_is_ricing/" rel="noopener noreferrer"&gt;ricing (?)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>productivity</category>
      <category>opensource</category>
      <category>discuss</category>
    </item>
    <item>
      <title>AutoHotKey Experience on Windows: I am loving it 🤓</title>
      <dc:creator>Kaustubh Joshi</dc:creator>
      <pubDate>Mon, 02 Jun 2025 12:17:01 +0000</pubDate>
      <link>https://forem.com/elpidaguy/autohotkey-experience-on-windows-i-am-loving-it-6di</link>
      <guid>https://forem.com/elpidaguy/autohotkey-experience-on-windows-i-am-loving-it-6di</guid>
      <description>&lt;h2&gt;
  
  
  This is not a Tutorial 🚦
&lt;/h2&gt;

&lt;p&gt;Hello fellow developers,&lt;br&gt;
are you forgetting the ways of the nerd development experience because you use mouse for (very) simple tasks? Do you feel like you have sinned because you are forgetting the default Windows keyboard shortcuts? Do you want custom Windows key binds so that you can do a chain of tasks with the pattern you can remember?&lt;/p&gt;

&lt;p&gt;Fear not, I bring to you -- &lt;a href="https://www.autohotkey.com/" rel="noopener noreferrer"&gt;AutoHotKey&lt;/a&gt; !!&lt;br&gt;
And this post will be a small yap about my AutoHotKey experience.&lt;/p&gt;


&lt;h2&gt;
  
  
  Don't know what AutoHotKey is? (it's 2025 😐)
&lt;/h2&gt;

&lt;p&gt;AutoHotKey is a very lightweight scripting tool available on Windows where you can create your own key-binds, automated tasks and macros. &lt;br&gt;
These scripts are very easy to learn and backed up by a huge open source community. &lt;br&gt;
So, when you are too tired to learn another script syntax, you can always browse what &lt;a href="https://www.autohotkey.com/boards/" rel="noopener noreferrer"&gt;others&lt;/a&gt; have made in the community. &lt;a href="https://safeweb.norton.com/report/show?url=autohotkey.com%2Fdownload" rel="noopener noreferrer"&gt;(Is it safe though?)&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  My Use Cases 🫡
&lt;/h2&gt;

&lt;p&gt;I have been using AHK mostly for Keyboard shortcuts and key re-mappings, following are the few which has helped me a lot.&lt;/p&gt;
&lt;h3&gt;
  
  
  Close Window
&lt;/h3&gt;

&lt;p&gt;Re-Mapping traditional &lt;code&gt;Alt+F4&lt;/code&gt; key for closing the window to &lt;code&gt;Alt+w&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Send&lt;/span&gt; &lt;span class="s"&gt;"!{F4}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Delete Entire Line
&lt;/h3&gt;

&lt;p&gt;When coding, I need to press multiple keys to delete the entire line, and keep cursor at the end of the line, so I pulled this one from a StackOverFlow answer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="n"&gt;Send&lt;/span&gt; &lt;span class="s"&gt;"{Home}{ShiftDown}{End}{Right}{ShiftUp}{Del}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Toggle Hidden Files
&lt;/h3&gt;

&lt;p&gt;Win11 comes up with confusing UX, and it is not very reliable to check/uncheck the hidden file box to see the dotfiles, I 'Yoinked' this one from a quick duckduckgo search:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; 
 &lt;span class="n"&gt;HiddenFiles_Status&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;RegRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hidden"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HiddenFiles_Status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="n"&gt;RegWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"REG_DWORD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hidden"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="n"&gt;Else&lt;/span&gt;
 &lt;span class="n"&gt;RegWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"REG_DWORD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hidden"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="n"&gt;Send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{F5}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  References 🪤
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;a href="https://www.autohotkey.com/docs/v2/Program.htm" rel="noopener noreferrer"&gt;How to Setup?&lt;/a&gt;&lt;br&gt;
🔗 &lt;a href="https://windowsloop.com/best-autohotkey-scripts/" rel="noopener noreferrer"&gt;More Examples&lt;/a&gt;&lt;br&gt;
🔗 &lt;a href="https://dev.to/t/autohotkey"&gt;Not a first AHK dev.to post&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Finally 👌
&lt;/h2&gt;

&lt;p&gt;AutoHotKey is a great plugin which you can start using today and optimize your day-to-day development experience by focusing your fingers more on the Keyboard and less on the Mouse.&lt;/p&gt;

&lt;p&gt;I may write another (big) post which would go in-depth on how to write these scripts to align with your needs, but no promises!&lt;/p&gt;

&lt;p&gt;Happy Coding!!!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>experience</category>
      <category>autohotkey</category>
    </item>
    <item>
      <title>Implement a Time-based Service in .NET 8 using IHostedService Interface🔍</title>
      <dc:creator>Kaustubh Joshi</dc:creator>
      <pubDate>Thu, 26 Dec 2024 10:43:19 +0000</pubDate>
      <link>https://forem.com/elpidaguy/implement-a-time-based-service-in-net-8-by-using-ihostedservice-interface-1328</link>
      <guid>https://forem.com/elpidaguy/implement-a-time-based-service-in-net-8-by-using-ihostedservice-interface-1328</guid>
      <description>&lt;h1&gt;
  
  
  👓 Introduction
&lt;/h1&gt;

&lt;p&gt;Just like we have &lt;code&gt;setInterval()&lt;/code&gt; in JavaScript, .NET 8 provides a very helpful interface known as &lt;code&gt;IHostedService&lt;/code&gt; in order to create a custom, independent, background running, timer interval based Services, where you can write your logic which will run after every configured interval of time.&lt;/p&gt;

&lt;p&gt;This post is a quick tutorial on &lt;strong&gt;What&lt;/strong&gt; is IHostedService in .NET, &lt;strong&gt;How&lt;/strong&gt; to use it to create timer based event services, &lt;strong&gt;What to avoid&lt;/strong&gt; while implementing the same and How this interface is &lt;strong&gt;different&lt;/strong&gt; from the BackgroundService Class.&lt;/p&gt;




&lt;h1&gt;
  
  
  🖼 What exactly is IHostedService Interface?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;IHostedService&lt;/code&gt;&lt;/strong&gt; is a .NET Interface, that is a part of .NET Hosting Infrastructure. &lt;br&gt;
You can develop &lt;strong&gt;cross-platform background services which are logging, configuration, and dependency injection (DI) ready&lt;/strong&gt;.&lt;br&gt;
Implementing IHostedService interface allows you to create long-running services that can be &lt;strong&gt;managed by the .NET host&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The interface defines two methods, managed by .NET Host:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;Task StartAsync(CancellationToken cancellationToken)&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Triggered when the application host is &lt;strong&gt;ready to start&lt;/strong&gt; the service.&lt;/li&gt;
&lt;li&gt;Input parameter - &lt;strong&gt;cancellationToken&lt;/strong&gt;, which Indicates that the start process has been aborted.&lt;/li&gt;
&lt;li&gt;Returns a Task that represents the &lt;strong&gt;asynchronous Start operation&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;Task StopAsync(CancellationToken cancellationToken)&lt;/code&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Triggered when the application host is &lt;strong&gt;performing a graceful shutdown&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Takes Input parameter - &lt;strong&gt;cancellationToken&lt;/strong&gt;, which Indicates that the shutdown process should no longer be graceful.&lt;/li&gt;
&lt;li&gt;Returns a Task that represents the &lt;strong&gt;asynchronous Stop operation&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  🎭 IHostedService vs. BackgroundService
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;IHostedService&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Interface&lt;/code&gt; provided by .NET&lt;/li&gt;
&lt;li&gt;Write your &lt;code&gt;complex/custom&lt;/code&gt; logic&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Fine-grained&lt;/code&gt; control over the service lifecycle&lt;/li&gt;
&lt;li&gt;Prefer using when you need to manage the start and stop logic explicitly&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;BackgroundService&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Abstract Class&lt;/code&gt; implements IHostedServices&lt;/li&gt;
&lt;li&gt;Overrides the ready-made &lt;code&gt;ExecuteAsync()&lt;/code&gt; method&lt;/li&gt;
&lt;li&gt;Simplification using &lt;code&gt;higher level Abstraction&lt;/code&gt; over IHostedService&lt;/li&gt;
&lt;li&gt;Prefer using when implementing &lt;code&gt;long-running tasks&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftz3v5nahxbgqq2r9f1pg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftz3v5nahxbgqq2r9f1pg.png" alt="IHostedService vs BackgroundService" width="800" height="171"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  ⌨ Example: Implementing a Timer-Based Service in .NET 8
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Create a New Project
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;dotnet&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt; &lt;span class="p"&gt;--&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="n"&gt;TimedHostedServiceExample&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  2. Create a New Class Named TimedHostedService.cs
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Threading&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Threading.Tasks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.Hosting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.Logging&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IHostedService&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IDisposable&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Logger instance&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;ILogger&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// DI ready Timer&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;Timer&lt;/span&gt; &lt;span class="n"&gt;_timer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;TimedHostService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ILogger&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_logger&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;StartAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Timer Service is starting."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;// Timer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period);&lt;/span&gt;
        &lt;span class="n"&gt;_timer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Timer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DoWork&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TimeSpan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Zero&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TimeSpan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CompletedTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// DoWork is where you will write your business logic&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;DoWork&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Timer Service is working."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;StopAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Timer Service is stopping."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;_timer&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;Change&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Timeout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Infinite&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CompletedTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Dispose&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Do not forget disposing the Timer instance to avoid any memory leaks&lt;/span&gt;
        &lt;span class="n"&gt;_timer&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;Dispose&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  3. Register the Service:
&lt;/h3&gt;

&lt;p&gt;In the Program.cs file, register the TimedHostedService with the host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.DependencyInjection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.Hosting&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateDefaultBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;ConfigureServices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;services&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddHostedService&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RunAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  If you are using AutoFac as your .NET IOC container, then 👇🏻
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;containerBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RegisterType&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;().&lt;/span&gt;&lt;span class="n"&gt;As&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IHostedService&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;().&lt;/span&gt;&lt;span class="nf"&gt;InstancePerDependency&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.Output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TimedHostedServiceExample&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="n"&gt;Timer&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;starting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Hosting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Lifetime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="n"&gt;started&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;Press&lt;/span&gt; &lt;span class="n"&gt;Ctrl&lt;/span&gt;&lt;span class="p"&gt;+&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;shut&lt;/span&gt; &lt;span class="n"&gt;down&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Hosting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Lifetime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="n"&gt;Hosting&lt;/span&gt; &lt;span class="n"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Development&lt;/span&gt;
&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Hosting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Lifetime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="n"&gt;Content&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;TimedHostedServiceExample&lt;/span&gt;
&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TimedHostedServiceExample&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="n"&gt;Timer&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;working&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Hosting&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Lifetime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;shutting&lt;/span&gt; &lt;span class="n"&gt;down&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TimedHostedServiceExample&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TimedHostedService&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="n"&gt;Timer&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;stopping&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  🧐 Avoid doing these mistakes
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Blocking the StartAsync Method&lt;/code&gt;&lt;/strong&gt;: Make sure the logic you put in your StartAsync code completes quickly. If this is not the case then the DoWork logic should be handled Asynchronously.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Not Handling Cancellation Properly&lt;/code&gt;&lt;/strong&gt;:Always respect the CancellationToken to ensure graceful shutdowns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Not disposing the Timer&lt;/code&gt;&lt;/strong&gt;: Make sure to dispose the Timer instance to avoid memory leaks.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🌱 Handle the DoWork logic Asynchronously to prevent a blocking long-running call
&lt;/h2&gt;

&lt;p&gt;So, in your use case, it might happen that the logic in DoWork method call, needs to be Asynchronous, i.e. it should not block the main thread until the business logic has completed its processing.&lt;/p&gt;

&lt;p&gt;To ensure that the DoWork method does not block the main thread, you can use the &lt;code&gt;Task.Run&lt;/code&gt; method to offload the work to a background thread. This will make main thread free and responsive for any further actions.&lt;br&gt;
Below is the &lt;code&gt;DoWork&lt;/code&gt; with Task.Run method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;DoWork&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DoWork started..."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Simulating some async work&lt;/span&gt;
        &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Asynchronous work completed."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to use the non-blocking logic?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I/O bound operations&lt;/li&gt;
&lt;li&gt;HTTP calls&lt;/li&gt;
&lt;li&gt;Any task where Async execution is needed&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔮 Conclusion
&lt;/h2&gt;

&lt;p&gt;Implementing background time-interval based services using IHostedService in .NET 8 provides a powerful way to manage your timer logic. &lt;br&gt;
By understanding the basics, avoiding common pitfalls, and choosing the right abstraction for your needs, you can effectively integrate background processing into your applications.&lt;/p&gt;

&lt;p&gt;Feel free to experiment with the provided example and explore the official documentation for more advanced scenarios. &lt;br&gt;
Happy coding! ❣&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/core/extensions/timer-service" rel="noopener noreferrer"&gt;IHostedService - learn.microsoft&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/a/60356456" rel="noopener noreferrer"&gt;Difference between ExecuteAsync and StartAsync methods in BackgroundService .net core&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dotnet</category>
      <category>tutorial</category>
      <category>csharp</category>
      <category>programming</category>
    </item>
    <item>
      <title>HTTP Response Status Codes | All you need to know | 2025🐱‍💻</title>
      <dc:creator>Kaustubh Joshi</dc:creator>
      <pubDate>Thu, 05 Dec 2024 16:12:28 +0000</pubDate>
      <link>https://forem.com/elpidaguy/http-response-status-codes-all-you-need-to-know-2025-d01</link>
      <guid>https://forem.com/elpidaguy/http-response-status-codes-all-you-need-to-know-2025-d01</guid>
      <description>&lt;h2&gt;
  
  
  😄 Introduction
&lt;/h2&gt;

&lt;p&gt;Most of the web developers in the tech industry are already familiar with different HTTP response status codes, like, &lt;strong&gt;200 OK, 404 NOT FOUND&lt;/strong&gt;, and so on. These status codes are important in understanding how your HTTP request has been processed on the server side. &lt;br&gt;
This quick read will help you shed light on different response status codes that HTTP supports.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you want to learn about &lt;strong&gt;HTTP Request Methods&lt;/strong&gt; first, feel free to jump to: &lt;a href="https://dev.to/elpidaguy/hello-i-m-http-and-these-are-my-request-methods-co"&gt;Hello, I'm HTTP and these are my request methods👋🏻&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🌲 Response classes/groups
&lt;/h2&gt;

&lt;p&gt;In the very basic way, responses are categorized in the 5 different classes as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjrxfjfeepevgr16ycw8y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjrxfjfeepevgr16ycw8y.png" alt="Responses are divided into 5 classes" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This way, you can easily get the idea on how your request has been processed on the server, just by looking at the first digit of the response code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp3dqbsd4mdckh8x8rqba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp3dqbsd4mdckh8x8rqba.png" alt="Birds eye view on response code classes" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📶 HTTP Response Status Codes
&lt;/h2&gt;

&lt;p&gt;Now let us get our hands dirty with each class:&lt;/p&gt;

&lt;h5&gt;
  
  
  Quick Guide:
&lt;/h5&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;WebDAV:&lt;/strong&gt; Set of extensions to the Hypertext Transfer Protocol&lt;br&gt;
&lt;strong&gt;Trash Icon&lt;/strong&gt; --&amp;gt; &lt;strong&gt;Deprecated&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Flask Icon&lt;/strong&gt; --&amp;gt; &lt;strong&gt;Experimental&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Star Icon&lt;/strong&gt; --&amp;gt; &lt;strong&gt;Common/Important&lt;/strong&gt;&lt;br&gt;
 &lt;br&gt;
I will not be covering Deprecated methods as they are no longer in use anymore.&lt;br&gt;
Please visit the links attached in the Reference section to learn more about these methods.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Informational Responses
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvn5lsdh1i1vvcw6dsd7q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvn5lsdh1i1vvcw6dsd7q.png" alt="IR status codes" width="800" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;100 Continue&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Tells client that their HTTP request is authorized to continue&lt;/li&gt;
&lt;li&gt;Client should ignore this response if the request is already finished&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;101 Switching Protocols&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This code is sent in response to an Upgrade request header from the client&lt;/li&gt;
&lt;li&gt;Tells client the protocol, the server is switching to&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;103 Early Hints&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This status code tells client to start pre-loading resources while the server prepares a response or preconnect to an origin from which the page will need resources&lt;/li&gt;
&lt;li&gt;This status code is primarily intended to be used with the Link header&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Successful Responses
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0dhxi3ksl24j7qk1zleu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0dhxi3ksl24j7qk1zleu.png" alt="Success status codes" width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;200 OK&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request succeeded&lt;/li&gt;
&lt;li&gt;Meaning of "Success" changes as per HTTP request Method

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GET&lt;/strong&gt; =&amp;gt; Resources has been fetched&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HEAD&lt;/strong&gt; =&amp;gt; Representation headers fetched, no message body&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PUT/POST&lt;/strong&gt; =&amp;gt; Result of the action performed is fetched in the message body&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TRACE&lt;/strong&gt; =&amp;gt; The message body contains the request as received by the server&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;201 Created&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request succeeded, and a new resource was created as a result&lt;/li&gt;
&lt;li&gt;Typically after HTTP POST or some PUT requests&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;202 Accepted&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Notification heads-up to client that the request has been received but not yet acted upon&lt;/li&gt;
&lt;li&gt;Used for cases where another process or server handles the request, or for batch processing&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;203 Non-Authoritative Information&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This response code means the returned metadata is not exactly the same as is available from the origin server, but is collected from a local or a third-party copy&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;204 No Content&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;There is no content to send for this request, but the headers are useful&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;205 Reset Content&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Tells the user agent to reset the document which sent this request&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;206 Partial Content&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Used when the client requests only part of a resource&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;207 Multi-Status (WebDAV)&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Conveys information about multiple resources, for situations where multiple status codes might be appropriate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;208 Already Reported (WebDAV)&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Used to avoid repeatedly enumerating the internal members of multiple bindings to the same collection&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;218 This is Fine&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This is an unofficial HTTP response that is used specifically by the Apache Web Server &lt;/li&gt;
&lt;li&gt;Indicate that there is a HTTP client error or HTTP server error&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;226 IM Used (HTTP Delta encoding)&lt;/em&gt; 👀
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Redirection Messages
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9blh043m8r8q1pw9o4dk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9blh043m8r8q1pw9o4dk.png" alt="Redirection status codes" width="798" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;300 Multiple Choices&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request has more than one possible response and the user agent or user should choose one of them&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;301 Moved Permanently&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The URL of the requested resource has been changed permanently&lt;/li&gt;
&lt;li&gt;The new URL is given in the response.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;302 Found&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This response code means that the URI of requested resource has been changed temporarily&lt;/li&gt;
&lt;li&gt;Further changes in the URI might be made in the future, so the same URI should be used by the client in future requests&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;303 See Other&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server sent this response to direct the client to get the requested resource at another URI with a GET request&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;304 Not Modified&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This is used for caching purposes&lt;/li&gt;
&lt;li&gt;It tells the client that the response has not been modified, so the client can continue to use the same cached version of the response&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;307 Temporary Redirect&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Imagine 302 Found again but this time the HTTP method (i.e. GET, POST...) used in the first request must not change&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;308 Permanent Redirect&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Imagine 301 Moved Permanently again but with the same restriction on HTTP method change&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Client Error Responses
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjsrtcbq6hqlrziibe0ns.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjsrtcbq6hqlrziibe0ns.png" alt="Client Error status codes" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;400 Bad Request&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server cannot or will not process the request due to client error&lt;/li&gt;
&lt;li&gt;Examples: malformed request syntax, invalid request message framing, or deceptive request routing&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;401 Unauthorized&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Semantically this response means "unauthenticated"&lt;/li&gt;
&lt;li&gt;Meaning, the client must authenticate itself to get the requested response&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;402 Payment Required&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The initial purpose of this code was for digital payment systems, however this status code is rarely used and no standard convention exists&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;403 Forbidden&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The client, although logged-in, does not have access rights to the content&lt;/li&gt;
&lt;li&gt;That is, it is unauthorized, so the server is refusing to give the requested resource&lt;/li&gt;
&lt;li&gt;Unlike 401 Unauthorized, the client's identity is known to the server&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;404 Not Found&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Most common status code in web community&lt;/li&gt;
&lt;li&gt;The server cannot find the requested resource&lt;/li&gt;
&lt;li&gt;In the browser, this means the URL is not recognized. &lt;/li&gt;
&lt;li&gt;In an API, this can also mean that the endpoint is valid but the resource itself does not exist&lt;/li&gt;
&lt;li&gt;Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;405 Method Not Allowed&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request HTTP method is known to the server but not supported for the target resource&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;406 Not Acceptable&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Sent when content negotiation doesn’t yield an acceptable content type&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;407 Proxy Authentication Required&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Similar to 401 Unauthorized but here the Authentication is needed to be done by a proxy&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;408 Request Timeout&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Sent by server when the server would like to shut down unused or idle connections&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;409 Conflict&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request conflicts with the server’s current state&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;410 Gone&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The requested content has been permanently deleted, with no forwarding address&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;411 Length Required&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server requires the Content-Length header field&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;412 Precondition Failed&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The client’s preconditions are not met by the server&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;413 Content Too Large&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request body is too big for the limits defined by server&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;414 URI Too Long&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Client has requested a URI which is longer than the server is willing to interpret&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fogv4w3cqetd64o66aqze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fogv4w3cqetd64o66aqze.png" alt="Client Error status codes 2" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;415 Unsupported Media Type&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The media format added in the request data is not supported by the server&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;416 Range Not Satisfiable&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The ranges specified by the Range header field in the request cannot be fulfilled by the server&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;417 Expectation Failed&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Indicate that the conditions set by the client using the Expect header can not be satisfied&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;418 I'm a teapot&lt;/em&gt; ☕
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Indicate that this server has been requested to brew coffee, yet, it’s a teapot&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;421 Misdirected Request&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Client error sent by a server that is unable to produce a response&lt;/li&gt;
&lt;li&gt;The client may retry the request using another connection.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;422 Unprocessable Content&lt;/em&gt; (WebDAV)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request was well-formed but was unable to be followed due to semantic errors&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;423 Locked&lt;/em&gt; (WebDAV)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The resource that is being accessed is locked&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;424 Failed Dependency&lt;/em&gt; (WebDAV)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The request failed due to failure of a previous dependent request&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;425 Too Early&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Indicates that the server is unwilling to risk processing a request that might be replayed&lt;/li&gt;
&lt;li&gt;Experimental&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;426 Upgrade Required&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Indicate that it is unwilling to process the request using the current protocol&lt;/li&gt;
&lt;li&gt;The server sends an Upgrade header in a this response to indicate the required protocol(s)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;428 Precondition Required&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Indicate that HTTP requests of this type must be made conditionally, yet no precondition was included&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;429 Too Many Requests&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The user has sent too many requests in a given amount of time&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;431 Request Header Fields Too Large&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server is unwilling to process the request because its header fields are too large&lt;/li&gt;
&lt;li&gt;The request may be resubmitted after reducing the size of the request header fields&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;451 Unavailable For Legal Reasons&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The user agent requested a resource that cannot legally be provided&lt;/li&gt;
&lt;li&gt;For example, a web page censored by a government&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Server Error Responses
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzuwaohuoi2nimfjujg86.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzuwaohuoi2nimfjujg86.png" alt="Server error status codes" width="800" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;500 Internal Server Error&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Most common status code&lt;/li&gt;
&lt;li&gt;This means that server has encountered a situation where it does not know how to handle it&lt;/li&gt;
&lt;li&gt;This error is generic, indicating that the server cannot find a more appropriate 5XX status code to respond with&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;501 Not Implemented&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Usually tells that method is available on the server but is not yet implemented as of now&lt;/li&gt;
&lt;li&gt;GET and HEAD methods are required to be supported by the server and therefore that must never return this code &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;502 Bad Gateway&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;503 Service Unavailable&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server is not ready to handle the request&lt;/li&gt;
&lt;li&gt;Common causes are a server that is down for maintenance or that is overloaded&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;504 Gateway Timeout&lt;/em&gt; 🌟
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This error response is given when the server is acting as a gateway to another resource and cannot get a response in time&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;505 HTTP Version Not Supported&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The HTTP version used in the request is not supported by the server&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;506 Variant Also Negotiates&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server has an internal configuration error&lt;/li&gt;
&lt;li&gt;and server can engage in transparent content negotiation&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;507 Insufficient Storage (WebDAV)&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Storage capacity of server is unable to store the representation needed of the request to succsfully complete it&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;508 Loop Detected (WebDAV)&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The server detected an infinite loop while processing the request&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;510 Not Extended&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The client request declares an HTTP Extension (RFC 2774) that should be used to process the request, but the extension is not supported&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;511 Network Authentication Required&lt;/em&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Indicates that the client needs to authenticate to gain network access&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  😸 Learn from the experts (they are cats!)
&lt;/h2&gt;

&lt;p&gt;Visit &lt;a href="https://http.cat/" rel="noopener noreferrer"&gt;http.cat&lt;/a&gt; and learn the HTTP response status codes in a very unique way 😼&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk80h0bgu3dn3ip3osak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnk80h0bgu3dn3ip3osak.png" alt="102 Processing" width="760" height="608"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🏮 Browser Compatibility
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfxlvzf8t0avcdfokjl0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfxlvzf8t0avcdfokjl0.png" alt="Browser Compatibility Table" width="800" height="798"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🐱‍🚀 Conclusion
&lt;/h2&gt;

&lt;p&gt;This post might save you some time searching different web pages for getting an understanding on HTTP Response status codes.&lt;/p&gt;

&lt;p&gt;I hope this post will help you in future, be it a help in your project or a last min study for your interview.&lt;/p&gt;

&lt;p&gt;HAPPY CODING!!!❤️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3ztu60c49fs9ya8ktz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3ztu60c49fs9ya8ktz2.png" alt="I'm a Teapot" width="712" height="552"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status" rel="noopener noreferrer"&gt;MDN Web Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://http.dev/" rel="noopener noreferrer"&gt;http.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/WebDAV" rel="noopener noreferrer"&gt;WebDAV&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@chaima.hajtaher/a-comprehensive-guide-to-http-response-status-codes-8f296831b400" rel="noopener noreferrer"&gt;This Medium Post&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://http.cat/" rel="noopener noreferrer"&gt;http.cat&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>http</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to Bulk Upload CSV file data into MySql Table? A very fast way using LOAD DATA.</title>
      <dc:creator>Kaustubh Joshi</dc:creator>
      <pubDate>Mon, 19 Aug 2024 06:53:57 +0000</pubDate>
      <link>https://forem.com/elpidaguy/how-to-bulk-upload-csv-file-data-into-mysql-table-a-very-fast-way-using-load-data-c44</link>
      <guid>https://forem.com/elpidaguy/how-to-bulk-upload-csv-file-data-into-mysql-table-a-very-fast-way-using-load-data-c44</guid>
      <description>&lt;h2&gt;
  
  
  😄 Introduction
&lt;/h2&gt;

&lt;p&gt;Are you still using "for" or "while" loops to iterate over your rows and insert them in your database? Do you still writing separate code for reading .csv file and the uploading it to your MySQL database?&lt;/p&gt;

&lt;p&gt;Say "NO" to linear logic with the "LOAD DATA" statement provided by the MySQL. Prepare yourself for changing your code to both minimize the lines, and increase the performance drastically.&lt;/p&gt;

&lt;h2&gt;
  
  
  🗃 What is the LOAD DATA INFILE Statement?
&lt;/h2&gt;

&lt;p&gt;MySql provides the &lt;a href="https://dev.mysql.com/doc/refman/8.0/en/load-data.html" rel="noopener noreferrer"&gt;LOAD DATA&lt;/a&gt; statement, which is a high-speed way to read the data from text files and insert it into table with very minimal code.&lt;/p&gt;

&lt;p&gt;As stated in the MySQL documentation, the LOAD DATA statement is used to Read Data from the file in a quick manner and you can insert this data in your table with one single query, instead of hitting your db multiple times with "INSERT INTO" query.&lt;/p&gt;

&lt;p&gt;MySQL also provides a statement -&amp;gt; "SELECT…INTO OUTFILE", which does exactly opposite of what "LOAD DATA" does, which is to read the data &lt;strong&gt;from the table to file&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.mysql.com/doc/refman/8.0/en/mysqlimport.html" rel="noopener noreferrer"&gt;mysqlimport&lt;/a&gt; utility provided by MySql internally calls the LOAD DATA statement on the server to import the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧐 How to Use it?
&lt;/h2&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Above gist snippet shows the generic load data statements. All the available options are mentioned in the code above. &lt;/p&gt;

&lt;p&gt;Let's now focus on a simple example of reading a .csv file and inserting its rows into a compatible table.&lt;/p&gt;

&lt;p&gt;A simple example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOAD DATA INFILE ‘data.csv’ INTO TABLE db.my_table
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;A birds-eye example with all essential options :&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Needless to say that your CSV file should be properly formatted for this statement to work😉.&lt;/p&gt;

&lt;p&gt;And voila, using the above statement, your .csv with more than 100 thousands rows will be imported into your table in seconds.&lt;/p&gt;

&lt;p&gt;Now, some important things to note:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The above statement runs at the MySql level, hence the source files are copied from client to server in order to import them. &lt;br&gt;
This raises some security issues, we need to make sure the client-server connection is secured while using this code.&lt;/p&gt;

&lt;p&gt;In MySql 8.0, the capability to use LOCAL is set as False by default. As your server and client should be configured to have LOCAL permited, some of you might get a permission error.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In case of permission error, we need to override it by enabling the &lt;strong&gt;local_infile&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SET GLOBAL local_infile = true;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Overriding this flag is not a security solution but rather an acknowledgement for accepting the risks, you can refer &lt;a href="https://dev.mysql.com/doc/refman/8.0/en/load-data-local-security.html" rel="noopener noreferrer"&gt;this&lt;/a&gt; documentation for more information.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  🐱‍🚀 Conclusion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MySql LOAD DATA statement is used to read files within very less time&lt;/li&gt;
&lt;li&gt;You can use this code with any backend API to provide the source file&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Source file can be any text file, we have used .csv in this example&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;LOAD DATA LOCAL&lt;/strong&gt; copies the source file to your server via MySql hence a security measures on the server side should be implemented&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;mysqlimport&lt;/strong&gt; utility uses the LOAD DATA statement internally&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can ignore the headers in CSV by adding &lt;strong&gt;IGNORE 1 LINES&lt;/strong&gt; in the statement&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2egqtw20ugrslgpyg9f.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2egqtw20ugrslgpyg9f.gif" alt="CAT WORKING ON MYSQL" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.mysql.com/doc/refman/8.0/en/load-data.html" rel="noopener noreferrer"&gt;Official Docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>mysql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Yet Another PostgreSQL-REGEX Article 🤺</title>
      <dc:creator>Kaustubh Joshi</dc:creator>
      <pubDate>Wed, 08 Nov 2023 05:36:58 +0000</pubDate>
      <link>https://forem.com/elpidaguy/yet-another-postgresql-regex-article-cheatsheet-2hg2</link>
      <guid>https://forem.com/elpidaguy/yet-another-postgresql-regex-article-cheatsheet-2hg2</guid>
      <description>&lt;h2&gt;
  
  
  😄 Introduction
&lt;/h2&gt;

&lt;p&gt;World famous Oxford English Dictionary defines the word &lt;code&gt;Regular&lt;/code&gt; as, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Characterized by evenness, order, or harmony in physical form, structure, or organization; arranged in or constituting a constant or definite pattern.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But when it comes to 'Regular' Expressions, they are the most uneven, disordered, and dissonance structures in coding I have ever seen. &lt;br&gt;
But again, When it comes to data cleaning, extracting data from a huge string or working on simple text parsing, nothing else can compete with the power of Regular Expressions.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛐 Relevant(?) XKCD
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsizndkcjejlsh86oac5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsizndkcjejlsh86oac5.png" alt="Image description" width="600" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PostgreSQL regular expressions are a combination of LIKE notations and POSIX regular expression notations.&lt;br&gt;
This post will provide you all the information you need to understand these notations a better and a simpler way.&lt;/p&gt;




&lt;h2&gt;
  
  
  💻Metacharacters and Operators
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Match Operators:&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;~&lt;/strong&gt; - String matches regular expression
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;thomas&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t.*ma&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- true
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;~&lt;/strong&gt;* - String matches regular expression, case-insensitively
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;thomas&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;~*&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;T.*ma&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- true
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;!~&lt;/strong&gt; - String does not match regular expression
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;thomas&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t.*max&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- true
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;!~&lt;/strong&gt;* - String does not match regular expression, case-insensitively
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;thomas&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="o"&gt;~*&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;T.*ma&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- false
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;POSIX Regular Expressions:&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;|&lt;/strong&gt; - Represents alternation, either of two alternatives provided in regex.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;CA|KS&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has either CA or KS as state
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;^&lt;/strong&gt; - Matches begining of the line.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;^B&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which name starts with 'B'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;$&lt;/strong&gt; - Matches end of the line.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;S$&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which name ends with S
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;. (dot)&lt;/strong&gt; - Matches any charcter.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.NN&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has character 'NN' anywhere in the name
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;*&lt;/strong&gt; - Denotes repetition of the character &lt;strong&gt;zero or more times&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.*N&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has zero or more repetition of character 'N'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;*?&lt;/strong&gt; - Denotes repetition of the character &lt;strong&gt;zero or more times&lt;/strong&gt; in &lt;strong&gt;non-greedy way.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;+&lt;/strong&gt; - Denotes repetition of the character &lt;strong&gt;one or more times&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.+N&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has one or more repetition of character 'N'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;+?&lt;/strong&gt; - Denotes repetition of the character &lt;strong&gt;one or more times&lt;/strong&gt; in &lt;strong&gt;non-greedy way.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;?&lt;/strong&gt; - Denotes repetition of the character zero or one time.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.?N&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has zero or one repetition of character 'N'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Working with Item Set:&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;{m}&lt;/strong&gt; -  Denotes repetition of the previous item exactly m times.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;N{2}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has 2 repetition of character 'N'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;{m,}&lt;/strong&gt; - Denotes repetition of the previous item m or more times.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;N{2,}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has 2 or more repetition of character 'N'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;{m,n}&lt;/strong&gt; - Denotes repetition of the previous item at least m and not more than n times.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;N{2,5}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has 2 to 5 repetition of character 'N'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;()&lt;/strong&gt; - Parentheses () can be used to group items into a single logical item.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;distinct&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt; &lt;span class="n"&gt;similar&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%(Long|New)%&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- List of cities which has 'Long' or 'New' in there name
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;(&lt;/strong&gt; - Indicates string extraction is to start&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;)&lt;/strong&gt; - Indicates string extraction is to end
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="nf"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.+@(.*)$&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- Returns domain name from email
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;[...]&lt;/strong&gt; - Can be used to match characters in listed set
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="nf"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[0-9]&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;taxdata&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- Returns emails which has any one of 0-9 digit
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;regexp_matches(input, regex)&lt;/strong&gt; - Returns a text array of matching substring(s) within the first match of a POSIX regular expression pattern to a string
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#Example:
&lt;/span&gt;    &lt;span class="n"&gt;SELECT&lt;/span&gt; &lt;span class="nf"&gt;regexp_match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;foobarbequebaz&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;(bar)(beque)&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;#Output:
#-- Returns output {bar,beque}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🤔 Greedy and Lazy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;greedy&lt;/strong&gt; - Greedy quantifiers first tries to repeat the token as many times as possible, and gradually gives up matches as the engine backtracks to find an overall match.&lt;br&gt;
&lt;em&gt;&lt;u&gt;tl;dr; Keep searching until condition is not satisfied.&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;lazy&lt;/strong&gt; - Lazy quantifier first repeats the token as few times as required, and gradually expands the match as the engine backtracks through the regex to find an overall match.&lt;br&gt;
&lt;em&gt;&lt;u&gt;tl;dr; Stop searching once condition is satisfied.&lt;/u&gt;&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  👁‍🗨 Conclusion
&lt;/h2&gt;

&lt;p&gt;This article should provide you with a birds-eye-view of different regular expressions and notations you can use in your Postgres queries.&lt;br&gt;
I hope you've found this post helpful and do not hesitate to revisit whenever you are stuck finding the correct way to write your regex.😉&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;NOTE: I would really encourage you to practice these operators on your own dataset or any real life examples. Remember practice is the key to become the hero who saves the day with REGEX.&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;HAPPY CODING!!!❤️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnajyeaov13xpvzuwc5qs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnajyeaov13xpvzuwc5qs.gif" alt="Image description" width="500" height="213"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.postgresql.org/docs/current/functions-matching.html" rel="noopener noreferrer"&gt;PostgreSQL Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//www.regular-expressions.info"&gt;www.regular-expressions.info&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/2301285/what-do-lazy-and-greedy-mean-in-the-context-of-regular-expressions" rel="noopener noreferrer"&gt;lazy and greedy in regex context&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>postgres</category>
      <category>regex</category>
      <category>sql</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Hello, I'm HTTP and these are my request methods👋🏻</title>
      <dc:creator>Kaustubh Joshi</dc:creator>
      <pubDate>Fri, 08 Oct 2021 12:44:51 +0000</pubDate>
      <link>https://forem.com/elpidaguy/hello-i-m-http-and-these-are-my-request-methods-co</link>
      <guid>https://forem.com/elpidaguy/hello-i-m-http-and-these-are-my-request-methods-co</guid>
      <description>&lt;h1&gt;
  
  
  😄 Introduction
&lt;/h1&gt;

&lt;p&gt;HTTP (Hyper Text Transfer Protocol) is heart of all the websites and that's one of the many reason to know the different &lt;strong&gt;request methods&lt;/strong&gt; this protocol provides, be it for REST API development, a frontend dev consuming APIs or even for cracking an Interview.&lt;/p&gt;

&lt;p&gt;This post will provide you all the information you need to understand HTTP a better and a simpler way.&lt;/p&gt;




&lt;h2&gt;
  
  
  💻 Semantics
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Idempotent" rel="noopener noreferrer"&gt;Idempotent Methods&lt;/a&gt; - Methods which doesn't change &lt;strong&gt;state of the server&lt;/strong&gt; even when the &lt;strong&gt;same (identical)&lt;/strong&gt; request is made &lt;em&gt;multiple&lt;/em&gt; times in a row.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Safe/HTTP" rel="noopener noreferrer"&gt;Safe Methods&lt;/a&gt; - Methods which doesn't change any &lt;strong&gt;resource&lt;/strong&gt; in a server.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/cacheable" rel="noopener noreferrer"&gt;Cacheable Methods&lt;/a&gt; - Methods whose response can be &lt;strong&gt;cached&lt;/strong&gt; on the &lt;strong&gt;client side&lt;/strong&gt; saving the REST call to the server.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; All SAFE methods are IDEMPOTENT but not vice versa.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📬 HTTP Request Methods
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;GET&lt;/em&gt;&lt;/strong&gt; - Represents a request for specific source. Only use to fetch data.

&lt;ul&gt;
&lt;li&gt;has request body - NO&lt;/li&gt;
&lt;li&gt;Idempotent - YES&lt;/li&gt;
&lt;li&gt;Safe - YES&lt;/li&gt;
&lt;li&gt;Cacheable - YES&lt;/li&gt;
&lt;li&gt;has response body - YES&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;POST&lt;/em&gt;&lt;/strong&gt; - Used to send data to the server. Ideally should use to &lt;strong&gt;create&lt;/strong&gt; new resource on the server.

&lt;ul&gt;
&lt;li&gt;has request body - YES&lt;/li&gt;
&lt;li&gt;Idempotent - NO (placing an order several time)&lt;/li&gt;
&lt;li&gt;Safe - NO&lt;/li&gt;
&lt;li&gt;Cacheable - &lt;a href="https://stackoverflow.com/questions/626057/is-it-possible-to-cache-post-methods-in-http" rel="noopener noreferrer"&gt;Only if freshness information is included&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;has response body - YES&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;PUT&lt;/em&gt;&lt;/strong&gt; - Used to &lt;strong&gt;create&lt;/strong&gt; new resource or &lt;strong&gt;update&lt;/strong&gt; an existing resource with the request body containing the newly-updated representation of the original resource.

&lt;ul&gt;
&lt;li&gt;has request body - YES&lt;/li&gt;
&lt;li&gt;Idempotent - YES&lt;/li&gt;
&lt;li&gt;Safe - NO&lt;/li&gt;
&lt;li&gt;Cacheable - NO&lt;/li&gt;
&lt;li&gt;has response body - NO&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;PATCH&lt;/em&gt;&lt;/strong&gt; - Used to &lt;strong&gt;partially&lt;/strong&gt; update data with the provided &lt;strong&gt;identifier&lt;/strong&gt;, if &lt;strong&gt;absent&lt;/strong&gt; it will throw an &lt;strong&gt;exception&lt;/strong&gt;.

&lt;ul&gt;
&lt;li&gt;has request body - YES&lt;/li&gt;
&lt;li&gt;Idempotent - NO&lt;/li&gt;
&lt;li&gt;Safe - NO&lt;/li&gt;
&lt;li&gt;Cacheable - NO&lt;/li&gt;
&lt;li&gt;has response body - YES&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;DELETE&lt;/em&gt;&lt;/strong&gt; - The HTTP DELETE request method &lt;strong&gt;deletes&lt;/strong&gt; the specified resource.

&lt;ul&gt;
&lt;li&gt;has request body - May&lt;/li&gt;
&lt;li&gt;Idempotent - YES&lt;/li&gt;
&lt;li&gt;Safe - NO&lt;/li&gt;
&lt;li&gt;Cacheable - NO&lt;/li&gt;
&lt;li&gt;has response body - May&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;OPTIONS&lt;/em&gt;&lt;/strong&gt; - The OPTIONS method describes the &lt;strong&gt;communication options&lt;/strong&gt; for the target resource. 

&lt;ul&gt;
&lt;li&gt;has request body - NO&lt;/li&gt;
&lt;li&gt;Idempotent - YES&lt;/li&gt;
&lt;li&gt;Safe - YES&lt;/li&gt;
&lt;li&gt;Cacheable - NO&lt;/li&gt;
&lt;li&gt;has response body - YES&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;HEAD&lt;/em&gt;&lt;/strong&gt; - Returns headers of the HTTP request &lt;strong&gt;without&lt;/strong&gt; response body. Same as GET without response body.

&lt;ul&gt;
&lt;li&gt;has request body - NO&lt;/li&gt;
&lt;li&gt;Idempotent - YES&lt;/li&gt;
&lt;li&gt;Safe - YES&lt;/li&gt;
&lt;li&gt;Cacheable - YES&lt;/li&gt;
&lt;li&gt;has response body - NO&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;CONNECT&lt;/em&gt;&lt;/strong&gt; - The HTTP CONNECT method starts two-way communications with the requested resource. It can be used to open a &lt;strong&gt;tunnel&lt;/strong&gt;.

&lt;ul&gt;
&lt;li&gt;has request body - NO&lt;/li&gt;
&lt;li&gt;Idempotent - NO&lt;/li&gt;
&lt;li&gt;Safe - NO&lt;/li&gt;
&lt;li&gt;Cacheable - NO&lt;/li&gt;
&lt;li&gt;has response body - NO&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;TRACE&lt;/em&gt;&lt;/strong&gt; - The HTTP TRACE method performs a &lt;strong&gt;message loop-back test&lt;/strong&gt; along the path to the target resource, providing a useful debugging mechanism.

&lt;ul&gt;
&lt;li&gt;has request body - NO&lt;/li&gt;
&lt;li&gt;Idempotent - YES&lt;/li&gt;
&lt;li&gt;Safe - YES&lt;/li&gt;
&lt;li&gt;Cacheable - NO&lt;/li&gt;
&lt;li&gt;has response body - NO&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; PUT will either update or create new resource where PATCH will always update it, if the provided identifier is absent on the server, it will throw an exception. (ex. invalid product id)&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🏮 Browser Compatibility
&lt;/h2&gt;

&lt;p&gt;This image is taken from &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmolk7gdrkjdtjbuionvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmolk7gdrkjdtjbuionvk.png" alt="image" width="800" height="692"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  👁‍🗨 Conclusion
&lt;/h2&gt;

&lt;p&gt;This article should provide you a birds-eye-view of all the HTTP request methods in less than 10 mins.&lt;br&gt;
I hope this post will help you in future, while choosing the correct method for your API or a last min study for your interview.&lt;/p&gt;

&lt;p&gt;HAPPY CODING!!!❤️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi8kta7fs4e4x6v9ez16j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi8kta7fs4e4x6v9ez16j.gif" alt="Alt Text" width="500" height="374"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/31089221/what-is-the-difference-between-put-post-and-patch" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/31089221/what-is-the-difference-between-put-post-and-patch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
