<?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>DEV Community: Brijesh Shah</title>
    <description>The latest articles on DEV Community by Brijesh Shah (@brijeshshah13).</description>
    <link>https://dev.to/brijeshshah13</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%2F435636%2Fb79bb3e6-54ab-467e-b3d3-b9b52fa0c542.jpeg</url>
      <title>DEV Community: Brijesh Shah</title>
      <link>https://dev.to/brijeshshah13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/brijeshshah13"/>
    <language>en</language>
    <item>
      <title>Cowin Vaccine Notifier</title>
      <dc:creator>Brijesh Shah</dc:creator>
      <pubDate>Mon, 03 May 2021 21:15:43 +0000</pubDate>
      <link>https://dev.to/brijeshshah13/cowin-vaccine-notifier-2hbi</link>
      <guid>https://dev.to/brijeshshah13/cowin-vaccine-notifier-2hbi</guid>
      <description>&lt;p&gt;To help people notify about new vaccination slots being opened in their area in India, I have developed a very simple app: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://cowin.tuls.in"&gt;https://cowin.tuls.in&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just enter your email id, age &amp;amp; area pincode against which you want to search the slots. If a valid slot is found matching your age group and pincode, you will be sent an email with the details of the same.&lt;/p&gt;

&lt;p&gt;Currently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the system checks for new slots every 2 hour, which might be changed depending on the users registration. This also means that you will receive the same emails every 2 hour. Please feel free to block the sender's email id if you are done with the vaccination and no londer require the service. An unsubscription functionality is in plan to rectify the same&lt;/li&gt;
&lt;li&gt;the system checks for new slots for today &amp;amp; 7 upcoming days&lt;/li&gt;
&lt;li&gt;the system automatically deletes users who registered before 7 days, to ensure new users get an equal chance to register. Also because the system is running on a server with limited resources. So, if you want to continue getting the updates, just register once again after 7 days&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Future improvements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Allow users to unsubcribe&lt;/li&gt;
&lt;li&gt;Allow users to enter multiple pincodes&lt;/li&gt;
&lt;li&gt;Allow users to enter till how many upcoming days do they want to check the slot availability for&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please share your feedback at: &lt;a href="mailto:openciappdev@gmail.com"&gt;openciappdev@gmail.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>productivity</category>
      <category>cowin</category>
    </item>
    <item>
      <title>Algorithms 101 - Two Numbers Sum</title>
      <dc:creator>Brijesh Shah</dc:creator>
      <pubDate>Thu, 25 Feb 2021 16:09:29 +0000</pubDate>
      <link>https://dev.to/brijeshshah13/algorithms-101-two-numbers-sum-571e</link>
      <guid>https://dev.to/brijeshshah13/algorithms-101-two-numbers-sum-571e</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Given an array of distinct integers, find the pair of integers whose sum is equal to the target number, if any.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arguments&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;numbersArray - Array of distinct integers&lt;/li&gt;
