<?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: Pratham Sharma</title>
    <description>The latest articles on DEV Community by Pratham Sharma (@ps173).</description>
    <link>https://dev.to/ps173</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%2F517918%2F34df02f5-db75-45d8-82bc-f60dd04f2ecc.jpg</url>
      <title>DEV Community: Pratham Sharma</title>
      <link>https://dev.to/ps173</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ps173"/>
    <language>en</language>
    <item>
      <title>Short appreciation for dev tools</title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Fri, 13 Dec 2024 18:31:42 +0000</pubDate>
      <link>https://dev.to/ps173/short-appreciation-for-dev-tools-16bl</link>
      <guid>https://dev.to/ps173/short-appreciation-for-dev-tools-16bl</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvw6ceh7lj20q81n5sec5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvw6ceh7lj20q81n5sec5.png" alt="tools I use everyday" width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have been using zed for quite a while now and here’s my experience / appreciation of zed. Or any dev tool that is made in a spirit of tooling, passion and preferences.&lt;/p&gt;

&lt;p&gt;Neovim and me&lt;br&gt;
I have been a long time vim / neovim user and have dabbled with many editors. Even tried developing my own but that didn’t pan out well. Initially I used vscode like everyone else. Then switched to neovim due to sheer speed and performance boost it gave over vscode. I have also always adored lua so neovim was very good experience for me. But I soon I got caught up with work and often forgot to update my config and soon I was running way behind on latest neovim features. I still really like neovim and it’s philosphy and have it on my machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Zed - my current daily driver
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dmo2jo8prah7etgo5ap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dmo2jo8prah7etgo5ap.png" alt="zed with tokyonight theme (extension)" width="800" height="521"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Initially I was really skeptical of zed when it was still a browser based downloadable editor. Also I am still not big on all that collabrative editing thing. But here’s the thing. It’s quite faster than vscode. Not as feature rich maybe. I often compare it with sublime. I think of it as sublime with better vim encodings. I am huge fan of their in-built keymaps that they give which fits so well with editor behaviour. Extensions are currently community maintained which is fine with me but there are lot of my favourite ones missing like wakatime ( huge bummer ), full fledged git support ( I use lazygit ), no zed mode and more that I can’t think or right now. But I can live without those things. I like the sheer no fuck around policy. It’s simple and all the shenanigans it has are searchable or just easy to use. So it’s all install and go with neovim like speed and keybinds. This was what I was looking for all along. Maybe I will change my mind in future but for now zed does it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Novelty bias
&lt;/h2&gt;

&lt;p&gt;Well I can try and explain with some logical points but that’s all useless. It’s all a matter of preference. I have deep appreciation for anyone who tries to make tools targetted for developers. Open source tools especially. So I would anyday pick a project where developers are trying really hard to give people a preference and make something authentic and unique. It’s really a small bubble to live in and well I would like to have a bigger bubble. So If I see a tool that does something which I already have a tool even then I would try it. Helix, kakoune, neovim are all smaller editor trying to find a place / preference for someone. Each carries it’s own story. Each software, each tool carrying their person type. So while we have it try and experiment and help in improving it.&lt;/p&gt;

</description>
      <category>tooling</category>
      <category>zed</category>
      <category>vscode</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Guide To Express Middlewares</title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Sun, 31 Oct 2021 09:56:22 +0000</pubDate>
      <link>https://dev.to/ps173/guide-to-express-middlewares-i7f</link>
      <guid>https://dev.to/ps173/guide-to-express-middlewares-i7f</guid>
      <description>&lt;h2&gt;
  
  
  A basic definition
&lt;/h2&gt;

&lt;p&gt;Express middlewares are the functions that have access to the &lt;code&gt;request&lt;/code&gt;, &lt;code&gt;response&lt;/code&gt; and &lt;code&gt;next&lt;/code&gt; function in applications request response cycle. The &lt;code&gt;next&lt;/code&gt; function calls the next middleware that is succeding the current middleware.&lt;/p&gt;

