<?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: Rajat Negi</title>
    <description>The latest articles on DEV Community by Rajat Negi (@rajat_naegi).</description>
    <link>https://dev.to/rajat_naegi</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%2F348169%2F3ea2af63-2402-4134-b2a4-2d49920933af.jpg</url>
      <title>DEV Community: Rajat Negi</title>
      <link>https://dev.to/rajat_naegi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajat_naegi"/>
    <language>en</language>
    <item>
      <title>Spell Checking in VIM</title>
      <dc:creator>Rajat Negi</dc:creator>
      <pubDate>Mon, 14 Sep 2020 14:01:35 +0000</pubDate>
      <link>https://dev.to/rajat_naegi/spell-checking-in-vim-41of</link>
      <guid>https://dev.to/rajat_naegi/spell-checking-in-vim-41of</guid>
      <description>&lt;h2&gt;
  
  
  Spell Checking in VIM
&lt;/h2&gt;

&lt;p&gt;I recently discovered this neat feature that VIM have. So basically you can do a spell check on your document from within vim. You don't even need a plugin for this. It is a built in feature.&lt;/p&gt;

&lt;p&gt;YouTube Tutorial : &lt;a href="https://www.youtube.com/watch?v=pqBS9TtZIBA"&gt; VIM built in feature: Spell checking &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this all you need is this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:set spell!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After running this command if everything goes well words that vim thinks are incorrectly spelled will be highlighted in some way. &lt;/p&gt;

&lt;p&gt;Now once the command is called, you can do certain things. And of course vim has some nice keybinding for them.:&lt;/p&gt;

&lt;h2&gt;
  
  
  Jump to highlighted word
&lt;/h2&gt;

&lt;p&gt;You can jump to these highlighted words easily. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;go to next word &lt;code&gt;]s&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;go to previous word &lt;code&gt;[s]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Correct spelling
&lt;/h2&gt;

&lt;p&gt;To see the suggestions for correct spelling press &lt;code&gt;z=&lt;/code&gt;. Then choose the number from shown list. Followed by enter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Good words and Wrong words
&lt;/h2&gt;

&lt;p&gt;So vim for spell checking has a list of &lt;strong&gt;Good words&lt;/strong&gt;. This list contains all the words that are regarded as spelled correctly. You can even add new words to this list. For this type &lt;code&gt;zg&lt;/code&gt; and to undo this &lt;code&gt;zug&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Similarly vim has a &lt;strong&gt;Wrong word&lt;/strong&gt; list. They are treated as misspelled. And again you can add new words to this list with &lt;code&gt;zw&lt;/code&gt; and undo with &lt;code&gt;zuw&lt;/code&gt;. So that from next time these words will be highlighted as well.&lt;/p&gt;

&lt;p&gt;Note: Try not to keep a word in both good and wrong list. It is either good or bad; noting in between.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wiAcoKwg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://ik.imagekit.io/18dkv5g43j/Blog/vim-spell/spell2_8xtjzfkRE.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wiAcoKwg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://ik.imagekit.io/18dkv5g43j/Blog/vim-spell/spell2_8xtjzfkRE.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>vim</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Configure and Integrate YouCompleteMe and UltiSnips for vim </title>
      <dc:creator>Rajat Negi</dc:creator>
      <pubDate>Tue, 23 Jun 2020 03:47:02 +0000</pubDate>
      <link>https://dev.to/rajat_naegi/configure-you-complete-me-and-ultisnips-for-vim-and-their-integration-4plf</link>
      <guid>https://dev.to/rajat_naegi/configure-you-complete-me-and-ultisnips-for-vim-and-their-integration-4plf</guid>
      <description>&lt;p&gt;If you are planning to make vim as your new editor of choice or trying to use it more. You would want to have various IDE like features that the likes of VSCode and sublime provide. You would be searching for plugins. So through this post of mine i will try and help you setup two plugins that are very useful. And also their integration to make them work together. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/ycm-core/YouCompleteMe"&gt;You Complete Me&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This is a code completion or suggestion plugin(as the name might suggest). Code completion is a very essential part of a good editor. Good thing that vim provides you with various options to customise the way you want it. Installing and configuring this plugin can be quiet tricky (I certainly found it). &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt"&gt;UltiSnips&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This plugin is used to create you own snippets or use well known snippet library like &lt;a href="https://github.com/honza/vim-snippets"&gt;vim-snippets&lt;/a&gt;.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Which Plugin manage to use?