&lt;li&gt;targetSum    - Target sum number&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Approach 1
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Run 2 &lt;em&gt;for&lt;/em&gt; loops, one nested inside the other.&lt;/li&gt;
&lt;li&gt;Check if the sum of the iterating elements equal the target sum.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;twoNumerSum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetSum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;firstNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;secondNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&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="nx"&gt;firstNumber&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;secondNumber&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;targetSum&lt;/span&gt;&lt;span class="p"&gt;)&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;span class="nx"&gt;firstNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secondNumber&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;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;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;p&gt;&lt;strong&gt;Time complexity&lt;/strong&gt; &lt;em&gt;O(n^2)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Space complexity&lt;/strong&gt; &lt;em&gt;O(1)&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Approach 2
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Initiate an empty object &amp;amp; iterate through the input array using a &lt;em&gt;for&lt;/em&gt; loop.&lt;/li&gt;
&lt;li&gt;Because we already know the target sum, we can instead search for the unique number, whose summation with the iterating number will be equal to the target sum.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;twoNumerSum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetSum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbersMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;targetSum&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;number&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="nx"&gt;numbersMap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;])&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;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="nx"&gt;numbersMap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;'&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;span class="k"&gt;return&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;p&gt;&lt;strong&gt;Time complexity&lt;/strong&gt; &lt;em&gt;O(n)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Space complexity&lt;/strong&gt; &lt;em&gt;O(n)&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Approach 3
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Input array can be sorted in O(nlogn) using quick sort. Let's do that first.&lt;/li&gt;
&lt;li&gt;Begin summation from the extreme indices and close in. If the sum is less than the target sum, move one index further from the left side, else, the right side.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;twoNumerSum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;targetSum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentSum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;right&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="nx"&gt;currentSum&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;targetSum&lt;/span&gt;&lt;span class="p"&gt;)&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;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;numbersArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;right&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentSum&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;targetSum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="nx"&gt;right&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&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;span class="k"&gt;return&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;p&gt;&lt;strong&gt;Time complexity&lt;/strong&gt; &lt;em&gt;O(nlogn)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Space complexity&lt;/strong&gt; &lt;em&gt;O(1)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Link to Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/brijeshshah13/algos/blob/master/two-number-sum/twoNumerSum.js"&gt;in node.js&lt;/a&gt;. Feel free to raise a PR in any other language.&lt;/p&gt;

&lt;p&gt;For the latest updates on the upcoming articles in this series, you can subscribe to the &lt;a href="https://brijeshshah.substack.com/"&gt;newsletter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>productivity</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How I started generating passive income</title>
      <dc:creator>Brijesh Shah</dc:creator>
      <pubDate>Fri, 01 Jan 2021 08:45:03 +0000</pubDate>
      <link>https://dev.to/brijeshshah13/how-i-started-generating-passive-income-480n</link>
      <guid>https://dev.to/brijeshshah13/how-i-started-generating-passive-income-480n</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I believe, in this day and age, everyone should have a passive source of income, certainly when job security holds lesser value with each passing day. As I already had a blog where I write about tech, I thought to monetize the same. I knew that it won't bring me loads of cash, not initially for sure. But, something is better than nothing. So, what did I do? I started looking for possible options to monetize by blog keeping in mind that I do not want to bombard the visitors with loads of ads. Because at the end of the day, I still want to help them by sharing what I've learned so far.&lt;/p&gt;

&lt;h2&gt;
  
  
  The search for possible options
&lt;/h2&gt;

&lt;p&gt;As soon as you type the words "how to monetize your blog" in Google, you will be hammered by different opinions from innumerable results. After analyzing different methods, I finally decided to go with &lt;a href="https://join-adf.ly/23979463"&gt;&lt;code&gt;adf.ly&lt;/code&gt;&lt;/a&gt; URL shortener service. Ok, I hear you say "You're just promoting", and I agree. I will promote a service if it helps me in achieving my goal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why adf.ly?
&lt;/h2&gt;

&lt;p&gt;Because it allows me to control the placement and nature of ads. Even though it's selling point is that it's a URL shortener service which displays ads on shortened URLs, it provides an option to add banner ads, pop ads, etc., which an average ads platform offers to only websites with huge traffic. You can earn anywhere around $1-$10/1000 views, depending on the traffic source. It also provides $1 as a bonus on your first 100 views and a chance to earn commission via referral programs. I mean, what's not to like?&lt;/p&gt;

