<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Thamaraiselvam</title>
    <description>The latest articles on Forem by Thamaraiselvam (@thamaraiselvam).</description>
    <link>https://forem.com/thamaraiselvam</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%2F14526%2F2bc11869-544d-4d51-8d47-f8ba2044d6a5.jpg</url>
      <title>Forem: Thamaraiselvam</title>
      <link>https://forem.com/thamaraiselvam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/thamaraiselvam"/>
    <language>en</language>
    <item>
      <title>Terminal Enhancers - Part 1</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Mon, 24 Aug 2020 05:33:14 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/terminal-enhancers-part-1-1fe3</link>
      <guid>https://forem.com/thamaraiselvam/terminal-enhancers-part-1-1fe3</guid>
      <description>&lt;p&gt;I have been thinking for a long time to write about terminal tools which help me to increase my productivity a lot. Finally yea! I have started writing. I do not want to put all these interesting tools in a single blog post so planned to write a series of blogs. &lt;/p&gt;

&lt;p&gt;Here is my terminal setup:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UG5FX65E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597585628615/wuQdnmIVw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UG5FX65E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597585628615/wuQdnmIVw.png" alt="Screenshot 2020-08-16 at 7.17.00 PM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the first part, we are going to talk about the top 5 tools (my personal choice)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alacritty&lt;/li&gt;
&lt;li&gt;Oh My ZSH!&lt;/li&gt;
&lt;li&gt;Tmux&lt;/li&gt;
&lt;li&gt;Starship&lt;/li&gt;
&lt;li&gt;Pet&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://github.com/alacritty/alacritty"&gt;Alacritty&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;As a developer who spends most of the time in the terminal. When I think about machine setup, the First thing that comes in my mind is Alacritty.&lt;/p&gt;

&lt;p&gt;Its GitHub page describes as follows, so do I.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Alacritty is the fastest terminal emulator in existence. Using the GPU for rendering enables optimizations that simply aren't possible without it. Alacritty currently supports macOS, Linux, BSD, and Windows. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I was a fan of Iterm multi panes but after started using alacritty + tmux, now I barely open iTerm on my machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;WHY Alacritty is better:&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Faster: It is written in rust with the philosophy of focusing on speed. Alacritty is one of the fastest terminal emulators out there.&lt;/li&gt;
&lt;li&gt;Highly customizable:
As developers, we love customization and alacritty provides a lot room for that. It's configuration file is very well made and easy to use by just editing "alacritty.yaml" file.&lt;/li&gt;
&lt;li&gt;Elegant and minimal:
Once you installed alacritty, the first thing you notice is very minimal, elegant UI and no clutters like UI settings and so on.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Install:
&lt;/h2&gt;

&lt;p&gt;Simply install with &lt;code&gt;brew&lt;/code&gt; for mac&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew cask install alacritty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refer official  &lt;a href="https://github.com/alacritty/alacritty/blob/master/INSTALL.md"&gt;installation guide&lt;/a&gt;  for other operating systems &lt;/p&gt;

&lt;p&gt;by default, alacritty does not create a config file. you can take  &lt;a href="https://github.com/alacritty/alacritty/blob/master/alacritty.yml"&gt;default config file&lt;/a&gt; from GitHub or here is my &lt;a href="https://github.com/thamaraiselvam/dotfiles/blob/master/alacritty/alacritty.yml"&gt;config file&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;create one on this location for alacritty to read it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.config/alacritty/alacritty.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;a href="https://ohmyz.sh/"&gt;Oh My ZSH!&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;The next tool that I cannot live without is ZSH. Zsh is also called Z shell, an extended version of Bourne Shell (sh) with plenty of features and support for plugins and themes. Usually, it may seem bash is enough for everything but once you started using zsh, you cannot go back to bash again because it provides thousands of useful features which increases your productivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  So Why use it?
&lt;/h2&gt;

&lt;p&gt;Zsh has so many features but here are some of the major ones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatic cd: Just type name of the directory&lt;/li&gt;
&lt;li&gt;Recursive path expansion: For example “/u/lo/b” expands to “/usr/local/bin”&lt;/li&gt;
&lt;li&gt;Spelling correction and approximate completion: If you make a minor mistake typing a directory name, ZSH will fix it for you&lt;/li&gt;
&lt;li&gt;Plugin and theme support: ZSH includes many different plugin frameworks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;plugins and themes support is probably the coolest feature of ZSH.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing ZSH
&lt;/h2&gt;

&lt;p&gt;If you're on Mac, use &lt;code&gt;brew&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re on Linux, the commands can vary by the distro, but it should be a default package in your package manager. You can consult  &lt;a href="https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH"&gt;this guide&lt;/a&gt;  if you’re having trouble.&lt;/p&gt;

&lt;p&gt;If you’re on Windows, you may not even have Bash in the first place. You can follow  &lt;a href="https://www.howtogeek.com/258518/how-to-use-zsh-or-another-shell-in-windows-10/"&gt;this guide&lt;/a&gt;  to set that up and enable ZSH.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Oh-My-Zsh
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Your terminal never felt this good before.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://github.com/robbyrussell/oh-my-zsh"&gt;Oh-My-Zsh&lt;/a&gt; is a famous framework for managing plugins for ZSH and it comes with plenty of plugins and themes as well.&lt;/p&gt;

&lt;p&gt;oh-my-zsh has simple install script you can run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read more about zsh &lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins"&gt;plugins&lt;/a&gt;  and  &lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Themes"&gt;themes&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://github.com/tmux/tmux/wiki/Getting-Started"&gt;tmux&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Simply speaking, Tmux act as a windows manager within your terminal that allows you to create multiple windows and panes in a single terminal window.&lt;/p&gt;

&lt;p&gt;here is an example of multiple panes in a single window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E69fxP2R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597674525646/HleIPrMJL.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E69fxP2R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1597674525646/HleIPrMJL.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So Why use it?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Session management:&lt;/strong&gt; Actually, in the background, all these panes and windows get its own terminal, and its managed by the tmux server so even you close your terminal application, tmux keeps the session in the background, so you can easily attach and detach to the session until you restart the machine. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Platform independence:&lt;/strong&gt;  I can use tmux on my Macbook, my Linux notebook, Cloud servers, Raspberry Pis, BeagleBones, etc.&lt;/li&gt;
&lt;li&gt;** customizable:** There are many ways that I can customize the look and behavior of my tmux and sync this across different platforms using dotfiles.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installing Tmux
&lt;/h2&gt;

&lt;p&gt;Fortunately installing tmux is pretty straightforward on most distributions a simple&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;sudo apt-get install tmux&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 (Ubuntu and derivatives) or&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;brew install tmux&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 (Mac) should be sufficient.&lt;/p&gt;

&lt;p&gt;Tmux has a prefix key to trigger functions by default it is &lt;code&gt;ctrl+b&lt;/code&gt; but most of the people change it to &lt;code&gt;ctrl+a&lt;/code&gt; here is my tmux  &lt;a href="https://github.com/thamaraiselvam/dotfiles/blob/master/tmux/.tmux.conf"&gt;config file&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The learning curve of tmux little bit steep but worth learning, you can learn more about tmux  &lt;a href="https://linuxize.com/post/getting-started-with-tmux/"&gt;here&lt;/a&gt; &lt;/p&gt;
&lt;h1&gt;
  
  
  &lt;a href="https://starship.rs/"&gt;Starship&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Starship is a &lt;strong&gt;cross shell prompt&lt;/strong&gt; and it is extremely handy to know about multiple things such as current state of git, which folder are you in, what version of the programming language you are using, and so on.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;it is minimal, blazing-fast, and infinitely customizable prompt for any shell! &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  So Why use it?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It saves tons of time and minimizes human errors&lt;/li&gt;
&lt;li&gt; It is very easy to install and  customize&lt;/li&gt;
&lt;li&gt;Works on most of the popular shell &lt;/li&gt;
&lt;li&gt;Extremely faster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;here is the demo video of the starship&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oyiTSyBJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1598084238079/4OnH07waY.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oyiTSyBJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1598084238079/4OnH07waY.gif" alt="ezgif-6-ac378aebf3d7.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://starship.rs/#quick-install"&gt;here is quick install guide from official page&lt;/a&gt; &lt;/p&gt;
&lt;h1&gt;
  
  
  &lt;a href="https://github.com/knqyf263/pet"&gt;PET&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Most of the time we want a command that was used a week ago, and it is very difficult to retrieve them. yes, we all have this pain. To fix this problem I wanted to write a program that saves all my important commands into GitHub gist so I can get it back whenever I want. But later I found an application which does the exactly same thing with lot of additional features as well, that is PET.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pet is a command-line snippet manager&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It also provides code script to integrate with our shells, customizable keybindings and it also provides the option to save these commands as private or public gist.&lt;/p&gt;
&lt;h2&gt;
  
  
  So Why use it?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Register your command snippets easily.&lt;/li&gt;
&lt;li&gt;Use variables in snippets.&lt;/li&gt;
&lt;li&gt;Search snippets interactively.&lt;/li&gt;
&lt;li&gt;Run snippets directly.&lt;/li&gt;
&lt;li&gt;Edit snippets easily (config is just a TOML file).&lt;/li&gt;
&lt;li&gt;Sync snippets via Gist or GitLab Snippets automatically.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How to install?
&lt;/h2&gt;

