<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Thamaraiselvam's Blog]]></title><description><![CDATA[Thamaraiselvam's Blog]]></description><link>https://thamaraiselvam.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 05:12:25 GMT</lastBuildDate><atom:link href="https://thamaraiselvam.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Terminal Enhancers - Part 1]]></title><description><![CDATA[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 seri...]]></description><link>https://thamaraiselvam.dev/terminal-enhancers-part-1</link><guid isPermaLink="true">https://thamaraiselvam.dev/terminal-enhancers-part-1</guid><category><![CDATA[Productivity]]></category><category><![CDATA[terminal]]></category><category><![CDATA[Developer Tools]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Mon, 24 Aug 2020 05:25:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1597590352012/aJ9_idHE0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>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. </p>
<p>Here is my terminal setup:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1597585628615/wuQdnmIVw.png" alt="Screenshot 2020-08-16 at 7.17.00 PM.png" /></p>
<p>In the first part, we are going to talk about the top 5 tools (my personal choice)</p>
<ul>
<li>Alacritty</li>
<li>Oh My ZSH!</li>
<li>Tmux</li>
<li>Starship</li>
<li>Pet</li>
</ul>
<h1 id="alacrittyhttpsgithubcomalacrittyalacritty"><a target="_blank" href="https://github.com/alacritty/alacritty">Alacritty</a></h1>
<p>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.</p>
<p>Its GitHub page describes as follows, so do I.</p>
<blockquote>
<p>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. </p>
</blockquote>
<p>I was a fan of Iterm multi panes but after started using alacritty + tmux, now I barely open iTerm on my machine.</p>
<h2 id="why-alacritty-is-better"><strong>WHY Alacritty is better:</strong></h2>
<ul>
<li>Faster: It is written in rust with the philosophy of focusing on speed. Alacritty is one of the fastest terminal emulators out there.</li>
<li>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.</li>
<li>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.</li>
</ul>
<h2 id="how-to-install">How to Install:</h2>
<p>Simply install with <code>brew</code> for mac</p>
<pre><code><span class="hljs-attribute">brew</span> cask install alacritty
</code></pre><p>Refer official  <a target="_blank" href="https://github.com/alacritty/alacritty/blob/master/INSTALL.md">installation guide</a>  for other operating systems </p>
<p>by default, alacritty does not create a config file. you can take  <a target="_blank" href="https://github.com/alacritty/alacritty/blob/master/alacritty.yml">default config file</a> from GitHub or here is my <a target="_blank" href="https://github.com/thamaraiselvam/dotfiles/blob/master/alacritty/alacritty.yml">config file</a>. </p>
<p>create one on this location for alacritty to read it.</p>
<pre><code>~<span class="hljs-regexp">/.config/</span>alacritty/alacritty.yml
</code></pre><h1 id="oh-my-zshhttpsohmyzsh"><a target="_blank" href="https://ohmyz.sh/">Oh My ZSH!</a></h1>
<p>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.</p>
<h2 id="so-why-use-it">So Why use it?</h2>
<p>Zsh has so many features but here are some of the major ones.</p>
<ul>
<li>Automatic cd: Just type name of the directory</li>
<li>Recursive path expansion: For example “/u/lo/b” expands to “/usr/local/bin”</li>
<li>Spelling correction and approximate completion: If you make a minor mistake typing a directory name, ZSH will fix it for you</li>
<li>Plugin and theme support: ZSH includes many different plugin frameworks</li>
</ul>
<p>plugins and themes support is probably the coolest feature of ZSH.</p>
<h2 id="installing-zsh">Installing ZSH</h2>
<p>If you're on Mac, use <code>brew</code></p>
<pre><code><span class="hljs-attribute">brew</span> install zsh
</code></pre><p>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  <a target="_blank" href="https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH">this guide</a>  if you’re having trouble.</p>
<p>If you’re on Windows, you may not even have Bash in the first place. You can follow  <a target="_blank" href="https://www.howtogeek.com/258518/how-to-use-zsh-or-another-shell-in-windows-10/">this guide</a>  to set that up and enable ZSH.</p>
<h2 id="installing-oh-my-zsh">Installing Oh-My-Zsh</h2>
<blockquote>
<p>Your terminal never felt this good before.</p>
</blockquote>
<p> <a target="_blank" href="https://github.com/robbyrussell/oh-my-zsh">Oh-My-Zsh</a> is a famous framework for managing plugins for ZSH and it comes with plenty of plugins and themes as well.</p>
<p>oh-my-zsh has simple install script you can run</p>
<pre><code>sh -<span class="hljs-built_in">c</span> <span class="hljs-string">"$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"</span>
</code></pre><p>Read more about zsh <a target="_blank" href="https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins">plugins</a>  and  <a target="_blank" href="https://github.com/ohmyzsh/ohmyzsh/wiki/Themes">themes</a> </p>
<h1 id="tmuxhttpsgithubcomtmuxtmuxwikigetting-started"><a target="_blank" href="https://github.com/tmux/tmux/wiki/Getting-Started">tmux</a></h1>
<p>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.</p>
<p>here is an example of multiple panes in a single window.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1597674525646/HleIPrMJL.png" alt="image.png" /></p>
<h2 id="so-why-use-it">So Why use it?</h2>
<ul>
<li><strong>Session management:</strong> 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. </li>
<li><strong>Platform independence:</strong>  I can use tmux on my Macbook, my Linux notebook, Cloud servers, Raspberry Pis, BeagleBones, etc.</li>
<li><strong> customizable:</strong> There are many ways that I can customize the look and behavior of my tmux and sync this across different platforms using dotfiles.</li>
</ul>
<h2 id="installing-tmux">Installing Tmux</h2>
<p>Fortunately installing tmux is pretty straightforward on most distributions a simple <code>sudo apt-get install tmux</code> (Ubuntu and derivatives) or <code>brew install tmux</code> (Mac) should be sufficient.</p>
<p>Tmux has a prefix key to trigger functions by default it is <code>ctrl+b</code> but most of the people change it to <code>ctrl+a</code> here is my tmux  <a target="_blank" href="https://github.com/thamaraiselvam/dotfiles/blob/master/tmux/.tmux.conf">config file</a> </p>
<p>The learning curve of tmux little bit steep but worth learning, you can learn more about tmux  <a target="_blank" href="https://linuxize.com/post/getting-started-with-tmux/">here</a> </p>
<h1 id="starshiphttpsstarshiprs"><a target="_blank" href="https://starship.rs/">Starship</a></h1>
<p>Starship is a <strong>cross shell prompt</strong> 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.</p>
<blockquote>
<p> it is minimal, blazing-fast, and infinitely customizable prompt for any shell! </p>
</blockquote>
<h2 id="so-why-use-it">So Why use it?</h2>
<ul>
<li>It saves tons of time and minimizes human errors</li>
<li>It is very easy to install and  customize</li>
<li>Works on most of the popular shell </li>
<li>Extremely faster</li>
</ul>
<p>here is the demo video of the starship</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1598084238079/4OnH07waY.gif" alt="ezgif-6-ac378aebf3d7.gif" /></p>
<p> <a target="_blank" href="https://starship.rs/#quick-install">here is quick install guide from official page</a> </p>
<h1 id="pethttpsgithubcomknqyf263pet"><a target="_blank" href="https://github.com/knqyf263/pet">PET</a></h1>
<p>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.</p>
<blockquote>
<p>Pet is a command-line snippet manager</p>
</blockquote>
<p>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.</p>
<h2 id="so-why-use-it">So Why use it?</h2>
<ul>
<li>Register your command snippets easily.</li>
<li>Use variables in snippets.</li>
<li>Search snippets interactively.</li>
<li>Run snippets directly.</li>
<li>Edit snippets easily (config is just a TOML file).</li>
<li>Sync snippets via Gist or GitLab Snippets automatically.</li>
</ul>
<h2 id="how-to-install">How to install?</h2>
<p>You can use homebrew on OS X.</p>
<pre><code>$ brew install knqyf263/pet/pet
</code></pre><p>Debian, Ubuntu</p>
<p>Download deb package from the releases page</p>
<pre><code>$ wget <span class="hljs-symbol">https:</span>/<span class="hljs-regexp">/github.com/knqyf</span>263/pet/releases/download/v<span class="hljs-number">0</span>.<span class="hljs-number">3.0</span>/pet_<span class="hljs-number">0</span>.<span class="hljs-number">3.0_</span>linux_amd64.deb
dpkg -i pet_<span class="hljs-number">0</span>.<span class="hljs-number">3.0_</span>linux_amd64.deb
</code></pre><h2 id="how-to-use">How to use?</h2>
<p>These are available pet commands. </p>
<pre><code>$ pet <span class="hljs-comment">--help</span>
pet - Simple command-line snippet manager.

Usage:
  pet [command]

Available Commands:
  configure   Edit config file
  edit        Edit snippet file
  exec        Run the selected commands
  <span class="hljs-keyword">help</span>        <span class="hljs-keyword">Help</span> about <span class="hljs-keyword">any</span> command
  <span class="hljs-keyword">list</span>        <span class="hljs-keyword">Show</span> all snippets
  <span class="hljs-keyword">new</span>         <span class="hljs-keyword">Create</span> a <span class="hljs-keyword">new</span> snippet
  <span class="hljs-keyword">search</span>      <span class="hljs-keyword">Search</span> snippets
  <span class="hljs-keyword">sync</span>        <span class="hljs-keyword">Sync</span> snippets
  <span class="hljs-keyword">version</span>     Print the <span class="hljs-keyword">version</span> <span class="hljs-built_in">number</span>
