<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohan Manavalan</title>
    <description>The latest articles on DEV Community by Mohan Manavalan (@_mohanmurali).</description>
    <link>https://dev.to/_mohanmurali</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F316831%2Fe975ce3e-09a4-4b07-bce6-e1f1467cf328.jpg</url>
      <title>DEV Community: Mohan Manavalan</title>
      <link>https://dev.to/_mohanmurali</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_mohanmurali"/>
    <language>en</language>
    <item>
      <title>Comparison of HTTP and WebSocket Protocols</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sat, 29 Jul 2023 14:24:10 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/comparison-of-http-and-websocket-protocols-55pd</link>
      <guid>https://dev.to/_mohanmurali/comparison-of-http-and-websocket-protocols-55pd</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;The Hypertext Transfer Protocol (HTTP)is the most widely used protocol over the internet. It falls under the application layer in the Internet Protocol suite. Hypertext documents are the building blocks of the World Wide Web, which uses HTTP as its primary data communication protocol. Hypertext documents contain hyperlinks that points to the location of other resources over the World Wide Web and makes it easy to access them by simply performing events like clicking or tapping on the screen. The HTTP protocol was primarily designed as a request-response protocol. The request originates from the user’s browser and a response is sent by the server for this request.&lt;br&gt;
While this is great for most applications, in today’s world there are certain scenarios where the server needs to push the data to the client and vice-versa asynchronously. While it is possible to achieve this using HTTP, the approaches for achieving this are often not optimal and has some drawbacks to it. The WebSocket protocol was designed to solve this problem. It enables two-way full duplex communication between a controlled client environment and a remote host server with minimum performance overhead while also using the existing HTTP infrastructure. &lt;/p&gt;

&lt;h1&gt;
  
  
  What is HTTP
&lt;/h1&gt;

&lt;p&gt;Before we deep dive into what HTTP is, we need to have some understanding of the common terminology used throughout the document.&lt;br&gt;
HTTP Terminology&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resource&lt;/strong&gt;: A service or piece of network data that can be recognised by a URI. Resources could come in different forms (it can be an image, text, or some other form of data), or they might be something completely different. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client&lt;/strong&gt;: A controlled environment, typically a web browser, that establishes a connection to submit requests to retrieve resources from the internet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server&lt;/strong&gt;: A software application that accepts connections and responds to queries by sending back information. Any program may be both a client and a server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Origin Server&lt;/strong&gt;: The server where a specific resource is located or created.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proxy&lt;/strong&gt;: A program that takes in a request from another client and forwards it to the server while also giving the response from the server back to the client thus behaving like both a server and a client. Requests are handled either internally or by forwarding them to other servers for possible translation. The HTTP specification's client and server requirements MUST be implemented by a proxy. A proxy is said to as "transparent" if it alters requests and responses only to the extent necessary for proxy authentication and identification. If a proxy modifies the request or response, then it is called a "non-transparent proxy. Unless explicitly stated otherwise, the HTTP proxy requirements apply to both types of proxies that use transparent or non-transparent behaviour.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gateway&lt;/strong&gt;: A server that acts as a go-between for many servers. Unlike a proxy, a gateway receives requests as if it were the origin server for the requested resource, the requesting client may not be aware that it is communicating with a gateway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tunnel&lt;/strong&gt;: A third-party application that serves as a blind relay between two connections Once the tunnel is active, it is not considered a part of the HTTP connection, even though the tunnel may have been initiated by an HTTP request. When the relayed connections are closed at both ends, the tunnel disappears.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache&lt;/strong&gt;: Local response message storage of a program and the subsystem that manages message storage, retrieval, and deletion. To speed up response times and conserve network capacity for similar future requests, a cache stores cacheable responses. Both the client and the server may have a cache. A server acting as a tunnel cannot have a cache.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic aspects of HTTP:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simplicity&lt;/strong&gt;: Even with the extra complexity created by enclosing HTTP messages in frames in HTTP/2, HTTP is still typically intended to be straightforward and easily readable. Humans are capable of reading and comprehending HTTP messages, making testing for developers easier and reducing complexity for novices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extensible&lt;/strong&gt;: This protocol is simple to modify and experiment with thanks to HTTP headers. Even a straightforward understanding of the semantics of a new header between a client and a server can result in the introduction of new functionality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stateless but not Sessionless&lt;/strong&gt;: Due to the statelessness of HTTP, there is no relationship between requests that are sent one after the other over the same connection. This has the potential to cause issues where users engage coherently with certain pages. HTTP cookies, however, enable the usage of stateful sessions even if HTTP's fundamental structure is stateless. Using header extensibility, HTTP Cookies are introduced to the workflow, allowing session generation on each HTTP request to share the same context or information.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Http Flow
&lt;/h2&gt;

&lt;p&gt;The following steps are performed by the client to communicate with the server&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open a TCP connection: To send one or more requests and receive responses, a TCP connection is used. The client can establish multiple TCP connections to the servers, reuse an existing connection, or establish new ones.&lt;/li&gt;
&lt;li&gt;HTTP Message is sent to the server: Before HTTP/2, HTTP messages can be viewed by humans. These straightforward messages are now encased in frames with HTTP/2, making it hard to read them directly, but the idea is still the same. &lt;/li&gt;
&lt;li&gt;Response from the server is read by the client&lt;/li&gt;
&lt;li&gt;Connection is closed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwqopzpm9umscmech2sv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwqopzpm9umscmech2sv.png" alt="Http Request Flow" width="800" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Realtime web with HTTP
&lt;/h2&gt;

&lt;p&gt;HTTP was originally designed as a request/response protocol. Hence, it’s unidirectional by nature, which means that the client always asks for the information that is sent by the server. But there are many cases where the server needs to push data to the client. For such cases, we can use the following techniques in HTTP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Http Short Pooling
&lt;/h2&gt;

&lt;p&gt;In HTTP polling, a series of request-response messages are sent. When the server receives a new request from the client, it replies with the response if it is available or responds with an empty message. The client queries the server once more after a brief period (referred to as the polling interval) to check for any new messages. HTTP polling is used by many programs, such as chat, online games, and text messaging.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furzxhduqz5780c31lkds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furzxhduqz5780c31lkds.png" alt="Http Short Pooling" width="592" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Http Long Pooling
&lt;/h2&gt;

&lt;p&gt;Every HTTP request is made with the intention of "holding open" (not replying immediately) and only responding when there are events to deliver. This minimises message delivery delay since there is always a pending request that the server may respond to, in order to transmit events as they happen.&lt;/p&gt;

&lt;p&gt;In contrast to "short polling," "long polling" tries to reduce both the consumption of processing and network resources as well as the latency in server-client message transmission. To accomplish these efficiencies, the server only responds to a request when a specific event, condition, or timeout has taken place. Normally, the client immediately sends a fresh long poll request when the server sends a long poll response. This effectively means that the server will always have a lengthy poll request open, to which it will respond as soon as fresh data becomes available for the client. As a result, the server is allowed to "initiate" communication asynchronously.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f2ailzg29mvof4998qa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1f2ailzg29mvof4998qa.png" alt="Http Long Pooling" width="666" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Http Streaming
&lt;/h2&gt;

&lt;p&gt;A request remains open indefinitely thanks to the HTTP streaming technology. The connection is kept open even after the server responds to the client’s request. Since the connection is always open, HTTP streaming allows the server to send responses in bits of packages. The responsibility of collecting and joining the packages is given to the client. Because the client and server do not have to open and close connections, this approach dramatically lowers network latency. Below image shows video streaming using http streaming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsb6lupw0xyz5sxnwvxpu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsb6lupw0xyz5sxnwvxpu.png" alt="Video streaming using http streaming" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Drawbacks of Realtime web with Http
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Overhead&lt;/strong&gt;: A HTTP request is always associated with headers. These headers are useless for a real-time application. So, using HTTP for Realtime has a severe overhead of useless headers data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unidirectional&lt;/strong&gt;: Since HTTP is unidirectional, the connection should still be opened by the client and needs to be maintained in its open state, else the server cannot push the message to the client&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  WebSockets
&lt;/h1&gt;