&lt;p&gt;You can use homebrew on OS X.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brew install knqyf263/pet/pet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Debian, Ubuntu&lt;/p&gt;

&lt;p&gt;Download deb package from the releases page&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ wget https://github.com/knqyf263/pet/releases/download/v0.3.0/pet_0.3.0_linux_amd64.deb
dpkg -i pet_0.3.0_linux_amd64.deb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to use?
&lt;/h2&gt;

&lt;p&gt;These are available pet commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pet --help
pet - Simple command-line snippet manager.

Usage:
  pet [command]

Available Commands:
  configure   Edit config file
  edit        Edit snippet file
  exec        Run the selected commands
  help        Help about any command
  list        Show all snippets
  new         Create a new snippet
  search      Search snippets
  sync        Sync snippets
  version     Print the version number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pet commands are very easy to use but you can make a lot easier by following the below steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;prev&lt;/code&gt; command
&lt;/h3&gt;

&lt;p&gt;Instead of using &lt;code&gt;pet new&lt;/code&gt;, you can configure &lt;code&gt;prev&lt;/code&gt; command with  &lt;a href="https://github.com/knqyf263/pet#register-the-previous-command-easily"&gt;this guide &lt;/a&gt;, thereafter just enter the command &lt;code&gt;prev&lt;/code&gt; to save your last executed command into the pet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5tx72Q1u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1598085985296/JXEX-IEqU.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5tx72Q1u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1598085985296/JXEX-IEqU.gif" alt="pet02.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Select snippets at the current line (like C-r)
&lt;/h3&gt;

&lt;p&gt;Rather than using &lt;code&gt;pet search&lt;/code&gt; command every time,  you can simply assign a keybinding for it using  &lt;a href="https://github.com/knqyf263/pet#select-snippets-at-the-current-line-like-c-r"&gt;this guide&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sync with Gist
&lt;/h3&gt;

&lt;p&gt;Backup and sharing is an important thing to do and pet provides an easier way for that, using pet sync you can manually upload all your saved commands to gist, it also can be automated using &lt;code&gt;pet configure&lt;/code&gt; and set &lt;code&gt;auto_sync&lt;/code&gt; to true. &lt;a href="https://github.com/knqyf263/pet#sync-snippets"&gt;Read more about pet sync&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;That's it for part 1, Feel free to post your favorite terminal tools on comments. See you in next the part 2 with another 5 useful terminal tools. &lt;/p&gt;

</description>
      <category>productivity</category>
      <category>developer</category>
      <category>devops</category>
      <category>terminal</category>
    </item>
    <item>
      <title>Synchronous Vs Asynchronous Database Replication</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Tue, 11 Feb 2020 18:05:04 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/synchronous-vs-asynchronous-database-replication-4k46</link>
      <guid>https://forem.com/thamaraiselvam/synchronous-vs-asynchronous-database-replication-4k46</guid>
      <description>&lt;p&gt;In the last two articles, we have seen &lt;a href="https://thamaraiselvam.dev/the-need-for-database-replication-ck63ymuc202q289s1e79s3tgw"&gt;the need for database replication&lt;/a&gt; and &lt;a href="https://thamaraiselvam.dev/database-replication-master-slave-replication-architecture-ck66skn6r03r8kbs16egqnzvg"&gt;master-replica architecture&lt;/a&gt; and in this article, we will discuss the different type of database replications.&lt;/p&gt;

&lt;p&gt;We know that all write requests go to the master and all read requests go to the replicas but there is an issue to achieve it because both master and replicas should be in sync always otherwise consistency problems will occur. So let's see what are the different types of replication strategies out there and how are they addressing consistency issues. &lt;/p&gt;

&lt;p&gt;There are three types of replication methods, they are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Synchronous replication&lt;/li&gt;
&lt;li&gt;Asynchronous replication&lt;/li&gt;
&lt;li&gt; Semi-synchronous replication&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Synchronous replication:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8tOoBlvk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581441255048/FRNLgdzkv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8tOoBlvk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581441255048/FRNLgdzkv.png" alt="Webp.net-resizeimage (5).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this replication method, once the master gets a write request from the application. first, writes data into the database then sends these changes to all replicas. Then the master waits till all replicas write the changes into their database and acknowledge and finally master responds success message to the application write request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--56IyOlyZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581439839301/upaWE_t0J.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--56IyOlyZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581439839301/upaWE_t0J.png" alt="Webp.net-resizeimage (4).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;let consider write operation when the user request for the write request, the application sends a request to the master in time T1 and master database write the changes in Time T2 and send those request to the replicas.&lt;/p&gt;

&lt;p&gt;Replicas receive the changes in T3 and T4 and populate data changes but that time master will be waiting for replica's response. As soon as replica1 is done with task send an acknowledgment to the master server which is T5 and master still waiting for replica2's response. At time T6 replica2 finishes the task sends acknowledge to the master server. Now master got the acknowledgment of all replicas. Now master will respond as the success message to the users.&lt;/p&gt;

&lt;p&gt;you also can easily see that the problem is Time. From time T2 to t7 master is just waiting for replica's acknowledgment by the time the user also is waiting. It affects user experience as well and what if replica2 has some problem and it takes a longer time to respond so the master database is ideally waiting for a long time. this is an unnecessary waiting time for the user. In this method,  Time will grow exponentially when replicas count getting increased because the master has to wait until all replicas to acknowledge.&lt;/p&gt;

&lt;h3&gt;
  
  
  Asynchronous replication:
&lt;/h3&gt;

&lt;p&gt;In the Asynchronous replication method, the master sends the confirmation to the application as soon as it has received the message and written successfully into the database then it sends the replicate request to all replicas.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--od0w1Yih--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581441387628/EqVYwWBmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--od0w1Yih--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581441387628/EqVYwWBmf.png" alt="Webp.net-resizeimage (6).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This looks great, we don’t notice any performance impact as the replication happens in the background after we already got a response and if the replica is dead or slow we won’t even notice it, as the data was already sent back to the client. Life is good.&lt;/p&gt;

&lt;p&gt;but there are two problems with this method one is replication lag and another one is we are weakening out durability guarantees lets focus of durability issue first&lt;/p&gt;

&lt;p&gt;our problem is that if the master fails before it sends the request to replicas then we lost the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1DVy9sdX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581441616407/QQ4-lTU6i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1DVy9sdX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1581441616407/QQ4-lTU6i.png" alt="Webp.net-resizeimage (7).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes, it may be totally fine to take the risk, but think about dealing with financial transactions? it is a nightmare.&lt;/p&gt;

&lt;p&gt;Another issue is that there could be some data delays between master and replicas so that we cannot send read requests to not synced replicas, this is called replication lag.&lt;/p&gt;

&lt;h3&gt;
  
  
  Semi-synchronous replication:
&lt;/h3&gt;

&lt;p&gt;There's some middle ground, We can define some replicas to replicate synchronously and others just use asynchronous manner. this is called Semi-synchronous replication&lt;/p&gt;

&lt;h3&gt;
  
  
  When to use what
&lt;/h3&gt;

&lt;p&gt;There is no clear answer to this question; your choice depends entirely on your business priorities. Asynchronous replication works best with projects that span across long distances and are allocated a minimal budget. It is also suitable for businesses that can afford partial data loss. On the other hand, synchronous replication is performed when reliable and long-term storage is necessary and the business cannot afford to lose any critical data. Also, semi-synchronous replication can be used to achieve the best of both.&lt;/p&gt;

&lt;p&gt;In the next article, we will talk about How to create database replication architecture for the Postgres database.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Database Replication: Master-Slave Replication Architecture</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Mon, 03 Feb 2020 18:37:13 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/database-replication-master-slave-replication-architecture-51j2</link>
      <guid>https://forem.com/thamaraiselvam/database-replication-master-slave-replication-architecture-51j2</guid>
      <description>&lt;p&gt;Recently I have started writing about database replication, In the first article I have explained &lt;strong&gt;the need for database replication&lt;/strong&gt; if you have not read yet, I recommend you to read &lt;a href="https://thamaraiselvam.dev/the-need-for-database-replication-ck63ymuc202q289s1e79s3tgw"&gt;Need for Database Replication&lt;/a&gt; on Hashnode or on &lt;a href="https://dev.to/thamaraiselvam/the-need-for-database-replication-2ncm"&gt;dev.to&lt;/a&gt; before continuing this. We will discuss Master-Slave replication architecture in this article.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Master-Slave architecture also called Active-Passive or Active-Standby or Leader based replication architecture&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The database request can be two types such as,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write request (Insertion, deletion, and updation)&lt;/li&gt;
&lt;li&gt;Read request &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note: I replaced all words slave with replica since it can be considered as &lt;a href="https://www.quora.com/What-do-you-think-about-few-major-software-removing-terms-master-and-slave-from-their-code-because-they-can-be-considered-offensive"&gt;offensive&lt;/a&gt;&lt;/em&gt; :p&lt;/p&gt;

&lt;h3&gt;
  
  
  Simple Master-Replica Architecture
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2bY9QAdk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580748641192/BVzvK_v4k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2bY9QAdk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580748641192/BVzvK_v4k.png" alt="Webp.net-resizeimage (1).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above diagram is the simple master-replica architecture contains one master and two replicas&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basically master replicates the database into multiple copies(also called replicas) through the replication stream.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All read/write request goes to the master. If any data changes happen in the master those changes will be streamed to replicas as well so master and replicas are in sync always. the lag between master and replica is called &lt;strong&gt;replication lag&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Avoid downtime using replicas
&lt;/h3&gt;