</code></pre><p>Pet commands are very easy to use but you can make a lot easier by following the below steps.</p>
<h3 id="prev-command"><code>prev</code> command</h3>
<p>Instead of using <code>pet new</code>, you can configure <code>prev</code> command with  <a target="_blank" href="https://github.com/knqyf263/pet#register-the-previous-command-easily">this guide </a>, thereafter just enter the command <code>prev</code> to save your last executed command into the pet.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1598085985296/JXEX-IEqU.gif" alt="pet02.gif" /></p>
<h3 id="select-snippets-at-the-current-line-like-c-r">Select snippets at the current line (like C-r)</h3>
<p>Rather than using <code>pet search</code> command every time,  you can simply assign a keybinding for it using  <a target="_blank" href="https://github.com/knqyf263/pet#select-snippets-at-the-current-line-like-c-r">this guide</a></p>
<h3 id="sync-with-gist">Sync with Gist</h3>
<p>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 <code>pet configure</code> and set <code>auto_sync</code> to true. <a target="_blank" href="https://github.com/knqyf263/pet#sync-snippets">Read more about pet sync</a> </p>
<p>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. </p>
]]></content:encoded></item><item><title><![CDATA[Synchronous Vs Asynchronous Database Replication]]></title><description><![CDATA[In the last two articles, we have seen the need for database replication and master-replica architecture and in this article, we will discuss the different type of database replications.
We know that all write requests go to the master and all read r...]]></description><link>https://thamaraiselvam.dev/synchronous-vs-asynchronous-database-replication</link><guid isPermaLink="true">https://thamaraiselvam.dev/synchronous-vs-asynchronous-database-replication</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Databases]]></category><category><![CDATA[distributed system]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Tue, 11 Feb 2020 18:01:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1581442608654/FEwSKd-2Y.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the last two articles, we have seen <a target='_blank' rel='noopener noreferrer'  href="https://thamaraiselvam.dev/the-need-for-database-replication-ck63ymuc202q289s1e79s3tgw">the need for database replication</a> and <a target='_blank' rel='noopener noreferrer'  href="https://thamaraiselvam.dev/database-replication-master-slave-replication-architecture-ck66skn6r03r8kbs16egqnzvg">master-replica architecture</a> and in this article, we will discuss the different type of database replications.</p>
<p>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&#39;s see what are the different types of replication strategies out there and how are they addressing consistency issues. </p>
<p>There are three types of replication methods, they are</p>
<ul>
<li>Synchronous replication</li>
<li>Asynchronous replication</li>
<li>Semi-synchronous replication</li>
</ul>
<h3 id="synchronous-replication-">Synchronous replication:</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1581441255048/FRNLgdzkv.png" alt="Webp.net-resizeimage (5).png"></p>
<p>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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1581439839301/upaWE_t0J.png" alt="Webp.net-resizeimage (4).png"></p>
<p>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.</p>
<p>Replicas receive the changes in T3 and T4 and populate data changes but that time master will be waiting for replica&#39;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&#39;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.</p>
<p>you also can easily see that the problem is Time. From time T2 to t7 master is just waiting for replica&#39;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.</p>
<h3 id="asynchronous-replication-">Asynchronous replication:</h3>
<p>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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1581441387628/EqVYwWBmf.png" alt="Webp.net-resizeimage (6).png"></p>
<p>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.</p>
<p>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</p>
<p>our problem is that if the master fails before it sends the request to replicas then we lost the changes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1581441616407/QQ4-lTU6i.png" alt="Webp.net-resizeimage (7).png"></p>
<p>Yes, it may be totally fine to take the risk, but think about dealing with financial transactions? it is a nightmare.</p>
<p>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.</p>
<h3 id="semi-synchronous-replication-">Semi-synchronous replication:</h3>
<p>There&#39;s some middle ground, We can define some replicas to replicate synchronously and others just use asynchronous manner. this is called Semi-synchronous replication</p>
<h3 id="when-to-use-what">When to use what</h3>
<p>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.</p>
<p>In the next article, we will talk about How to create database replication architecture for the Postgres database.</p>
]]></content:encoded></item><item><title><![CDATA[Database Replication: Master-Slave Replication Architecture]]></title><description><![CDATA[Recently I have started writing about database replication, In the first article I have explained the need for database replication if you have not read yet, I recommend you to read Need for Database Replication before continuing this. We will discus...]]></description><link>https://thamaraiselvam.dev/database-replication-master-slave-replication-architecture</link><guid isPermaLink="true">https://thamaraiselvam.dev/database-replication-master-slave-replication-architecture</guid><category><![CDATA[Databases]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Developer]]></category><category><![CDATA[distributed system]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Mon, 03 Feb 2020 18:32:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1580754731961/dypcqrla1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Recently I have started writing about database replication, In the first article I have explained <strong>the need for database replication</strong> if you have not read yet, I recommend you to read <a target='_blank' rel='noopener noreferrer'  href="https://thamaraiselvam.dev/the-need-for-database-replication-ck63ymuc202q289s1e79s3tgw">Need for Database Replication</a> before continuing this. We will discuss Master-Slave replication architecture in this article.</p>
<blockquote>
<p>Master-Slave architecture also called Active-Passive or Active-Standby or Leader based replication architecture</p>
</blockquote>
<p>The database request can be two types such as,</p>
<ul>
<li>Write request (Insertion, deletion, and updation)</li>
<li>Read request </li>
</ul>
<p><em>Note: I replaced all words slave with replica since it can be considered as <a target='_blank' rel='noopener noreferrer'  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">offensive</a></em> :p</p>
<h3 id="simple-master-replica-architecture">Simple Master-Replica Architecture</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1580748641192/BVzvK_v4k.png" alt="Webp.net-resizeimage (1).png"></p>
<p>Above diagram is the simple master-replica architecture contains one master and two replicas</p>
<p><strong>Basically master replicates the database into multiple copies(also called replicas) through the replication stream.</strong></p>
<p>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 <strong>replication lag</strong></p>
<h3 id="avoid-downtime-using-replicas">Avoid downtime using replicas</h3>
<p>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.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1580752780371/rR2L78t_6.png" alt="Webp.net-resizeimage (2).png"></p>
<p>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.</p>
<p>In this way, replicas can be used to achieve high availability database. </p>
<h3 id="improve-performance-using-replicas">Improve performance using replicas</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1580754605396/OG_XTkpK8.png" alt="Webp.net-resizeimage (3).png"></p>
<p>We can also significantly improve the performance of our database by</p>
<ul>
<li><p>Redirecting all <strong>read requests to replicas</strong></p>
</li>
<li><p>Redirect only <strong>write requests to master</strong></p>
</li>
</ul>
<p>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.</p>
<p>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.</p>
<p>as said above even master goes down immediately the master switch will happen so there will be very little downtime for write requests.</p>
<p>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.</p>
<p> In the next article, we will discuss how synchronization happens between master and replicas.</p>
]]></content:encoded></item><item><title><![CDATA[The need for Database Replication]]></title><description><![CDATA[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 ...]]></description><link>https://thamaraiselvam.dev/the-need-for-database-replication</link><guid isPermaLink="true">https://thamaraiselvam.dev/the-need-for-database-replication</guid><category><![CDATA[Databases]]></category><category><![CDATA[distributed system]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Sat, 01 Feb 2020 18:58:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1580583492877/aVoljQ7W-.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>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&#39;s start.</p>
<h3 id="what-is-the-replication">What is the replication</h3>
<p>Replication is keeping multiple copies of the database.</p>
<h3 id="why-replication-is-important">Why replication is important</h3>
<p>There are many reasons. I have taken three important reasons for having multiple copies of the database they are,</p>
<ul>
<li>Availability</li>
<li>Latency</li>
<li>Scalability</li>
</ul>
<p>Let&#39;s see each one of them in details</p>
<h4 id="availability">Availability</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1580580383291/U3Tr3yXq8.png" alt="Webp.net-resizeimage.png"></p>
<p>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.</p>
<p>Let&#39;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 <strong>single point of failure</strong>.</p>
<p>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.</p>
<h4 id="latency">Latency</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1580580257174/xQNZ40wu9.png" alt="network-latency-1.png"></p>
<p>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.</p>
<p>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.</p>
<h4 id="scalability">Scalability</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1580580658571/7xOgmkSbh.png" alt="images.png"></p>
<p>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.</p>
<p>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 <strong>load balancing</strong>.  Now we have divided the requests to the different servers so the chances of overloading the servers are very less.</p>
<p>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.</p>
<p>These are the most important reasons to have replication of the database. In the next articles, we will see Master-Slave replication architecture.</p>
<p>Update: Read <a target='_blank' rel='noopener noreferrer'  href="https://thamaraiselvam.dev/database-replication-master-slave-replication-architecture-ck66skn6r03r8kbs16egqnzvg">Master-Slave replication architecture</a> </p>
]]></content:encoded></item><item><title><![CDATA[How to allow Touch ID to authenticate for Sudo commands on Mac]]></title><description><![CDATA[To enable TouchID on your Mac to authenticate you for sudo access instead of a password you need to do the following steps.

Open Sudo configuration file with the following command

sudo vi /etc/pam.d/sudo
Initially file content should look like this...]]></description><link>https://thamaraiselvam.dev/how-to-allow-touch-id-to-authenticate-for-sudo-commands-on-mac</link><guid isPermaLink="true">https://thamaraiselvam.dev/how-to-allow-touch-id-to-authenticate-for-sudo-commands-on-mac</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[macOS]]></category><category><![CDATA[terminal]]></category><category><![CDATA[authentication]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Sat, 02 Nov 2019 08:23:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1572683000885/JiKHunOe2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>To enable TouchID on your Mac to authenticate you for sudo access instead of a password you need to do the following steps.</p>
<ul>
<li>Open Sudo configuration file with the following command</li>
</ul>
<p><code>sudo vi /etc/pam.d/sudo</code></p>
<p>Initially file content should look like this</p>
<pre><code># sudo: auth account password session
auth       <span class="hljs-keyword">required</span>       pam_opendirectory.so
account    <span class="hljs-keyword">required</span>       pam_permit.so
password   <span class="hljs-keyword">required</span>       pam_deny.so
session    <span class="hljs-keyword">required</span>       pam_permit.so
</code></pre><ul>
<li>Paste <code>auth sufficient pam_tid.so</code> on line 2 of the document (underneath the initial comment line)</li>
</ul>
<p>After pasting contents should be like this</p>
<pre><code># <span class="hljs-selector-tag">sudo</span>: <span class="hljs-selector-tag">auth</span> <span class="hljs-selector-tag">account</span> <span class="hljs-selector-tag">password</span> <span class="hljs-selector-tag">session</span>
<span class="hljs-selector-tag">auth</span>       <span class="hljs-selector-tag">sufficient</span>     <span class="hljs-selector-tag">pam_tid</span><span class="hljs-selector-class">.so</span>
<span class="hljs-selector-tag">auth</span>       <span class="hljs-selector-tag">required</span>       <span class="hljs-selector-tag">pam_opendirectory</span><span class="hljs-selector-class">.so</span>
<span class="hljs-selector-tag">account</span>    <span class="hljs-selector-tag">required</span>       <span class="hljs-selector-tag">pam_permit</span><span class="hljs-selector-class">.so</span>
<span class="hljs-selector-tag">password</span>   <span class="hljs-selector-tag">required</span>       <span class="hljs-selector-tag">pam_deny</span><span class="hljs-selector-class">.so</span>
<span class="hljs-selector-tag">session</span>    <span class="hljs-selector-tag">required</span>       <span class="hljs-selector-tag">pam_permit</span><span class="hljs-selector-class">.so</span>
</code></pre><ul>
<li><p>Save the file (Since this file is read-only, you may be required to do force save, Eg <code>vim</code> will require you to use <code>wq!</code> when saving)</p>
</li>
<li><p>Now try to use sudo command on terminal and you should be prompted to authenticate with Touch ID as shown below</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1572680707181/dnTJUzFIm.png" alt="Screenshot 2019-11-02 at 1.13.51 PM.png"></p>
<ul>
<li><p>If you click &#39;Cancel&#39; you can just enter your password at the terminal prompt if you click &#39;Use Password&#39; you can enter your password in the dialog box.</p>
</li>
<li><p>If you SSH into your machine it will fall back to just use your password since you can&#39;t send your TouchID fingerprints over SSH</p>
</li>
</ul>
<ul>
<li>If you&#39;re using <strong>iTerm2</strong> (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: <strong>iTerm2-&gt;Preferences &gt; Advanced &gt; (Goto the Session heading) &gt; Allow sessions to survive logging out and back in.</strong></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1572680888792/ocxzOZYT5.png" alt="Screenshot 2019-11-02 at 1.17.56 PM.png"></p>
<p>Reference: https://apple.stackexchange.com/questions/259093/can-touch-id-for-the-mac-touch-bar-authenticate-sudo-users-and-admin-privileges</p>
]]></content:encoded></item><item><title><![CDATA[How to Bookmark commands in Terminal]]></title><description><![CDATA[Always we hate to type or search or copy and paste most often used commands in the terminal.
I found a great tool to ease the navigation in the terminal, called Apparix. It lets you bookmark a folder so that you easily can navigate to it just by typi...]]></description><link>https://thamaraiselvam.dev/how-to-bookmark-commands-in-terminal</link><guid isPermaLink="true">https://thamaraiselvam.dev/how-to-bookmark-commands-in-terminal</guid><category><![CDATA[Developer]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[tips]]></category><category><![CDATA[terminal]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Thu, 22 Aug 2019 18:46:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1566499557423/dW3lf22Fk.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Always we hate to type or search or copy and paste most often used commands in the terminal.</p>
<p>I found a great tool to ease the navigation in the terminal, called <a target='_blank' rel='noopener noreferrer'  href="https://micans.org/apparix/"><strong>Apparix</strong></a>. It lets you bookmark a folder so that you easily can navigate to it just by typing</p>
<p><code>to nameofbookmark</code></p>
<p>To install apparix in Ubuntu, type</p>
<p><code>sudo apt-get install apparix</code></p>
<p>To install in Mac, type</p>
<p><code>brew install -v apparix</code> or  <a target='_blank' rel='noopener noreferrer'  href="https://gist.github.com/glombard/a91a822098aed7bb50a7">Run this Script</a> </p>
<p>in a terminal window.</p>
<p>After installation, you need to set up the aliases <code>bm</code> for bookmarking and <code>to</code> for going to a bookmark by adding a few functions to your <code>.bashrc file</code> in your home folder (if you don’t have this file, you can create it yourself).</p>
<p>You’ll find the functions you need to add by issuing the command</p>
<p><code>apparix –shell-examples</code></p>
<p>in a terminal window. Copy everything below <strong>Bash-style functions</strong> except the <strong>CSH-style aliases</strong>. Paste this into your <code>.bashrc file</code>.</p>
<p>Open up a new terminal, cd to your directory of choice and type</p>
<p><code>bm mybookmark</code></p>
<p>to bookmark the folder. Afterward, you can go to any folder and type</p>
<p><code>to mybookmark</code></p>
<p>to go to your bookmark.</p>
<p>This tool is, of course, available for other Linux distributions too.</p>
<p>Reference:  <a target='_blank' rel='noopener noreferrer'  href="https://micans.org/apparix/">https://micans.org/apparix/</a> </p>
]]></content:encoded></item><item><title><![CDATA[MEAN Stack - Cheat Sheet]]></title><description><![CDATA[MEAN Stack Cheat Sheet Github Repository
Those who want to become a Full Stack Developer their first choice is MEAN Stack 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 The Technic...]]></description><link>https://thamaraiselvam.dev/mean-stack-cheat-sheet</link><guid isPermaLink="true">https://thamaraiselvam.dev/mean-stack-cheat-sheet</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[Angular]]></category><category><![CDATA[Express]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Thu, 11 Jul 2019 10:44:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1562841799917/4MBXdKRun.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="-mean-stack-cheat-sheet-github-repository-https-github-com-thamaraiselvam-mean-stack-cheat-sheet-"><a target='_blank' rel='noopener noreferrer'  href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet">MEAN Stack Cheat Sheet Github Repository</a></h3>
<p>Those who want to become a <em>Full Stack Developer</em> their first choice is <strong>MEAN Stack</strong> because it has a lot of scopes and easy to learn as well but preparing is hard so Here&#39;s a Cheat Sheet - Inspired by <a target='_blank' rel='noopener noreferrer'  href="https://gist.github.com/TSiege/cbb0507082bb18ff7e4b">The Technical Interview Cheat Sheet.md</a></p>
<p><img src="https://media.giphy.com/media/uGjzzKY4BhtKw/giphy.gif" alt="Shortcut"></p>
<blockquote>
<p>This list is meant to be both a quick guide and reference for further research into these topics. It&#39;s basically a summary of important topics, there&#39;s no way it can cover everything in depth.  It also will be available as on <a target='_blank' rel='noopener noreferrer'  href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet">Github</a> for everyone. Please feel free to rise a <a target='_blank' rel='noopener noreferrer'  href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/issues">issue</a> or <a target='_blank' rel='noopener noreferrer'  href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/pulls">PR</a> if anything missing or any correction required.</p>
</blockquote>
<h2 id="what-the-heck-is-mean-stack">What the heck is MEAN Stack</h2>
<ul>
<li>MEAN is an acronym for <strong>MongoDB</strong>, <strong>ExpressJS</strong>, <strong>AngularJS</strong> and <strong>Node.js</strong></li>
<li>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.</li>
</ul>
<h2 id="mongodb">MongoDB</h2>
<p><img src="https://media.giphy.com/media/3otPoHMzdMgfZznjpe/giphy.gif" alt="mongo"></p>
<h3 id="mongodb-introduction">MongoDB Introduction</h3>
<ul>
<li><h4 id="-what-is-mongodb-and-where-to-be-used-"><em>What is MongoDB and where to be used ?</em></h4>
</li>
</ul>
<p>MongoDB is a type of NoSQL DB and used in the following applications such as unstable schema, need highly scalability and availability.  <a target='_blank' rel='noopener noreferrer'  href="https://www.mongodb.com/what-is-mongodb">Read More</a></p>
<ul>
<li><h4 id="-difference-between-nosql-and-sql-"><em>Difference between NoSQL and SQL ?</em></h4>
</li>
</ul>
<table>
<thead>
<tr>
<td>MySQL Terms</td><td>MongoDB Terms</td></tr>
</thead>
<tbody>
<tr>
<td>database</td><td>database</td></tr>
<tr>
<td>table</td><td>collection</td></tr>
<tr>
<td>row</td><td>document or BSON document</td></tr>
<tr>
<td>column</td><td>field</td></tr>
<tr>
<td>index</td><td>index</td></tr>
<tr>
<td>table joins</td><td>embedded documents and linking</td></tr>
<tr>
<td>primary key Specify any unique column or column combination as the primary key.</td><td>primary key In MongoDB, the primary key is automatically set to the _id field.</td></tr>
<tr>
<td>aggregation (e.g. group by)</td><td>aggregation pipeline</td></tr>
</tbody>
</table>
<p> <a target='_blank' rel='noopener noreferrer'  href="https://www.mongodb.com/compare/mongodb-mysql">Read more detailed comparison on MongoDB vs MySQL</a></p>
<h3 id="install-mongodb">Install MongoDB</h3>
<ul>
<li><h4 id="-how-to-install-mongodb-and-robo-3t-"><em>How to Install <strong>MongoDB</strong> and <strong>Robo 3T</strong>?</em></h4>
</li>
</ul>
<p><a target='_blank' rel='noopener noreferrer'  href="https://docs.mongodb.com/manual/installation/">Install MongoDB</a> and  <a target='_blank' rel='noopener noreferrer'  href="https://robomongo.org/download">Robo 3T</a> (Robo 3T -formerly Robomongo is the free lightweight GUI for MongoDB enthusiasts)</p>
<ul>
<li><h4 id="-how-to-install-the-mongoose-node-module-"><em>How to Install the <strong>mongoose</strong> node module?</em></h4>
</li>
</ul>
<p><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/mongoose">Mongoose</a> is MongoDB driver which connects MongoDB and Node.JS <a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/guide.html">Read Document</a></p>
<h3 id="work-with-mongoose">Work with Mongoose</h3>
<ul>
<li><h4 id="-start-with-schema-"><em>Start with Schema?</em></h4>
</li>
</ul>
<p>Everything in Mongoose starts with a Schema. Each schema maps to a MongoDB collection and defines the shape of the documents within that collection.</p>
<pre><code class="lang-js"> <span class="hljs-keyword">var</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);
  <span class="hljs-keyword">var</span> Schema = mongoose.Schema;

  <span class="hljs-keyword">var</span> blogSchema = <span class="hljs-keyword">new</span> Schema({
    title:  <span class="hljs-built_in">String</span>,
    author: <span class="hljs-built_in">String</span>,
    body:   <span class="hljs-built_in">String</span>,
    comments: [{ body: <span class="hljs-built_in">String</span>, date: <span class="hljs-built_in">Date</span> }],
    date: { type: <span class="hljs-built_in">Date</span>, <span class="hljs-keyword">default</span>: <span class="hljs-built_in">Date</span>.now },
    hidden: <span class="hljs-built_in">Boolean</span>,
    meta: {
      votes: <span class="hljs-built_in">Number</span>,
      favs:  <span class="hljs-built_in">Number</span>
    }
  });