&lt;p&gt;As we have seen above, using HTTP for Realtime applications has increased overhead in communication. Because the WebSocket protocol offers a full-duplex bi-directional communication channel that is accomplished with a single socket, it enables a robust real-time online application.&lt;br&gt;
For achieving a WebSocket connection, first, a two-way handshake should be achieved between the server and the client. The client sends an Upgrade request to the server through HTTP. This is the only time HTTP is used and this is just used to initiate the handshake. If the server is configured to use WebSockets, it will respond with a connection upgrade response. With this, the handshake is completed and a WebSocket connection is created. Once the connection is made, any data like images and text can be transferred simultaneously in any direction in full duplex mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xsg31w31pkfp8qzv7qk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xsg31w31pkfp8qzv7qk.png" alt="WebSocket communication" width="800" height="890"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of WebSocket
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Allows bidirectional communications between the client and the server without significant performance overhead.&lt;/li&gt;
&lt;li&gt;WebSocket connection can bypass proxies and firewalls which can be challenging for many applications using the HTTP protocol. Whenever a WebSocket connection detects a proxy, it automatically creates a tunnel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Security Model in WebSocket
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;WebSocket Protocol does not restrict access from clients with different origins. But it is possible to specify the clients during the HTTP handshake process using the origin header. Using this we can limit which web pages are permitted to talk to WebSocket Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This protocol is designed to fail when trying to connect to servers of other protocols like SMTP and HTTP, however, it does provide HTTP servers the option of supporting it if they so choose. This is accomplished by restricting the amount of data that may be added to the connection before the handshake's completion (therefore minimising the amount of server influence that can occur).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebSocket Payload size should be restricted to a maximum limit. There are no inbuilt restrictions for this, and a payload of any size can be sent using WebSocket which might be dangerous. Hence maximum payload size should be restricted by the WebSocket server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebSocket does not provide any mechanisms for identifying the user. Hence it is always better to authenticate the users before the handshake and allow them to perform the handshake only when they are authenticated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can also use SSL over WebSockets just like we do in HTTP. WebSocket servers should always be configured to use SSL encryption.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Application of WebSocket
&lt;/h2&gt;

&lt;p&gt;The following lists several instances of real-time applications that have used WebSockets:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Financial Tickers&lt;/em&gt;&lt;br&gt;
Because of how quickly the financial world is evolving and how quickly human minds can digest information, algorithms are deployed. Data can be streamed without delays using WebSocket when it is necessary to track businesses that are worth using a dashboard for right now rather than a few seconds ago.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sports updates&lt;/em&gt;&lt;br&gt;
A further advantage of WebSocket is its applicability to sports updates, which enables users to stay informed if sports news is integrated in Web applications.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Multimedia Chat&lt;/em&gt;&lt;br&gt;
When everyone can't be there in person, video conferencing is employed, yet in-person meetings cannot be replaced. As a better alternative, WebSocket is utilised with HTML5 video components, and obtain User Media APIs because the plug-in used in videoconferencing is quite hefty.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Location Based Apps&lt;/em&gt;&lt;br&gt;
Applications are increasingly employing GPS to locate users and follow their movement along routes, allowing for the collection of relevant data.&lt;br&gt;
Because HTTP is overly complicated, WebSocket is being utilised in place of it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Online Education&lt;/em&gt;&lt;br&gt;
As the internet is becoming more affordable and accessible and education becomes more and more expensive, online education is quickly becoming a great alternative. A fantastic online learning platform for communication between students and teachers can be provided by using WebSocket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cons of using WebSocket
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Although WebSocket runs mostly on TCP, the initial handshake is still done over HTTP. So WebSocket servers need to support both TCP and HTTP implementations.&lt;/li&gt;
&lt;li&gt;The security in WebSocket is still an un-explored territory and might be open to vulnerabilities.&lt;/li&gt;
&lt;li&gt;The information from a WebSocket server cannot be cached by an intermediary (such as a proxy) as it is supposed to be changing continuously. Also, it’s not possible to perform pre-fetching of data from a CDN for WebSockets.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;HTTP is the most widely used protocol on the internet. While it is suitable and optimized for many applications, when it comes to real-time data fetching, the traditional HTTP approach such as HTTP long pooling and HTTP streaming is not much effective. For these scenarios, we need to use the new HTML5 WebSocket protocol, which was designed to use the existing HTTP infrastructure to achieve real-time data fetching from the server.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding JWT</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Thu, 02 Jun 2022 05:05:38 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/understanding-jwt-2728</link>
      <guid>https://dev.to/_mohanmurali/understanding-jwt-2728</guid>
      <description>&lt;h2&gt;
  
  
  What is JWT
&lt;/h2&gt;

&lt;p&gt;JWT stands for JSON web tokens. It is an industry-standard, for passing user claims between client and service and between services. The claims in a JWT are encoded as a JSON object. A claim is just information of the user which is needed by the server to verify their identity and assign appropriate roles.&lt;br&gt;
A JWT consists of 3 parts&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Header&lt;/li&gt;
&lt;li&gt;Payload&lt;/li&gt;
&lt;li&gt;Signature&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Header
&lt;/h4&gt;

&lt;p&gt;The Header in JWT indicates that it is a JWT token and identifies which algorithm is used to generate the signature.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"alg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HS256"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"typ"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"JWT"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Payload
&lt;/h4&gt;

&lt;p&gt;The payload contains a set of claims.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1234567890"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"John Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"iat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1516239022&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Signature
&lt;/h4&gt;

&lt;p&gt;The signature validates the JWT token. The signature is generated by encoding the header and the payload along with a secret and concatenating the two together with a period separator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;HMAC_SHA&lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;secret,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;base&lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="err"&gt;urlEncoding(header)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'.'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;+&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;base&lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="err"&gt;urlEncoding(payload)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The three parts are encoded and combined using a period separator to form a JWT token. This is what a sample JWT looks like. (The red part indicates the Header, the purple indicates the Payload and the blue indicates the Signature)&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuovmafs8gwor67mpea3r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuovmafs8gwor67mpea3r.png" alt="Sample JWT" width="489" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why JWT
&lt;/h3&gt;

&lt;p&gt;Most of the application we use requires us to be logged in to access some additional functionality. Normally user logs in by giving his credentials. It is not good practice to use the credentials provided by the user throughout the lifetime of the user's session.&lt;/p&gt;

&lt;p&gt;Traditionally, the user's state and related information was maintained by servers. They would store this information in external storage like Redis. A session cookie was used to get the user's data from the external storage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhitgtcmlzbpd9zrb7rv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhitgtcmlzbpd9zrb7rv.jpg" alt="Session based authentication" width="672" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This solution would still work, but modern applications rely on RESTful services and RESTful services are stateless. They don't store any state information in them. This makes them highly scalable. So JWT was needed. JWT can store the required state-level information in them in a somewhat secure manner. The server will send this JWT token to the client and the client has to send this token in every subsequent request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcw8vs40o4q1bjp3rtt7o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcw8vs40o4q1bjp3rtt7o.jpg" alt="JWT based authentication" width="652" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the pros and cons of using JWT
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Pros of using JWT
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Since the tokens contain all the necessary information, you do not have to query the DB all the time&lt;/li&gt;
&lt;li&gt;The server does not need to maintain an external storage to handle users state&lt;/li&gt;
&lt;li&gt;Easy to validate across multiple services. You just have one server which does the authorization and then passes the token across multiple services that require the information&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Cons of using JWT
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;If someone gets the JWT, they may be able to impersonate the person&lt;/li&gt;
&lt;li&gt;You cannot store lots of information into the JWT token as it will create a data overload. It is advised to store only the basic information and fetch other data by querying DB as required. Also for web applications, you will use JWT with cookies can store only a certain bytes of data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Securing your JWT
&lt;/h3&gt;