&lt;p&gt;Since all request goes to master then what is the use of these replicas? What happens when our master goes down for some reason then our application also will go down because there is no master to handles requests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TC9e9sDL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580752780371/rR2L78t_6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TC9e9sDL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580752780371/rR2L78t_6.png" alt="Webp.net-resizeimage (2).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using replicas we can avoid this. When the master goes down. there will be an election between replicas and one replica will be elected as leader and replace the dead master. as you can see in the above example since the master is dead replica-1 is elected as the new master.&lt;/p&gt;

&lt;p&gt;In this way, replicas can be used to achieve high availability database. &lt;/p&gt;

&lt;h3&gt;
  
  
  Improve performance using replicas
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uVRCJuSg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580754605396/OG_XTkpK8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uVRCJuSg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580754605396/OG_XTkpK8.png" alt="Webp.net-resizeimage (3).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also significantly improve the performance of our database by&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Redirecting all &lt;strong&gt;read requests to replicas&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redirect only &lt;strong&gt;write requests to master&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;previously master handles both read and write but now we bifurcated the requests among master and replicas. this kind of architecture balances the load on our database server. In our example diagram, there are only two replicas but in actual application, it can be more as 100s of replicas based on application load so the read requests even more divided among replicas.&lt;/p&gt;

&lt;p&gt;Now let say master goes down for some reason. now only our write requests will go down till master switch happens and users can still do the read requests so this will not be a single point of failure.&lt;/p&gt;

&lt;p&gt;as said above even master goes down immediately the master switch will happen so there will be very little downtime for write requests.&lt;/p&gt;

&lt;p&gt;also, we can tell our application to select the nearest replicas based on geographical locations for reading requests so network latency will be improved drastically.&lt;/p&gt;

&lt;p&gt;In the next article, we will discuss how synchronization happens between master and replicas.&lt;/p&gt;

</description>
      <category>database</category>
      <category>tutorial</category>
      <category>devops</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>The need for Database Replication</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Sat, 01 Feb 2020 19:03:33 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/the-need-for-database-replication-2ncm</link>
      <guid>https://forem.com/thamaraiselvam/the-need-for-database-replication-2ncm</guid>
      <description>&lt;p&gt;Recently I got an opportunity to learn about database replication then I felt that every developer should know about database replication and I have planned to write series of articles to explain the database replication such as the need of database replication and master-slave concepts and how to set up database replication on different databases and Let's start.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the replication
&lt;/h3&gt;

&lt;p&gt;Replication is keeping multiple copies of the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why replication is important
&lt;/h3&gt;

&lt;p&gt;There are many reasons. I have taken three important reasons for having multiple copies of the database they are,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Availability&lt;/li&gt;
&lt;li&gt;Latency&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's see each one of them in details&lt;/p&gt;

&lt;h4&gt;
  
  
  Availability
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kKd_ydyr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580580383291/U3Tr3yXq8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kKd_ydyr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580580383291/U3Tr3yXq8.png" alt="Webp.net-resizeimage.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first thing is availability, the application needs data from the database or application needs to write/persist data into the database so it fires a request to the database server then database respect to that request. This is how the application and database server communicates.&lt;/p&gt;

&lt;p&gt;Let's say we have a single copy of the database and the database resides on a particular server goes down for some reason like something corrupt on that machine, then what happens to the request which goes to the database? The database cannot respond to the application requests and our application will go down so the application will not be available to serve the users. This is called &lt;strong&gt;single point of failure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If we have multiple replicas of the database, also we have some mechanism to redirect all requests to another machine so even one machine goes down another will serve the requests. This is one of the most important reasons for having multiple replicas of the database.&lt;/p&gt;

&lt;h4&gt;
  
  
  Latency
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r4lyXGQz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580580257174/xQNZ40wu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r4lyXGQz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580580257174/xQNZ40wu9.png" alt="network-latency-1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assume our application is available in different geographical locations like the US, India, Australia and so on but our database resides in the server located in India. The person lives in the US who uses our application then all request network packets travel from the US to India to get data from the database and response packets will go back from India to the US. there is huge network latency is created because of the distance.&lt;/p&gt;

&lt;p&gt;So if we keep a replica of our database in the US itself so whenever the user hits the request our application will go to the database which nearest to that particular geographical location. Our replication has reduced the latency caused by distance. Now you understand another important reason to have a replica of the database.&lt;/p&gt;

&lt;h4&gt;
  
  
  Scalability
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n35ywU3K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580580658571/7xOgmkSbh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n35ywU3K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1580580658571/7xOgmkSbh.png" alt="images.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imaging our application is getting requests like millions per second and one single database cannot serve them all even it is managed to serve but it cannot give data in a fraction of seconds and users will feel the slowness of the application.&lt;/p&gt;

&lt;p&gt;If we have multiple replicas of the database in different servers, we can balance the load into different servers using some load balancer and this is called &lt;strong&gt;load balancing&lt;/strong&gt;.  Now we have divided the requests to the different servers so the chances of overloading the servers are very less.&lt;/p&gt;

&lt;p&gt;Another thing is that if we have multiple replicas we can do like one set of replicas takes care of write requests and others will serve read requests, in this way system is more scalable.&lt;/p&gt;

&lt;p&gt;These are the most important reasons to have replication of the database. In the next articles, we will see Master-Slave replication architecture.&lt;/p&gt;

&lt;p&gt;This article originally published on &lt;a href="https://thamaraiselvam.dev/the-need-for-database-replication-ck63ymuc202q289s1e79s3tgw"&gt;hashnode&lt;/a&gt; &lt;/p&gt;

</description>
      <category>database</category>
      <category>distributedsystems</category>
      <category>tutorial</category>
      <category>devops</category>
    </item>
    <item>
      <title>Any active contributors on Stackoverflow?</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Thu, 14 Nov 2019 04:05:07 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/any-active-contributors-on-stackoverflow-5g14</link>
      <guid>https://forem.com/thamaraiselvam/any-active-contributors-on-stackoverflow-5g14</guid>
      <description>&lt;p&gt;Reputation values are changing across Stack Overflow&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.blog/2019/11/13/were-rewarding-the-question-askers/"&gt;https://stackoverflow.blog/2019/11/13/were-rewarding-the-question-askers/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I got 600 reputations. It is a good chance for me because of its added value for good questions. what about others and whats your thoughts on this change?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>How to allow Touch ID to authenticate for Sudo commands on Mac</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Sat, 02 Nov 2019 08:26:42 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/how-to-allow-touch-id-to-authenticate-for-sudo-commands-on-mac-2a68</link>
      <guid>https://forem.com/thamaraiselvam/how-to-allow-touch-id-to-authenticate-for-sudo-commands-on-mac-2a68</guid>
      <description>&lt;p&gt;To enable TouchID on your Mac to authenticate you for sudo access instead of a password you need to do the following steps.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Sudo configuration file with the following command
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;sudo vi /etc/pam.d/sudo&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Initially file content should look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# sudo: auth account password session
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Paste &lt;code&gt;auth sufficient pam_tid.so&lt;/code&gt; on line 2 of the document (underneath the initial comment line)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After pasting contents should be like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# sudo: auth account password session
auth       sufficient     pam_tid.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Save the file (Since this file is read-only, you may be required to do force save, Eg &lt;code&gt;vim&lt;/code&gt; will require you to use &lt;code&gt;wq!&lt;/code&gt; when saving)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now try to use sudo command on terminal and you should be prompted to authenticate with Touch ID as shown below&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---xFfi-bJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1572680707181/dnTJUzFIm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---xFfi-bJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1572680707181/dnTJUzFIm.png" alt="Screenshot 2019-11-02 at 1.13.51 PM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you click 'Cancel' you can just enter your password at the terminal prompt if you click 'Use Password' you can enter your password in the dialog box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you SSH into your machine it will fall back to just use your password since you can't send your TouchID fingerprints over SSH&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you're using &lt;strong&gt;iTerm2&lt;/strong&gt; (v3.2.8+) you may have seen Touch ID failing to work with sudo in the terminal despite having made the pam_tid.so modification as above, and it works in previous versions. This is down to an advanced feature that seems to be now enabled by default - this needs to be turned off here: &lt;strong&gt;iTerm2-&amp;gt;Preferences &amp;gt; Advanced &amp;gt; (Goto the Session heading) &amp;gt; Allow sessions to survive logging out and back in.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o2Yu6mU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1572680888792/ocxzOZYT5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o2Yu6mU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1572680888792/ocxzOZYT5.png" alt="Screenshot 2019-11-02 at 1.17.56 PM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://apple.stackexchange.com/questions/259093/can-touch-id-for-the-mac-touch-bar-authenticate-sudo-users-and-admin-privileges"&gt;https://apple.stackexchange.com/questions/259093/can-touch-id-for-the-mac-touch-bar-authenticate-sudo-users-and-admin-privileges&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Bookmark commands in Terminal</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Thu, 22 Aug 2019 18:48:17 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/how-to-bookmark-commands-in-terminal-2igo</link>
      <guid>https://forem.com/thamaraiselvam/how-to-bookmark-commands-in-terminal-2igo</guid>
      <description>&lt;p&gt;Always we hate to type or search or copy and paste most often used commands in the terminal.&lt;/p&gt;