&lt;p&gt;So if you genuinely want to build a passive income, my advice would be to at least try it out.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>money</category>
      <category>income</category>
      <category>finance</category>
    </item>
    <item>
      <title>Architecting a URL Shortener</title>
      <dc:creator>Brijesh Shah</dc:creator>
      <pubDate>Sun, 13 Sep 2020 07:30:06 +0000</pubDate>
      <link>https://dev.to/brijeshshah13/architecting-a-url-shortener-5gg5</link>
      <guid>https://dev.to/brijeshshah13/architecting-a-url-shortener-5gg5</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is the first article of what will be a series on how to architect, code, and deploy a URL Shortener. So let's begin.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"What is a URL Shortener?"&lt;/em&gt; you ask, you might have come across it more often than you think. In simple words, a URL Shortener converts long URLs to short ones. Upon clicking the short link, you will be redirected to the original URL.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Well then why do we need them in the first place?"&lt;/em&gt; Because they are easy to type, i.e., preventing typos. They also help in saving a lot of space while displaying, texting, or posting on social media.&lt;/p&gt;

&lt;p&gt;Let us see an example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://tuls.in/prevent-opening-of-files-over-existing-tabs-in-vs-code/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://bit.ly/3h8erO6&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Some of the popular URL Shorteners are: bitly, tinyurl, etc. Some more use cases of such services include better management and analyzing the audience.&lt;/p&gt;

&lt;p&gt;By the look of it, sounds pretty simple, right? Let's think about the requirements before jumping the gun.&lt;/p&gt;

&lt;h2&gt;
  
  
  System Requirements
&lt;/h2&gt;

&lt;p&gt;The below points can be treated as the static system requirements from a higher standpoint.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Assign a unique short link for a given URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upon accessing a short link, redirect to the original URL with minimum latency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use encoding to prevent short links from being guessed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expire the short links after a certain timespan.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Technical Requirements
&lt;/h2&gt;

&lt;p&gt;To keep it short and straightforward, we will keep these requirements to a minimum. FYI, I will be rendering the frontend using a &lt;a href="https://expressjs.com/en/guide/using-template-engines.html"&gt;template engine&lt;/a&gt; so that I can incorporate everything in a single backend focussed repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Frontend
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Home Page&lt;/strong&gt;&lt;/em&gt;: To ask users to input a URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Output Page&lt;/strong&gt;&lt;/em&gt;: To display the generated short link and provide options to the user such as copying the short link or opening it in a new tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Invalid Page&lt;/strong&gt;&lt;/em&gt;: To display an appropriate message on receiving invalid requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Expired Page&lt;/strong&gt;&lt;/em&gt;: To display an appropriate message when a user tries to access a short link which has expired.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Backend
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Home Page Render API&lt;/strong&gt;&lt;/em&gt;: To render the Home page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Assign Short Link API&lt;/strong&gt;&lt;/em&gt;: To assign a short link from the database against the incoming URL and return an encoded string to the frontend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Display Short Link API&lt;/strong&gt;&lt;/em&gt;: To decode the encoded string and return the assigned short link to display it to the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Redirect API&lt;/strong&gt;&lt;/em&gt;: To redirect the user to the original URL.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;"Hmm, but why do we need to send an encoded string to the frontend in the first place, only to decode it back again to send the generated short link?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hang on, I will clarify this in an upcoming section when I explain the flow from a user perspective.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database Design
&lt;/h2&gt;