</code></pre>
<ul>
<li><h4 id="-creating-a-model-"><em>Creating a Model?</em></h4>
</li>
</ul>
<p>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)</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> Blog = mongoose.model(<span class="hljs-string">'Blog'</span>, blogSchema);
</code></pre>
<p><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/guide.html#definition">Read More Mongoose guide</a></p>
<h3 id="basic-curd-functions">Basic CURD functions</h3>
<blockquote>
<p>Mongoose models provide several static helper functions for CRUD operations.</p>
</blockquote>
<ul>
<li><h4 id="-create-https-mongoosejs-com-docs-api-html-model_model-create-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.create">create()</a></em></h4>
</li>
</ul>
<p>Save one or more Documents to the database</p>
<ul>
<li><h4 id="-insertmany-https-mongoosejs-com-docs-api-html-model_model-insertmany-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.insertMany">insertMany()</a></em></h4>
</li>
</ul>
<p>Shortcut for validating an array of documents and inserting them into MongoDB if they&#39;re all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.</p>
<ul>
<li><h4 id="-findone-https-mongoosejs-com-docs-api-html-model_model-findone-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.findOne">findOne()</a></em></h4>
</li>
</ul>
<p>Finds one document</p>
<ul>
<li><h4 id="-find-https-mongoosejs-com-docs-api-html-model_model-find-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.find">find()</a></em></h4>
</li>
</ul>
<p>Finds documents</p>
<ul>
<li><h4 id="-updateone-https-mongoosejs-com-docs-api-html-model_model-updateone-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.updateOne">updateOne()</a></em></h4>
</li>
</ul>
<p>Updates one document in the database without returning it.</p>
<ul>
<li><h4 id="-update-https-mongoosejs-com-docs-api-html-model_model-update-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.update">update()</a></em></h4>
</li>
</ul>
<p>Same as update(), except it does not support the multi or overwrite options.</p>
<ul>
<li><h4 id="-updatemany-https-mongoosejs-com-docs-api-html-model_model-updatemany-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.updateMany">updateMany()</a></em></h4>
</li>
</ul>
<p>Same as update(), except MongoDB will update all documents that match filter</p>
<ul>
<li><h4 id="-deleteone-https-mongoosejs-com-docs-api-html-model_model-deleteone-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.deleteOne">deleteOne()</a></em></h4>
</li>
</ul>
<p>Deletes the first document that matches conditions from the collection.</p>
<ul>
<li><h4 id="-deletemany-https-mongoosejs-com-docs-api-html-model_model-deletemany-"><em><a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api.html#model_Model.deleteMany">deleteMany()</a></em></h4>
</li>
</ul>
<p>Deletes all of the documents that match conditions from the collection</p>
<p>Read more about  <a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/queries.html">Mongoose Queries</a></p>
<h3 id="aggregation">Aggregation</h3>
<blockquote>
<p>Aggregations are operations that process data records and return computed results</p>
</blockquote>
<p>These are operations like sum, count, average, group etc where we need to generated grouped results out of collection.
MongoDB exposes a pipeline based framework for aggregations, which looks something like below and <a target='_blank' rel='noopener noreferrer'  href="https://mongoosejs.com/docs/api/aggregate.html#aggregate_Aggregate">Read more</a></p>
<pre><code class="lang-js">Model.aggregrate([
   pipe1_operator : {...},
   pipe2_operator : {...},
   pipe3_operator : {...}
])
</code></pre>
<ul>
<li><h4 id="-group-"><em>$group</em></h4>
</li>
</ul>
<p>Count the number of Users Belonging To A Particular Region</p>
<ul>
<li><h4 id="-match-"><em>$match</em></h4>
</li>
</ul>
<p>$match acts as a where condition to filter out documents.</p>
<ul>
<li><h4 id="-project-"><em>$project</em></h4>
</li>
</ul>
<p>$project is used to add columns dynamically to the collection and use it for further aggregation.</p>
<ul>
<li><h4 id="-count-"><em>count</em></h4>
</li>
</ul>
<p>Count Number of User who belong to a certain region</p>
<ul>
<li><h4 id="-distinct-"><em>distinct</em></h4>
</li>
</ul>
<p>Find all distinct regions</p>
<p>There are many more pipeline operators than dicussed above, which can be seen <a target='_blank' rel='noopener noreferrer'  href="http://docs.mongodb.org/manual/reference/operator/aggregation/#aggregation-expression-operators">here</a></p>
<h2 id="node-js">Node.JS</h2>
<p><img src="https://user-images.githubusercontent.com/6559664/60865631-0c56c600-a244-11e9-972e-c367bcff55f6.gif" alt="node cats"></p>
<h3 id="what-is-node-js">What is Node.JS</h3>
<ul>
<li>Node.js is a server-side platform (JavaScript runtime) built on <a target='_blank' rel='noopener noreferrer'  href="https://v8.dev/">Chrome&#39;s V8 JavaScript engine</a></li>
<li>It is an open source server environment and free</li>
<li>It runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)</li>
</ul>
<h3 id="why-node-js">Why Node.js</h3>
<h4 id="asynchronous-and-event-driven">Asynchronous and Event Driven</h4>
<p>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.</p>
<h4 id="very-fast">Very Fast</h4>
<p>Being built on Google Chrome&#39;s V8 JavaScript Engine, Node.js library is very fast in code execution.</p>
<h4 id="single-threaded-but-highly-scalable">Single Threaded but Highly Scalable</h4>
<p>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</p>
<h4 id="no-buffering">No Buffering</h4>
<p>Node.js applications never buffer any data. These applications simply output the data in chunks.</p>
<h3 id="where-to-use-node-js">Where to use Node.js</h3>
<p>Following are the areas where Node.js is proving itself as a perfect technology partner.</p>
<ul>
<li>I/O bound Applications</li>
<li>Data Streaming Applications</li>
<li>Data Intensive Real-time Applications (DIRT)</li>
<li>JSON APIs based Applications</li>
<li>Single Page Applications</li>
</ul>
<p><strong><em> It is not advisable to use Node.js for CPU intensive applications </em></strong></p>
<h3 id="npm">NPM</h3>
<p>NPM is a package manager for the JavaScript programming language. It is the default package manager for Node.js and it is the world&#39;s largest Software Registry. It contains more than one million packages.</p>
<h3 id="install-node-js-and-npm">Install Node.js and NPM</h3>
<p>Simply download the <a target='_blank' rel='noopener noreferrer'  href="https://nodejs.org/en/#download">Installer</a> directly from the <a target='_blank' rel='noopener noreferrer'  href="https://nodejs.org/en/">nodejs.org</a> web site or follow the instructions for platform specific.</p>
<h3 id="linux">Linux</h3>
<h4 id="debian-based-distributions">Debian based distributions</h4>
<p>Such as Debian, Ubuntu, Linux mint and Raspbian</p>
<pre><code class="lang-bash">sudo apt-get install nodejs npm
</code></pre>
<h4 id="arch-linux">Arch Linux</h4>
<pre><code class="lang-bash">pacman -S nodejs npm
</code></pre>
<h4 id="macos">MacOS</h4>
<pre><code class="lang-bash">brew install node
</code></pre>
<h4 id="windows">Windows</h4>
<p>Simply download the <a target='_blank' rel='noopener noreferrer'  href="https://nodejs.org/en/#download">Windows Installer</a> directly from the <a target='_blank' rel='noopener noreferrer'  href="https://nodejs.org/en/">nodejs.org</a> web site.</p>
<h3 id="techical-depth">Techical Depth</h3>
<h4 id="single-thread">Single thread</h4>
<p>Single threaded processes contain the execution of instructions in a single sequence. In other words, one command is processed at a time. <a target='_blank' rel='noopener noreferrer'  href="https://www.tutorialspoint.com/single-threaded-and-multi-threaded-processes">Read more about single thread vs multi thread</a></p>
<h4 id="event-loop">Event Loop</h4>
<p>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.</p>
<p>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</p>
<p>Read the following links to learn more about Event Loop</p>
<p><a target='_blank' rel='noopener noreferrer'  href="https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/">The Node.js Event Loop</a></p>
<p><a target='_blank' rel='noopener noreferrer'  href="https://www.youtube.com/watch?v=8aGhZQkoFbQ">What the heck is the event loop anyway? by Philip Roberts - JSConf EU</a></p>
<p><a target='_blank' rel='noopener noreferrer'  href="http://latentflip.com/loupe/">Visualisation tool for event loop</a></p>
<h4 id="javascript-engine-vs-javascript-runtime">JavaScript Engine vs JavaScript Runtime</h4>
<p>A <strong>JavaScript engine</strong> 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.</p>
<p><strong>JavaScript runtime</strong> 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.</p>
<p><a target='_blank' rel='noopener noreferrer'  href="https://medium.com/@misbahulalam/uncover-the-javascript-engine-vs-runtime-6556ef449634">Read more here</a></p>
<h3 id="ecmascript">ECMAScript</h3>
<p>ECMAScript(ES) is a scripting-language <strong>specification standard</strong>ized by Ecma International. It was created to standardize JavaScript and new standards is released on every year.</p>
<p><a target='_blank' rel='noopener noreferrer'  href="http://es6-features.org/">ES6 Features</a>
<a target='_blank' rel='noopener noreferrer'  href="https://medium.com/@madasamy/javascript-brief-history-and-ecmascript-es6-es7-es8-features-673973394df4">ES7, ES8, ES9 Features</a></p>
<h3 id="hello-world-in-node-js">Hello World in Node.js</h3>
<p>Refer <a class='post-section-overview' href="#express">express</a> for hello world program.</p>
<h3 id="some-common-npm-packages">Some Common NPM Packages</h3>
<ul>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/express">express</a></li>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/body-parser">body-parser</a></li>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/lodash">lodash</a></li>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/async">async</a></li>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/moment">moment</a></li>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/request">request</a></li>
</ul>
<h2 id="rest-api">REST API</h2>
<p><img src="https://media.giphy.com/media/e3NinswgSNdRu/giphy.gif" alt="REST API"></p>
<h3 id="-what-is-rest-api-"><em>What is REST API</em></h3>
<ul>
<li><p>A REST stands for Representational State Transfer is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.</p>
</li>
<li><p>REST is a style of software architecture. As described in a dissertation by Roy Fielding, REST is an &quot;architectural style&quot; that basically exploits the existing technology and protocols of the Web.</p>
</li>
</ul>
<h3 id="-http-methods-"><em>HTTP Methods</em></h3>
<p>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).</p>
<p>Use below-given information to find suitable HTTP method for the action performed by API.</p>
<ul>
<li><h4 id="-http-get-"><em>HTTP GET</em></h4>
</li>
</ul>
<p>Use GET requests to retrieve resource representation/information only – and not to modify it in any way</p>
<ul>
<li><h4 id="-http-post-"><em>HTTP POST</em></h4>
<p>POST methods are used to create a new resource into the collection of resources.</p>
</li>
<li><h4 id="-http-put-"><em>HTTP PUT</em></h4>
</li>
</ul>
<p>Use PUT APIs primarily to update an existing resource.</p>
<ul>
<li><h4 id="-http-delete-"><em>HTTP DELETE</em></h4>
</li>
</ul>
<p>As the name applies, DELETE APIs are used to delete resources.</p>
<ul>
<li><h4 id="-http-patch-"><em>HTTP PATCH</em></h4>
</li>
</ul>
<p>PATCH requests are to make partial update on a resource</p>
<p>Read more <a target='_blank' rel='noopener noreferrer'  href="https://restfulapi.net/http-methods/">HTTP Methods</a></p>
<h2 id="express">Express</h2>
<p><img src="https://media.giphy.com/media/3oriNYQX2lC6dfW2Ji/giphy.gif" alt="Express cat"></p>
<ul>
<li><h3 id="-what-is-express-"><em>What is Express</em></h3>
</li>
</ul>
<p>The fast, unopinionated, minimalist web framework for node.</p>
<ul>
<li><h3 id="-installation-"><em>Installation</em></h3>
</li>
</ul>
<p><a target='_blank' rel='noopener noreferrer'  href="http://expressjs.com/en/starter/installing.html">Follow this simple instruction by Express Community</a></p>
<ul>
<li><h3 id="-create-hello-world-rest-api-with-express-"><em>Create Hello World REST API with Express</em></h3>
</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>)
<span class="hljs-keyword">const</span> app = express()
<span class="hljs-keyword">const</span> port = <span class="hljs-number">3000</span>