&lt;p&gt;I found a great tool to ease the navigation in the terminal, called &lt;a href="https://micans.org/apparix/"&gt;&lt;strong&gt;Apparix&lt;/strong&gt;&lt;/a&gt;. It lets you bookmark a folder so that you easily can navigate to it just by typing&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;to nameofbookmark&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;To install apparix in Ubuntu, type&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo apt-get install apparix&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;To install in Mac, type&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew install -v apparix&lt;/code&gt; or  &lt;a href="https://gist.github.com/glombard/a91a822098aed7bb50a7"&gt;Run this Script&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;in a terminal window.&lt;/p&gt;

&lt;p&gt;After installation, you need to set up the aliases &lt;code&gt;bm&lt;/code&gt; for bookmarking and &lt;code&gt;to&lt;/code&gt; for going to a bookmark by adding a few functions to your &lt;code&gt;.bashrc file&lt;/code&gt; in your home folder (if you don’t have this file, you can create it yourself).&lt;/p&gt;

&lt;p&gt;You’ll find the functions you need to add by issuing the command&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apparix –shell-examples&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;in a terminal window. Copy everything below &lt;strong&gt;Bash-style functions&lt;/strong&gt; except the &lt;strong&gt;CSH-style aliases&lt;/strong&gt;. Paste this into your &lt;code&gt;.bashrc file&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Open up a new terminal, cd to your directory of choice and type&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bm mybookmark&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;to bookmark the folder. Afterward, you can go to any folder and type&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;to mybookmark&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;to go to your bookmark.&lt;/p&gt;

&lt;p&gt;This tool is, of course, available for other Linux distributions too.&lt;/p&gt;

&lt;p&gt;Reference:  &lt;a href="https://micans.org/apparix/"&gt;https://micans.org/apparix/&lt;/a&gt; &lt;/p&gt;

</description>
      <category>productivity</category>
      <category>terminal</category>
      <category>linux</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>MEAN Stack Cheat-Sheet</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Thu, 11 Jul 2019 10:55:22 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/mean-stack-cheat-sheet-5a1n</link>
      <guid>https://forem.com/thamaraiselvam/mean-stack-cheat-sheet-5a1n</guid>
      <description>&lt;h2&gt;
  
  
  Deprecated !!!
&lt;/h2&gt;

&lt;p&gt;It has been 2 years since I have updated this article, Please refer respective documents to learn latest changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet" rel="noopener noreferrer"&gt;MEAN Stack Cheat Sheet Github Repository&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Those who want to become a &lt;em&gt;Full Stack Developer&lt;/em&gt; their first choice is &lt;strong&gt;MEAN Stack&lt;/strong&gt; because it has a lot of scopes and easy to learn as well but preparing is hard so Here's a Cheat Sheet - Inspired by &lt;a href="https://gist.github.com/TSiege/cbb0507082bb18ff7e4b" rel="noopener noreferrer"&gt;The Technical Interview Cheat Sheet.md&lt;/a&gt;&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%2F3cm4hqh8iw85uv00vnyz.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%2Fuploads%2Farticles%2F3cm4hqh8iw85uv00vnyz.gif" alt="Shortcut"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This list is meant to be both a quick guide and reference for further research into these topics. It's basically a summary of important topics, there's no way it can cover everything in depth.  It also will be available as on &lt;a href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet" rel="noopener noreferrer"&gt;Github&lt;/a&gt; for everyone. Please feel free to rise a &lt;a href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/issues" rel="noopener noreferrer"&gt;issue&lt;/a&gt; or &lt;a href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; if anything missing or any correction required.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What the heck is MEAN Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MEAN is an acronym for &lt;strong&gt;MongoDB&lt;/strong&gt;, &lt;strong&gt;ExpressJS&lt;/strong&gt;, &lt;strong&gt;AngularJS&lt;/strong&gt; and &lt;strong&gt;Node.js&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;One of the main benefits of the MEAN stack is that a single language, JavaScript, runs on every level of the application, making it an efficient and modern approach to web development.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  MongoDB
&lt;/h2&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%2Fm6t2g7l0lr2qeeuo9o0n.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%2Fuploads%2Farticles%2Fm6t2g7l0lr2qeeuo9o0n.gif" alt="mongo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  MongoDB Introduction
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;What is MongoDB and where to be used ?&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;MongoDB is a type of NoSQL DB and used in the following applications such as unstable schema, need highly scalability and availability.  &lt;a href="https://www.mongodb.com/what-is-mongodb" rel="noopener noreferrer"&gt;Read More&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Difference between NoSQL and SQL ?&lt;/em&gt;
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;MySQL Terms&lt;/th&gt;
&lt;th&gt;MongoDB Terms&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;database&lt;/td&gt;
&lt;td&gt;database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;table&lt;/td&gt;
&lt;td&gt;collection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;row&lt;/td&gt;
&lt;td&gt;document or BSON document&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;column&lt;/td&gt;
&lt;td&gt;field&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;index&lt;/td&gt;
&lt;td&gt;index&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;table joins&lt;/td&gt;
&lt;td&gt;embedded documents and linking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;primary key Specify any unique column or column combination as the primary key.&lt;/td&gt;
&lt;td&gt;primary key In MongoDB, the primary key is automatically set to the _id field.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;aggregation (e.g. group by)&lt;/td&gt;
&lt;td&gt;aggregation pipeline&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.mongodb.com/compare/mongodb-mysql" rel="noopener noreferrer"&gt;Read more detailed comparison on MongoDB vs MySQL&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Install MongoDB
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;How to Install MongoDB and Robo 3T?&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://docs.mongodb.com/manual/installation/" rel="noopener noreferrer"&gt;Install MongoDB&lt;/a&gt; and  &lt;a href="https://robomongo.org/download" rel="noopener noreferrer"&gt;Robo 3T&lt;/a&gt; (Robo 3T -formerly Robomongo is the free lightweight GUI for MongoDB enthusiasts)&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;How to Install the mongoose node module?&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/mongoose" rel="noopener noreferrer"&gt;Mongoose&lt;/a&gt; is MongoDB driver which connects MongoDB and Node.JS &lt;a href="https://mongoosejs.com/docs/guide.html" rel="noopener noreferrer"&gt;Read Document&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Work with Mongoose
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Start with Schema?&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Everything in Mongoose starts with a Schema. Each schema maps to a MongoDB collection and defines the shape of the documents within that collection.&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;var&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&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;mongoose&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;Schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;blogSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt; &lt;span class="p"&gt;}],&lt;/span&gt;
    &lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;votes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;favs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="nb"&gt;Number&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;h4&gt;
  
  
  &lt;em&gt;Creating a Model?&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;To use our schema definition, we need to convert our blogSchema into a Model we can work with. To do so, we pass it into mongoose.model(modelName, schema)&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;var&lt;/span&gt; &lt;span class="nx"&gt;Blog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;blogSchema&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://mongoosejs.com/docs/guide.html#definition" rel="noopener noreferrer"&gt;Read More Mongoose guide&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic CURD functions
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Mongoose models provide several static helper functions for CRUD operations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.create" rel="noopener noreferrer"&gt;create()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Save one or more Documents to the database&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.insertMany" rel="noopener noreferrer"&gt;insertMany()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.findOne" rel="noopener noreferrer"&gt;findOne()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Finds one document&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.find" rel="noopener noreferrer"&gt;find()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Finds documents&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.updateOne" rel="noopener noreferrer"&gt;updateOne()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Updates one document in the database without returning it.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.update" rel="noopener noreferrer"&gt;update()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Same as update(), except it does not support the multi or overwrite options.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.updateMany" rel="noopener noreferrer"&gt;updateMany()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Same as update(), except MongoDB will update all documents that match filter&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.deleteOne" rel="noopener noreferrer"&gt;deleteOne()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Deletes the first document that matches conditions from the collection.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;&lt;a href="https://mongoosejs.com/docs/api.html#model_Model.deleteMany" rel="noopener noreferrer"&gt;deleteMany()&lt;/a&gt;&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Deletes all of the documents that match conditions from the collection&lt;/p&gt;

&lt;p&gt;Read more about  &lt;a href="https://mongoosejs.com/docs/queries.html" rel="noopener noreferrer"&gt;Mongoose Queries&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Aggregation
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Aggregations are operations that process data records and return computed results&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are operations like sum, count, average, group etc where we need to generated grouped results out of collection.&lt;br&gt;
MongoDB exposes a pipeline based framework for aggregations, which looks something like below and &lt;a href="https://mongoosejs.com/docs/api/aggregate.html#aggregate_Aggregate" rel="noopener noreferrer"&gt;Read more&lt;/a&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;Model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;aggregrate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
   &lt;span class="nx"&gt;pipe1_operator&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{...},&lt;/span&gt;
   &lt;span class="nx"&gt;pipe2_operator&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{...},&lt;/span&gt;
   &lt;span class="nx"&gt;pipe3_operator&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{...}&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;


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

&lt;/div&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;$group&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Count the number of Users Belonging To A Particular Region&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;$match&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;$match acts as a where condition to filter out documents.&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;$project&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;$project is used to add columns dynamically to the collection and use it for further aggregation.&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;count&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Count Number of User who belong to a certain region&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;distinct&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Find all distinct regions&lt;/p&gt;