&lt;p&gt;As mentioned above, if some malicious user gets access to your JWT, they might be able to impersonate your user. So you must be careful when using a JWT.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never store JWT in local storage in browser. Any malicious javascript code can easily access this.&lt;/li&gt;
&lt;li&gt;If possible, create JWTs with short life. But be careful, if you invalidate your JWT, your users will be treated as logged off. You don't want your users to be logging in all the time.&lt;/li&gt;
&lt;li&gt;Make sure you use SSL as it will encrypt your network traffic which will prevent your JWT from being stolen by anyone who has access to your network.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What to do if you loose your JWT
&lt;/h3&gt;

&lt;p&gt;A compromised JWT is same as a compromised password. You should follow the same procedure as you do for a compromised password. This might include&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blocking the user's account&lt;/li&gt;
&lt;li&gt;Asking the user to change his password immediately&lt;/li&gt;
&lt;li&gt;Revoking all permissions from the user&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How to know if you have lost a JWT
&lt;/h4&gt;

&lt;p&gt;Acting quickly on a compromised JWT can be vital in preventing the loss of your customer data. We can do the following to know if we have lost a JWT&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Monitor the client's location. Most likely, if someone has breached your security, he will try to use the token from some other location than the one which your client was using. This can be a good indicator to know that your JWT is stolen. But masking location is a simple task.&lt;/li&gt;
&lt;li&gt;Analyze the pattern of the user. If your attacker has stolen your JWT, he will try to make use of it as soon as possible. So you will have to check the behavior of the JWTs. For example, if a user who normally sends 10 requests per minute, starts sending 50 requests then that is a sign of lost JWT.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you see, securing a JWT is a complex task in itself and would require a significant effort if you care about the data of your users. That's why it is always advised that you delegate the task of handling authentication to an external service like Auth0 or Okta or FusionAuth. For a nominal charge, these services will take care of all your authentication problems.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>security</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding password storage</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sun, 27 Mar 2022 11:02:04 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/understanding-password-storage-195e</link>
      <guid>https://dev.to/_mohanmurali/understanding-password-storage-195e</guid>
      <description>&lt;p&gt;Storing passwords can be a challenging and painful task. With this post, I hope to highlight some of the challenges. Keep in mind that managing password by yourself is never a good idea and it's always best to hand it over to a security expert by making use of one of the several auth providers out there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Storing Passwords in plain text
&lt;/h2&gt;

&lt;p&gt;So what's the deal with storing the passwords. Can't they just be stored as it is like other things in DB. Well, we can, but we should not do that due to the following 2 reasons&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Anyone who has access to the database can then easily see and use the password. Sure, they might not do it, but nothing is stopping them from not doing it.&lt;/li&gt;
&lt;li&gt;If your table is compromised by someway by a hacker, they can easily get access to the login details of your user. They just have to get access to the one table in the database. This might cause serious data breach and even legal problems.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we know that we should not store passwords as plain text. Lets look at some of the way, data can be stored safely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Encryption Vs Hashing
&lt;/h2&gt;

&lt;p&gt;Encryption is a mathematical algorithm that converts some text to something completely different by using an encryption key. Anyone who has access to the key can decrypt the encrypted data. If the encryption key is compromised, the passwords are likely compromised as well. Since we can find out the original password using an encryption key, it is not safe to use encryption for storing passwords.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zzke763dpi2zpufijhe.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zzke763dpi2zpufijhe.jpeg" alt="encryption-decryption" width="576" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hashing is another kind of cryptographic mathematical function that converts a string into a completely random combination of characters of a fixed length. Unlike encryption, it is not possible to find the original string easily once hashed. Due to this reason, hashing is the preferred way of storing passwords. Some common hashing algorithms are MD-5, SHA-1, and SHA-2 family algorithms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkpkjo50cqkbqyptra7l.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkpkjo50cqkbqyptra7l.jpeg" alt="hashing" width="576" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hashing works well for storing the password for the below reason&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It is impossible to know the length of the original password by looking into the hashed password.&lt;/li&gt;
&lt;li&gt;It is close to impossible to reverse the hash. &lt;/li&gt;
&lt;li&gt;Even a small change in input will produce a dramatically different hash.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input - password
hash - 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8

input - Password
hash - e7cf3ef4f17c3999a94f2c6f612e8a888e5b1026878e4e19398b23bd38ec221a
// Just by changing p to caps produces totally different hash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So if we don't know the original password, how will we validate if the password entered by the user is correct? We will validate it by hashing the password entered by the user and comparing it with the stored hash in the table. We will get the same hash for the same input. Hence if the hashed password matches, that means the user has entered the right password. This is also the reason why it is not possible to retrieve your password once you have lost it (but still you can validate it with previously stored hashed passwords by comparing the hashed values)&lt;br&gt;
So now even if your database is compromised, all the attacker will see is a collection of hashed passwords. Great! that means our client's data is safe right? Well, hashing protects data to an extent, but it's not completely safe. Let's put on our hacker's cap and try to see what we can do with the hashed password list.&lt;/p&gt;
&lt;h2&gt;
  
  
  Limitations of Hashing
&lt;/h2&gt;

&lt;p&gt;Now we have a list of hashed passwords. You go through the list and find that there are a few identical hashes. That probably means that the password is a commonly used word. As a hacker, you can then just use the commonly used passwords as input and see if you can crack it. Most probably you would. That's the reason it's always advised to use a complicated password. But not all users are going to use it. And if you lose the user's data, it's going to be your responsibility.&lt;br&gt;
There is also a list of commonly used passwords and there hashes available that get updated with every data breach. These are called the rainbow table which the hackers can use to figure out the password. So how can we overcome it?&lt;/p&gt;
&lt;h2&gt;
  
  
  Seasoning with Salt
&lt;/h2&gt;

&lt;p&gt;As storing the password with hashing alone might not be enough, we have to combine the password with a randomly generated string which we call as the "salt" and then hash them together. Since we generate the salt randomly, we will get different hash even from the same passwords. So hashing makes it much more secure to save the password. The salt is then stored usually in a different database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input1 - password
unsalted hash - 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
salted input - password6m:f?F!cZal-
salted hash - d60ec14145dcf8631e604b6db2a2fc1b0ef18460f8ecba77e79b2662ba36c9be

input2 - password
unsalted hash - 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
salted input - passwordtJgeu:nJSgvf
salted hash - 6a8cdd9c910aa70ed8bbd58eb03b1d46bc524cc0d85800b58c9bcf801b15c1d9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, with salt even for the same input, we generate completely different hashes. This makes salting passwords much better even for not so strong passwords.&lt;br&gt;
To validate the user input, we will have to get the salt stored for that user, add the given password with the salt and hash it and see if it matches the hash stored in the database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spicing with pepper
&lt;/h2&gt;

&lt;p&gt;It is not unheard of that even the database containing the salt of the user is compromised. If you want to secure our passwords further, we have to use a random string that we add to all passwords along with the password and salt. This random string is called "pepper" and it's usually stored right inside the source code. Just make sure you don't push this into a publicly hosted repository.&lt;br&gt;
Using pepper might not be necessary all the time. And it might cause an issue if you compromise the value in the pepper cause you have hashed all the passwords with this single value and it is not easy to change. So keep that in mind.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>security</category>
      <category>backend</category>
    </item>
    <item>
      <title>Linked List and how dynamic collection of data is handled in modern languages</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Wed, 23 Feb 2022 03:19:33 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/linked-list-and-how-dynamic-collection-of-data-is-handled-in-modern-languages-5a0h</link>
      <guid>https://dev.to/_mohanmurali/linked-list-and-how-dynamic-collection-of-data-is-handled-in-modern-languages-5a0h</guid>
      <description>&lt;p&gt;During programming, we often need to use collection of data. Collection of data can be handled in an array or in a linked list. Lets see the advantages and disadvantages for both.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arrays