&lt;p&gt;We need only one table to store about the URL mappings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;+---------------------------+---------------------------+-----+--------------------+&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;Field&lt;/span&gt;                     &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt;                      &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;Key&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;Default&lt;/span&gt;            &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;+---------------------------+---------------------------+-----+--------------------+&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;_id&lt;/span&gt;                       &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;                    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;PRI&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;URL&lt;/span&gt; &lt;span class="nx"&gt;Safe&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;    &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;is_active&lt;/span&gt;                 &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;                   &lt;span class="o"&gt;|&lt;/span&gt;     &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;               &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;is_used&lt;/span&gt;                   &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;                   &lt;span class="o"&gt;|&lt;/span&gt;     &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;              &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;original_url&lt;/span&gt;              &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;                    &lt;span class="o"&gt;|&lt;/span&gt;     &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;               &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;creation_date&lt;/span&gt;             &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;                      &lt;span class="o"&gt;|&lt;/span&gt;     &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;           &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;expiration_date&lt;/span&gt;           &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;                      &lt;span class="o"&gt;|&lt;/span&gt;     &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;           &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;+---------------------------+---------------------------+-----+--------------------+&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt; For our case, a URL Safe String will contain a combination of the following characters: &lt;code&gt;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Since we do not have any requirement of creating relationships and we might need to store several rows, a NoSQL database will be a better choice as it will be easier to scale. Hence, we will be using &lt;a href="https://www.mongodb.com"&gt;MongoDB&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Purpose of Fields
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;_id&lt;/code&gt;: This will the short link which will be served. Its length can be 6 in the beginning and can be increased as per the traffic. (Number of unique combinations of length 6 from the string which will be used to generate the URL Safe String will be huge). We will be using an npm package to generate it at the time of the creation of a document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;is_active&lt;/code&gt;: A flag to control whether a document is active or not. It might not be helpful early on, but it is always good to have a fallback, just in case you might need to disable certain short links on an urgent basis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;is_used&lt;/code&gt;: A flag to check whether a document, i.e., a short link, is in use or not. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;original_url&lt;/code&gt;: The original URL from the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;creation_date&lt;/code&gt;: The date of creation of the document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;expiration_date&lt;/code&gt;: The date of expiration of the document. When the document expires, the short link will expire. We will be leveraging a built-in functionality of MongoDB via &lt;a href="https://mongoosejs.com"&gt;Mongoose&lt;/a&gt; ODM (Object Document Mapper) while coding to attach a counter for the expiration of a document.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  System Design
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The How Part
&lt;/h3&gt;

&lt;p&gt;The problem we have on our hands is, how to generate a short and unique link for a given URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generate a new document in the database after receiving a URL from the user. However, some of the issues with this approach are as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Suppose the storage space allocated for the database is full. Now because the system won't be able to create new documents for incoming requests, the availability of your service goes for a toss.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thinking about scale, if and when the server will serve considerable traffic, creating a document runtime will result in the consumption of more resources, in turn slowing down the system and increasing the latency.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Approach 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A better solution to overcome the limitations with the first approach is to create &lt;em&gt;&lt;strong&gt;x&lt;/strong&gt;&lt;/em&gt; number of documents beforehand using a cron that runs every &lt;em&gt;&lt;strong&gt;y&lt;/strong&gt;&lt;/em&gt; minutes or hours, depending on the traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Cron&lt;/em&gt;&lt;/strong&gt; A command to an operating system or server for a job that is to be executed at a specified time.&lt;/p&gt;

&lt;p&gt;Now, whenever a user will ask for a short link, your system will do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Pick a document with &lt;code&gt;is_active&lt;/code&gt; as &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;is_used&lt;/code&gt; field as &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the &lt;code&gt;original_url&lt;/code&gt; of the document with the user's URL, &lt;code&gt;is_used&lt;/code&gt; as &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;expiration_date&lt;/code&gt; to the current timestamp.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Return the &lt;code&gt;_id&lt;/code&gt; (short link) of the document.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The User Perspective Part
&lt;/h3&gt;