&lt;p&gt;There are many more pipeline operators than dicussed above, which can be seen &lt;a href="http://docs.mongodb.org/manual/reference/operator/aggregation/#aggregation-expression-operators" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Node.JS
&lt;/h2&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%2Fjwwg2agszj7gjvgu8k60.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%2Fuploads%2Farticles%2Fjwwg2agszj7gjvgu8k60.gif" alt="node cats"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What is Node.JS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Node.js is a server-side platform (JavaScript runtime) built on &lt;a href="https://v8.dev/" rel="noopener noreferrer"&gt;Chrome's V8 JavaScript engine&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;It is an open source server environment and free&lt;/li&gt;
&lt;li&gt;It runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Why Node.js
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Asynchronous and Event Driven
&lt;/h4&gt;

&lt;p&gt;All APIs of Node.js library are asynchronous, that is, non-blocking. It essentially means a Node.js based server never waits for an API to return data. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.&lt;/p&gt;
&lt;h4&gt;
  
  
  Very Fast
&lt;/h4&gt;

&lt;p&gt;Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.&lt;/p&gt;
&lt;h4&gt;
  
  
  Single Threaded but Highly Scalable
&lt;/h4&gt;

&lt;p&gt;Node.js uses a single threaded model with event looping. Event mechanism helps the server to respond in a non-blocking way and makes the server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and the same program can provide service to a much larger number of requests than traditional servers like Apache HTTP Server&lt;/p&gt;
&lt;h4&gt;
  
  
  No Buffering
&lt;/h4&gt;

&lt;p&gt;Node.js applications never buffer any data. These applications simply output the data in chunks.&lt;/p&gt;
&lt;h3&gt;
  
  
  Where to use Node.js
&lt;/h3&gt;

&lt;p&gt;Following are the areas where Node.js is proving itself as a perfect technology partner.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I/O bound Applications&lt;/li&gt;
&lt;li&gt;Data Streaming Applications&lt;/li&gt;
&lt;li&gt;Data Intensive Real-time Applications (DIRT)&lt;/li&gt;
&lt;li&gt;JSON APIs based Applications&lt;/li&gt;
&lt;li&gt;Single Page Applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*** It is not advisable to use Node.js for CPU intensive applications ***&lt;/p&gt;
&lt;h3&gt;
  
  
  NPM
&lt;/h3&gt;

&lt;p&gt;NPM is a package manager for the JavaScript programming language. It is the default package manager for Node.js and it is the world's largest Software Registry. It contains more than one million packages.&lt;/p&gt;
&lt;h3&gt;
  
  
  Install Node.js and NPM
&lt;/h3&gt;

&lt;p&gt;Simply download the &lt;a href="https://nodejs.org/en/#download" rel="noopener noreferrer"&gt;Installer&lt;/a&gt; directly from the &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;nodejs.org&lt;/a&gt; web site or follow the instructions for platform specific.&lt;/p&gt;
&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Debian based distributions
&lt;/h4&gt;

&lt;p&gt;Such as Debian, Ubuntu, Linux mint and Raspbian&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;nodejs npm


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

&lt;/div&gt;
&lt;h4&gt;
  
  
  Arch Linux
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

pacman &lt;span class="nt"&gt;-S&lt;/span&gt; nodejs npm


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

&lt;/div&gt;
&lt;h4&gt;
  
  
  MacOS
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

brew &lt;span class="nb"&gt;install &lt;/span&gt;node


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

&lt;/div&gt;
&lt;h4&gt;
  
  
  Windows
&lt;/h4&gt;

&lt;p&gt;Simply download the &lt;a href="https://nodejs.org/en/#download" rel="noopener noreferrer"&gt;Windows Installer&lt;/a&gt; directly from the &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;nodejs.org&lt;/a&gt; web site.&lt;/p&gt;
&lt;h3&gt;
  
  
  Techical Depth
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Single thread
&lt;/h4&gt;

&lt;p&gt;Single threaded processes contain the execution of instructions in a single sequence. In other words, one command is processed at a time. &lt;a href="https://www.tutorialspoint.com/single-threaded-and-multi-threaded-processes" rel="noopener noreferrer"&gt;Read more about single thread vs multi thread&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Event Loop
&lt;/h4&gt;

&lt;p&gt;The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.&lt;/p&gt;

&lt;p&gt;Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback may be added to the poll queue to eventually be executed&lt;/p&gt;

&lt;p&gt;Read the following links to learn more about Event Loop&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/" rel="noopener noreferrer"&gt;The Node.js Event Loop&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=8aGhZQkoFbQ" rel="noopener noreferrer"&gt;What the heck is the event loop anyway? by Philip Roberts - JSConf EU&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://latentflip.com/loupe/" rel="noopener noreferrer"&gt;Visualisation tool for event loop&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  JavaScript Engine vs JavaScript Runtime
&lt;/h4&gt;

&lt;p&gt;A &lt;strong&gt;JavaScript engine&lt;/strong&gt; is a program or interpreter which reads our JavaScript code, produces machine code, and finally runs the machine code. It is landed in JavaScript runtimes like web browsers, Node.js, or even Java Runtime Environment (JRE). Like any other interpreters, its job is to read and execute code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript runtime&lt;/strong&gt; is another software. It uses JavaScript Engine and provides some additional functionalities as needed. The most common example of the runtime is the web browser. Probably the second most widely used runtime is Node.js.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@misbahulalam/uncover-the-javascript-engine-vs-runtime-6556ef449634" rel="noopener noreferrer"&gt;Read more here&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ECMAScript
&lt;/h3&gt;

&lt;p&gt;ECMAScript(ES) is a scripting-language &lt;strong&gt;specification standard&lt;/strong&gt;ized by Ecma International. It was created to standardize JavaScript and new standards is released on every year.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://es6-features.org/" rel="noopener noreferrer"&gt;ES6 Features&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/@madasamy/javascript-brief-history-and-ecmascript-es6-es7-es8-features-673973394df4" rel="noopener noreferrer"&gt;ES7, ES8, ES9 Features&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Hello World in Node.js
&lt;/h3&gt;

&lt;p&gt;Refer express for hello world program.&lt;/p&gt;
&lt;h3&gt;
  
  
  Some Common NPM Packages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/express" rel="noopener noreferrer"&gt;express&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/body-parser" rel="noopener noreferrer"&gt;body-parser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/lodash" rel="noopener noreferrer"&gt;lodash&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/async" rel="noopener noreferrer"&gt;async&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/moment" rel="noopener noreferrer"&gt;moment&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/request" rel="noopener noreferrer"&gt;request&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  REST API
&lt;/h2&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%2Fa4s5csvan55x2c4f4ebk.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%2Fuploads%2Farticles%2Fa4s5csvan55x2c4f4ebk.gif" alt="REST API"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;What is REST API&lt;/em&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A REST stands for Representational State Transfer is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;REST is a style of software architecture. As described in a dissertation by Roy Fielding, REST is an "architectural style" that basically exploits the existing technology and protocols of the Web.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;HTTP Methods&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;RESTful APIs enable you to develop any kind of web application having all possible CRUD operations. REST guidelines suggest using a specific HTTP method on a specific type of call made to the server (though technically it is possible to violate this guideline, yet it is highly discouraged).&lt;/p&gt;

&lt;p&gt;Use below-given information to find suitable HTTP method for the action performed by API.&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;HTTP GET&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Use GET requests to retrieve resource representation/information only – and not to modify it in any way&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;HTTP POST&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;POST methods are used to create a new resource into the collection of resources.&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;HTTP PUT&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Use PUT APIs primarily to update an existing resource.&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;HTTP DELETE&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;As the name applies, DELETE APIs are used to delete resources.&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;HTTP PATCH&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;PATCH requests are to make partial update on a resource&lt;/p&gt;

&lt;p&gt;Read more &lt;a href="https://restfulapi.net/http-methods/" rel="noopener noreferrer"&gt;HTTP Methods&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Express
&lt;/h2&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%2Fsism46d6b0cuisb742rw.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%2Fuploads%2Farticles%2Fsism46d6b0cuisb742rw.gif" alt="Express cat"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;What is Express&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;The fast, unopinionated, minimalist web framework for node.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;Installation&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://expressjs.com/en/starter/installing.html" rel="noopener noreferrer"&gt;Follow this simple instruction by Express Community&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;em&gt;Create Hello World REST API with Express&lt;/em&gt;
&lt;/h3&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="nf"&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="nf"&gt;express&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;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello 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;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Example app listening on port &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;This app starts a server and listens on port 3000 for connections. The app responds with “Hello World!” for requests to the root URL (/) or route. Read &lt;a href="http://expressjs.com/en/guide/routing.html" rel="noopener noreferrer"&gt;Express Guide&lt;/a&gt; to know more about Express Routing&lt;/p&gt;
&lt;h2&gt;
  
  
  Angular
&lt;/h2&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%2Ffv04lf243s9aunc0fl1c.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%2Fuploads%2Farticles%2Ffv04lf243s9aunc0fl1c.gif" alt="angular cat"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Note: Always Refer &lt;a href="https://angular.io/docs" rel="noopener noreferrer"&gt;Angular Docs&lt;/a&gt;  for a detailed explanation&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Angular
&lt;/h3&gt;