&lt;/h2&gt;

&lt;p&gt;Arrays are probably the most commonly used data structures. They are fixed length data structure. That means when you create an array, the language compiler will allocate a fixed length of memory for you to use. You can add elements till that length. If you need to add more, you will have to create a new array. One advantage of an array is that we can access any element in the array if we know the index. This is one of the reason why they are the most common data structure. So in short&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrays has limited size allocated to them&lt;/li&gt;
&lt;li&gt;If we know the index, it is very easy to access the element of the array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjr9m333n6yn3dhrffx0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjr9m333n6yn3dhrffx0.jpg" alt="Arrays" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Linked List
&lt;/h2&gt;

&lt;p&gt;Often times we don't really know the size of the collection that we use. We might need to add elements to the collection to satisfy our use case. This is where Linked List come into use. Linked List is a collection of data where each data is linked to each other. Depending on the type of linked list each of your data might know the details of its next value in the collection (singly linked list) or it might know both the next and previous value in the collection (doubly linked list). They don't need to have a fixed length and it is possible to add new data to the a linked list. So to summarize&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linked list is a collection of data where each data knows about its adjacent data&lt;/li&gt;
&lt;li&gt;The length of a linked list is dynamic. We can easily add data to a linked list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Singly Linked List&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktq1bcpqsopy5oecabgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktq1bcpqsopy5oecabgi.png" alt="Singly Linked List" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Doubly Linked List&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzl9cponcayup3sq9oqg2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzl9cponcayup3sq9oqg2.png" alt="Doubly Linked List" width="800" height="164"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Solutions offered by modern languages
&lt;/h2&gt;

&lt;p&gt;As I said, arrays are probably the most used data structures. On the others hand linked list are almost never used. Even though we find that in many scenarios we don't really know the length of the collection of data. Still we use arrays most of the time. This is possible because of two reasons&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Most languages offer simple solution to add data by abstracting the creation of new array and providing simple methods to add data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example C# provides List collection for handling collection of data whose length is not fixed. &lt;/p&gt;

&lt;p&gt;Internally when we create a new List object, the compiler assign creates and array with double the size of the given length. It adds data to the same array when we use the List.Add method. When the length exceeds the initial allocated memory, the compiler then creates a new array with increased size and allocates all the data to this array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The c# compiler creates an array of length 2 * given length&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;  &lt;span class="c1"&gt;// creates an array of length 8&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// all the allocated memory of array is filled&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// this now creates a new array with the increased length&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If there is no way to figure out the initial length, then the compiler creates an array of length 4.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt; &lt;span class="c1"&gt;//this creates an array of length 4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the reason, we are not allowed to access the length property for a c# List object. Instead we are given a Count property which gives us the count of data stored in the array instead of the length of the array.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Most of the languages are now garbage collected, so the unused array is removed with very little loss of memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We might end up having to create large number of new arrays by using the inbuilt language methods. It would not be efficient and might take huge space if those memories locations are not freed. Fortunately, most of the modern languages comes with garbage collector. The garbage collectors takes up the responsibility of freeing up the unused memory. So we don't have to worry about clearing the memory manually, which might become a tedious process.&lt;/p&gt;

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

&lt;p&gt;While creating a new array for each element added might take a bit more processing power, its usually always compensated by the ease which arrays allows us to access its elements. This makes arrays the most popular data structures and almost always more efficient to use then the linked list. While linked list might not see much use, understanding the working of linked list will help us understand other data structures more easily.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Understanding Dependency Injection in JavaScript</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Mon, 06 Dec 2021 06:02:32 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/understanding-dependency-injection-in-javascript-3374</link>
      <guid>https://dev.to/_mohanmurali/understanding-dependency-injection-in-javascript-3374</guid>
      <description>&lt;p&gt;Dependency Injection is a fairly complex topic for beginners. It might not be necessary to know the concept but knowing it will help you make better decisions on your code.&lt;/p&gt;

&lt;p&gt;Lets start by the definition. &lt;br&gt;
Dependency Injection - Dependency Injection is the technique in which an object receives other object in which it depends on (source: Wikipedia). &lt;/p&gt;

&lt;p&gt;Now lets try to break down the definition a bit. Lets start by object. An object is an instance of a class. For Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// lets define a class dog&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;speak&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;wuff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//now lets create object dog&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fluffy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, we have a class Dog and fluffy is the object of the class Dog. When we new up a class we create an object of that class. This is one of the ways of creating an object in Javascript (and its the common way to create an object in languages like c# and java). &lt;br&gt;
Lets now see an example where 2 objects are dependent on each other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;whatDoesMyPetSay&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;speak&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fluffy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;fluffy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;whatDoesMyPetSay&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// response will be "wuff"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, as we see, the class Pet is dependent on class Dog. So to get what we want, we need to create an instance of Dog inside our Pet class. Now this class is not reusable as it is tied to Dog class. If someone has a cat as Pet, they wont be able to use this class. This is what is called as tightly coupled code.&lt;br&gt;
Now lets change this code and try to satisfy all other pet owners with dependency Injection. But first, lets create a cat class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Cat&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;speak&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;meow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cat class must also implement the same method for Dependency Injection to work. In languages like C# and Java this is ensured by using an interface. But we have no such method in JavaScript, so it is up to the developer to remember it. Now lets see the new implementation of the pet class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//usually we have a private variable that needs &lt;/span&gt;
  &lt;span class="c1"&gt;//to be accessed only in this class&lt;/span&gt;
  &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;//create a constructor that recieves the dependent&lt;/span&gt;
  &lt;span class="c1"&gt;//object&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;pet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;whatDoesMyPetSay&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="c1"&gt;//as long as pet class implements speak method we are fine&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;speak&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//what does fluffy the dog say?&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fluffy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="nx"&gt;fluffy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;whatDoesMyPetSay&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;//The response will be "wuff"&lt;/span&gt;

&lt;span class="c1"&gt;//what does milo the cat say?&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;milo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Cat&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="nx"&gt;milo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;whatDoesMyPetSay&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;//The response will be "meow"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we have removed the dependency from inside the pet class and have given it to the caller of the class. This promotes the reusability of the pet class. This is a very simple example and the purpose is to only understand dependency injection and not to implement it. In real world, the dependency is abstracted even from the caller and given to a new object, which is usually called an Injector.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not to use Dependency Injection in JavaScript
&lt;/h2&gt;

&lt;p&gt;If you have read till here I hope you are clearer with the concept of dependency injection. Now lets see some reasons we might not want to use dependency injection&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unlike purely class based languages like c# and java, JavaScript provides us lots of flexibility when it comes to grouping functionalities. Many times, you won't even need to use a class and just using a function might be enough. In those cases, trying to implement Dependency injection will only create unnecessary complexities.&lt;/li&gt;
&lt;li&gt;JavaScript also happens to be dynamic in nature. You can overwrite and use any function implementation in JavaScript. So we should make use of these rather then dependency injection for unit testing our code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end of the day, as a developer, we should realize that there is no one solution that fits all problems. I hope with this article, you would be able to take a better decision on your solutions.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Web Developer environment setup for a new Ubuntu/ Ubuntu based distro</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sun, 07 Nov 2021 05:15:09 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/web-developer-environment-setup-for-a-new-ubuntu-ubuntu-based-distro-bpn</link>
      <guid>https://dev.to/_mohanmurali/web-developer-environment-setup-for-a-new-ubuntu-ubuntu-based-distro-bpn</guid>
      <description>&lt;p&gt;In this post I will share the common developer environment setup steps once you have a new Ubuntu/Ubuntu based distro setup. This can be a clean OS installation or a Windows subsystem for Linux setup.&lt;/p&gt;