app.get(<span class="hljs-string">'/'</span>, (req, res) =&gt; res.send(<span class="hljs-string">'Hello World!'</span>))

app.listen(port, () =&gt; <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Example app listening on port <span class="hljs-subst">${port}</span>!`</span>))
</code></pre>
<p>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 <a target='_blank' rel='noopener noreferrer'  href="http://expressjs.com/en/guide/routing.html">Express Guide</a> to know more about Express Routing</p>
<h2 id="angular">Angular</h2>
<p><img src="https://media.giphy.com/media/r7Y17m4862kdW/giphy.gif" alt="angular cat">
&lt;/p&gt;</p>
<p>Note: Always Refer <a target='_blank' rel='noopener noreferrer'  href="https://angular.io/docs">Angular Docs</a>  for a detailed explanation</p>
<h3 id="what-is-angular">What is Angular</h3>
<p>Angular is a TypeScript-based open-source web application framework for building mobile and desktop web applications</p>
<h3 id="why-angular">Why Angular</h3>
<ul>
<li>Angular was written in TypeScript, a superset of JavaScript that implements many new ES2016+ features.</li>
<li>Awesome Command Line Interface (CLI)</li>
<li>Develop across all platforms</li>
<li>Speed, Performance, and Scalability</li>
<li>Incredible tooling</li>
<li>Perfect for Single Page Application</li>
</ul>
<h3 id="setup-angular">Setup Angular</h3>
<h4 id="step-1-install-node-js">Step 1: Install Node.js</h4>
<p>Angular requires Node.js version 10.9.0 or later. To install node.js, go to <a class='post-section-overview' href="#where-to-use-nodejs">Install Node</a></p>
<h4 id="step-2-install-the-angular-cli">Step 2: Install the Angular CLI</h4>
<pre><code class="lang-bash">npm install -g @angular/cli
</code></pre>
<p>that&#39;s it you have installed Angular on your machine.</p>
<h3 id="angular-cli">Angular CLI</h3>
<p>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.</p>
<p>Enter the following to list commands or options for a given command (such as generate) with a short description</p>
<pre><code class="lang-bash">ng <span class="hljs-built_in">help</span>
ng generate --help
</code></pre>
<p>Know more about <a target='_blank' rel='noopener noreferrer'  href="https://angular.io/cli">Angular CLI</a></p>
<h3 id="create-and-run-an-application">Create and Run an application</h3>
<p>Now it is time to create your first Angular application.</p>
<h4 id="create-new-angular-application">Create New Angular Application</h4>
<p>Use the <code>new</code> command to create a new application.</p>
<pre><code class="lang-bash">ng new my-first-project
</code></pre>
<p>and enter into created application <code>cd my-first-project</code></p>
<p>Use <code>serve</code> to run the application.</p>
<pre><code class="lang-bash">ng serve
</code></pre>
<p>In your browser, open <a target='_blank' rel='noopener noreferrer'  href="http://localhost:4200/">http://localhost:4200/</a> 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.</p>
<h3 id="fundamentals">Fundamentals</h3>
<h4 id="architecture">Architecture</h4>
<p>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.</p>
<h4 id="module">Module</h4>
<p>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</p>
<p>Learn more about <a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/architecture-modules">Angular Modules</a></p>
<h4 id="component">Component</h4>
<p>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.</p>
<p>Learn more about <a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/architecture-components">Angular components</a></p>
<h4 id="services-and-di">Services and DI</h4>
<p>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.</p>
<p>You can have sharable methods and data into services.</p>
<p>Learn more about <a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/architecture-services">Angular Services</a></p>
<h4 id="routing">Routing</h4>
<p>Angular Routing helps to control navigation paths of an application.
which helps to retain the application state as well.</p>
<p>Learn more about <a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/router">Angular Routings</a></p>
<h4 id="directive">Directive</h4>
<p>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.</p>
<p>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</p>
<ul>
<li>Structural directives</li>
</ul>
<p>Structural directives alter layout by adding, removing, and replacing elements in the DOM. For Example <em>ngFor, </em>ngIf, *ngSwitch and so on.</p>
<p><a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/structural-directives">Angular structural directives</a></p>
<ul>
<li>Attribute directives</li>
</ul>
<p>Attribute directives alter the appearance or behavior of an existing element. In templates they look like regular HTML attributes, hence the name. For example <strong>[style.color], [color], [(ngModel)] and so on</strong>.</p>
<p><a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/attribute-directives">Angular Attribute directives</a></p>
<h4 id="lifecycle-hooks">Lifecycle Hooks</h4>
<ul>
<li><p>A component has a lifecycle managed by angular.</p>
</li>
<li><p>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.</p>
</li>
<li><p>Angular offers lifecycle hooks that provide visibility into these key life moments and the ability to act when they occur.</p>
</li>
</ul>
<h4 id="lifecycle-sequence">Lifecycle sequence</h4>
<p>After creating a component/directive by calling its constructor, Angular calls the lifecycle hook methods in the following sequence at specific moments:</p>
<ul>
<li>ngOnChanges()</li>
<li>ngOnInit()</li>
<li>ngDoCheck()</li>
<li>ngAfterContentInit()</li>
<li>ngAfterContentChecked()</li>
<li>ngAfterViewInit()</li>
<li>ngAfterViewChecked()</li>
<li>ngOnDestroy()</li>
</ul>
<p>Learn More about <a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/lifecycle-hooks">Angular Lifecycle</a></p>
<h3 id="file-structure">File Structure</h3>
<p>You can see that your angular application has dozens of files and folders. lets see what is the purpose of them.</p>
<ul>
<li>e2e</li>
</ul>
<p>the e2e folder has all unit test files and you should write unit testing inside this dir only.</p>
<ul>
<li>src/app</li>
</ul>
<p>This folder contains all our application codes such as components, services and so on.</p>
<ul>
<li>src/asset</li>
</ul>
<p>This folder is for asset files such as images, fonts.</p>
<ul>
<li>src/environments</li>
</ul>
<p>This is for environment configurations such as Devopment mode, Production mode.</p>
<ul>
<li>src/polyfills</li>
</ul>
<p>All browser compatibility stuff lies here.</p>
<ul>
<li>src/style.css</li>
</ul>
<p>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.</p>
<ul>
<li>src/karma</li>
</ul>
<p>The unit testing configuration file</p>
<ul>
<li>package.json</li>
</ul>
<p>Package.json contains all npm and script related stuff</p>
<ul>
<li>angular.json</li>
</ul>
<p>This file contains meta related to the angular application</p>
<ul>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.typescriptlang.org/docs/handbook/tsconfig-json.html">tsconfig.json</a></li>
</ul>
<p>Compiler Configuration for TypeScript</p>
<ul>
<li><a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/tslint">tslint.json</a></li>
</ul>
<p>Linter Configurations</p>
<ul>
<li><a target='_blank' rel='noopener noreferrer'  href="https://editorconfig.org/">editorconfig</a></li>
</ul>
<p>EditorConfig helps maintain consistent coding styles for multiple developers</p>
<h3 id="deep-diving">Deep Diving</h3>
<h4 id="components-communication">Components Communication</h4>
<ul>
<li>Parent -&gt; Child Via @Input</li>
<li>Child -&gt; Parent Via @ViewChild</li>
<li>Child -&gt; Parent Via @Output EventEmitters</li>
<li>Child &lt;-&gt; Parent Via with Service</li>
</ul>
<p><a target='_blank' rel='noopener noreferrer'  href="https://angularfirebase.com/lessons/sharing-data-between-angular-components-four-methods/">Sharing Data Between Angular Components - Four Methods</a></p>
<h4 id="pipes">Pipes</h4>
<p>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.</p>
<pre><code class="lang-html"><span class="hljs-comment">&lt;!-- Default format: output 'Jun 15, 2015'--&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Today is {{today | date}}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

<span class="hljs-comment">&lt;!-- fullDate format: output 'Monday, June 15, 2015'--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>The date is {{today | date:'fullDate'}}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

 <span class="hljs-comment">&lt;!-- shortTime format: output '9:43 AM'--&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>The time is {{today | date:'shortTime'}}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<h4 id="data-binding">Data Binding</h4>
<p>One way data binding from Component to View</p>
<ul>
<li><a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/displaying-data#interpolation">Interpolation</a> - {{}}</li>
<li><a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/template-syntax#property-binding">Property Binding</a> - []</li>
</ul>
<p>One way data binding from View to Component</p>
<ul>
<li><a target='_blank' rel='noopener noreferrer'  href="https://angular.io/guide/user-input#binding-to-user-input-events">Event Binding</a> - ()</li>
</ul>
<p>Two-way data binding between Component to View</p>
<ul>
<li><a target='_blank' rel='noopener noreferrer'  href="https://angular.io/api/forms/NgModel">ngModel Directive</a> [()]</li>
</ul>
<p>That&#39;s it. These are the most important topics of MEAN Stack, Please feel free to rise a <a target='_blank' rel='noopener noreferrer'  href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/issues">issue</a> or <a target='_blank' rel='noopener noreferrer'  href="https://github.com/thamaraiselvam/MEAN-Stack-Cheat-Sheet/pulls">PR</a> if anything is missing or any correction required.</p>
<p>Now go and Practice.</p>
<p><img src="https://user-images.githubusercontent.com/6559664/61043713-8f1e8300-a3f4-11e9-8650-3fbb51dbab47.gif" alt="practice cat"></p>
]]></content:encoded></item><item><title><![CDATA[Create Extensions for VS Code- Part 2]]></title><description><![CDATA[Introduction
This is the second part of the Create Extension for VS Code series. You can also read the first part in  My Dev Blog , or in  dev.to :
In the first part, we learned how to create a simple Hello World Extension and the basic understanding...]]></description><link>https://thamaraiselvam.dev/create-extensions-for-vs-code-part-2</link><guid isPermaLink="true">https://thamaraiselvam.dev/create-extensions-for-vs-code-part-2</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Visual Studio Code]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Developer]]></category><category><![CDATA[extension]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Mon, 24 Jun 2019 10:16:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1561371335656/SG6goatFO.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>This is the second part of the <strong>Create Extension for VS Code</strong> series. You can also read the first part in  <a target='_blank' rel='noopener noreferrer'  href="https://thamaraiselvam.com/create-extensions-for-vs-code-part-1-cjx5r238f000t65s1ag0fdn8e">My Dev Blog</a> , or in  <a target='_blank' rel='noopener noreferrer'  href="https://dev.to/thamaraiselvam/create-extensions-for-vs-code-part-1-10o0">dev.to</a> :</p>
<p>In the first part, we learned how to create a simple <strong>Hello World Extension</strong> and the basic understanding file structure of extension.</p>
<p>In Part 2, We will go a little deeper and learn the most common extension feature  such as</p>
<ul>
<li>Creating Menus</li>
<li>Creating Settings (Configurations)</li>
<li>Defining Keyboard Shortcuts (KeyBinding)</li>
</ul>
<p>Come on Let&#39;s dive into it.</p>
<p><img src="https://media.giphy.com/media/NqZn5kPN8VVrW/giphy.gif" alt="dive"></p>
<h3 id="creating-menus">Creating Menus</h3>
<p>Creating menus for the extension is pretty simple. The menu consists of three properties such as </p>
<ul>
<li><code>command</code> - The command (action) which gets executed on the click</li>
<li><code>title</code> - Display name for the menu</li>
<li><code>category</code> - Just groupings for the menus.</li>
</ul>
<p>Define menus in <strong><em>package.json -&gt; contributes -&gt; commands</em></strong></p>
<h4 id="snippet">Snippet</h4>
<pre><code><span class="hljs-string">"commands"</span>: [
    {
        <span class="hljs-string">"command"</span>: <span class="hljs-string">"extension.helloWorld"</span>,
        <span class="hljs-string">"title"</span>: <span class="hljs-string">"Say Hello World"</span>,
        <span class="hljs-string">"category"</span>: <span class="hljs-string">"Demo"</span>
    }
]
</code></pre><h4 id="demo">Demo</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1561366700516/a4OspZpaN.gif" alt="menu.gif"></p>
<h3 id="creating-settings-configurations-">Creating Settings (Configurations)</h3>
<p>The setting has the following properties.</p>
<ul>
<li><code>properties -&gt; Key</code> - An unique key which will be used to set/get values.</li>
<li><code>type</code>  - Data Type for the setting.</li>
<li><code>default</code>  - It will be set as the default value on the plugin activation.</li>
<li><code>description</code>  - This note will be shown under the setting.</li>
</ul>
<p>Define settings in  <strong><em>package.json -&gt; contributes  -&gt; configuration</em></strong></p>
<h4 id="snippet">Snippet</h4>
<pre><code><span class="hljs-string">"configuration"</span>: {
    <span class="hljs-string">"title"</span>: <span class="hljs-string">"Hello World configuration"</span>,
    <span class="hljs-string">"properties"</span>: {
        <span class="hljs-string">"hello-world.customMessage"</span>: {
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"string"</span>,
            <span class="hljs-string">"default"</span>: <span class="hljs-string">"Hello World"</span>,
            <span class="hljs-string">"description"</span>: <span class="hljs-string">"This message will be show on menu click"</span>
        }
    }
}
</code></pre><h4 id="get-current-value">Get current Value</h4>
<p>We can get the current value of settings in <code>Extension.ts</code> with the help of <code>vscode.workspace</code>  object and unique key (<code>hello-world.customMessage</code>) which is mentioned on <strong>package.json</strong>.</p>
<pre><code><span class="hljs-keyword">const</span> msg = vscode.workspace.getConfiguration().<span class="hljs-keyword">get</span>(<span class="hljs-string">'hello-world.customMessage'</span>);
</code></pre><h4 id="demo">Demo</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1561368986348/G4-tWm4Mt.gif" alt="setting.gif"></p>
<h3 id="defining-keyboard-shortcuts-keybinding-">Defining Keyboard Shortcuts (KeyBinding)</h3>
<p>We can trigger an action of our extension on specific keyboard shortcuts which is known as keybinding.</p>
<p>It has two properties they are,</p>
<ul>
<li>Command - Action needs to be triggered</li>
<li>Key - Combination of keys</li>
</ul>
<p>Define keybinding in  <strong><em>package.json -&gt; contributes  -&gt; keybindings</em></strong></p>
<h4 id="snippet">Snippet</h4>
<p><code>helloWorld</code> action will be executed on the keybinding of <strong>Ctrl+Shift+A  + Ctrl+Shift+Z</strong></p>
<pre><code><span class="hljs-string">"keybindings"</span>: [
    {
        <span class="hljs-string">"command"</span>: <span class="hljs-string">"extension.helloWorld"</span>,
        <span class="hljs-string">"key"</span>: <span class="hljs-string">"Ctrl+Shift+A Ctrl+Shift+Z"</span>
    },
]
</code></pre><h4 id="demo">Demo</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1561370165271/z9VK52En0.png" alt="keybinding.PNG"></p>
<p>We have learned the most common extension features !!! 🎉🎉🎉🎉🎉</p>
<p><img src="https://media.giphy.com/media/7SfAXqgRgh0li/giphy.gif" alt="dance1"> </p>
<p>In the next part, We will see how to build and publish our extension on  <a target='_blank' rel='noopener noreferrer'  href="https://marketplace.visualstudio.com/vscode">Visual Studio Marketplace</a> </p>
<p>Thanks for reading!</p>
<p>Please provide your Feedbacks and comments.</p>
<p><img src="https://media.giphy.com/media/13mQQzQF7fUD3q/giphy.gif" alt="feedback"></p>
]]></content:encoded></item><item><title><![CDATA[Create Extensions for VS Code - Part 1]]></title><description><![CDATA[I wanted to develop a VS Code extension  to solve one of my daily problems, so I started to look at  VS Code API
They have really awesome documentation and sample extensions which are really helpful.

I could run my first Hello world extension in les...]]></description><link>https://thamaraiselvam.dev/create-extensions-for-vs-code-part-1</link><guid isPermaLink="true">https://thamaraiselvam.dev/create-extensions-for-vs-code-part-1</guid><category><![CDATA[General Programming]]></category><category><![CDATA[Visual Studio Code]]></category><category><![CDATA[extension]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Fri, 21 Jun 2019 07:05:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1561100434586/ig2xSjrhN.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I wanted to develop a <strong>VS Code extension </strong> to solve one of my daily problems, so I started to look at  <a target='_blank' rel='noopener noreferrer'  href="https://code.visualstudio.com/api">VS Code API</a></p>
<p>They have really awesome documentation and sample extensions which are really helpful.</p>
<blockquote>
<p>I could run my first Hello world extension in less than 5 minutes.</p>
</blockquote>
<p>It is very easy and super simple, come on let&#39;s see how to develop one.</p>
<h3 id="installation">Installation</h3>
<p> Install the following Node modules for Kick Starting new extension <a target='_blank' rel='noopener noreferrer'  href="https://yeoman.io/">Yeoman </a>  and  <a target='_blank' rel='noopener noreferrer'  href="https://www.npmjs.com/package/generator-code">VS Code Extension Generator </a></p>
<p><code>npm install -g yo generator-code</code></p>
<h3 id="create-new-extension">Create New Extension</h3>
<p>Execute this command  <code>yo code</code>  and select New Extension -Typescript (Which is most recommended one) to create a new extension then answer questions. It will create a Hello World <strong>boilerplate </strong> and also Install required node modules.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1561096703338/0BeEQrUoe.png" alt="yo code.PNG"></p>
<h4 id="extension-file-structure">Extension File Structure</h4>
<p>This auto-generated extension has dozen of files, refer following images to know more about file structure.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1561097102805/Uxir8exLD.png" alt="atonomy.PNG"></p>
<p>But we are going to focus on only two files in major which are </p>
<ul>
<li>src/exntension.ts</li>
<li>package.json</li>
</ul>
<h3 id="run-extension">Run Extension</h3>
<p>Running extension is pretty simple, Just go to debug menu from the left side menu or hit  <code>Ctrl+Shift+D</code>  keybinding, Then click <strong>Run Extension</strong>.</p>
<p>It will open a new window where your extension will be running, To confirm that you can see &quot;Hello World&quot; on the right bottom.</p>
<p><img src="https://media.giphy.com/media/OVXDh4cOaLawM/giphy.gif" alt="Tada"></p>
<h3 id="okay-but-how-does-it-work-">Okay, But How Does it work?</h3>
<p>VS code Extension is all event-based, we need to define all our commands (actions) in package.json</p>
<h4 id="package-json">Package.json</h4>
<p>you can <strong>package.json </strong> files in the root dir, which holds the all the events inside of <code>contributes</code>  -&gt; <code>commands</code>, In this case, we have only one command which is <code>extension.helloWorld</code></p>
<pre><code><span class="hljs-string">"contributes"</span>: {
        <span class="hljs-string">"commands"</span>: [
            {
                <span class="hljs-string">"command"</span>: <span class="hljs-string">"extension.helloWorld"</span>,
                <span class="hljs-string">"title"</span>: <span class="hljs-string">"Hello World"</span>
            }
        ]
}
</code></pre><p>We enable our events by adding our commands into <code>activationEvents</code></p>
<pre><code><span class="hljs-string">"activationEvents"</span>: [
    <span class="hljs-string">"onCommand:extension.helloWorld"</span>
]
</code></pre><p><code>main</code> property holds file path which will be executed at first, once the extension is activated</p>
<pre><code><span class="hljs-string">"main"</span>: <span class="hljs-string">"./out/extension.js"</span>
</code></pre><h4 id="extension-ts">Extension.ts</h4>
<p>Good to see that, this file has very detailed comments for better understanding.</p>
<ul>
<li><p><code>function activate(context: vscode.ExtensionContext)</code> - This Function executed at first when extension gets activated and our all business logic will lie here.</p>
</li>
<li><p><code>vscode.commands.registerCommand(&#39;extension.helloWorld&#39;, () =&gt; {})</code> - Registering <code>extension.helloWorld</code> event with callback function.</p>
</li>
<li><p><code>vscode.window.showInformationMessage(&#39;Hello World!&#39;);</code>  - It makes message box on the right bottom</p>
</li>
</ul>
<p>Finally, we should push our registered command into <code>context.subscriptions</code></p>
<p><strong>Congratulations for your first vs code extension </strong> 🎉🎉🎉🎉🎉</p>
<p><img src="https://media.giphy.com/media/apdfsXZENhMsM/giphy.gif" alt="Made it"></p>
<p>In the next article, I will explain how to implement the most common extension feature such as menus, settings, keybindings and status message bar.</p>
<p>If you have any issues or question please comment, I am glad to help you :D</p>
<p>Thank you !!!
<img src="https://media.giphy.com/media/l2R0eYcNq9rJUsVAA/giphy.gif" alt="Thank you"></p>
<h4 id="read-part-two-on-dev-blog-https-thamaraiselvam-com-create-extensions-for-vs-code-part-2-cjxa87y7t001mvzs11rgng6th-or-in-dev-to-https-dev-to-thamaraiselvam-create-extensions-for-vs-code-part-2-1gj7-">Read Part two on  <a target='_blank' rel='noopener noreferrer'  href="https://thamaraiselvam.com/create-extensions-for-vs-code-part-2-cjxa87y7t001mvzs11rgng6th">Dev Blog</a>  or in  <a target='_blank' rel='noopener noreferrer'  href="https://dev.to/thamaraiselvam/create-extensions-for-vs-code-part-2-1gj7">Dev.to</a></h4>
]]></content:encoded></item><item><title><![CDATA[Database Normalization in simple term]]></title><description><![CDATA[The database design goal is always to store and retrieve the data in the most efficient manner, bad database design will lead to huge problems when the application grows bigger.
To avoid them database design should consist of the following properties...]]></description><link>https://thamaraiselvam.dev/database-normalization-in-simple-term</link><guid isPermaLink="true">https://thamaraiselvam.dev/database-normalization-in-simple-term</guid><category><![CDATA[Databases]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Fri, 26 Apr 2019 19:10:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1556305779500/jT031BGpo.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The database design goal is always to store and retrieve the data in the most efficient manner, bad database design will lead to huge problems when the application grows bigger.</p>
<p>To avoid them database design should consist of the following properties</p>
<ul>
<li>No data redundancy</li>
<li>Data integrity</li>
</ul>
<p><strong>No Data Redundancy</strong> in simple term <strong>No Repetitive Data</strong></p>
<p><strong>Data integrity</strong> in simple term <strong>Should able to CRUD without negative effect on other data</strong></p>
<h2 id="normalization">Normalization</h2>
<p>Process of organizing a database to avoid data redundancy and ensure data integrity.</p>
<h3 id="normal-forms">Normal Forms</h3>
<p>The normalization process can be done by step by step process they are called Normal Forms (NF). Let&#39;s see first three Normal Forms.</p>
<h4 id="1nf">1NF</h4>
<ul>
<li><h5 id="each-record-should-represent-only-one-primary-key">Each record should represent only one primary key</h5>
</li>
<li><h5 id="one-columns-should-have-a-single-value">One columns should have a single value</h5>
<p>The column should have atomic values in simple terms it cannot be divided any further</p>
</li>
<li><h5 id="no-repeating-groups">No repeating groups</h5>
<p>The table should not have the same group of columns example <em>phone_number1, phone_number2...phone_numberN</em></p>
</li>
</ul>
<h4 id="2nf">2NF</h4>
<ul>
<li><h5 id="no-partial-dependencies">No partial dependencies</h5>
Non-primary columns should depend only on the primary column</li>
</ul>
<p><strong>Example</strong>:
The teacher column is determined only by the class_id, not by the entire primary identifier of (student_id, class_id) and the following table will lead to data redundancy because of repeating teacher name</p>
<table>
<thead>
<tr>
<td>student_id</td><td>class_id</td><td>teacher</td></tr>
</thead>
<tbody>
<tr>
<td>1</td><td>1</td><td>Smith</td></tr>
<tr>
<td>2</td><td>2</td><td>Jackson</td></tr>
<tr>
<td>3</td><td>3</td><td>James</td></tr>
<tr>
<td>4</td><td>2</td><td>Jackson</td></tr>
</tbody>
</table>
<p><strong>Solution</strong>: create a separate table for <strong>Teachers</strong> </p>
<h4 id="3nf">3NF</h4>
<ul>
<li><h5 id="there-are-no-transitive-dependencies">There are no transitive dependencies</h5>
</li>
</ul>
<p>A transitive dependency is when the following happens:</p>
<ul>
<li>A determines B</li>
<li>B does not determine A</li>
<li>B determines C</li>
</ul>
<p><strong>Example</strong>: Following to table will lead to data redundancy because of repeating teacher name</p>
<p>id and class_name determine teacher but the teacher does not determine the id or class_name This is because a teacher could teach multiple classes.</p>
<table>
<thead>
<tr>
<td>id</td><td>class_name</td><td>teacher</td><td>office</td></tr>
</thead>
<tbody>
<tr>
<td>1</td><td>Math</td><td>Smith</td><td>A107</td></tr>
<tr>
<td>2</td><td>Programming</td><td>Jackson</td><td>B205</td></tr>
<tr>
<td>3</td><td>History</td><td>James</td><td>A100</td></tr>
<tr>
<td>4</td><td>Science</td><td>Jackson</td><td>B205</td></tr>
</tbody>
</table>
<p><strong>Solution</strong>: isolate those related columns (teacher, office) and move them into a separate table</p>
<p>Referenced from <a target='_blank' rel='noopener noreferrer'  href="https://dev.to/adammc331/how-to-properly-design-a-database-part-1-2h6f">Adam McNeilly&#39;s post</a></p>
]]></content:encoded></item><item><title><![CDATA[Learn and Implement Data Structure in JS - Singly LinkedList]]></title><description><![CDATA[The problem is that many of the people trying to learn data structures but not implementing them.
People start worrying about data structures. This occurs because everyone has heard that a good knowledge of data structures is important for technical ...]]></description><link>https://thamaraiselvam.dev/learn-and-implement-data-structure-in-js-singly-linkedlist</link><guid isPermaLink="true">https://thamaraiselvam.dev/learn-and-implement-data-structure-in-js-singly-linkedlist</guid><category><![CDATA[data structures]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Thu, 25 Apr 2019 10:33:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1556188505928/Rap-7o-WU.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The problem is that many of the people trying to learn data structures but not implementing them.</p>
<p>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&#39;t realize they&#39;d be better served by implementing them rather than just read about it.</p>
<p>So I have started this series to focus on each data structure and how to implement them in Javascript.</p>
<p>In this article, we will be implementing a <strong>Singly LinkedList </strong>data structure in Javascript. </p>
<h3 id="what-is-singly-linked-list">What is Singly Linked List</h3>
<blockquote>
<p>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.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1556185078570/8dYXQPl7w.png" alt="single linked list.png"></p>
<h3 id="implementing-singly-linked-list">Implementing Singly Linked List</h3>
<pre><code><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Node</span> </span>{
    <span class="hljs-keyword">constructor</span>(element) {
        <span class="hljs-keyword">this</span>.element = element;
        <span class="hljs-keyword">this</span>.next = <span class="hljs-literal">null</span>;
    }
}
</code></pre><p>As in the code above, we have two properties <code>elements</code> which holds the data of the current node and <code>next</code> holds the pointer (address) of the next node which initialized to <code>null</code>.</p>
<pre><code><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SinglyLinkedList</span> </span>{
    <span class="hljs-keyword">constructor</span>() {
        <span class="hljs-keyword">this</span>.head = <span class="hljs-literal">null</span>;
    }
}
</code></pre><p>Above code shows a SinglyLinkedList class with constructor, the Linked list has a property called <strong><code>head</code> which will hold the first node of the linked list**</strong>.</p>
<h4 id="adding-element-into-list">Adding element into list</h4>
<pre><code>add(element) {
    <span class="hljs-comment">//create new node</span>
    let node = new Node(element);

    let current = <span class="hljs-literal">null</span>;

    <span class="hljs-comment">//If head is empty then insert at first item</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.head == <span class="hljs-literal">null</span>) {
        <span class="hljs-keyword">this</span>.head = node;
    } <span class="hljs-keyword">else</span> {
        current = <span class="hljs-keyword">this</span>.head;

        <span class="hljs-comment">//iterate to end of list</span>
        <span class="hljs-keyword">while</span> (current.next) {
            current = current.next;
        }


        <span class="hljs-comment">//Finally add new node</span>
        current.next = node;
    }

    <span class="hljs-keyword">this</span>.size++;
}
</code></pre><p>In order to add an element, in the end, we should consider the following :</p>
<ul>
<li><p>If the list is empty then add an element and it will be head</p>
</li>
<li><p>If the list is not empty then iterate to end of the list then add an element to end of the list.</p>
</li>
</ul>
<h3 id="removing-element-from-the-list">Removing element from the list</h3>
<pre><code>removeElement(element) {
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.head === <span class="hljs-literal">null</span>) {
        <span class="hljs-keyword">throw</span> Error (<span class="hljs-string">'List is empty'</span>);
    }

    let current = <span class="hljs-keyword">this</span>.head;
    let prev = <span class="hljs-literal">null</span>;

    <span class="hljs-comment">//Iterate over the list</span>
    <span class="hljs-keyword">while</span> (current != <span class="hljs-literal">null</span>) {

        <span class="hljs-keyword">if</span> (current.element === element) {
            <span class="hljs-comment">//If prev node is null then first node is required element</span>
            <span class="hljs-keyword">if</span> (prev === <span class="hljs-literal">null</span>) {
                <span class="hljs-keyword">this</span>.head = current.next;
            } <span class="hljs-keyword">else</span> {
                <span class="hljs-comment">//if prev node found then unset current node</span>
                prev.next = current.next;
            }

            <span class="hljs-keyword">return</span> current.element;
        }

        prev = current;

        <span class="hljs-comment">//iterate to next node</span>
        current = current.next;
    }
    <span class="hljs-keyword">return</span> <span class="hljs-string">'Element not found'</span>;
}
</code></pre><ul>
<li><code>this.head === null</code> If List is empty then throw an error `</li>
<li>while (current != null)` Iterate list till find the element</li>
<li><code>prev === null</code> If <code>prev node</code> is null then first node is required element so make second node as head</li>
<li>If prev node is found then <code>prev.next = current.next</code> detach current node from list</li>
</ul>
<p>That&#39;s it we have covered basics of Singly LinkedList. </p>
<h3 id="unit-test">Unit Test</h3>
<pre><code><span class="hljs-keyword">var</span> assert = <span class="hljs-built_in">require</span>(<span class="hljs-string">'assert'</span>);
<span class="hljs-keyword">const</span> LinkedList = <span class="hljs-built_in">require</span>(<span class="hljs-string">'./single.linkedlist'</span>);

describe(<span class="hljs-string">'Single Linked List'</span>, <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span>{

    <span class="hljs-keyword">const</span> linkedList = <span class="hljs-keyword">new</span> LinkedList();
    it(<span class="hljs-string">'Should add an element'</span>, <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span>{
        linkedList.add(<span class="hljs-number">10</span>);
        <span class="hljs-keyword">let</span> result = linkedList.get(<span class="hljs-string">'list'</span>);
        assert.equal(<span class="hljs-built_in">JSON</span>.stringify(result), <span class="hljs-string">'{"element":10,"next":null}'</span>)
    })

    it(<span class="hljs-string">'Should add two element'</span>, <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span>{
        linkedList.add(<span class="hljs-number">20</span>);
        linkedList.add(<span class="hljs-number">30</span>);
        <span class="hljs-keyword">let</span> result = linkedList.get(<span class="hljs-string">'list'</span>);
        assert.equal(<span class="hljs-built_in">JSON</span>.stringify(result), <span class="hljs-string">'{"element":10,"next":{"element":20,"next":{"element":30,"next":null}}}'</span>)
    })

    it(<span class="hljs-string">'Should remove an element'</span>, <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span>{
        linkedList.removeElement(<span class="hljs-number">20</span>);
        <span class="hljs-keyword">let</span> result = linkedList.get(<span class="hljs-string">'list'</span>);
        assert.equal(<span class="hljs-built_in">JSON</span>.stringify(result), <span class="hljs-string">'{"element":10,"next":{"element":30,"next":null}}'</span>)
    })
})
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1556187182742/dJmGVWgZ0.png" alt="Capture.PNG"></p>
<p>Check  <a target='_blank' rel='noopener noreferrer'  href="https://github.com/thamaraiselvam/data-structures">Github Repo </a> for full source code.</p>
<p>Stay Tuned for the next story.</p>
]]></content:encoded></item><item><title><![CDATA[How to check Which Application is Draining Your Battery on Linux]]></title><description><![CDATA[Powertop  is a tool to diagnose issues with power consumption and power management to help set power saving settings.
Installation
Arch Linux:
sudo pacman -S powertop
Debian based (Ubuntu, Mint, Raspbian ..etc):
add-apt-repository ppa:eugenesan/ppa
a...]]></description><link>https://thamaraiselvam.dev/how-to-check-which-application-is-draining-your-battery-on-linux</link><guid isPermaLink="true">https://thamaraiselvam.dev/how-to-check-which-application-is-draining-your-battery-on-linux</guid><category><![CDATA[Linux]]></category><category><![CDATA[Ubuntu]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Wed, 24 Apr 2019 17:10:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1556125819096/YrdRw2U6g.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p> <a target='_blank' rel='noopener noreferrer'  href="https://en.wikipedia.org/wiki/PowerTOP">Powertop</a>  is a tool to diagnose issues with power consumption and power management to help set power saving settings.</p>
<h3 id="installation">Installation</h3>
<h4 id="arch-linux-">Arch Linux:</h4>
<pre><code><span class="hljs-attribute">sudo</span> pacman -S powertop
</code></pre><h4 id="debian-based-ubuntu-mint-raspbian-etc-">Debian based (Ubuntu, Mint, Raspbian ..etc):</h4>
<pre><code>add-apt-repository ppa:eugenesan/ppa
apt-get <span class="hljs-keyword">update</span>
apt-<span class="hljs-keyword">get</span> <span class="hljs-keyword">install</span> powertop -y
</code></pre><p>PowerTOP has been installed, you can use the following command to know more about it.</p>
<pre><code><span class="hljs-attribute">powertop</span> --help
</code></pre><h3 id="profile-battery-usages">Profile battery usages</h3>
<p>Following command will generate the HTML file called powerreport.html Open the report in your favorite web browser.</p>
<pre><code><span class="hljs-attribute">sudo</span> powertop --html=powerreport.html
</code></pre><p><code>powerreport.html</code> file will be stored on DIR where you are running this command.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1556126934031/gYALxkPr_.png" alt="result.png"></p>
<h3 id="tuning">Tuning</h3>
<pre><code><span class="hljs-attribute">sudo</span> powertop
</code></pre><p>The <strong>Tuning</strong> tab of the report shows the actual parameters suggested by the tool to apply to save power</p>
<p>For more information:   <a target='_blank' rel='noopener noreferrer'  href="https://wiki.archlinux.org/index.php/powertop">https://wiki.archlinux.org/index.php/powertop</a> </p>
]]></content:encoded></item><item><title><![CDATA[Configure Xdebug + PHP 7 + Nginx + Any Linux Distribution]]></title><description><![CDATA[Xdebug deepens debugging PHP apps and websites to a level you can’t receive from the manual process of using code level var_dump()
Get your php.ini
Next output your php.ini information into a file or place you can get the information from. I like to ...]]></description><link>https://thamaraiselvam.dev/configure-xdebug-php-7-nginx-any-linux-distribution</link><guid isPermaLink="true">https://thamaraiselvam.dev/configure-xdebug-php-7-nginx-any-linux-distribution</guid><category><![CDATA[PHP]]></category><category><![CDATA[PHP7]]></category><category><![CDATA[debugging]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Thamaraiselvam]]></dc:creator><pubDate>Tue, 23 Apr 2019 08:52:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1556009482301/5b0AkAboq.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Xdebug deepens debugging PHP apps and websites to a level you can’t receive from the manual process of using code level <code>var_dump()</code></p>
<h3 id="get-your-php-ini">Get your php.ini</h3>
<p>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 <strong>php-info.txt</strong></p>
<p><code>sudo php -i &gt; ~/php-info.txt</code></p>
<h3 id="use-the-xdebug-wizard">Use the Xdebug Wizard</h3>
<p>Send the text file information into the wizard at Xdebug Wizard. Then follow the instructions the wizard supplies.</p>
<h3 id="install-php-xdebug">Install php-xdebug</h3>
<p>This will connect the php with xdebug to the editor also you can configure like editors and remote configurations.</p>
<h4 id="debian-based-distributions-debian-ubuntu-linux-mint-">Debian based distributions( Debian, Ubuntu, Linux Mint)</h4>
<p><code>sudo apt install php-xdebug</code></p>
<h4 id="arch-linux">Arch Linux</h4>
<p><code>sudo pacman -Sy xdebug</code></p>
<h3 id="edit-xdebug-ini">Edit xdebug.ini</h3>
<p>Now edit the <strong>xdebug.ini</strong></p>
<p><code>sudo nano /etc/php/7.0/mods-available/xdebug.ini</code></p>
<p>Then paste the following configuration</p>
<pre><code class="lang-zend_extension=/usr/lib/php/20151012/xdebug.so">xdebug.remote_autostart = 1
xdebug.remote_<span class="hljs-built_in">enable</span> = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_<span class="hljs-built_in">log</span> = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9005 <span class="hljs-comment">#this can be modified</span>
</code></pre>
<h3 id="restart-the-services">Restart the services</h3>
<pre><code><span class="hljs-selector-tag">sudo</span> <span class="hljs-selector-tag">systemctl</span> <span class="hljs-selector-tag">restart</span> <span class="hljs-selector-tag">php7</span><span class="hljs-selector-class">.0-fpm</span>
<span class="hljs-selector-tag">sudo</span> <span class="hljs-selector-tag">systemctl</span> <span class="hljs-selector-tag">restart</span> <span class="hljs-selector-tag">nginx</span>
</code></pre><h3 id="configure-the-editor">Configure the editor</h3>
<p>In my case, I am using Sublime Text 3 so installed xdebug package using package control</p>
<p>Restart the sublime text.</p>
<p><strong><em>That’s all. You have configured Xdebug successfully !!!</em></strong></p>
<p>If you have any issues, Just comment below</p>
]]></content:encoded></item></channel></rss>