&lt;p&gt;Angular is a TypeScript-based open-source web application framework for building mobile and desktop web applications&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Angular
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Angular was written in TypeScript, a superset of JavaScript that implements many new ES2016+ features.&lt;/li&gt;
&lt;li&gt;Awesome Command Line Interface (CLI)&lt;/li&gt;
&lt;li&gt;Develop across all platforms&lt;/li&gt;
&lt;li&gt;Speed, Performance, and Scalability&lt;/li&gt;
&lt;li&gt;Incredible tooling&lt;/li&gt;
&lt;li&gt;Perfect for Single Page Application&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setup Angular
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step 1: Install Node.js
&lt;/h4&gt;

&lt;p&gt;Angular requires Node.js version 10.9.0 or later. To install node.js, go to Install Node&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2: Install the Angular CLI
&lt;/h4&gt;

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

npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @angular/cli


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

&lt;/div&gt;

&lt;p&gt;that's it you have installed Angular on your machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Angular CLI
&lt;/h3&gt;

&lt;p&gt;The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications. You can use the tool directly in a command shell.&lt;/p&gt;

&lt;p&gt;Enter the following to list commands or options for a given command (such as generate) with a short description&lt;/p&gt;

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

ng &lt;span class="nb"&gt;help
&lt;/span&gt;ng generate &lt;span class="nt"&gt;--help&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Know more about &lt;a href="https://angular.io/cli" rel="noopener noreferrer"&gt;Angular CLI&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create and Run an application
&lt;/h3&gt;

&lt;p&gt;Now it is time to create your first Angular application.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create New Angular Application
&lt;/h4&gt;

&lt;p&gt;Use the &lt;code&gt;new&lt;/code&gt; command to create a new application.&lt;/p&gt;

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

ng new my-first-project


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

&lt;/div&gt;

&lt;p&gt;and enter into created application &lt;code&gt;cd my-first-project&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;serve&lt;/code&gt; to run the application.&lt;/p&gt;

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

ng serve


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

&lt;/div&gt;

&lt;p&gt;In your browser, open &lt;a href="http://localhost:4200/" rel="noopener noreferrer"&gt;http://localhost:4200/&lt;/a&gt; to see the new app run. When you use the ng serve command to build an app and serve it locally, the server automatically rebuilds the app and reloads the page when you change any of the source files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fundamentals
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Architecture
&lt;/h4&gt;

&lt;p&gt;Angular is a platform and framework for building client applications in HTML and TypeScript. Angular is written in TypeScript. It implements core and optional functionality as a set of TypeScript libraries that you import into your apps.&lt;/p&gt;

&lt;h4&gt;
  
  
  Module
&lt;/h4&gt;

&lt;p&gt;The basic building blocks of an Angular application are &lt;strong&gt;NgModules&lt;/strong&gt;, which provide a compilation context for components. NgModules collect related code into functional sets; an Angular app is defined by a set of NgModules. An app always has at least a root module that enables bootstrapping and typically has many more feature modules&lt;/p&gt;

&lt;p&gt;Learn more about &lt;a href="https://angular.io/guide/architecture-modules" rel="noopener noreferrer"&gt;Angular Modules&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Component
&lt;/h4&gt;

&lt;p&gt;Components define views, which are sets of screen elements that Angular can choose among and modify according to your program logic and data. Every component consists of a selector, template, and style. Template and style can be inline or separate files.&lt;/p&gt;

&lt;p&gt;Learn more about &lt;a href="https://angular.io/guide/architecture-components" rel="noopener noreferrer"&gt;Angular components&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Services and DI
&lt;/h4&gt;

&lt;p&gt;Components use services, which provide specific functionality not directly related to views. Service providers can be injected into components as dependencies, making your code modular, reusable, and efficient.&lt;/p&gt;

&lt;p&gt;You can have sharable methods and data into services.&lt;/p&gt;

&lt;p&gt;Learn more about &lt;a href="https://angular.io/guide/architecture-services" rel="noopener noreferrer"&gt;Angular Services&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Routing
&lt;/h4&gt;

&lt;p&gt;Angular Routing helps to control navigation paths of an application.&lt;br&gt;
which helps to retain the application state as well.&lt;/p&gt;

&lt;p&gt;Learn more about &lt;a href="https://angular.io/guide/router" rel="noopener noreferrer"&gt;Angular Routings&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Directive
&lt;/h4&gt;

&lt;p&gt;Angular templates are dynamic. When Angular renders them, it transforms the DOM according to the instructions given by directives. A directive is a class with a @Directive() decorator.&lt;/p&gt;

&lt;p&gt;A component is technically a directive. However, components are so distinctive and central to Angular applications that Angular defines the @Component() decorator, which extends the @Directive() decorator with template-oriented features&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structural directives&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Structural directives alter layout by adding, removing, and replacing elements in the DOM. For Example *ngFor, *ngIf, *ngSwitch and so on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://angular.io/guide/structural-directives" rel="noopener noreferrer"&gt;Angular structural directives&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Attribute directives&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Attribute directives alter the appearance or behavior of an existing element. In templates they look like regular HTML attributes, hence the name. For example &lt;strong&gt;[style.color], [color], [(ngModel)] and so on&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://angular.io/guide/attribute-directives" rel="noopener noreferrer"&gt;Angular Attribute directives&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Lifecycle Hooks
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A component has a lifecycle managed by angular.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Angular creates it, renders it, creates and renders its children, checks it when its data-bound properties change and destroys it before removing it from the DOM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Angular offers lifecycle hooks that provide visibility into these key life moments and the ability to act when they occur.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Lifecycle sequence
&lt;/h4&gt;

&lt;p&gt;After creating a component/directive by calling its constructor, Angular calls the lifecycle hook methods in the following sequence at specific moments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ngOnChanges()&lt;/li&gt;
&lt;li&gt;ngOnInit()&lt;/li&gt;
&lt;li&gt;ngDoCheck()&lt;/li&gt;
&lt;li&gt;ngAfterContentInit()&lt;/li&gt;
&lt;li&gt;ngAfterContentChecked()&lt;/li&gt;
&lt;li&gt;ngAfterViewInit()&lt;/li&gt;
&lt;li&gt;ngAfterViewChecked()&lt;/li&gt;
&lt;li&gt;ngOnDestroy()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Learn More about &lt;a href="https://angular.io/guide/lifecycle-hooks" rel="noopener noreferrer"&gt;Angular Lifecycle&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  File Structure
&lt;/h3&gt;

&lt;p&gt;You can see that your angular application has dozens of files and folders. lets see what is the purpose of them.&lt;/p&gt;

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

&lt;p&gt;the e2e folder has all unit test files and you should write unit testing inside this dir only.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src/app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This folder contains all our application codes such as components, services and so on.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src/asset&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This folder is for asset files such as images, fonts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src/environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is for environment configurations such as Devopment mode, Production mode.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src/polyfills&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All browser compatibility stuff lies here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src/style.css&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This style file is common for entire angular application. if you want to define a style for the whole app, you can do here, such as theming styles.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src/karma&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The unit testing configuration file&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;package.json&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Package.json contains all npm and script related stuff&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;angular.json&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This file contains meta related to the angular application&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.typescriptlang.org/docs/handbook/tsconfig-json.html" rel="noopener noreferrer"&gt;tsconfig.json&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compiler Configuration for TypeScript&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/tslint" rel="noopener noreferrer"&gt;tslint.json&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linter Configurations&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://editorconfig.org/" rel="noopener noreferrer"&gt;editorconfig&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EditorConfig helps maintain consistent coding styles for multiple developers&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Diving
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Components Communication
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Parent -&amp;gt; Child Via @Input&lt;/li&gt;
&lt;li&gt;Child -&amp;gt; Parent Via @ViewChild&lt;/li&gt;
&lt;li&gt;Child -&amp;gt; Parent Via @Output EventEmitters&lt;/li&gt;
&lt;li&gt;Child &amp;lt;-&amp;gt; Parent Via with Service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://angularfirebase.com/lessons/sharing-data-between-angular-components-four-methods/" rel="noopener noreferrer"&gt;Sharing Data Between Angular Components - Four Methods&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Pipes
&lt;/h4&gt;

&lt;p&gt;Angular pipes let you declare display-value transformations in your template HTML. A class with the @Pipe decorator defines a function that transforms input values to output values for display in a view.&lt;/p&gt;


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

&lt;p&gt;&lt;span class="c"&gt;&amp;lt;!-- Default format: output 'Jun 15, 2015'--&amp;gt;&lt;/span&gt;&lt;br&gt;
 &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Today is {{today | date}}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;&amp;lt;!-- fullDate format: output 'Monday, June 15, 2015'--&amp;gt;&lt;/span&gt;&lt;br&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;The date is {{today | date:'fullDate'}}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;&amp;lt;!-- shortTime format: output '9:43 AM'--&amp;gt;&lt;/span&gt;&lt;br&gt;
 &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;The time is {{today | date:'shortTime'}}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/p&gt;

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

&lt;/div&gt;
&lt;h4&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Data Binding&lt;br&gt;
&lt;/h4&gt;