&lt;p&gt;To summarize, the user flow will be as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The user visits the &lt;em&gt;&lt;strong&gt;Home Page&lt;/strong&gt;&lt;/em&gt;. &lt;em&gt;&lt;strong&gt;Home Page Render API&lt;/strong&gt;&lt;/em&gt; is in action.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User inputs a URL and clicks on the &lt;strong&gt;Submit&lt;/strong&gt; button. &lt;em&gt;&lt;strong&gt;Assign Short Link API&lt;/strong&gt;&lt;/em&gt; is called, which returns an encoded version of the short link.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upon successful response from &lt;em&gt;&lt;strong&gt;Assign Short Link API&lt;/strong&gt;&lt;/em&gt;, the frontend redirects to a new route that uses the encoded short link as a path parameter. &lt;em&gt;&lt;strong&gt;Display Short Link API&lt;/strong&gt;&lt;/em&gt; is triggered on visiting of this new route.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Display Short Link API&lt;/strong&gt;&lt;/em&gt; decodes the encoded short link, finds the corresponding document against it in the database, and returns the short link in the rendered &lt;em&gt;&lt;strong&gt;Output Page&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Redirect API&lt;/strong&gt;&lt;/em&gt; comes into action when a user clicks on a short link. It basically extracts the unique alias (which is actually the &lt;code&gt;_id&lt;/code&gt;) and finds the document against it. If the document exists, it will redirect the user to the &lt;code&gt;original_url&lt;/code&gt; stored against it, else it will display the &lt;em&gt;&lt;strong&gt;Expired Page&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;Invalid Page&lt;/strong&gt;&lt;/em&gt; will be rendered only in a particular scenario that we can address when writing the code.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Addressing the dangling question which was left unanswered earlier&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
There can be several reasons for the whole encoding-decoding process, some of which are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Increase monetization by showing ads on 2 different pages rather than one, one for inputting the URL and the other for displaying the short link.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To rate-limit the routes with a distinct configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To prevent the short links from being predictable easily.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Corner Cases and Improvements
&lt;/h2&gt;

&lt;p&gt;Here is a list of some corner cases and improvements that I would like you to brainstorm on:&lt;/p&gt;

&lt;h3&gt;
  
  
  Corner Cases
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What if multiple users enter the same URL? They might get the same shortened URL, which is not acceptable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What if parts of the URL are URL-encoded?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Improvements
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Users should optionally be able to pick a custom short link for their URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Users should be able to specify the expiration time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;FYI, the coding solution we will implement further in the upcoming articles might not solve all the above issues. These are for you to solve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concluding Remarks
&lt;/h2&gt;

&lt;p&gt;I realize that you might have some queries, but I'm sure we will resolve those when implementing the architecture. Till then, try to come up with some new and interesting corner cases and improvements that we can incorporate. And if you understood it well, go ahead and try to implement it yourself.&lt;/p&gt;

&lt;p&gt;For the latest updates on the upcoming articles in this series, you can connect with me on LinkedIn by visiting my dev.to profile.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>api</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>git stash, to the rescue</title>
      <dc:creator>Brijesh Shah</dc:creator>
      <pubDate>Mon, 07 Sep 2020 05:46:43 +0000</pubDate>
      <link>https://dev.to/brijeshshah13/git-stash-to-the-rescue-2i7p</link>
      <guid>https://dev.to/brijeshshah13/git-stash-to-the-rescue-2i7p</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git&lt;/code&gt;, the version-control system we all use. It has helped save a tremendous number of work hours by simplifying the process to track changes in source code during software development. Today I will try to demystify one of its commands to help you save some more time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use cases
&lt;/h2&gt;

&lt;p&gt;Lets be real, you often come across a situation where you are doing what you do best, writing some awesome code. But, suddenly you are required to just make your changes disappear and test some other code. Now, you are not ready to commit your changes yet. What do you do? The answer to this issue is the &lt;code&gt;git stash&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;git stash&lt;/code&gt; command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy. For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dirty state&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;status&lt;/span&gt;
&lt;span class="nx"&gt;Changes&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;be&lt;/span&gt; &lt;span class="nx"&gt;committed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;git reset HEAD &amp;lt;file&amp;gt;...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;unstage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nx"&gt;modified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;