&lt;p&gt;Let's simplify the above statement a bit. So a express middleware is basically a function that has &lt;code&gt;req&lt;/code&gt;,&lt;code&gt;res&lt;/code&gt; and &lt;code&gt;next&lt;/code&gt; as a parameters. For example,&lt;br&gt;
&lt;/p&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;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I am a middleware and I log the text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hellow World!!&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now here I have a &lt;code&gt;logger&lt;/code&gt; function which is a middleware. Yup that's how simple a middleware can be. Here the &lt;code&gt;logger&lt;/code&gt; function has one thing which other functions don't have. You &lt;strong&gt;always&lt;/strong&gt; have to call &lt;code&gt;next&lt;/code&gt; at the end of the middleware. This basically invokes the next or succeding middleware.&lt;br&gt;
For example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;logger1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I am first&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;logger2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I am second&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;logger1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;logger2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here &lt;code&gt;logger1&lt;/code&gt; is the first middleware and the &lt;code&gt;logger2&lt;/code&gt; is next or succeding middleware.This of course depends on the which function is loaded first in &lt;code&gt;app.use()&lt;/code&gt;. So now whenever express calls a callback then these 2 middlewares will do a &lt;code&gt;console.log()&lt;/code&gt; before running that callback. If I was to load the &lt;code&gt;logger2&lt;/code&gt; before &lt;code&gt;logger1&lt;/code&gt; then &lt;code&gt;logger2&lt;/code&gt; will &lt;code&gt;console log&lt;/code&gt; before &lt;code&gt;logger1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example if I add this to last line of previous code then.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hellow World!!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I am a callback&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="c1"&gt;// output in the console will be&lt;/span&gt;
&lt;span class="c1"&gt;// I am first&lt;/span&gt;
&lt;span class="c1"&gt;// I am second&lt;/span&gt;
&lt;span class="c1"&gt;// I am a callback&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;next&lt;/code&gt; function could be named anything else either but by convention it is always named &lt;code&gt;next&lt;/code&gt;. So to avoid any confusion we continue calling it next. &lt;strong&gt;Also remeber if you don't call &lt;code&gt;next()&lt;/code&gt; at the end of the middleware then the middleware will never go to the next or succeding middleware. This means the request will left hanging and will never proceed&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example : Using a middleware to get a object from database
&lt;/h2&gt;

&lt;p&gt;In my app I use following middleware to get a snippet by a certain id provided in a request.&lt;/p&gt;

&lt;p&gt;This can give you a gist of where to use a middleware.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getSnippetById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&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;snippet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// here Snippets is mongoose schema.&lt;/span&gt;
    &lt;span class="nx"&gt;snippet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Snippets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&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;snippet&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;question does not exist&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="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;snippet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;snippet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;next&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;In this middleware I simply check for the snippet in database if it does not exists we return a error other wise I attach the snippet with give header. Now here snippet keyword is a custom header that I provide which I can access in the callback further.&lt;br&gt;
For example if I do&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/:id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getSnippetById&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;snippet&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;now here I didn't use app.use instead I called the middleware directly inside the get request. This is useful because app.use will call the function &lt;code&gt;getSnippetById&lt;/code&gt; beforeevery request which is not what we want. So instead we call it only for some function such as when we want to delete, update or get a object(in this case snippet) by a certain id.&lt;/p&gt;

&lt;p&gt;I should also mention something called as a &lt;strong&gt;error-handling middleware&lt;/strong&gt; which depends on same concept. You can see more about error handling middleware &lt;a href="https://expressjs.com/en/guide/error-handling.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;So we went over how the middlewares are called, what is next function and what happens when we don't call it and also we went over a real world example of a middleware too. To read a better and a detailed explanation &lt;a href="https://expressjs.com/en/guide/writing-middleware.html"&gt;checkout the express docs on writing a middleware&lt;/a&gt; and also on &lt;a href="https://expressjs.com/en/guide/using-middleware.html"&gt;using a middleware&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>node</category>
    </item>
    <item>
      <title>Trying Out Svelte For First Time</title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Thu, 07 Oct 2021 13:57:43 +0000</pubDate>
      <link>https://dev.to/ps173/trying-out-svelte-for-first-time-223f</link>
      <guid>https://dev.to/ps173/trying-out-svelte-for-first-time-223f</guid>
      <description>&lt;p&gt;So I have been wanting to re-create my personal &lt;a href="//ps173.github.io"&gt;website&lt;/a&gt; (another blog on this soon). I really like development with next-js. But there's a lot of lot of dependencies which makes it quite a huge app. And I think that a personal website should be as fast as possible. So why not choose something like vanilla html. Well Yea html will work totally fine. But I wanted to try something new. I choose svelte as a the other framework. I wanted to try it for the longest time. And thus I choose svelte.&lt;/p&gt;