&lt;p&gt;One way data binding from Component to View&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://angular.io/guide/displaying-data#interpolation" rel="noopener noreferrer"&gt;Interpolation&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://angular.io/guide/template-syntax#property-binding" rel="noopener noreferrer"&gt;Property Binding&lt;/a&gt; - []&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One way data binding from View to Component&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://angular.io/guide/user-input#binding-to-user-input-events" rel="noopener noreferrer"&gt;Event Binding&lt;/a&gt; - ()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two-way data binding between Component to View&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://angular.io/api/forms/NgModel" rel="noopener noreferrer"&gt;ngModel Directive&lt;/a&gt; [()]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's it. These are the most important topics of MEAN Stack, Please feel free to rise a &lt;a href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/issues" rel="noopener noreferrer"&gt;issue&lt;/a&gt; or &lt;a href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; if anything is missing or any correction required.&lt;/p&gt;

&lt;p&gt;Now go and Practice.&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%2Fj3s8bz5se8ql2tgfoycp.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%2Fuploads%2Farticles%2Fj3s8bz5se8ql2tgfoycp.gif" alt="practice cat"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>angular</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create Extensions for VS Code- Part 2</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Mon, 24 Jun 2019 10:25:30 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/create-extensions-for-vs-code-part-2-1gj7</link>
      <guid>https://forem.com/thamaraiselvam/create-extensions-for-vs-code-part-2-1gj7</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is the second part of the &lt;strong&gt;Create Extension for VS Code&lt;/strong&gt; series. You can also read the first part in  &lt;a href="https://thamaraiselvam.com/create-extensions-for-vs-code-part-1-cjx5r238f000t65s1ag0fdn8e" rel="noopener noreferrer"&gt;My Dev Blog&lt;/a&gt; , or in  &lt;a href="https://dev.to/thamaraiselvam/create-extensions-for-vs-code-part-1-10o0"&gt;dev.to&lt;/a&gt; :&lt;/p&gt;

&lt;p&gt;In the first part, we learned how to create a simple &lt;strong&gt;Hello World Extension&lt;/strong&gt; and the basic understanding file structure of extension.&lt;/p&gt;

&lt;p&gt;In Part 2, We will go a little deeper and learn the most common extension feature  such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating Menus&lt;/li&gt;
&lt;li&gt;Creating Settings (Configurations)&lt;/li&gt;
&lt;li&gt;Defining Keyboard Shortcuts (KeyBinding)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Come on Let's dive into it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/NqZn5kPN8VVrW/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/NqZn5kPN8VVrW/giphy.gif" alt="dive"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Menus
&lt;/h3&gt;