&lt;p&gt;So the first thing we need to do is update the existing packages currently present. To do that we need to run the following command in the terminal. This will make sure that you have the latest security patches updated in your instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will install NodeJs. We will install NodeJs using the apt package manager which is the default package manager for Ubuntu. We need to use the following command on the terminal to install the latest LTS version of NodeJs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that node is installed using the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Node will also install node package manager. If you don't see node package manager, then you can install it separately using the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can verify the installation with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also like to install Node Version Manager (NVM) tool. NVM makes working with different versions of NodeJs so much easier. To install NVM you need to use the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once nvm is installed, you will need to restart your terminal to be able to use it.&lt;/p&gt;

&lt;p&gt;Most of the Linux distro installations should come with Git. But if git is not present in your installation, you can easily install it using the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have installed git, you need to configure it with your user name and email. This can be done with the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name &lt;span class="s2"&gt;"John Doe"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email johndoe@example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like to configure some global git alias as well to make my life easier to work with git. The most common one if to get a better log info. This is what I use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; alias.lg &lt;span class="s2"&gt;"log --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&amp;lt;%an&amp;gt;%Creset' --abbrev-commit --date=relative"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next thing you need to do is install a text editor of your choice. I like to install VSCode. It works especially well with WSL. &lt;/p&gt;

&lt;p&gt;With this you should be good to start with your development journey. But I like to do the following things to improve my developer experience. Feel free to skip this part if you are new or not interested in this.&lt;/p&gt;

&lt;p&gt;The default editor for Ubuntu is nano. I don't really like to use nano. So I usually change it to vim. Ubuntu comes with vim pre-installed as well. You can change the default editor using the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;update-alternatives &lt;span class="nt"&gt;--config&lt;/span&gt; editor
&lt;span class="c"&gt;#Type the number which corresponds to vim and press enter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should set your default editor to vim. You can change it to something else as well with the same command if you don't prefer vim.&lt;/p&gt;

&lt;p&gt;Next think I like to change is the default shell. By default Ubuntu comes with Bash shell which is not the best shell option to have. I like to install ZSH. To do that use the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once ZSH is installed, you need to change the default shell from bash to ZSH. Use the following command to do that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chsh &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;which zsh&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will need to restart your terminal window to see the change. To verify that the default shell is set to ZSH, use the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$SHELL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should print out the following output.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If everything is fine, then we move on to install Oh My Zsh which is a framework for managing your ZSH configuration. It superpowers your terminal experience and a must have according to me. You can install Oh My Zsh with the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once its installed you should see the following in your terminal.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv4uahffgh9qvmrut5c5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv4uahffgh9qvmrut5c5.PNG" alt="oh-my-zsh install success" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you need to select a good theme for your oh-my-zsh installation. You can browse the list of available themes from the below links.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Themes" rel="noopener noreferrer"&gt;https://github.com/ohmyzsh/ohmyzsh/wiki/Themes&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes" rel="noopener noreferrer"&gt;https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have selected the theme, you open your .zshrc file and change the theme name. .zshrc file is located in your home folder which can be accessed by using &lt;code&gt;cd ~&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ZSH_THEME="intheloop"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this is done you will need to restart your terminal fo rthe change to take place.&lt;/p&gt;

&lt;p&gt;Now you are really good to start your development journey in your new Ubuntu based instance (This time honestly). &lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>ubuntu</category>
      <category>webdev</category>
      <category>linux</category>
    </item>
    <item>
      <title>Change the directory of WSL</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sun, 31 Oct 2021 06:29:31 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/change-the-directory-of-wsl-36hg</link>
      <guid>https://dev.to/_mohanmurali/change-the-directory-of-wsl-36hg</guid>
      <description>&lt;p&gt;Windows sub-system for Linux (WSL) is an extremely useful tool for developers to improve their development experience in windows operating system. It allows the users to run Linux commands and apps directly in windows without having to use a VM or dual booting your computer. But one issue I faced was that by default, It is installed in c drive of windows. You can use WSL in other drives as well, but to make full use of the speed and functionality offered by WSL, it is recommended to use it in its home drive, which by default is set to C with no option to change it during the time of installation. Now if you are someone like me who has a small C drive with windows installed on it (stored in SSD to speed up the OS boot-time, or some other reason), you might find yourself going out of space in C drive pretty quickly. To overcome this we can change the directory of WSL to some other drive. &lt;br&gt;
To do that we need few things. First you need the WSL command line tool. Please note that WSL command line tools windows version 1903 or later. Chances are, if you have installed WSL, you must have already be having it. If you don't have WSL, then you need to open a command prompt or PowerShell window with admin permission and just use the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wsl.exe &lt;span class="nt"&gt;--install&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will take care of installing WSL for you along with the WSL command line tool.&lt;/p&gt;

&lt;p&gt;Once done you can verify the installation by using the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wsl.exe &lt;span class="nt"&gt;--list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should show you the list of distributions currently installed in your computer. &lt;/p&gt;

&lt;p&gt;Now that we have WSL installed, we will look into how we can change the default directory. First you need to create a .tar file of your existing Linux distro. To do that you must use the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wsl.exe &lt;span class="nt"&gt;--export&lt;/span&gt; &amp;lt;Distro Name&amp;gt; &amp;lt;&lt;span class="nb"&gt;tar &lt;/span&gt;file name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here Distro Name will be the name of the Linux distribution whose directory you wish to move.  will be the path along with file name where your .tar file be generated. If you don't give the path in  it will be created in the current directory. For example -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wsl.exe &lt;span class="nt"&gt;--export&lt;/span&gt; Ubuntu20.04 d:&lt;span class="se"&gt;\u&lt;/span&gt;buntu.tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this is done verify that the .tar file is generated in the path. Once that is done, you need to take a backup of all the data from your current home path of the distro, cause after this you will loose access to your distro and might loose the files. Once that is done, use the below command to unregister your distro and bring back all the precious space that your distro had hogged up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wsl.exe &lt;span class="nt"&gt;--unregister&lt;/span&gt; &amp;lt;Distro Name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again the Distro Name will be the name of the distro you wish to unregister.&lt;br&gt;
Now the final step is to import the exported .tar file into your desired directory. To do that use the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wsl.exe &lt;span class="nt"&gt;--import&lt;/span&gt; &amp;lt;New Distro Name&amp;gt; &amp;lt;Distro Path&amp;gt; &amp;lt;&lt;span class="nb"&gt;tar &lt;/span&gt;file name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The  is the name you wish to identify your distro as in your computer.  will be the path you wish to store this distro in. Typically this will be some path in the directory you wish to move your WSL.  will be the full path and name of your exported .tar file. An example of the above command will look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wsl.exe &lt;span class="nt"&gt;--import&lt;/span&gt; Ubuntu d:&lt;span class="se"&gt;\w&lt;/span&gt;sl&lt;span class="se"&gt;\U&lt;/span&gt;buntu d:&lt;span class="se"&gt;\u&lt;/span&gt;buntu.tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the command is executed, your distro will be created in the new path. By default, we will be logged in as the root user. Its not the ideal scenario as the root user has access to change things without needing the password. So it is better to change to a new sudo(sudo user is like admin user in linux) user. You will still have the user and password you created at the time of installing WSL available. You can switch to that user by using the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;su &amp;lt;username&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where username is the user name of the user you created while installing WSL. You can verify the user details by using the below command in terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;whoami&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this shows the user name instead of root. Then you have successfully switched to the account. Now you will have to give password for making changes with sudo command. &lt;br&gt;
Its not ideal to have to switch to the new user every time you open your terminal. It would be great if we could set it as the default user just like how it was before we moved the disk. To do that we will need to open a command prompt or windows powershell and add the following command based on your distro&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&amp;lt;distro-name&amp;gt; config &lt;span class="nt"&gt;--default-user&lt;/span&gt; &amp;lt;username&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where username is the name of the user you wish to configure and distro-name will be the name of your distro.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;for Ubuntu it will be "ubuntu"&lt;/li&gt;
&lt;li&gt;for openSUSE Leap 42 it will be "opensuse-42"&lt;/li&gt;
&lt;li&gt;for SUSE Linux Enterprise Server 12 it will be "sles-12"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now each time you open up your terminal, you will be set as this user by default. You can verify that by running &lt;code&gt;whoami&lt;/code&gt; command in your terminal.&lt;/p&gt;