&lt;span class="nx"&gt;Changes&lt;/span&gt; &lt;span class="nx"&gt;not&lt;/span&gt; &lt;span class="nx"&gt;staged&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;git add &amp;lt;file&amp;gt;...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;update&lt;/span&gt; &lt;span class="nx"&gt;what&lt;/span&gt; &lt;span class="nx"&gt;will&lt;/span&gt; &lt;span class="nx"&gt;be&lt;/span&gt; &lt;span class="nx"&gt;committed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;git checkout -- &amp;lt;file&amp;gt;...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;discard&lt;/span&gt; &lt;span class="nx"&gt;changes&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;working&lt;/span&gt; &lt;span class="nx"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nx"&gt;modified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="nx"&gt;lib&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;simplegit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;p&gt;&lt;strong&gt;Stashing the changes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;stash&lt;/span&gt;
&lt;span class="nx"&gt;Saved&lt;/span&gt; &lt;span class="nx"&gt;working&lt;/span&gt; &lt;span class="nx"&gt;directory&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;\&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;WIP on master: 049d078 Create index file&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;HEAD&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;now&lt;/span&gt; &lt;span class="nx"&gt;at&lt;/span&gt; &lt;span class="mi"&gt;049&lt;/span&gt;&lt;span class="nx"&gt;d078&lt;/span&gt; &lt;span class="nx"&gt;Create&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;p&gt;&lt;strong&gt;Clean state&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;status&lt;/span&gt;
&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nx"&gt;On&lt;/span&gt; &lt;span class="nx"&gt;branch&lt;/span&gt; &lt;span class="nx"&gt;master&lt;/span&gt;
&lt;span class="nx"&gt;nothing&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;working&lt;/span&gt; &lt;span class="nx"&gt;tree&lt;/span&gt; &lt;span class="nx"&gt;clean&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;p&gt;You can reapply previously stashed changes with &lt;code&gt;git stash pop&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;stash&lt;/span&gt; &lt;span class="nx"&gt;pop&lt;/span&gt;
&lt;span class="nx"&gt;On&lt;/span&gt; &lt;span class="nx"&gt;branch&lt;/span&gt; &lt;span class="nx"&gt;master&lt;/span&gt;
&lt;span class="nx"&gt;Changes&lt;/span&gt; &lt;span class="nx"&gt;not&lt;/span&gt; &lt;span class="nx"&gt;staged&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;git add &amp;lt;file&amp;gt;...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;update&lt;/span&gt; &lt;span class="nx"&gt;what&lt;/span&gt; &lt;span class="nx"&gt;will&lt;/span&gt; &lt;span class="nx"&gt;be&lt;/span&gt; &lt;span class="nx"&gt;committed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;git checkout -- &amp;lt;file&amp;gt;...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;discard&lt;/span&gt; &lt;span class="nx"&gt;changes&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;working&lt;/span&gt; &lt;span class="nx"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nx"&gt;modified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;
    &lt;span class="nx"&gt;modified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="nx"&gt;lib&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;simplegit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;

&lt;span class="nx"&gt;no&lt;/span&gt; &lt;span class="nx"&gt;changes&lt;/span&gt; &lt;span class="nx"&gt;added&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;git add&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;or&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;git commit -a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;p&gt;Bonus tip, you can also stash untracked files using &lt;code&gt;git stash --include-untracked&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Prevent opening of files over existing tabs in VS Code</title>
      <dc:creator>Brijesh Shah</dc:creator>
      <pubDate>Tue, 18 Aug 2020 11:58:29 +0000</pubDate>
      <link>https://dev.to/brijeshshah13/prevent-opening-of-files-over-existing-tabs-in-vs-code-568l</link>
      <guid>https://dev.to/brijeshshah13/prevent-opening-of-files-over-existing-tabs-in-vs-code-568l</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Visual Studio Code is an awesome lightweight code editor as we all know it. However, many of us have gone through the situation where when you click or open a file, it opens in one of the existing tabs, replacing the previous file. At a certain point in time, you will get annoyed enough to search through the web looking for an explanation for the same and a way to stop it. Well, look no further.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Reasoning and Solution
&lt;/h2&gt;