&lt;p&gt;I like lot of stuff about svelte. The idea of keeping things less complex and fast to code is very likeable. If I would have tried using svelte right after learning js, I think it would be easier than getting used to react. Here's my opinion or more of a description of svelte. I might be wrong about something so pardon me there as I have spent less than a week with svelte.&lt;/p&gt;

&lt;p&gt;Also Since I have made the intro this long. I might just say that I don't really want to hate on other framework. I think this &lt;a href="https://www.urbandictionary.com/define.php?term=opinionism"&gt;opinionism&lt;/a&gt; is bad. I just want to keep this a healthy overview of svelte.&lt;/p&gt;

&lt;h1&gt;
  
  
  About Svelte ✌️
&lt;/h1&gt;

&lt;p&gt;Svelte is a UI framework. Unlike react and friends (or should I say enemies), svelte does not use any virtual DOM. Rather it compiles your code to tiny framework less vanilla js. This makes the app really fast. Also not to mentiont the incredible guide the &lt;a href="https://svelte.dev/tutorial/basics"&gt;svelte-tutorial&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Components in Svelte 🐻‍❄️
&lt;/h1&gt;

&lt;p&gt;So let's start with what I think the makes all the frameworks worth using, Components. I think making your UI into little components makes UI really easy to manage and program. I am not a frontend guy honestly but I like the fact that I can have multiple elements divided in my UI. Again this post is not on why frontend frameworks are good. &lt;/p&gt;

&lt;p&gt;In svelte the components are files with .svelte extension. Not a great change that's just another syntax ( also btw why do all these frameworks create their own custom syntax).  But wait you don't have to export the components here. Suppose you have this parent called &lt;code&gt;App.svelte&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!--Lets' call this component App.svelte and yes this is a html comment--&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;// here is js comment :)&lt;/span&gt;
 &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;path-to-component/MyComponent.svelte&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;MyComponent&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and here's &lt;code&gt;MyComponent.svelte&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!--- MyComponent.svelte ---&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
This is my component
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Props in Svelte 🐻
&lt;/h1&gt;

&lt;p&gt;You thought that svelte does not have props.  Svelte has export statements to export props or as I like to say 'recognize props' (Not a proper term don't use it).&lt;/p&gt;

&lt;p&gt;This is a child component let's call it &lt;code&gt;Weatherdetails.svelte&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!--- Weatherdetails.svelte ---&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;The weather is {answer}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's call the parent component &lt;code&gt;App.svelte&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Weatherdetails&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Weatherdetails.svelte&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;Weatherdetails&lt;/span&gt; &lt;span class="na"&gt;answer=&lt;/span&gt;&lt;span class="s"&gt;"humid :\"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like how svelte devs explain how this in not javascript-ish.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;this may feel a little weird at first. That's not how export&lt;br&gt;
normally works in JavaScript modules! Just roll with it for now — it'll soon&lt;br&gt;
become second nature.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I am hoping to see it become second nature :)&lt;/p&gt;

&lt;h1&gt;
  
  
  Reactivity in Svelte 🐨
&lt;/h1&gt;

&lt;p&gt;Again as svelte describes it does not uses any complex state management.According to the svelte website "At heart of svelte is a powerful system of reactivity". This means that you can call javascript inside your html (not literally I just like to think of it this way). Here's the reactivity explained in the good ol' counter app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;increaseCount&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nx"&gt;count&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="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; Current Count : {count} &lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{increaseCount}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; 
    click to increase count ! 
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wow that was quick.&lt;/p&gt;

&lt;p&gt;Here you can see it's like react state just has a lot less boiler-plate. Also svelte introduces a special thing which is somewhat similar to &lt;code&gt;useEffect&lt;/code&gt; hook in react.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;increaseCount&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nx"&gt;count&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="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; Current Count : {count} &lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{increaseCount}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; 
    click to increase count ! 
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;The square of {count} is {square} &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here the &lt;code&gt;$&lt;/code&gt; looks a little weird. But this basically tells svelte compiler that whenever any of referenced value statement changes do this thing.&lt;/strong&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  Conditional rendering and Await in markup 🐑
&lt;/h1&gt;

&lt;p&gt;To render text conditionally svelte applies a little bit custom markup syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;loggedIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loggedIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loggedIn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