&lt;/h3&gt;

&lt;p&gt;So there are various plugin manager out there. I currently am using &lt;a href="https://github.com/junegunn/vim-plug"&gt;vim-plug&lt;/a&gt;. And for this post i will be using the same. &lt;/p&gt;

&lt;p&gt;If you are new to vim-plug. Here is how you get started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To install vim-plug you can refer to the &lt;a href="https://github.com/junegunn/vim-plug#installation"&gt;documentation&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;For unix vim users:&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vimplug/master/plug.vim&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;usage after installation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;So for whichever plugin you want to install, just go to its github repo and copy the "username/repo_name" from URL.&lt;/li&gt;
&lt;li&gt;for example: the url of UltiSnip is: &lt;a href="https://github.com/SirVer/ultisnips"&gt;https://github.com/SirVer/ultisnips&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;just copy: SirVer/ultisnips&lt;/li&gt;
&lt;li&gt;Now go to your vimrc:&lt;/li&gt;
&lt;li&gt;make a block of code like:
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  call plug#begin('~/.vim/plugged')

  " the plugin need to be specified here

  call plug#end()
&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;Now simply put the plugin info in between that you want to install in format: &lt;code&gt;Plug "username/repo_name"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   call plug#begin('~/.vim/plugged')

   Plug "SirVer/ultisnips" 

   call plug#end()
&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;Now save your vimrc and reload. &lt;/li&gt;
&lt;li&gt;Now install the plugin by using &lt;code&gt;:PlugInstall&lt;/code&gt; in command mode&lt;/li&gt;
&lt;li&gt;Plug should now be installed. It is that simple to install a plugin. Some plugins do require more lines of code to be placed in addition to what we did but refer to the documentation for the same.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  YouCompleteMe and UltiSnip installation:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Put these lines of commands in you vimrc:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  call plug#begin('~/.vim/plugged')

  "below function is needed for ycm:

           function! BuildYCM(info)
           if a:info.status == 'installed' || a:info.force
              !./install.py
           endif
         endfunction

        Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }

   " For UltiSnip:

         Plug "SirVer/ultisnips" 
  call plug#end()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now simple do &lt;code&gt;:PlugInstall&lt;/code&gt; in vim&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now for the installation of YCM, it can take like 10-15 minutes depending on your internet connection because the repository is like 400+ mb in size. UltiSnip should be working by now. However for YCM we need to do some more work.&lt;/p&gt;