&lt;p&gt;Creating menus for the extension is pretty simple. The menu consists of three properties such as &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;command&lt;/code&gt; - The command (action) which gets executed on the click&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt; - Display name for the menu&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;category&lt;/code&gt; - Just groupings for the menus.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Define menus in &lt;strong&gt;&lt;em&gt;package.json -&amp;gt; contributes -&amp;gt; commands&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Snippet
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"commands": [
    {
        "command": "extension.helloWorld",
        "title": "Say Hello World",
        "category": "Demo"
    }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Demo
&lt;/h4&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561366700516%2Fa4OspZpaN.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561366700516%2Fa4OspZpaN.gif" alt="menu.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Settings (Configurations)
&lt;/h3&gt;

&lt;p&gt;The setting has the following properties.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;properties -&amp;gt; Key&lt;/code&gt; - An unique key which will be used to set/get values.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type&lt;/code&gt;  - Data Type for the setting.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;default&lt;/code&gt;  - It will be set as the default value on the plugin activation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;description&lt;/code&gt;  - This note will be shown under the setting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Define settings in  &lt;strong&gt;&lt;em&gt;package.json -&amp;gt; contributes  -&amp;gt; configuration&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Snippet
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"configuration": {
    "title": "Hello World configuration",
    "properties": {
        "hello-world.customMessage": {
            "type": "string",
            "default": "Hello World",
            "description": "This message will be show on menu click"
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Get current Value
&lt;/h4&gt;

&lt;p&gt;We can get the current value of settings in &lt;code&gt;Extension.ts&lt;/code&gt; with the help of &lt;code&gt;vscode.workspace&lt;/code&gt;  object and unique key (&lt;code&gt;hello-world.customMessage&lt;/code&gt;) which is mentioned on &lt;strong&gt;package.json&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const msg = vscode.workspace.getConfiguration().get('hello-world.customMessage');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Demo
&lt;/h4&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561368986348%2FG4-tWm4Mt.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561368986348%2FG4-tWm4Mt.gif" alt="setting.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining Keyboard Shortcuts (KeyBinding)
&lt;/h3&gt;

&lt;p&gt;We can trigger an action of our extension on specific keyboard shortcuts which is known as keybinding.&lt;/p&gt;

&lt;p&gt;It has two properties they are,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Command - Action needs to be triggered&lt;/li&gt;
&lt;li&gt;Key - Combination of keys&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Define keybinding in  &lt;strong&gt;&lt;em&gt;package.json -&amp;gt; contributes  -&amp;gt; keybindings&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Snippet
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;helloWorld&lt;/code&gt; action will be executed on the keybinding of &lt;strong&gt;Ctrl+Shift+A  + Ctrl+Shift+Z&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"keybindings": [
    {
        "command": "extension.helloWorld",
        "key": "Ctrl+Shift+A Ctrl+Shift+Z"
    },
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Demo
&lt;/h4&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561370165271%2Fz9VK52En0.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561370165271%2Fz9VK52En0.png" alt="keybinding.PNG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have learned the most common extension features !!! 🎉🎉🎉🎉🎉&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/7SfAXqgRgh0li/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/7SfAXqgRgh0li/giphy.gif" alt="dance1"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In the next part, We will see how to build and publish our extension on  &lt;a href="https://marketplace.visualstudio.com/vscode" rel="noopener noreferrer"&gt;Visual Studio Marketplace&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;p&gt;Please provide your Feedbacks and comments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/13mQQzQF7fUD3q/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/13mQQzQF7fUD3q/giphy.gif" alt="feedback"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>typescript</category>
      <category>tutorial</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Create Extensions for VS Code - Part 1</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Fri, 21 Jun 2019 07:31:50 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/create-extensions-for-vs-code-part-1-10o0</link>
      <guid>https://forem.com/thamaraiselvam/create-extensions-for-vs-code-part-1-10o0</guid>
      <description>&lt;p&gt;I wanted to develop a *&lt;em&gt;VS Code extension *&lt;/em&gt; to solve one of my daily problems, so I started to look at  &lt;a href="https://code.visualstudio.com/api" rel="noopener noreferrer"&gt;VS Code API&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;They have really awesome documentation and sample extensions which are really helpful.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I could run my first Hello world extension in less than 5 minutes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is very easy and super simple, come on let's see how to develop one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Install the following Node modules for Kick Starting new extension &lt;a href="https://yeoman.io/" rel="noopener noreferrer"&gt;Yeoman &lt;/a&gt;  and  &lt;a href="https://www.npmjs.com/package/generator-code" rel="noopener noreferrer"&gt;VS Code Extension Generator &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -g yo generator-code&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create New Extension
&lt;/h3&gt;

&lt;p&gt;Execute this command  &lt;code&gt;yo code&lt;/code&gt;  and select New Extension -Typescript (Which is most recommended one) to create a new extension then answer questions. It will create a Hello World *&lt;em&gt;boilerplate *&lt;/em&gt; and also Install required node modules.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561096703338%2F0BeEQrUoe.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561096703338%2F0BeEQrUoe.png" alt="yo code.PNG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Extension File Structure
&lt;/h4&gt;

&lt;p&gt;This auto-generated extension has dozen of files, refer following images to know more about file structure.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561097102805%2FUxir8exLD.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1561097102805%2FUxir8exLD.png" alt="atonomy.PNG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But we are going to focus on only two files in major which are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src/exntension.ts&lt;/li&gt;
&lt;li&gt;package.json&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Run Extension
&lt;/h3&gt;

&lt;p&gt;Running extension is pretty simple, Just go to debug menu from the left side menu or hit  &lt;code&gt;Ctrl+Shift+D&lt;/code&gt;  keybinding, Then click &lt;strong&gt;Run Extension&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It will open a new window where your extension will be running, To confirm that you can see "Hello World" on the right bottom.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/OVXDh4cOaLawM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/OVXDh4cOaLawM/giphy.gif" alt="Tada"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Okay, But How Does it work?
&lt;/h3&gt;

&lt;p&gt;VS code Extension is all event-based, we need to define all our commands (actions) in package.json&lt;/p&gt;

&lt;h4&gt;
  
  
  Package.json
&lt;/h4&gt;

&lt;p&gt;you can *&lt;em&gt;package.json *&lt;/em&gt; files in the root dir, which holds the all the events inside of &lt;code&gt;contributes&lt;/code&gt;  -&amp;gt; &lt;code&gt;commands&lt;/code&gt;, In this case, we have only one command which is &lt;code&gt;extension.helloWorld&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"contributes": {
        "commands": [
            {
                "command": "extension.helloWorld",
                "title": "Hello World"
            }
        ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We enable our events by adding our commands into &lt;code&gt;activationEvents&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"activationEvents": [
    "onCommand:extension.helloWorld"
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;main&lt;/code&gt; property holds file path which will be executed at first, once the extension is activated&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"main": "./out/extension.js"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Extension.ts
&lt;/h4&gt;

&lt;p&gt;Good to see that, this file has very detailed comments for better understanding.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;function activate(context: vscode.ExtensionContext)&lt;/code&gt; - This Function executed at first when extension gets activated and our all business logic will lie here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;vscode.commands.registerCommand('extension.helloWorld', () =&amp;gt; {})&lt;/code&gt; - Registering &lt;code&gt;extension.helloWorld&lt;/code&gt; event with callback function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;vscode.window.showInformationMessage('Hello World!');&lt;/code&gt;  - It makes message box on the right bottom&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, we should push our registered command into &lt;code&gt;context.subscriptions&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Congratulations for your first vs code extension *&lt;/em&gt; 🎉🎉🎉🎉🎉&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/apdfsXZENhMsM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/apdfsXZENhMsM/giphy.gif" alt="Made it"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next article, I will explain how to implement the most common extension feature such as menus, settings, keybindings and status message bar.&lt;/p&gt;

&lt;p&gt;If you have any issues or question please comment, I am glad to help you :D&lt;/p&gt;

&lt;p&gt;Thank you !!!&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%2Frqju5jpgzeaumpoduudl.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%2Fuploads%2Farticles%2Frqju5jpgzeaumpoduudl.gif" alt="Thank you"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article originally published on &lt;a href="https://thamaraiselvam.com/create-extensions-for-vs-code-part-1-cjx5r238f000t65s1ag0fdn8e" rel="noopener noreferrer"&gt;Hashnode&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Read Part two on  &lt;a href="https://thamaraiselvam.com/create-extensions-for-vs-code-part-2-cjxa87y7t001mvzs11rgng6th" rel="noopener noreferrer"&gt;Dev Blog&lt;/a&gt;  or in  &lt;a href="https://dev.to/thamaraiselvam/create-extensions-for-vs-code-part-2-1gj7"&gt;Dev.to&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>vscode</category>
      <category>typescript</category>
      <category>tutorial</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Configure Xdebug + PHP 7 + Nginx + Any Linux Distribution</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Tue, 30 Apr 2019 03:20:14 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/configure-xdebug-php-7-nginx-any-linux-distribution-3ic0</link>
      <guid>https://forem.com/thamaraiselvam/configure-xdebug-php-7-nginx-any-linux-distribution-3ic0</guid>
      <description>&lt;p&gt;Xdebug deepens debugging PHP apps and websites to a level you can’t receive from the manual process of using code level&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var_dump()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get your php.ini
&lt;/h3&gt;

&lt;p&gt;Next output your php.ini information into a file or place you can get the information from. I like to save mine to a file called &lt;strong&gt;php-info.txt&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo php -i &amp;gt; ~/php-info.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use the Xdebug Wizard
&lt;/h3&gt;

&lt;p&gt;Send the text file information into the wizard at Xdebug Wizard. Then follow the instructions the wizard supplies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install php-xdebug
&lt;/h3&gt;

&lt;p&gt;This will connect the php with xdebug to the editor also you can configure like editors and remote configurations.&lt;/p&gt;

&lt;h4&gt;
  
  
  Debian based distributions( Debian, Ubuntu, Linux Mint)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install php-xdebug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Arch Linux
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo pacman -Sy xdebug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Edit xdebug.ini
&lt;/h3&gt;

&lt;p&gt;Now edit the &lt;strong&gt;xdebug.ini&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/php/7.0/mods-available/xdebug.ini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then paste the following configuration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9005 #this can be modified
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Restart the services
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Configure the editor
&lt;/h3&gt;

&lt;p&gt;In my case, I am using Sublime Text 3 so installed xdebug package using package control&lt;/p&gt;

&lt;p&gt;Restart the sublime text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;That’s all. You have configured Xdebug successfully !!!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have any issues, Just comment below&lt;/p&gt;

&lt;p&gt;this article originally published on &lt;a href="https://thamaraiselvam.com/configure-xdebug-php-7-nginx-any-linux-distribution-cjutjwkqh001ssns1f53yt2ez"&gt;Hashnode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>debugging</category>
      <category>linux</category>
      <category>xdebug</category>
    </item>
    <item>
      <title>Singly LinkedList - Learn and Implement Data Structure in JS : Part 1</title>
      <dc:creator>Thamaraiselvam</dc:creator>
      <pubDate>Fri, 26 Apr 2019 12:27:19 +0000</pubDate>
      <link>https://forem.com/thamaraiselvam/singly-linkedlist-learn-and-implement-data-structure-in-js-part-1-21kh</link>
      <guid>https://forem.com/thamaraiselvam/singly-linkedlist-learn-and-implement-data-structure-in-js-part-1-21kh</guid>
      <description>&lt;p&gt;The problem is that many of the people trying to learn data structures but not implementing them.&lt;/p&gt;

&lt;p&gt;People start worrying about data structures. This occurs because everyone has heard that a good knowledge of data structures is important for technical interviews and so people get obsessed with trying to learn these topics. They don't realize they'd be better served by implementing them rather than just read about it.&lt;/p&gt;

&lt;p&gt;So I have started this series to focus on each data structure and how to implement them in Javascript.&lt;/p&gt;

&lt;p&gt;In this article, we will be implementing a **Singly LinkedList **data structure in Javascript. &lt;/p&gt;

&lt;h3&gt;
  
  
  What is Singly Linked List
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;A linked list is a linear data structure, in which we can add or remove elements at ease, and it can even grow as needed. Just like arrays, but elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers.&lt;/p&gt;
&lt;/blockquote&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1556185078570%2F8dYXQPl7w.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1556185078570%2F8dYXQPl7w.png" alt="single linked list.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Singly Linked List
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Node {
    constructor(element) {
        this.element = element;
        this.next = null;
    }
}

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

&lt;/div&gt;



&lt;p&gt;As in the code above, we have two properties &lt;code&gt;elements&lt;/code&gt; which holds the data of the current node and &lt;code&gt;next&lt;/code&gt; holds the pointer (address) of the next node which initialized to &lt;code&gt;null&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SinglyLinkedList {
    constructor() {
        this.head = null;
    }
}

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

&lt;/div&gt;



&lt;p&gt;Above code shows a SinglyLinkedList class with constructor, the Linked list has a property called &lt;strong&gt;&lt;code&gt;head&lt;/code&gt; which will hold the first node of the linked list&lt;/strong&gt;**.&lt;/p&gt;

&lt;h4&gt;
  
  
  Adding element into list
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add(element) {
    //create new node
    let node = new Node(element);

    let current = null;

    //If head is empty then insert at first item
    if (this.head == null) {
        this.head = node;
    } else {
        current = this.head;

        //iterate to end of list
        while (current.next) {
            current = current.next;
        }


        //Finally add new node
        current.next = node;
    }

    this.size++;
}

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

&lt;/div&gt;



&lt;p&gt;In order to add an element, in the end, we should consider the following :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the list is empty then add an element and it will be head&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the list is not empty then iterate to end of the list then add an element to end of the list.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Removing element from the list
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;removeElement(element) {
    if (this.head === null) {
        throw Error ('List is empty');
    }

    let current = this.head;
    let prev = null;

    //Iterate over the list
    while (current != null) {

        if (current.element === element) {
            //If prev node is null then first node is required element
            if (prev === null) {
                this.head = current.next;
            } else {
                //if prev node found then unset current node
                prev.next = current.next;
            }

            return current.element;
        }

        prev = current;

        //iterate to next node
        current = current.next;
    }
    return 'Element not found';
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;this.head === null&lt;/code&gt; If List is empty then throw an error `&lt;/li&gt;
&lt;li&gt; while (current != null)` Iterate list till find the element&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev === null&lt;/code&gt; If &lt;code&gt;prev node&lt;/code&gt; is null then first node is required element so make second node as head&lt;/li&gt;
&lt;li&gt;If prev node is found then &lt;code&gt;prev.next = current.next&lt;/code&gt; detach current node from list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's it we have covered basics of Singly LinkedList. &lt;/p&gt;

&lt;h3&gt;
  
  
  Unit Test
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var assert = require('assert');
const LinkedList = require('./single.linkedlist');

describe('Single Linked List', () =&amp;gt;{

    const linkedList = new LinkedList();
    it('Should add an element', () =&amp;gt;{
        linkedList.add(10);
        let result = linkedList.get('list');
        assert.equal(JSON.stringify(result), '{"element":10,"next":null}')
    })

    it('Should add two element', () =&amp;gt;{
        linkedList.add(20);
        linkedList.add(30);
        let result = linkedList.get('list');
        assert.equal(JSON.stringify(result), '{"element":10,"next":{"element":20,"next":{"element":30,"next":null}}}')
    })

    it('Should remove an element', () =&amp;gt;{
        linkedList.removeElement(20);
        let result = linkedList.get('list');
        assert.equal(JSON.stringify(result), '{"element":10,"next":{"element":30,"next":null}}')
    })
})

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

&lt;/div&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1556187182742%2FdJmGVWgZ0.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1556187182742%2FdJmGVWgZ0.png" alt="Capture.PNG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check  &lt;a href="https://github.com/thamaraiselvam/data-structures" rel="noopener noreferrer"&gt;Github Repo &lt;/a&gt; for full source code.&lt;/p&gt;

&lt;p&gt;Stay Tuned for the next story.&lt;/p&gt;

&lt;p&gt;This article published on &lt;a href="https://thamaraiselvam.com/learn-and-implement-data-structure-in-js-part-1-singly-linkedlist-cjuwiew21000wyus1lxkr0lnk" rel="noopener noreferrer"&gt;Hashnode&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