&lt;p&gt;Phew, quite a bit of work. You can finally use your WSL without worrying about space.&lt;/p&gt;

&lt;p&gt;Hope this article was helpful. Thanks for reading. &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What is RESTful Service?</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sat, 24 Jul 2021 17:28:35 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/what-is-restful-service-5ai5</link>
      <guid>https://dev.to/_mohanmurali/what-is-restful-service-5ai5</guid>
      <description>&lt;p&gt;Web is a place where there are tons of computers talking to each other. As the web grew, it became clear that we needed a common and secure way to allow others to interact with our application. This need gave rise to Representational State Transfer Architecture or more commonly known as REST architecture. REST defines a set of constraints for how the web should behave.&lt;br&gt;
REST defines a &lt;em&gt;client-server communication model&lt;/em&gt;. The device making the request is called the &lt;em&gt;Client&lt;/em&gt; and the device which is listening for the requests is called a &lt;em&gt;Server&lt;/em&gt; The server is in charge of the resources. A resource can be anything like a HTML file, a JSON object, an image file or event a JavaScript file. The client-server communication happens with HTTP/HTTPS protocols. The actual logic for fetching the resource is abstracted behind the server and the client has no idea about what happens in the server. The resource might be fetched from the server the client requested or it can be fetched from some other server. The only thing client is concerned is that if they are getting the resource or not, and if they don't receive the resource, what is the reason for that? REST is also &lt;em&gt;Stateless&lt;/em&gt;, which means that the server has no idea about the previous calls from the client. The server does not hold on to information's for the client. A web service that obeys the REST constraints is called a &lt;strong&gt;RESTful service&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjirtblkzi0qcc48yemmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjirtblkzi0qcc48yemmu.png" alt="Client-Server" width="800" height="323"&gt;&lt;/a&gt;&lt;br&gt;
The Client calls the server using http methods and gets a http response code and http response status along with the resource as the response. The most commonly used HTTP methods are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GET&lt;/strong&gt;: This the the most widely used request method. When the client makes a GET request, it means that the client is asking for the resource mentioned in the URI. Multiple GET request for the same resource will result in same response from the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;POST&lt;/strong&gt;: The second most common request method. A POST request from the client comes with a request body that contains a structure of the resource itself. POST request is used to create the resource enclosed in the request body of a POST request. Every time we make a POST request, the server will create a new request even if the body of the request doesn't change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PUT&lt;/strong&gt;: A PUT request, just like the POST request contains a structure of the resource in its request body. A PUT request tries to find of the resource is already present and if its present then update the resource and if its not present it will create the resource. Hence PUT request will always give same response for same request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DELETE&lt;/strong&gt;: A DELETE request from the client means the client wants to delete resource. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The response codes from the server are in the following categories&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Successful responses&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
When we get the expected response from the server. This includes the following status codes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;200 OK&lt;/strong&gt;: This means that the request was success. This can be the result for any HTTP methods.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;201 Created&lt;/strong&gt;: This means that the resource was created. This will be the response for either PUT or POST request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Client error responses&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
When there is something wrong with the request made by the client we get one of the client error response.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;400 Bad Request&lt;/strong&gt;: The server was not able to understand the request due to as the structure of the resource in request body is not same as the one server expects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;401 Unauthorized&lt;/strong&gt;: The client is not recognized by the server and this is a resource only for recognized clients.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;403 Forbidden&lt;/strong&gt;: The client does not have access to the resource. Unlike 401, here the server is aware of the client but the client does not have access to the resource.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;404 Not Found&lt;/strong&gt;: The server cannot find the requested resource.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Server error responses&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
When there is something wrong with the server, then we get one of the server error response.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;500 Internal Server Error&lt;/strong&gt;: The server encountered a situation it doesn't know how to handle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;501 Not Implemented&lt;/strong&gt;: The request method is not supported by the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;503 Service Unavailable&lt;/strong&gt;: The server is not available to handle the request. This might be due to the server being down for maintenance.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>codenewbie</category>
      <category>rest</category>
    </item>
    <item>
      <title>Serverless Computing</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sat, 17 Jul 2021 16:53:30 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/serverless-computing-2e38</link>
      <guid>https://dev.to/_mohanmurali/serverless-computing-2e38</guid>
      <description>&lt;h3&gt;
  
  
  What is Serverless?
&lt;/h3&gt;

&lt;p&gt;The concept of cloud is to move the infrastructure our application is managed by the cloud vendor. Serverless takes it one step further. With serverless you don't have to worry about anything except for your code. Everything else like the OS of the server, or even the framework of the application is taken care by the cloud vendor. This allows the developer to concentrate only on the code. With serverless, the developer has to write a function that gets executed by a trigger. The trigger is an event that can be configured as per the requirements. Since serverless is mostly functions that respond to triggers, its also called &lt;em&gt;serverless functions&lt;/em&gt;. Even though it's named serverless, it doesn't really mean that we don't have any servers, it just means we don't have to worry about managing the servers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why select serverless?
&lt;/h3&gt;

&lt;p&gt;Now you might be wondering, why do we need a serverless function? The advantage of a server less function is that you will only be charged for the amount of time your function is hit. You don't need to pay anything if your serverless function is not being used. The others advantage is that you can easily scale up and scale down your function based on its load easily. &lt;/p&gt;

&lt;h3&gt;
  
  
  Popular Serverless Offerings
&lt;/h3&gt;

&lt;p&gt;Serverless functions can be used in lots of scenarios. Because of this, most popular cloud vendors are offering serverless functions. AWS lamda is the first and probably the most popular serverless functions offering. The other famous function offerings are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Cloud Functions from Google Cloud platform&lt;/li&gt;
&lt;li&gt;Azure Functions from Microsoft Azure&lt;/li&gt;
&lt;li&gt;Oracle Cloud Fn from Oracle&lt;/li&gt;
&lt;li&gt;OpenWhisk from IBM&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Working with AWS Lamda.
&lt;/h3&gt;

&lt;p&gt;AWS lamda is the serverless offering provided by amazon web service. Aws provides 1 million requests for free forever which is a great offering. But please note that AWS lamda needs to be called by an another AWS service which might not be free, so please do check AWS pricing for that.&lt;/p&gt;

&lt;p&gt;We will see a sample AWS lamda funtion created using node js. You can create an AWS lamda function from the AWS console. When you create a new function you will see something like this&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxmhmdyv2wnn879a42q3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxmhmdyv2wnn879a42q3.PNG" alt="aws lamda" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS lamda function is called by a trigger. This trigger is by one of the other services offered by the AWS, it can either be a api gateway, S3 bucket, dynamo DB etc.&lt;/p&gt;

&lt;p&gt;The function may or may not call other AWS services like S3, or SNS service which will be the destination if it does calls them.&lt;/p&gt;