{#if user.loggedIn}
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{toggle}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        Log out
    &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
{:else}
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{toggle}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        Log in
    &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
{/if}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So here according to svelte website again &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A # character always indicates a block opening tag. &lt;br&gt;
A / character always indicates a block closing tag. &lt;br&gt;
A : character, as in {:else}, indicates a block continuation tag. &lt;br&gt;
Don't worry — you've already learned almost all the syntax Svelte adds to HTML.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now this the normal part. Jinja follows same pattern. But wait we have more. Introducing the asynchronous await in markup. Wanna see how this looks. Here&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getCatImage&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;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.thecatapi.com/v1/images/search&lt;/span&gt;&lt;span class="dl"&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;jsonres&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&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;imageUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;jsonres&lt;/span&gt;&lt;span class="p"&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;url&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&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="nx"&gt;imageUrl&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="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;No image found or something went wrong&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;getCatImage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;getCatImage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{handleClick}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
A random cat 🐈
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Awaitting the response --&amp;gt;&lt;/span&gt;
{#await promise}
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;...waiting&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{:then src}
    &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"a cat"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
{:catch error}
    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{error.message}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{/await}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Honestly I was really impressed when I first saw this. This is was so cool see.&lt;/p&gt;

&lt;p&gt;Here's the working demo 🐈✨ :&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/await-svelte-ejwo3"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Lifecycle ♻️
&lt;/h1&gt;

&lt;p&gt;Yay! Lifecycle methods. Lifecycle in svelte is quite similar to react. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The most common lifecycle method is &lt;code&gt;onMount&lt;/code&gt;. This is basically a function
that is executed when component is rendered. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onDestroy&lt;/code&gt; is function that runs when a component is destroyed. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;beforeUpdate&lt;/code&gt; and &lt;code&gt;afterUpdate&lt;/code&gt; do what there names suggest run a function before or after the component is rendered.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These were quite similar to the lifecycle methods in react. &lt;/p&gt;

&lt;p&gt;The last lifecycle method is &lt;code&gt;tick&lt;/code&gt;. The &lt;code&gt;tick&lt;/code&gt; function is unlike other lifecycle methods it can be called anytime. It returns a promise that resloves as soon as any pending state changes have been applied to DOM. &lt;strong&gt;In simpler words you can say that when you want to ensure that state immediately updates you can run &lt;code&gt;tick&lt;/code&gt; function.&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Binding the state 🐲
&lt;/h1&gt;

&lt;p&gt;Do you guys remember the old class based components in react where you had to bind the function to specific component. Svelte does something similar but more simpler looking.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;bind:value=&lt;/span&gt;&lt;span class="s"&gt;{name}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this will change the value of name with input provided. The bind-action (in this case value) may change from element to element. &lt;/p&gt;

&lt;h3&gt;
  
  
  This Binding
&lt;/h3&gt;

&lt;p&gt;One binding that applies to all is &lt;code&gt;this&lt;/code&gt;. You can compare it to something like &lt;code&gt;useRef&lt;/code&gt; hook from react. It provides you a reference to a rendered element.&lt;/p&gt;

&lt;p&gt;For example you can do something like this ✨:&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/svelte-magic-drawboard-7mh87"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;And now I can use canvas api just like native javascript. I really like the canvas api and wanted to use react but I was not able to get that level of simplicity as in native js. Svelte makes it almost similar to native js&lt;/p&gt;

&lt;h1&gt;
  
  
  Store 🦄
&lt;/h1&gt;

&lt;p&gt;Store is a way to manage state across the whole app. You may pass down state to childrenusing props but the when you have to share state across various parent components you can use store. A breif overview of stores can be given this way&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Store.js : Here we can initialize store --&amp;gt;&lt;/span&gt;
import { writable } from 'svelte/store';

export const count = writable(0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- And let's subscribe this store to App.svelte --&amp;gt;
&amp;lt;!-- so I can just do --&amp;gt; 
&amp;lt;script&amp;gt;
import { count } from './stores.js';

let count_value;

count.subscribe(value =&amp;gt; {
        count_value = value;
});
&amp;lt;/script&amp;gt;

&amp;lt;h1&amp;gt;The count is {count_value}&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stores are a bit complex topic ( not really quite simple once you go through the tutorial ) And I am not gonna cover everything about them in this post. So that may be a different blog for different time. Meanwhile if you really wanna know just go on to the &lt;a href="https://svelte.dev/tutorial/writable-stores"&gt;tutorial&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Inbuilt Transitions and animations 🐳
&lt;/h1&gt;

&lt;p&gt;This one surprised me. Svelte has inbuild transitions, animation and motions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;blur&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svelte/transition&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;visible&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"checkbox"&lt;/span&gt; &lt;span class="na"&gt;bind:checked=&lt;/span&gt;&lt;span class="s"&gt;{visible}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    visible
&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

{#if visible}
    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;transition:blur&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        Fades in and out
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{/if}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This piece of code shows how simple it is to implement the fade transition.  This is all I wanted from frontend frameworks. Isn't this amazing. I just love svelte now. There are more animation related stuff which you can again see in the &lt;a href="https://svelte.dev/tutorial/transition-events"&gt;svelte-tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a little navbar that I made using svelte builtin transitions :&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/simple-navbar-with-svelte-t4rp3"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion 💫
&lt;/h1&gt;

&lt;p&gt;This was just a breifing of svelte. There is so much more that I didn't cover. I have already link svelte tutorial like 10 times in this blog so not gonna do It again. This post really helped me understand lot of stuff about svelte and also react.&lt;/p&gt;

&lt;p&gt;What I think of svelte ? Well I think svelte is amazing. I like it and most of the developers out there like it. It makes lot of things simpler. Obviously it does not kill all the other frameworks and Neither I will start making making all my apps in svelte. Though this aside. I will svelte for lot of apps that I want to quickly setup. This is one thing that I again loved about svelte. The amount of boiler plate that goes in svelte is really low. And not mention the app speed. The above 3 example are really fast in comparisont to those written in react or any other framework out there. Also I recently saw &lt;a href="https://svelte-native.technology/"&gt;svelte-native&lt;/a&gt; which now makes me want to try it.&lt;/p&gt;

&lt;p&gt;Overall Svelte is a amazing and lovely piece of technology. God bless the creators of svelte for making it.&lt;/p&gt;

&lt;p&gt;Thanks for reading. Please consider following this took a huge amount of time to write. And if this helps you well don't thank me just follow. I post stuff like this or sometime vim related workflow.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>svelte</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Discovering Vim : Netrw </title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Sat, 02 Oct 2021 10:09:05 +0000</pubDate>
      <link>https://dev.to/ps173/discovering-vim-netrw-me8</link>
      <guid>https://dev.to/ps173/discovering-vim-netrw-me8</guid>
      <description>&lt;p&gt;Do you use a file explorer in vim ? I guess it probably is something like &lt;a href="https://github.com/preservim/nerdtree" rel="noopener noreferrer"&gt;this&lt;/a&gt;, &lt;a href="https://github.com/kyazdani42/nvim-tree.lua" rel="noopener noreferrer"&gt;this&lt;/a&gt; or maybe &lt;a href="https://github.com/ms-jpq/chadtree" rel="noopener noreferrer"&gt;this&lt;/a&gt;. While all these are fancy looking with icons and stuff there is a file tree and explorer in vim already. It is not the best file-explorer honestly but it works and is faster than most of these. Yes I am talking about the good ol' netrw. &lt;/p&gt;

&lt;p&gt;Now the stuff I am talking here is very limited to basic needs only and you can obviously see &lt;code&gt;:h netrw&lt;/code&gt; if you want to know more. &lt;/p&gt;

&lt;p&gt;So anyway here's a breif guide. Firstly let's talk what should I be able to do with any file explorer. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;add file and directory &lt;/li&gt;
&lt;li&gt;delete file and directory &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So well let's start with opening some new directory called &lt;code&gt;tmp&lt;/code&gt;. Now in this &lt;code&gt;tmp&lt;/code&gt; directory suppose I want to add a file. So In vim I do &lt;code&gt;:Explore&lt;/code&gt;. Now explore opens netrw for the file-directory ( also try doing explore in any help menu it opens all the files linked to that help article). After Opening Explore you will see a empty directory like this. &lt;br&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%2Fuploads%2Farticles%2F93vjw8xvp495sridtuzc.png" 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%2Fuploads%2Farticles%2F93vjw8xvp495sridtuzc.png" alt="Empty Directory"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I wan't to add a file to this directory. I can press &lt;code&gt;%&lt;/code&gt; key in netrw and that will show this prompt. &lt;br&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%2Fuploads%2Farticles%2F738hrud09iz6zicc31gt.png" 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%2Fuploads%2Farticles%2F738hrud09iz6zicc31gt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Add the file name press enter and bam! Netrw will open the file in new buffer. Now u can add text to same file and save it. After Saving the file Try doing &lt;code&gt;:Explore&lt;/code&gt; again and now you will see the new file. &lt;br&gt;
To remove this file you can press &lt;code&gt;D&lt;/code&gt; key that will bring up another prompt looking like this. &lt;br&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%2Fuploads%2Farticles%2F09mlwpok0tq3rbytja66.png" 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%2Fuploads%2Farticles%2F09mlwpok0tq3rbytja66.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can add a directory by doing &lt;code&gt;d&lt;/code&gt; and delete it too with &lt;code&gt;D&lt;/code&gt;. This enough for most of the work I need to do with file explorer. I do rest with normal &lt;code&gt;mv&lt;/code&gt; or &lt;code&gt;cp&lt;/code&gt;. Now let's say you want this netrw to be displayed while editing file and you don't like how netrw looks. Well netrw can be configured with global vim variables. Here's my netrw settings. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight viml"&gt;&lt;code&gt;

&lt;span class="c"&gt;" This get's rif of that stupid banner&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;g:netrw_banner&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;

&lt;span class="c"&gt;" netrw has liststyle types which you can search in \:help netrw&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;g:netrw_liststyle&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; 

&lt;span class="c"&gt;" If you have wildignore set&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;g:netrw_list_hide&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &amp;amp;&lt;span class="nb"&gt;wildignore&lt;/span&gt;

&lt;span class="c"&gt;" size of window&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;g:netrw_winsize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;Again Look at &lt;code&gt;:help netrw&lt;/code&gt; to see what do these do. Some other good commands are &lt;code&gt;:Lex&lt;/code&gt; for opening Lexplore which a split view of netrw. Do &lt;code&gt;:Lex!&lt;/code&gt; to get a funky right side view like me. There is also &lt;code&gt;:Hexplore&lt;/code&gt;, &lt;code&gt;:Rexplore&lt;/code&gt;, &lt;code&gt;:Sexplore&lt;/code&gt; and &lt;code&gt;:Texplore&lt;/code&gt;. Most of these are for opening netrw in different directions which again is really cool. &lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;For further reading check out these articles : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.vim.org/scripts/script.php?script_id=1075#:~:text=Netrw%20supports%20reading%20and%20writing,using%20a%20variety%20of%20methods." rel="noopener noreferrer"&gt;netrw.vim&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://shapeshed.com/vim-netrw/" rel="noopener noreferrer"&gt;You don't need a nerd tree maybe !&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/vim/comments/22ztqp/why_does_nerdtree_exist_whats_wrong_with_netrw/" rel="noopener noreferrer"&gt;What's wrong with netrw&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw" rel="noopener noreferrer"&gt;netrw docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/" rel="noopener noreferrer"&gt;good vimcast on project drawers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tpope/vim-vinegar" rel="noopener noreferrer"&gt;tpope plugin to improve netrw&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yup that's all for today. I wrote this cause sometimes we don't really need some external plugins. There are some issues with netrw. But most of the time it works without any problems. Again I just wanted people to acknowledge netrw a bit more and then decide to choose for other file explorers. &lt;/p&gt;

</description>
      <category>vim</category>
      <category>neovim</category>
      <category>productivity</category>
      <category>linux</category>
    </item>
    <item>
      <title>Easy way to fish shell</title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Tue, 13 Jul 2021 17:46:59 +0000</pubDate>
      <link>https://dev.to/ps173/easy-way-to-fish-shell-l7c</link>
      <guid>https://dev.to/ps173/easy-way-to-fish-shell-l7c</guid>
      <description>&lt;p&gt;So when I first started linux and went into command line it looked a bit ugly (yeah the bash prompt is ugly initially :p). So well I tried customizing it a bit. Soon after I got bored with bash and I heard about this new guy zsh and then I switched to zsh. And zsh was more powerful than bash cause it had a better completion and a better vi mode. I used oh-my-zsh for most of the time and for themes I went with default one. Besides I also used syntax highlight plugins and autocompletion plugin too. It was all working pretty fine but then I had to move to a new machine and soon I forgot how to install these plugins in zsh. I mean I could have googled but I am quite lazy so I got oh-my-zsh and that was it. &lt;/p&gt;

&lt;p&gt;Fast forward to this week I picked this new shell called fish. This blog will be a brief intro to fish from perspective of a zsh/posix shell user.&lt;/p&gt;

&lt;p&gt;So fish is a non posix shell which means that your bash scripts don't work here (most of them). Although almost all the unix commands work in fish so you don't have to worry about a missing command for most of time. &lt;/p&gt;

&lt;p&gt;Now Some good features that you get in fish by default are auto-completion , auto-suggestion, syntax highlighting and it all works out of box&lt;/p&gt;

&lt;p&gt;So let's talk about making fish usable. For example like using aliases and where is the config file?. So generally the config file for fish is in &lt;code&gt;.config/fish/config.fish&lt;/code&gt;. You can open this file in any text editor u want.&lt;/p&gt;

&lt;p&gt;Inside the file you can add all your configuration and functions like you do in zsh file. Ok what did I wanted to do ? Yeah alias. &lt;strong&gt;In fish shell there is nothing called alias rather it is called abbreviations&lt;/strong&gt;. Abbreviations are almost similar to aliases. According fish's web site " Abbreviations are user-defined words that are replaced with longer phrases after they are entered. "&lt;br&gt;
This means that &lt;strong&gt;abbreviations are somewhat similar to snippets&lt;/strong&gt;. You type the initials and it automatically completes it. Which is wonderful because you get to see the command that you have abbreviated. To set abbreviations you can do &lt;code&gt;abbr -a v nvim&lt;/code&gt; in your &lt;code&gt;config.fish&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;v is the abbreviation and nvim is the completion for it. Also there are minor syntax differences in fish from zsh/posix. Honestly I think that fish's syntax can be called more a bit modernish. Nonetheless you can look at the syntax &lt;a href="https://fishshell.com/docs/current/tutorial.html"&gt;here&lt;/a&gt; . &lt;/p&gt;

&lt;p&gt;There are plugins-managers like ohmyzsh available for fish too. Some of them are :   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/oh-my-fish/oh-my-fish"&gt;ohmyfish&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jorgebucaran/fisher"&gt;fisher&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And maybe more I don't know all of them. I personally use fisher because it's quite easy. &lt;br&gt;
For prompt's you have :   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/IlanCosman/tide"&gt;Tide&lt;/a&gt;
I like tide cause it looks exactly similar to p10k and you can also configure it the same way from zsh. It's cool :p.
&lt;/li&gt;
&lt;li&gt;You can use others like &lt;a href="https://github.com/simnalamburt/shellder"&gt;shellder&lt;/a&gt;, and &lt;a href="https://starship.rs/"&gt;starship&lt;/a&gt; too. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note : for nvm users fish does not support nvm instead u get &lt;a href="https://github.com/jorgebucaran/nvm.fish"&gt;this&lt;/a&gt; or something like &lt;a href="https://github.com/FabioAntunes/fish-nvm"&gt;this&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7k_lfLSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5zjq7c4m10qeiew0pd39.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7k_lfLSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5zjq7c4m10qeiew0pd39.png" alt="Here is my config"&gt;&lt;/a&gt;&lt;br&gt;
You can see the way my shell looks. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WEbiP_EW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rozs3s8odvjfefty6czc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WEbiP_EW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rozs3s8odvjfefty6czc.gif" alt="Working demo"&gt;&lt;/a&gt;&lt;br&gt;
It all get's completed with a spacebar :)&lt;/p&gt;

&lt;p&gt;Yup so that's all about fish. I would really recommend fish to developers because of it's ease of use and setting up. If not using it forever atleast try giving fish a try. &lt;/p&gt;

</description>
      <category>linux</category>
      <category>tooling</category>
      <category>shell</category>
      <category>configs</category>
    </item>
    <item>
      <title>My first PR... I feel really dumb now </title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Fri, 18 Jun 2021 19:59:46 +0000</pubDate>
      <link>https://dev.to/ps173/my-first-pr-i-feel-really-dumb-now-4ep</link>
      <guid>https://dev.to/ps173/my-first-pr-i-feel-really-dumb-now-4ep</guid>
      <description>&lt;p&gt;So recently I was working on a personal project. And I was using code mirror as dependency in it and I came across a small css bug related to cursor in vim mode. So I did a natural thing and opened a issue, fixed the bug and committed changes.&lt;/p&gt;

&lt;p&gt;Before getting any further I want to remind you that this is my first pr and I have never contributed to any opensource project before. &lt;/p&gt;

&lt;p&gt;So after I pushed changes I made a pull request and added somewhat okay description. I was happily glaring at the description I added and felt really happy to have made my first pr. And then I noticed the changes I made. I made &lt;strong&gt;153 changes&lt;/strong&gt;. In all hurry I went to see the changes I made and realize that &lt;strong&gt;stupid vscode auto formatted everything in css&lt;/strong&gt;. And therefore all the css files I changed had extra lines. Well so instead of reverting changes I made a edit in comment (very professional of me) about formatting. And just waited for the maintainer to reply. Maintainer replies after an hour or so. He says no he cannot commit. &lt;/p&gt;

&lt;p&gt;Yay there goes my dream to get in netflix. Anyway that was a silly mistake I made. And just to clear  I reverted the changes asap and now I am waiting for the maintainer to see and reply. Will edit the article if anything else happens. I really feel dumb. But hey that was a new experience anyway. I will have fun story to tell people future. :| &lt;/p&gt;

&lt;p&gt;Edit : My PR was merged by author&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>jokes</category>
    </item>
    <item>
      <title>VimGore : an interactive game to learn vim </title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Sat, 15 May 2021 18:13:44 +0000</pubDate>
      <link>https://dev.to/ps173/vimgore-an-interactive-game-to-learn-vim-10kn</link>
      <guid>https://dev.to/ps173/vimgore-an-interactive-game-to-learn-vim-10kn</guid>
      <description>&lt;p&gt;So I wanted to try MERN stack and thus started out with this idea of creating a game that will provide you with snippets of code which will be corrected by the user using vim mode. So this idea was enough to give me motivation to jump into the project state.&lt;/p&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%2Fuploads%2Farticles%2Fnfd54mffjm6ondg69lzk.png" 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%2Fuploads%2Farticles%2Fnfd54mffjm6ondg69lzk.png" alt="VimGore"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So below is the link to the app. It is not fully featured and I think that it is missing lot of stuff but will be happy to get a overall feedback. &lt;/p&gt;

&lt;p&gt;If you have any issues then report in repo :)&lt;/p&gt;

&lt;p&gt;For now this is vimgore&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/ps173/VimGore" rel="noopener noreferrer"&gt;source code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vimgore.netlify.app/" rel="noopener noreferrer"&gt;live site&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(also this was my first proper full-stack project)&lt;br&gt;
Thanks For Reading 😁️&lt;br&gt;
and keep up the hardwork 💪&lt;/p&gt;

</description>
      <category>vim</category>
      <category>react</category>
      <category>node</category>
      <category>showdev</category>
    </item>
    <item>
      <title>What I learned after failing to build a Project</title>
      <dc:creator>Pratham Sharma</dc:creator>
      <pubDate>Thu, 06 May 2021 15:26:39 +0000</pubDate>
      <link>https://dev.to/ps173/what-i-learned-after-failing-to-build-a-project-3ka8</link>
      <guid>https://dev.to/ps173/what-i-learned-after-failing-to-build-a-project-3ka8</guid>
      <description>&lt;p&gt;So I have been working on an Image-Editor for react for past few days. And just to clear I have dropped the idea for time being due to lot of reasons. Firstly I was not enjoying the process of developing it anymore. Other reasons were that canvas API is very hard to work in with react. Also I am very aware of all the libraries that make it easier to use but then the application had nothing to offer if it was build on something as Konva or Toast-image-editor. It is very true that I worked on the project for 5 days in row and therefore it was more disappointing to drop the project.&lt;/p&gt;

&lt;p&gt;But the project taught me a lot of stuff including how to manage uploading of image files in react,Using context api, how to convert them to base64 and even how to manipulate them. Project also taught me to keep some general things in mind. They are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Build UI first - Prior to functionality building UI must be given importance. This is so because a well developed UI can help you remain motivated and support the development. Also a good UI is a great step towards clearing the thoughts for further development in my opinion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always Plan Well Before Project - So It was not like I did not planned well before developing it was more like I was confused. Well since I had already made the test version in vanilla javascript. I was confident or overconfident to step directly without doing proper research. So an Important take-back is that research. Even if you have the idea. Plan the stack or library you were going to use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If It’s not working then don’t stress - Yes if it does not work give up on it for the time being and pick it later. Maybe you are just tired of looking at same thing, change the pace, work on something else.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And I guess those were it. I was really disappointed in myself because I was building it since long back. Well I will make sure to pick this up again someday in future till then I will keep up the hardwork on other projects. If you want to share your experiences with failed projects then please do.✌️&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>watercooler</category>
      <category>productivity</category>
      <category>react</category>
    </item>
  </channel>
</rss>