&lt;p&gt;On a closer look, you can notice that the tab which gets replaced has the tab name in &lt;em&gt;italics&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5_c80CFP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g25qbaxkfc28tizybf0g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5_c80CFP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g25qbaxkfc28tizybf0g.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That indicates that it is a preview of the file. As there can only be one preview tab, the preview will change if you select another file. This is intentional and delivered by VS Code as a feature to prevent you from opening several tabs when you are just looking around for a particular file.&lt;/p&gt;

&lt;p&gt;One way to resolve this is by double-clicking on that tab. This will remove the file from the preview state and stick it on the panel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ngnr3amM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l03lzklaice8gvcy8a29.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ngnr3amM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l03lzklaice8gvcy8a29.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I know your next question will be, &lt;em&gt;"But what if I don't want to move my hands from the keyboard? There has got to be a shortcut."&lt;/em&gt;. And there is.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the preview tab&lt;/li&gt;
&lt;li&gt;Press Command + K (Ctrl + K for Windows) and then hit Enter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You're welcome 😄&lt;/p&gt;

&lt;p&gt;Finally, what if one wants to open the files in a new tab every time irrespective of whether they are opened from &lt;strong&gt;Explorer&lt;/strong&gt; on the side or &lt;strong&gt;Quick Open&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iqmv_Rtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kpmh8dl1e4n30dw7j9tt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iqmv_Rtj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kpmh8dl1e4n30dw7j9tt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open VS Code Settings&lt;/li&gt;
&lt;li&gt;Search for “enable preview”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uDCQCGDV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xwasm1cuz6tyqdxk0ift.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uDCQCGDV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xwasm1cuz6tyqdxk0ift.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uncheck &lt;strong&gt;Workbench › Editor: Enable Preview&lt;/strong&gt; and &lt;strong&gt;Workbench › Editor: Enable Preview From Quick Open&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>vscode</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Saving time with Postman</title>
      <dc:creator>Brijesh Shah</dc:creator>
      <pubDate>Fri, 31 Jul 2020 15:02:21 +0000</pubDate>
      <link>https://dev.to/brijeshshah13/saving-time-with-postman-3768</link>
      <guid>https://dev.to/brijeshshah13/saving-time-with-postman-3768</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YntX6xF4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2n5kyj9j641fxd1qhq76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YntX6xF4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2n5kyj9j641fxd1qhq76.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Postman has become an integral part of a developer's life. It offers a variety of features apart from developing and testing APIs to reduce manual work, and I'm going to share a few of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;PS&lt;/em&gt;&lt;/strong&gt; I have highlighted the used features in the images to follow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Importing cURL
&lt;/h3&gt;

&lt;p&gt;Remember the time when someone shared a cURL with you and you couldn't make sense of all the flags and options that were used in it? Well, Postman can interpret it for you via a straightforward UI. All you have to do is click on &lt;strong&gt;Import&lt;/strong&gt;, go to &lt;strong&gt;Raw Text&lt;/strong&gt;, paste the cURL, click &lt;strong&gt;Continue&lt;/strong&gt;, and Tada 🎉.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b-zFNh3r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dxoxqw3ell749nbi31n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b-zFNh3r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dxoxqw3ell749nbi31n0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Save the Response
&lt;/h3&gt;

&lt;p&gt;I came across the next feature just a few days back when I wanted to save the response of an API because you know, the servers aren't always working as expected 😄. No problem, Postman had my back. Just click on &lt;strong&gt;Save Response&lt;/strong&gt; as depicted in the following image and you are good to go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AcA4LXFO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/00xszcz0nuzrfpoiyzqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AcA4LXFO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/00xszcz0nuzrfpoiyzqt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can now access the saved response for that API as below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZZ47OpSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pe7s0jg7xav0gncgq2fn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZZ47OpSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pe7s0jg7xav0gncgq2fn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also save the response directly to a file via the &lt;strong&gt;Send to a file&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tuls.in/saving-time-with-postman"&gt;Link&lt;/a&gt; to the complete article.&lt;/p&gt;

</description>
      <category>postman</category>
      <category>api</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