&lt;p&gt;A simple lamda function looks like below in node js.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.handler = async (event) =&amp;gt; {
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    return response;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every lamda function will have a handler function. The handler is the function that gets called by the trigger. You can write whole application in this handler function like call a DB and send mail etc. AWS makes it very easy to integrate with other AWS services.&lt;/p&gt;

&lt;p&gt;Thats it for today. This was a very basic introduction for serverless computing. Please let me know your thoughts in the comments.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Deep dive into Git Rebase</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sat, 10 Jul 2021 11:57:00 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/deep-dive-into-git-rebase-5b05</link>
      <guid>https://dev.to/_mohanmurali/deep-dive-into-git-rebase-5b05</guid>
      <description>&lt;p&gt;Whenever we have two branches and they are being worked on by separate members and we want to integrate the changes from one branch to the other, we have two options, merging and rebasing. These two commands work in a very different way. Merge will take the changes from the other branch and create a new commit with those changes into the branch. In a way, merge happens as if we did those change ourselves and committed those changes. But merge preserves the reference from the main branch in its log.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// checkout the branch your are working and merge the branch with latest changes into it.
git checkout branch1
git merge branch2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git rebase however performs this differently.  When you rebase your branch onto another branch, git changes the whole base of the branch to the new commit. Its is as though you have started working from the latest changes of the other branch. It takes all the commits from your branch and starts applying them one by one on the new branch, thereby modifying the git branch history.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;///  checkout the branch your are working and rebase the branch with latest changes into it.
git checkout branch1
git rebase branch2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkftpmgzz7ixtqaxldsw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkftpmgzz7ixtqaxldsw.jpg" alt="Merge vs rebase" width="786" height="828"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Git Rebase?
&lt;/h3&gt;

&lt;p&gt;Rebase is an operation that is not used or not understood properly. If we can just merge the changes, then why would you need to think of rebasing? But rebase has its own uses. One of the most important advantages of git rebase is, it keeps your history in a linear fashion. There will not be any unnecessary branchings when you use rebase.  Git rebase also allows us to rebase the commits in an interactive way. This allows us to perform lots of other operations&lt;/p&gt;

&lt;h3&gt;
  
  
  Git Rebase interactive
&lt;/h3&gt;

&lt;p&gt;If we want to rebase with the interactive prompt, we need to use the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rebase branch2 -i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some of the functionalities we can achieve through interactive rebasing are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;we can squash multiple commits into a single commit&lt;/li&gt;
&lt;li&gt;normally git rebase will apply all the commits. We can choose to skip the commits we don't want to include.&lt;/li&gt;
&lt;li&gt;change the order in which commit occurs in your git history.&lt;/li&gt;
&lt;li&gt;change the commit messages of previously committed changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tm2e8kfzr0phh192mcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tm2e8kfzr0phh192mcq.png" alt="rebase interactive" width="800" height="756"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Rebase only part of the commit
&lt;/h3&gt;

&lt;p&gt;If you want to rebase only a specific number of commits then you can do so by using the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rebase branch2 -i HEAD~3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will now rebase only the last 3 commits.&lt;/p&gt;

&lt;p&gt;These are some very powerful functionalities that will affect the whole branch. We should be careful and use rebase only when we know it's safe to do so. Once you have changes git history it is impossible to recover that.&lt;/p&gt;

&lt;h3&gt;
  
  
  When should you not use git rebase
&lt;/h3&gt;

&lt;p&gt;Usually, it is advised to use rebase only on the branches in which only you are working. It is useful to use rebase in this case and it also helps to keep the local commit tree clean from unnecessary commits. But once you have raised a PR, we should not rebase any further as it will change the commit tree which will cause confusion for the reviewer.&lt;br&gt;
Another thing to keep in mind is that we should never rebase a public branch. We should never rebase a feature branch, in which lots of people are working. This will cause lots of issues for those who are using the branch currently. So it's not a great idea to rebase on public facing branches.&lt;/p&gt;

</description>
      <category>github</category>
      <category>codenewbie</category>
      <category>webdev</category>
      <category>codereview</category>
    </item>
    <item>
      <title>Demystifying Web Jargons Part - 2</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sun, 04 Jul 2021 10:58:48 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/demystifying-web-jargons-part-2-24nh</link>
      <guid>https://dev.to/_mohanmurali/demystifying-web-jargons-part-2-24nh</guid>
      <description>&lt;p&gt;Welcome to the second part of my demystifying web jargons series. If you have not checked the first part, you can do so from here&lt;br&gt;
&lt;a href="https://dev.to/_mohanmurali/demystifying-web-jargons-part-1-1364"&gt;Demystifying Web Jargons Part - 1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today we will be covering the below topics. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API&lt;/li&gt;
&lt;li&gt;DOM&lt;/li&gt;
&lt;li&gt;Web Service &lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So let's start straight away.&lt;/p&gt;

&lt;h3&gt;
  
  
  API
&lt;/h3&gt;

&lt;p&gt;API stands for &lt;em&gt;Application Programming Interface&lt;/em&gt;. According to Wikipedia “&lt;em&gt;an API is a type of software interface, offering a service to other pieces of software&lt;/em&gt;”. Let's try to understand this definition by breaking it down. First of all, it's a software interface, which means it is a bridge that allows the software to talk to another software. Unlike a graphical user interface (GUI), which allows a person to communicate with a computer or a computer program, an API is not designed to be used by common people. It is specifically designed to be used by a software of software developer.&lt;br&gt;
    The second line state that it offers services to other software. That means it allows others programs to talk to software through certain methods. These methods are called the &lt;em&gt;endpoints&lt;/em&gt; or &lt;em&gt;API methods&lt;/em&gt; that the API is said to &lt;em&gt;expose&lt;/em&gt; to the outer world. This is one of the purposes of API, which is to hide the underlying implementation of a program. When a program uses these exposed methods it is said to &lt;em&gt;consume&lt;/em&gt; the API method or endpoint.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  DOM
&lt;/h3&gt;

&lt;p&gt;We now know that the browser renders a webpage with the help of HTML (check part 1 of this post for details). HTML along with CSS allows us to create beautiful web pages. But if you see any modern websites, you will notice that they allow users to interact with them in multiple ways other than just navigating from one page to the next. This capability to be interactive with the user is done using javascript which is a programming language (although nowadays you can also use web assemblies to achieve this). But to interact with an HTML element javascript will need to understand and parse HTML in a way that makes it easy for it to work with it.&lt;/p&gt;

&lt;p&gt;The browser engine converts the HTML document to a tree structure, wherein each node is an object representing a part of the document. Each branch of the tree ends in a note. This Tree structure is called &lt;em&gt;Document Object Model or DOM&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The DOM API exposes methods that allow programmatic access to the tree and one can change the structure, style, and/or content of the HTML document using these APIs. They also expose APIs, that allow us to attach &lt;em&gt;Event handlers&lt;/em&gt; to the DOM nodes. An &lt;em&gt;Event Handler&lt;/em&gt; is a function that is triggered when a certain event is fired. An event can be any of the inputs even like a mouse click or button press. There are various events available for us to work with. Using these &lt;em&gt;Event Handlers&lt;/em&gt; It becomes possible for us to build an interactive website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqie9v5ooxhbny9og95k.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqie9v5ooxhbny9og95k.jpg" alt="DOM tree" width="600" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Web Service
&lt;/h3&gt;

&lt;p&gt;An interactive site is not very useful if it doesn't have any data. Every site needs data from the server. A &lt;em&gt;web service&lt;/em&gt; is an API through which a client or another server can talk to a server. A web service can be called from a client or another server. It allows us to communicate with other devices through the world wide web. In other words, a web service is an interface that allows us to communicate over the internet by transferring data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7e7784cjlw2pnshcigw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7e7784cjlw2pnshcigw.png" alt="Web Service" width="592" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Database
&lt;/h3&gt;

&lt;p&gt;Now we got the data from the client, but this data needs to be stored somewhere. Storing data is a complex and sensitive task. Over the internet, data is everything. A small data inconsistency might be the doom of a company if not worse.&lt;/p&gt;

&lt;p&gt;A &lt;em&gt;Database&lt;/em&gt; is a special server dedicated to storing and updating data. A database is usually controlled by a &lt;em&gt;database management system (DBMS)&lt;/em&gt;. There are Primarily two kinds of databases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Relational Database&lt;/li&gt;
&lt;li&gt; Document Database&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Relational Database
&lt;/h3&gt;

&lt;p&gt;Relational database stores the data in an optimized fashion, to minimize the duplicate storing of the data, by splitting the data and storing them into different tables. When we need to manipulate this data, we need to connect these tables and update the data. This is a complex task and usually performed by using &lt;em&gt;Structured Query Language&lt;/em&gt; or &lt;em&gt;SQL&lt;/em&gt;. SQL is used by almost all relational database management systems for handling the connected or relational nature of the tables. Since the data is split and stored in multiple tables, the data needs to be looked up and fetched from multiple tables. Due to this, a relational database tends to be a little slower in its capacity to read and write data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw429urpoz85ez5svip2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw429urpoz85ez5svip2z.png" alt="Relational DB" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Document Database
&lt;/h3&gt;

&lt;p&gt;A document database stores the data in unstructured documents or collections. These database systems do not depend on tables and hence they don't need special language like SQL to work with the data. They are also extremely fast in their reads and writes as they don't need to look up and connect multiple tables. The drawback of a document Database is that since they store data in unstructured form, the data is often duplicated and hence they require more space. In a way, document databases are similar to the traditional storage of data in a paper document.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftw861jqaylcwesolmiku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftw861jqaylcwesolmiku.png" alt="Doc DB" width="754" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>webdev</category>
      <category>database</category>
    </item>
    <item>
      <title>Understanding Git a little better.</title>
      <dc:creator>Mohan Manavalan</dc:creator>
      <pubDate>Sun, 27 Jun 2021 16:24:35 +0000</pubDate>
      <link>https://dev.to/_mohanmurali/understanding-git-a-little-better-3h4p</link>
      <guid>https://dev.to/_mohanmurali/understanding-git-a-little-better-3h4p</guid>
      <description>&lt;p&gt;I see that a lot of people are confused and even scared of git, especially the beginners. To me, git is an awesome and powerful tool. I will try to explain the common use cases of git. I will not be telling about the commands, but the concepts, so that it will be easier for everyone even if you are using a GUI tool to work with git.&lt;/p&gt;

&lt;p&gt;Let's start by explaining a common word used across git, &lt;em&gt;repository&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Repository
&lt;/h3&gt;

&lt;p&gt;A &lt;em&gt;repository&lt;/em&gt; or a repo (as it is commonly called) is a folder containing all your source code, the build scripts, dependency information, unit tests, environment variables, etc. Basically, when you say you are working in an app, everything for that app will be under a single repository (although not necessary).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh08wj8lxw3a130jum912.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh08wj8lxw3a130jum912.jpg" alt="Repository" width="291" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Branch
&lt;/h3&gt;

&lt;p&gt;This is probably the most basic use case of a version control system. When you have an app running in production, typically you would not want to change its code as it might impact your live app. So, if you want to make any changes, first you need to create a copy of the original repo, and then work on it. Git allows us to easily create this copy by using &lt;em&gt;Branches&lt;/em&gt;. The original repo is usually called the &lt;strong&gt;main&lt;/strong&gt; branch or &lt;strong&gt;master&lt;/strong&gt; branch. The copied branch can be named anything, feature, beta, v1.0, v2, depending on the naming scheme of your team. From here onwards, I will just call it the feature branch for simplicity's&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdrvm23dhmfomi4njuya.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdrvm23dhmfomi4njuya.jpg" alt="branch" width="451" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloning
&lt;/h3&gt;

&lt;p&gt;It's not a good idea to keep your code only in your local machine. If something happens to your computer, you will lose all your code. To prevent this from happening, we normally host our repos in servers like Github, Bitbucket, Codecommit, etc (Github being the most popular one). If your fellow developer wants to work on the code, they will need to download a copy of your code into their local machine. This process of downloading the code into our local machine from a server is called &lt;em&gt;cloning&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4nxmr1vin8fc3qbb0i4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4nxmr1vin8fc3qbb0i4.jpg" alt="Cloning" width="800" height="629"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Commit
&lt;/h3&gt;

&lt;p&gt;You have made some changes for your feature. Now you need to save your changes into your git repository. We can do this by using commit. But commit not only saves the files but also creates a copy or snapshot of the original file and saves the file every time you perform &lt;em&gt;commit&lt;/em&gt;. Commit is one of the core features of git. Git does not take any changes that we make into consideration unless we explicitly mark the change for commiting. This process of marking the change for commiting is called &lt;em&gt;staging in git&lt;/em&gt;.  After you stage a file, you will need to give some message on what the change is. This will be useful in case you ever want to come back to this commit. So it is always advised to give a proper and meaningful &lt;em&gt;commit message&lt;/em&gt;. Each time we commit a change, git tracks it and adds a unique id for that commit.  You can get the full information on all the commits by using &lt;em&gt;git log&lt;/em&gt; or any nice GUI tool that shows the &lt;em&gt;git graph&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjz1am3hf8pog0v2dznr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjz1am3hf8pog0v2dznr.jpg" alt="git log" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Log will show you where your current code is usually by marking them as &lt;em&gt;head&lt;/em&gt;. It also shows other information's such as the commit message, author information, the date and time of the commit, etc. If you are using a GUI tool, it might show the information in a different way. If you are using VS code, I would recommend installing the git graph extension. It shows the information in a really nice way as below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvr24jc07v2p2t3d69x2.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvr24jc07v2p2t3d69x2.JPG" alt="git log as graph" width="800" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you see the data is shown in a table here. The columns denote the commit messages, Date, author and commit ids. each row is actually a git commit. "origin/Head" shows at which commit the code is in our local, which in this case happens to be at "origin/master". "origin/docs", "origin/feat/automatic-esm-file-generation" and "origin/feat/show-sent-data-in-rest-errors" are the other branches in this repo (as you see in the graph column, they are also denoted with a different color). Here we can see that "origin/feat/automatic-esm-file-generation" and "origin/feat/show-sent-data-in-rest-errors" are branches with changes that are not there in the master branch as they start from the master branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Push
&lt;/h3&gt;

&lt;p&gt;When we make a change and commit the code, the change is only saved in our local machine. To share this change with other team members you will need to upload these changes into your git repository on your server. To do this we need to perform push. It's like we are pushing the code from our local machine back to the server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkje6v34atyqzooyruxp0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkje6v34atyqzooyruxp0.jpg" alt="Git push" width="692" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Pull
&lt;/h3&gt;

&lt;p&gt;In a team, there will be more than one developer working on the code. The code in the server constantly keeps getting updated. But these changes will not be automatically downloaded into your local machine. To get the code into your local machine you need to &lt;em&gt;pull&lt;/em&gt;. Pull will get the latest code of your selected branch into your local machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fetch and Fetch All
&lt;/h3&gt;

&lt;p&gt;Pull will get the latest changes from the server into your local machine and update it in your branch. If you just want to get the latest changes of the branch, then you need to &lt;em&gt;fetch&lt;/em&gt;. If you want all the latest changes from the server to your local, you have to perform &lt;em&gt;Fetch All&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Merge
&lt;/h3&gt;

&lt;p&gt;If you want to get the latest changes from another branch into your branch, then you will have to &lt;em&gt;merge&lt;/em&gt; the other branch into the branch. If you are working on a file that was also changed in the other branch, then you will be shown conflicts while merging. You need to resolve these conflicts before you can proceed with the merge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg44rxny9jvz5vi5dzqfd.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg44rxny9jvz5vi5dzqfd.JPG" alt="merge" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>codenewbie</category>
      <category>git</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