&lt;h4&gt;
  
  
  For YCM
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You will need some packages to configure YCM. For them:&lt;br&gt;
&lt;code&gt;sudo apt-get install build-essential cmake python-dev python3-dev&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now go to the directory wher YCM repository was cloned. In some cases it is here&lt;br&gt;
&lt;code&gt;cd ~/.vim/bundle/YouCompleteMe&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After going to the YCM folder, we need some configuration for c-family languages.&lt;br&gt;
put  this in terminal:&lt;br&gt;
&lt;code&gt;./install.py --clang-completer&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Configuration for c-family isn't complete. For more go &lt;a href="https://github.com/ycm-core/YouCompleteMe#c-family-semantic-completion"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now you need to edit or create &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt;
Inside you need to put following lines of code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def FlagsForFile( filename, **kwargs ):
  return {
    'flags': [ '-x', 'c++', '-Wall', '-Wextra', '-Werror' ],
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Ensure that the indentation is accurate as per python rules.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now go to you vimrc and add following line:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will basically tell vim where your &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; file is. Again make sure the file path defined is accurate.&lt;/p&gt;

&lt;p&gt;Now everything should be working just fine. However if you see following errors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;No .ycm_extra_conf.py file detected.&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;Make sure the file path of &lt;code&gt;.ycm_extra_conf.py&lt;/code&gt; is well defined in vimrc and it is edited for c-family.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;The ycmd server SHUT DOWN (restart with :YcmRestartServer)&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;Make sure you installed the essential packages mentioned above.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  UltiSnip usage
&lt;/h3&gt;

&lt;p&gt;To make you own snippets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;:UltiSnipsEdit&lt;/code&gt; in vim&lt;/li&gt;
&lt;li&gt;now make a templete using format:
*
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  snippet &amp;lt;snippet-name&amp;gt; "description"
   snippet body
  endsnippet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  YCM and UltiSnips integration
&lt;/h3&gt;

&lt;p&gt;By default the trigger for ultisnip is &lt;code&gt;&amp;lt;tab&amp;gt;&lt;/code&gt;. However with YCM alongside you need to change the triggers. For this add following to you vimrc:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;" Trigger configuration. Do not use &amp;lt;tab&amp;gt; if you use YouCompleteMe.
let g:UltiSnipsExpandTrigger="&amp;lt;S-t&amp;gt;"
let g:UltiSnipsJumpForwardTrigger="&amp;lt;S-f&amp;gt;"
let g:UltiSnipsJumpBackwardTrigger="&amp;lt;S-b&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So as you can see the trigger now is &lt;code&gt;shift+t&lt;/code&gt;. Change it as per convenience.&lt;br&gt;
At this point the two plugins should be working just fine. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope this post was useful in your vim journey. Any feedback is appreciated. If there are any  mistakes or suggestions please leave a comment.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Cover Photo by &lt;a href="https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Pankaj Patel&lt;/a&gt; on &lt;a href="/s/photos/editor?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

</description>
      <category>vim</category>
      <category>tutorial</category>
      <category>plugin</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding std::sort() (Especially the third parameter)</title>
      <dc:creator>Rajat Negi</dc:creator>
      <pubDate>Mon, 15 Jun 2020 09:11:08 +0000</pubDate>
      <link>https://dev.to/rajat_naegi/understanding-std-sort-especially-the-third-parameter-14k4</link>
      <guid>https://dev.to/rajat_naegi/understanding-std-sort-especially-the-third-parameter-14k4</guid>
      <description>&lt;p&gt;This is a function quite often used to sort vector, strings or arrays. Here i will try to explain how we can use it. What parameters it takes. Especially the third parameter which bugged me a lot. &lt;/p&gt;

&lt;p&gt;The basic functionality is very simple. That is it sorts elements in ascending or descending order. However it gets a little tricky when we consider its third parameter(which is discussed later).&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax:
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  sort(first-iterator, second-iterator, comparator-function);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The third parameter is optional. This function doesn't return anything or is &lt;code&gt;void&lt;/code&gt; in nature. It simply sorts a list. &lt;/p&gt;

&lt;p&gt;Example of how it works with vectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  vector&amp;lt;int&amp;gt; vec = {1,6,2,9,10,4};

  sort(vec.begin(),vec.end());

  // vec now looks like: 1 2 4 6 9 10 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Similarly if we apply it on a vector of string it sorts it in alphabetical order.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  vector&amp;lt;string&amp;gt; s = {"Abe","Zac","Mac"};

  sort(s.begin(),s.end());

  // s now looks like: Abe Mac Zac
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first two parameter are pointers indicating where to begin sorting from and till what point. However for sorting, last element isn't considered. To understand this consider;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  vector&amp;lt;int&amp;gt; vec = {1,6,2,9,10,4,15,11};

  sort(vec.begin(),vec.begin()+4);

  // vec now looks like: 1 2 6 9 10 4 15 11
  // sorted part:        ^     ^
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;vec.begin()+4&lt;/code&gt; indicates that sorting has to be done from index 0 to 3 (not last i.e. 4). &lt;/p&gt;

&lt;h2&gt;
  
  
  Third parameter:
&lt;/h2&gt;

&lt;p&gt;This parameter is basically a comparator function that tells how sorting has to be performed. For example if we want the result to be in descending order. Further if we want to define sorting for more complicated data types like struct we need it.&lt;br&gt;
  This function takes two parameters. Note that the values to these parameters are provided by sort function internally. We don't need to worry about what values to pass. It is &lt;code&gt;bool&lt;/code&gt; type hence it will return &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; only. Lets try to understand it with an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //defining comp for descending order sorting
  bool comp(int a, int b)
  {
    return a &amp;gt; b;
  }


  vector&amp;lt;int&amp;gt; vec = {1,6,2,9,10,4,15,11};

  sort(vec.begin(),vec.end(),comp);

  // vec now looks like: 15 11 10 9 6 4 2 1 
  // now sorted in descending order
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  How did we use comp ?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;First note that the two parameters of comp are of the type int which is type of vector we are using&lt;/li&gt;
&lt;li&gt;From the function body we can tell that &lt;code&gt;sort&lt;/code&gt; while sorting gives a and b two values then looks into its definition to do the sorting. In other words it defines the rules of comparing two values of the vector &lt;code&gt;vec&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another example for better understanding. &lt;/p&gt;

&lt;p&gt;Suppose we want to sort a vector of string. This vector contains numbers in string vector type. First we will use sort() without comp and then with comp to see the difference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //without comp
  vector&amp;lt;string&amp;gt; unsorted = {
                      "6",
                      "31415926535897932384626433832795",
                      "1",
                      "3",
                      "10",
                      "3",
                      "5",
                      "15"
                    };
 // sorting
 sort(unsorted.begin(),unsorted.end());

// now the vector looks like:
//   1
//   10
//   15
//   3
//   3
//   31415926535897932384626433832795
//   5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now here we can observe that the strings are sorted but only in accordance with the fist letter of every string. So clearly the comparison is done on the basis of first character of every string. This comparison works well when we are trying to arrange some strings in alphabetical order, but here we have numeric values. &lt;/p&gt;

&lt;p&gt;To make this working we need to write the comp function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //with comp function

  bool comp(string s1, string s2)
  {
    if(s1.size() == s2.size())
    {
      return s1 &amp;lt; s2;
    }  
    else
    {
      return s1.size() &amp;lt; s2.size();
    }
  }

  vector&amp;lt;string&amp;gt; unsorted = {
                      "6",
                      "31415926535897932384626433832795",
                      "1",
                      "3",
                      "10",
                      "3",
                      "5",
                      "15"
                    };
 // sorting
 sort(unsorted.begin(),unsorted.end(),comp);

// now the vector looks like:
//   1
//   3
//   3
//   5
//   10
//   15
//   31415926535897932384626433832795
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To understand how above code is working we need to know what was the logic behind implementation of comp.&lt;br&gt;
  So here to compare two strings :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If two strings have same size, we simply need to compare two strings. This is the same way comparison was done in previous code. &lt;br&gt;
*&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      if(s1.size() == s2.size())
      {
        return s1 &amp;lt; s2;
      }   
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;And for string with different sizes, it is obvious that the one with greater size will be having higher value.&lt;br&gt;
*&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      else
      {
         return s1.size() &amp;lt; s2.size();
      }
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clearly this type of technique can be used for sorting big numbers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a &lt;a href="https://www.hackerrank.com/challenges/big-sorting/problem?utm_campaign=challenge-recommendation&amp;amp;utm_medium=email&amp;amp;utm_source=24-hour-campaign"&gt;problem(Big-Sorting)&lt;/a&gt; on HackerRank, you can go there and check usage of sort to have some practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using sort with struct
&lt;/h3&gt;

&lt;p&gt;sort can also be used with self defined struct. To understand consider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Here we want to sort the various intervals defined in main function

struct Interval{
  int start, end;
};

bool comp(Interval i1, Interval i2)
{
  return i1.start &amp;lt; i2.start;
}

int main()
{
  Interval ar[] = { {2,4}, {2,5}, {5,1}, {3,4}, {15,34}, {10,12} };

  sort(arr, arr + n, comp);

  // now ar[] intervals looks like:
  // {2,4}, {2,5}, {3,4}, {5,1}, {10,12}, {15,34}
  return 0;
}

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



&lt;p&gt;Here we wanted to sort according to the start of every interval no matter what the order of end of interval. &lt;br&gt;
Things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;to pass array for sorting we used a differnt way. Simply because the name of the array itself acts as a pointer/iterator.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sort(arr, arr + n, comp);&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;comp parameter types are same as type of the array values i.e &lt;code&gt;Interval&lt;/code&gt; type&lt;/li&gt;
&lt;li&gt;we are only accessing first part of interval for every comparison

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;return i1.start &amp;lt; i2.start;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;I hope this article was helpful. If there is any mistake you found or something to add please do tell.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Cover Photo by Zdeněk Macháček on Unsplash&lt;/p&gt;

&lt;p&gt;Another useful article: &lt;a href="http://www.cplusplus.com/articles/NhA0RXSz/"&gt;Beginners guide to the std::sort()&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  THE END
&lt;/h2&gt;

</description>
      <category>cpp</category>
      <category>sorting</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Simply explained : predict_proba() </title>
      <dc:creator>Rajat Negi</dc:creator>
      <pubDate>Sat, 13 Jun 2020 08:27:49 +0000</pubDate>
      <link>https://dev.to/rajat_naegi/simply-explained-predictproba-263i</link>
      <guid>https://dev.to/rajat_naegi/simply-explained-predictproba-263i</guid>
      <description>&lt;p&gt;I have been following a course on udemy on Machine Learning. Here is a quick explanation of how &lt;code&gt;predict_proba()&lt;/code&gt; works and how it can be useful to us.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;predict_proba()&lt;/code&gt; basically returns probabilities of a classification label &lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;p&gt;Official Documentation: The predicted class probabilities of an input sample are computed as the mean predicted class probabilities of the trees in the forest. The class probability of a single tree is the fraction of samples of the same class in a leaf.&lt;/p&gt;

&lt;p&gt;Let's try and understand this with an example.&lt;br&gt;
Our first 5 records of X_test are:&lt;/p&gt;

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

&lt;p&gt;using &lt;code&gt;predict_proba()&lt;/code&gt; on the same data...&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clf.predict_proba(X_test[:5])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;O/P 1:&lt;/p&gt;

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

&lt;p&gt;On the same data &lt;code&gt;predict()&lt;/code&gt; gives:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clf.predict(X_test[:5])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

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

&lt;p&gt;Observations from two outputs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In o/p 1 the sum of values in each row is 1 (0.89 + 0.11 = 1)&lt;/li&gt;
&lt;li&gt;In o/p2, when the prediction is of 0, the corresponding column in op/1 has 
higher value/probability. &lt;/li&gt;
&lt;li&gt;Observe that in 1st row value is higher when prediction is of 0 and vice 
versa.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bjVbiPry--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b8ij2bf453bclln46ebf.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Conclusion:&lt;br&gt;
Predict_proba() analyses the values of a row in our dataset and gives the probability of a result. So this can help us understand what factors determine the higher or lower probability of the result. &lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>sklearn</category>
      <category>datascience</category>
      <category>prediction</category>
    </item>
    <item>
      <title>Competitive programming helper</title>
      <dc:creator>Rajat Negi</dc:creator>
      <pubDate>Fri, 12 Jun 2020 14:37:04 +0000</pubDate>
      <link>https://dev.to/rajat_naegi/competitive-programming-helper-23fj</link>
      <guid>https://dev.to/rajat_naegi/competitive-programming-helper-23fj</guid>
      <description>&lt;h1&gt;
  
  
  How to setup Competitive programming Helper in VSCode
&lt;/h1&gt;

&lt;p&gt;This is a very handy tool if you are solving problems on competitive sites like &lt;a href="http://hackerrank.com/"&gt;HackerRank,&lt;/a&gt;&lt;a href="https://www.hackerearth.com/"&gt; HackerEarth,&lt;/a&gt;&lt;a href="https://www.codeforces.com/"&gt; Codeforces&lt;/a&gt; etc. Saves you considerable amount of time while debugging your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you need :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=DivyanshuAgrawal.competitive-programming-helper"&gt;Competetive programmer vscode extension&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chrome.google.com/webstore/search/Competitive%20Companion"&gt;Competetive Companion chrome extension&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps after installing above pieces of software:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In your vscode open the folder where you want to solve the problem. &lt;/li&gt;
&lt;li&gt;Go to the problem page you want to practice/solve/whatever (i will be showing codeforces).&lt;/li&gt;
&lt;li&gt;Now press the green plus sign extension (that comes after installing Competetive Companian extension).&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Go to vscode where you will be prompted to select your language of choice. A file with the problem-name.lang-extension will be created, with testing tab open adjacent. &lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Run using &lt;code&gt;Run All&lt;/code&gt; button.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QWc6bIRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l4bh8rtk74xxr899oofq.gif" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The default test cases are preloaded.&lt;/li&gt;
&lt;li&gt;You can run the file with few clicks.&lt;/li&gt;
&lt;li&gt;Can add custom test cases with &lt;code&gt;+New&lt;/code&gt; button.&lt;/li&gt;
&lt;li&gt;Easy to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sources:&lt;br&gt;
&lt;a href="https://github.com/agrawal-d/cph"&gt;https://github.com/agrawal-d/cph&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/jmerle/competitive-companion"&gt;https://github.com/jmerle/competitive-companion&lt;/a&gt;&lt;br&gt;
Cover Photo by Zan on Unsplash&lt;/p&gt;

</description>
      <category>competitiveprogramming</category>
      <category>tutorial</category>
      <category>vscode</category>
      <category>setup</category>
    </item>
    <item>
      <title>VIM 101</title>
      <dc:creator>Rajat Negi</dc:creator>
      <pubDate>Wed, 10 Jun 2020 04:29:10 +0000</pubDate>
      <link>https://dev.to/rajat_naegi/vim-101-4gj6</link>
      <guid>https://dev.to/rajat_naegi/vim-101-4gj6</guid>
      <description>&lt;p&gt;In this post i will try to give you a view of how you can use vim. A very basic guide to get you started with using vim. If you are always looking to improve your efficiency while coding or typing in general you might have come across somebody mentioning about vim. &lt;/p&gt;

&lt;p&gt;At first glance vim looks like an age old editor. There is nothing flashy about it. But if you know enough, you will realise that, you can customise it in many ways according to your need and preference. But for a beginner, you must first know how to do basic editing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modes
&lt;/h2&gt;

&lt;p&gt;Vim has two modes of input. These are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Command Mode&lt;/li&gt;
&lt;li&gt;Insert Mode&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Command Mode:
&lt;/h3&gt;

&lt;p&gt;In this mode what you type is taken as command. Nothing will get inserted into your file in this mode(unless you have made a command for that). Whatever you type in this mode can be seen in the bottom left corner. More on what you can do in this mode later. &lt;/p&gt;

&lt;h3&gt;
  
  
  Insert Mode:
&lt;/h3&gt;

&lt;p&gt;In this mode whatever you type is inserted just like any other text editor.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to switch between Insert mode and Command Mode?
&lt;/h4&gt;

&lt;p&gt;When you open a new vim window, by default you are in command mode. You won't be able to write yet. To got into insert mode press &lt;code&gt;i&lt;/code&gt;. At bottom left you can see that now you are in insert mode. Now you can type as usual. To go back to cmd mode just press &lt;code&gt;ESC&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to save a file?
&lt;/h4&gt;

&lt;p&gt;When you have edited you file, you have to know a way to save it as well. Normally editors have &lt;code&gt;Ctrl + s&lt;/code&gt; as save command. If you haven't searched yet you will try to do the same. But here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;first you go to cmd mode (using &lt;code&gt;ESC&lt;/code&gt;). &lt;/li&gt;
&lt;li&gt;Now you press &lt;code&gt;:w &amp;lt;filename.extension&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Or simply &lt;code&gt;:w&lt;/code&gt; if you dont want to create a new file&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  How to quit vim?
&lt;/h4&gt;

&lt;p&gt;Now the beginners really get frustrated at this. Well i definitely got. It is just because you realise at this point that why do i have to use a command for even the basic stuff. But if you use vim enough you will realise it is much faster this way and doesn't really require using mouse(cool right!). For this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;type &lt;code&gt;:q&lt;/code&gt; in cmd mode&lt;/li&gt;
&lt;li&gt;If you still aren't able to quit press &lt;code&gt;:q!&lt;/code&gt;. Here &lt;code&gt;!&lt;/code&gt; tells the editor to force quit. Similarly if you weren't able to save before you could have used &lt;code&gt;:w!&lt;/code&gt;. &lt;/li&gt;
&lt;/ul&gt;

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

&lt;h4&gt;
  
  
  How to navigate without arrow keys?
&lt;/h4&gt;

&lt;p&gt;In vim without leaving the primary typing area, you can navigate easily. In cmd mode, use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;h&lt;/code&gt; as left arrow&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;j&lt;/code&gt; as below arrow&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;k&lt;/code&gt; as up arrow&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;l&lt;/code&gt; as right arrow&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Useful commands to begin with.
&lt;/h2&gt;

&lt;p&gt;Now i will introduce some basic commands to tell how editing can be so fun with vim. And of course you need to remember to insert press &lt;code&gt;i&lt;/code&gt; and to give command &lt;code&gt;ESC&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To indent a line :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From wherever you are in a line press &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; in cmd mode(for forward indent). Similarly &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; for backward indent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To go to top of your document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From wherever you are just go to cmd mode and press &lt;code&gt;gg&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To go to bottom of your document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From wherever you are just go to cmd mode and press &lt;code&gt;G&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To go to end of line and enter insert mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;A&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To go to beginning of line and enter insert mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;I&lt;/code&gt; (note this is capitalised)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To delete current line (In vim delete and cut are very much the same thing):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dd&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To copy current line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;yy&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;In vim copying is called &lt;em&gt;yanking&lt;/em&gt;. Hence the y.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To Paste copied line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;p&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;will be pasted below the line under cursor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Combining commands
&lt;/h2&gt;

&lt;p&gt;In vim you can combine one or more command to have a better result.&lt;br&gt;
Examples:&lt;/p&gt;

&lt;p&gt;To delete 2 lines below including current line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;d2j&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To delete from line number 32 to 56:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;:32,56d&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you are aware of the basic commands these combinations come instinctively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vimrc
&lt;/h2&gt;

&lt;p&gt;To customise your vim we basically write a script. The language used here is called vimscript Don't worry you don't really need to learn an entire language to begin using vim. For basic editing you will only need commands like mentioned above. However, with growing need you will want to have more features. &lt;/p&gt;

&lt;p&gt;And to begin with with you can simply get the snippets of other people and keep experimenting.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to edit your vimrc?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to the path where the vimrc is located. To find the path use &lt;code&gt;:scriptnames&lt;/code&gt; in any vim window. A list of scripts including vimrc will be included. &lt;/li&gt;
&lt;li&gt;After navigating to the path, use &lt;code&gt;sudo vim vimrc&lt;/code&gt; to edit the file.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;For a beginner it might seem like a tedious task to learn so many commands to do even the basic stuff. But once you have a good amount of practice, you will find using other IDE based editors to be slower. Using you vimrc you will want to customise your editor in whatever ways possible. You don't have that level of luxury at root level in other editors. &lt;br&gt;
Here i have only scratched the surface of Vim. But i think it is enough to get you interested. Rest is up to you how deep you want to dive.&lt;/p&gt;

</description>
      <category>vim</category>
      <category>linux</category>
      <category>editor</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to get out of a Rut? </title>
      <dc:creator>Rajat Negi</dc:creator>
      <pubDate>Wed, 18 Mar 2020 18:15:59 +0000</pubDate>
      <link>https://dev.to/rajat_naegi/how-to-get-out-of-a-rut-3fh5</link>
      <guid>https://dev.to/rajat_naegi/how-to-get-out-of-a-rut-3fh5</guid>
      <description>&lt;p&gt;So what is the problem here? You have the time, you have the resources. You keep telling yourself unconsciously that you need to be productive. Yet days go by and you don't get much done. You are trying sometimes but can't stay focused for long. Also, you keep jumping from one topic to the other and can't get anything done till completion.&lt;/p&gt;

&lt;p&gt;There can be many things that are causing you to be non-productive. But I believe if you start doing certain things in a more positive and planned manner other better things also follow. In other words, you improve what you think you have control over and don't worry much about the rest for now.&lt;/p&gt;

&lt;p&gt;As I said there can be many causes. Let us just focus on two major causes. one is procrastination and the other is impostor syndrome.&lt;/p&gt;

&lt;p&gt;First, let us talk about procrastination. You basically avoid focused and quality time. When you try you do it for a short span of time, you get frustrated and immediately seek an escape. This escape can be in various forms like Netflix, video games etc. Sometimes even this escape is pseudo-productive. You make yourself believe that you are being productive but in reality, you are avoiding the major task in hand. &lt;/p&gt;

&lt;p&gt;One solution for this is to use the Pomodoro technique. There are various ways to go about it but the basic principle is very simple. You just have to spend some quality work for a fixed amount of time without any interruption. So how will this help? Well, you are basically working against your habit of procrastination. before you were impatient for even 10-15 minute task. now you are deliberately putting yourself into action and committing to staying focused for some time. this gives a sense of achievement and makes you believe in your ability. You can picture this like working out. Just like you work on your muscles by doing an exercise again and again. Similarly, the more sessions you have done more confident you become on your ability to stay focused. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q-CbucRB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/66az3kfv36gdf36m9j6f.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q-CbucRB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/66az3kfv36gdf36m9j6f.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
One way of achieving this is by using forest app. It sort of gamifies the Pomodoro technique. You get a dose of dopamine after fully growing a number of trees on a day. More dopamine when you post your trees grown/productive time on social media like twitter. The community always likes these efforts and you will feel a sense of achievement. &lt;/p&gt;

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

&lt;p&gt;Now comes the second problem which is impostor syndrome. Well everybody suffers from this, some more than others. At its peak, you never feel you are doing the things right. In my case, I felt like I am just not challenging myself enough. I kept trying new things but always felt like this is gonna get me nowhere.&lt;/p&gt;

&lt;p&gt;To work around this first you have to follow the Pomodoro technique secondly you have to set a specific goal. That is you have to stay focused on your decided goal and you cannot allow yourself to get deviated. your goal should be reasonable. Do some research before and then decide. if it is a long term goal, try and break it into steps. and focus only on one step at a time. &lt;/p&gt;

&lt;p&gt;Follow these simple steps for some time until you get back on track. Once there is a good momentum you will want to improve and new ideas will emerge. Just keep doing the deep work and you will have the satisfaction.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>procrastination</category>
      <category>pomodoro</category>
      <category>impostor</category>
    </item>
  </channel>
</rss>
