<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: iAmGjert</title>
    <description>The latest articles on Forem by iAmGjert (@iamgjert).</description>
    <link>https://forem.com/iamgjert</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%2F817715%2F1175eb71-2eb9-4aec-a6e8-0cbd81b2ca7c.png</url>
      <title>Forem: iAmGjert</title>
      <link>https://forem.com/iamgjert</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/iamgjert"/>
    <language>en</language>
    <item>
      <title>Cascade with me down the sheet</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Wed, 06 Jul 2022 17:21:06 +0000</pubDate>
      <link>https://forem.com/iamgjert/cascade-with-me-down-the-sheet-5dif</link>
      <guid>https://forem.com/iamgjert/cascade-with-me-down-the-sheet-5dif</guid>
      <description>&lt;h2&gt;
  
  
  CSS
&lt;/h2&gt;

&lt;p&gt;Have you ever sat down to read a document and thought, "Man, there is just so much black and white. This isn't fun to read..."? Well, you're not alone! Way back in 1994 Håkon Wium Lie thought the same thing and, while working with a computer scientist named Tim-Berners-Lee, invested the first iteration of CSS! While both men were working for CERN (Yes, the same CERN that recently started up their large hadron collider) they wanted to provide a way to style documents being presented. This led to the start of CSS, which mostly just allowed different fonts, font colors, and backgrounds.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  CSS2 &amp;amp; CSS3
&lt;/h2&gt;

&lt;p&gt;CSS2 was released in November of 1997 and addressed multiple issues with it's predecessor as well as updated it's styling options and design influences. It mostly centered around allowing CSS to be used on other media types so that it could be used for page layout design. Just a year and a half later CSS3 came out adding presentation-style properties. Key updates included rounded-borders and the ability to split text sections into multiple columns. CSS3 separated the CSS into individual modules, improving functionality. Without CSS, many web designers had to use techniques such as HTML tables to display information, which isn't always the easiest to read. CSS allows us to add more animation and less static properties to our webpages. Previously, we needed some additional programming and scripting, but now it can all be done in CSS3. One of the few downsides is that not all web browsers have the same default CSS stylesheet. In order to correct this and ensure your information is displayed the same way regardless of web browser, you'd have to use a CSS reset.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Reset
&lt;/h2&gt;

&lt;p&gt;CSS resets come in all shapes and sizes. Some are more thorough while others cover multiple properties and attributes you may not have even thought of. You can find a lot of different CSS reset templates online, but an example I use often is from &lt;a href="//meyerweb.com"&gt;MeyerWeb&lt;/a&gt; that coveres a large portion of what's needed in a CSS reset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This CSS reset isn't perfect and doesn't cover all instances: notably it does not set a background. You may think it'd be a good idea to zero everything out via the universal selector, but doing so can cause you to miss some attributes. Some browsers will apply these styles to all elements, some will ignore them altogether on nested attributes and form elements. It's typically safer to explicitly list your elements and force the reset.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS4
&lt;/h2&gt;

&lt;p&gt;Since we've already had three iterations of CSS, you may be asking yourself, "What about CSS4?!" Well, the answer is there is no CSS4. Since CSS was modulated, individual components have reached level 4, but others haven't needed to be or haven't been updated to that level and likely won't be updated or upgraded to that level. So, it's said that there is no and will be no CSS4.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Label the ends of your &lt;code&gt;div&lt;/code&gt;. Sometimes it's helpful to have a comment label at the closing tags to help you keep track of your &lt;code&gt;div&lt;/code&gt;'s.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test as you go! Test on multiple browsers as you're building so you don't have to make so many changes later on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use image optimization software to safe space without losing image quality.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Practice, practice, practice. There are always more then one way to style something, but some ways are more efficient then others! Practice makes perfect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try to keep all styling in one location. In-line style tags can be a pain. Avoid mixing CSS and HTML if possible outside of development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript at the bottom! It was a common practice in the late 90's and early 00's to place your &lt;code&gt;script&lt;/code&gt; tag in the &lt;code&gt;head&lt;/code&gt; of your html. You want to place your JavaScript at the bottom of your documents. That will ensure that JS files will be loaded only when the content has properly been displayed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ways to Practice
&lt;/h2&gt;

&lt;p&gt;There are plenty of ways out there to practice CSS, from styling your own projects to trying to recreate a webpage you're looking at. My favorite way to practice is &lt;a href="https://cssbattle.dev/" rel="noopener noreferrer"&gt;CSSBattle&lt;/a&gt;. CSSBattle has new challenges everyday. It shows you a small 300x200px image and asks you to recreate that image using only CSS in as few characters as possible. It has a leaderboard for you to track your skills as you go and challenge your friends!&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>X marks the 'ngin'</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Wed, 06 Jul 2022 08:45:39 +0000</pubDate>
      <link>https://forem.com/iamgjert/x-marks-the-ngin-58jj</link>
      <guid>https://forem.com/iamgjert/x-marks-the-ngin-58jj</guid>
      <description>&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Web server&lt;/strong&gt;: The computer that is serving web pages.&lt;/p&gt;

&lt;p&gt;A web server delivers requested web pages. Users send requests along their local area network, and that request gets sent along to the webserver at the URL. That webserver will process the request and generate a response containing the requested URL's &lt;code&gt;/endpoint&lt;/code&gt; index.&lt;/p&gt;

&lt;p&gt;There are a plethora of webserver software out there, including XAMPP, Apache, Nginx, Tornado, Caddy, Microsoft Internet Information Services (IIS), and many more! The one you choose is typically up to personal preference, but today I'm going to focus on Nginx.&lt;/p&gt;

&lt;p&gt;Nginx is an open source software developed in 2002. It is a webserver used for reverse proxying, caching, and load balancing. Nginx was designed with maximum performance and stability in mind. A few of the benefits of using Nginx are that it functions as a proxy server for emails. It uses a non-threaded and event driven architecture. It's simple to use and reduces overall load times for your clients. &lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;Architecture of nginx: master-slave architecure. Nginx supports asychronous, event driven, and non-blocking model&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IK7_WeGB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vnddee9xd9yipqsen5k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IK7_WeGB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vnddee9xd9yipqsen5k.png" alt="Nginx Archetecture" width="788" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reasons to use Nginx:&lt;br&gt;
-Easy to install and maintain&lt;br&gt;
   the installation process is only three simple steps and you only need to remember one command to start/stop/restart the server.&lt;br&gt;
-Reduced wait times for users&lt;br&gt;
-Improved Performance&lt;br&gt;
  if you run multiple instances of the same server, nginx can route traffic for you in such a way that increases your overall speed.&lt;br&gt;
-Load Balancing&lt;br&gt;
  some commercial load balancing programs are expensive. Nginx is free.&lt;br&gt;
-Scalability&lt;br&gt;
   Some webservers are only able to handle a set number of concurrent requests. Nginx does not have that limitation and can will not throttle speeds depending on the number of incoming requests.&lt;br&gt;
-No downtime during upgrades.&lt;br&gt;
   Nginx is able to restart without any downtime at all. Less downtime means less waiting and confusion for your clients.&lt;/p&gt;
&lt;h2&gt;
  
  
  Config
&lt;/h2&gt;

&lt;p&gt;Core settings of Nginx are mainly configured in the &lt;code&gt;nginx.conf&lt;/code&gt; file. The config is mainly structured in contexts. Some of the most important parts of the config file are: &lt;br&gt;
Worker processes&lt;br&gt;
-defines the number of worker processes that nginx will use.&lt;br&gt;
-usually equal to the number of CPU cores&lt;br&gt;
worker connections&lt;br&gt;
-maximum number of simultaneous connections for each worker processes.&lt;br&gt;
-tells worker processes how many people can simultaneously be served by nginx.&lt;br&gt;
access &amp;amp; error log&lt;br&gt;
-files used to log any erros and access attempts. Used for debugging.&lt;br&gt;
gzip&lt;br&gt;
-settings for gzip compression of nginx responses.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to Install Nginx in 3 Steps:
&lt;/h2&gt;

&lt;p&gt;Step 1: Install Nginx&lt;br&gt;
&lt;code&gt;sudo apt-get install nginx&lt;/code&gt;&lt;br&gt;
Step 2: Adjust Firewall&lt;br&gt;
&lt;code&gt;sudo ufw enable&lt;/code&gt;&lt;br&gt;
Step 3: Check your server.&lt;br&gt;
&lt;code&gt;sudo ufw app list&lt;/code&gt;&lt;br&gt;
You should see a list of a few different applications. Nginx HTTP allows traffic along port 80 for unencrypted web traffic. Nginx HTTPS allows traffic along port 443 for encrypted traffic.&lt;br&gt;
&lt;code&gt;sudo ufw allow 'Nginx Full'&lt;/code&gt; is an example of the command to choose which configuration is choses.&lt;br&gt;
You can use the command &lt;code&gt;sudo ufw status&lt;/code&gt; to see the status of your firewall as well as all allowed traffic.&lt;/p&gt;
&lt;h2&gt;
  
  
  Manage the Nginx process
&lt;/h2&gt;

&lt;p&gt;You can check that status of Nginx with the command &lt;code&gt;sudo systemctl status nginx&lt;/code&gt;&lt;br&gt;
this will output a message about nginx service and reverse proxy is active as well as some other useful information.&lt;/p&gt;

&lt;p&gt;You're essentially setup! One of the last steps is defining your configuration and making sure your server files are accessible by nginx.&lt;/p&gt;

&lt;p&gt;Navigate to and create a new file /etc/nginx/sites-available/&lt;strong&gt;YOUR APP NAME&lt;/strong&gt;. Inside of this file you'll need to define a few parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
listen 80 default_server;
listen [::] default_server;
root /var/www/**YOUR FILE NAME**;
index index.html;
server_name **YOUR SERVER NAME**;
location / {
try_files $uri $uri/ =404;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to make a copy of that file and put it in our sites-enabled directory. Use the command:&lt;br&gt;
&lt;code&gt;sudo ln -s /etc/nginx/sites-available/**YOUR FILE NAME** /etc/nginx/sites-enabled/**YOUR FILE NAME**&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Lastly, there's already a default file being served on port 80. You'll have to move that file out of the /etc/nginx/sites-enabled directory to somewhere else.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo mv /etc/nginx/sites-enabled/default /home/default&lt;/code&gt;&lt;br&gt;
This command will move that file out of the sites-enabled directory and put it in your home directory.&lt;/p&gt;

&lt;p&gt;Now, restarting nginx with the command &lt;code&gt;sudo systemctl restart nginx&lt;/code&gt; you can restart the nginx server (with no downtime) and it should now display the application you were attempting to serve.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>nginx</category>
      <category>javascript</category>
    </item>
    <item>
      <title>VR/MR/AR/XR in Javascript?</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Tue, 28 Jun 2022 14:19:13 +0000</pubDate>
      <link>https://forem.com/iamgjert/vrmrarxr-in-javascript-1gg1</link>
      <guid>https://forem.com/iamgjert/vrmrarxr-in-javascript-1gg1</guid>
      <description>&lt;h2&gt;
  
  
  Starting with the basics
&lt;/h2&gt;

&lt;p&gt;VR is Virtual Reality. Virtual Reality intends to bring it's users into a new reality to explore and experience things unavailable in the real world.&lt;/p&gt;

&lt;p&gt;AR is Augmented Reality. AR uses a combination of sensors, cameras, and mapping software to brings virtual objects and images into the real world. &lt;/p&gt;

&lt;p&gt;MR is Mixed Reality and aims to do a little of both of the above.&lt;/p&gt;

&lt;p&gt;XR or Extended Reality is a sort of larger umbrella term used to describe tech that takes in human-to-PC interface and modifies it by either immersing you in a virtual world (VR), brings new things to or adds to your existing environment (AR) or does a combination of those things (MR).&lt;/p&gt;

&lt;p&gt;The selling points of any good XR experience is how immersive it is to the user. Early on there were limitations in the hardware and users were only able to experience 3 Degrees of Freedom (3DoF) with devices like Google Cardboard or Oculus Go. That meant that while inside the experience the virtual world would rotate with the movement of your cameras, but if you were to physically walk forward or crouch up and down the world would move with you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C--lNrP7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7g3vtomnw3jx68m9zmt6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C--lNrP7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7g3vtomnw3jx68m9zmt6.png" alt="DoF" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Over time a new system of inside out tracking allowed for 6 Degrees of Freedom (6DoF). Now, not only did the hardware track the rotation of your cameras, but also it's relative position in space and could translate that data into your XR experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web-Based AR/VR
&lt;/h2&gt;

&lt;p&gt;Getting started with AR/VR development can be tough, and there are a few arguments to be made for why starting out web-based may be the way to go.&lt;br&gt;
1) Nobody has to download an app! Just click the link and your user is already on the way to using your AR/VR experience.&lt;br&gt;
2) No fees to host your product on an app store! No waiting/review period to see if your app makes the cut!&lt;br&gt;
3) Web Dev is cross-platform and can quickly get your product into more end users hands.&lt;br&gt;
4) Web 2.0 effect. Apps are constantly building on and integrating each other. Developing open-source projects online allows for other users to potentially use your product in a more grand design.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CSTpSFPS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7slq2iqnkkh2i8iyp3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CSTpSFPS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7slq2iqnkkh2i8iyp3p.png" alt="Early web building" width="661" height="625"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Historical Challenges to Web-Based AR/VR
&lt;/h2&gt;

&lt;p&gt;Historically web applications live in a browser sandbox, and aren't given much access to the external hardware that would be needed to build out an AR/VR experience worth coming back to. More modern day devices make this less of problem then it used to be, but AR/VR require a lot of processing power. They can be very CPU/GPU intensive and that could lead to poor performance in a browser application. On top of those cons, building for the web means you're going to have less access to the mature building blocks that already exist and make building VR/AR applications easier. (Things like Vuforia, UNREAL engine, Unity, or ARKit) &lt;/p&gt;

&lt;p&gt;Things are changing, though...&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aYAUaKH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1rb8ze7bf23fzkl26sj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aYAUaKH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1rb8ze7bf23fzkl26sj.png" alt="times changing" width="697" height="651"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Options for building Web AR applications
&lt;/h2&gt;

&lt;p&gt;Most simple AR applications use a Marker system to anchor your AR objects in space. These systems use a camera to locate a symbol nd generate content relative to that symbols location.&lt;/p&gt;

&lt;p&gt;More modern Markerless AR content also exists. AR that through an understanding of the world around it can recognize and map out horizontal surfaces. &lt;br&gt;
It uses SLAM (Simultaneous Localization and Mapping) tracking. Using ARkit and SLAM tracking we're able to make unique AR experiences such as "portals" that have been seen on popular apps such as Snapchat and Instagram. &lt;/p&gt;

&lt;p&gt;Three.js is a JavaScript based 3D library that allows you to write JavaScript code to instantiate 3D graphics and objects.&lt;/p&gt;

&lt;p&gt;aframe is an Entity Component System that can run on top of three.js&lt;/p&gt;

&lt;p&gt;An Entity Component System is a "Data oriented architectural systems that lend themselves well to game development because instead of of object oriented objects that derive their identity from a class or subclass they inherit from, entities derive their identity by their association with named sets of data (i.e. components) and you can mutate or assign those components to other entities on the fly and those entities wills start to adopt behavior that comes from those data sets through the systems that process those components." -Don Shin, CrossComm&lt;/p&gt;

&lt;p&gt;Three.js has a free editor.&lt;br&gt;
aframe has a visual inspector.&lt;br&gt;
Below is an example of a primitive entity object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a-entity id="box1"
        geometry="primitive: box"
        material="color: #FF9999; shader: flat"
        position="0 0.15 -5"
        rotation="0 45 0"
        &amp;gt;&amp;lt;/a-entity&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These tools are not as well polished as unity, but gives hope for the future of web development as better ecosystems for building 3d environments through web based technologies continue to emerge.&lt;/p&gt;

&lt;p&gt;AR.js is a JavaScript framework (abstraction of JSARToolKit5) for building AR applications.&lt;/p&gt;

&lt;p&gt;AR.js has 3 key features out of the box -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Image Tracking using Natural Feature Tracking (NFT)&lt;/li&gt;
&lt;li&gt;Location Based AR&lt;/li&gt;
&lt;li&gt;Simple Marker (patterns, QWR codes) tracking&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can use AR.js on top of aframe of just AR.js alone.&lt;/p&gt;

&lt;p&gt;Below are some rendered objects using aframe&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tt3tcIda--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2rtz59gr5k47z8c7l4h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tt3tcIda--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2rtz59gr5k47z8c7l4h.png" alt="Example of rendered objects" width="717" height="745"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vr</category>
      <category>xr</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building your own Authentication!</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Fri, 17 Jun 2022 08:48:31 +0000</pubDate>
      <link>https://forem.com/iamgjert/building-your-own-authentication-77o</link>
      <guid>https://forem.com/iamgjert/building-your-own-authentication-77o</guid>
      <description>&lt;h2&gt;
  
  
  What is authentication?
&lt;/h2&gt;

&lt;p&gt;Authentication is the process of verifying that a user is who they are. Nowadays almost everyone is getting so used to clicking "Login with Google" or "Login with Facebook" etc. that it's becoming second nature. Most everyone has a Google or Facebook account so it makes it easier on the user to not have to go through another tedious account creation. Similarly, it makes it easier on the end developer because most of what they'd need from a user to create a basic account is provided by those services when you use them to authenticate users on your application. What happens, though, when your user doesn't have an account with one of these 3rd party services? Are you expecting all your end users who don't have a Google or Facebook account to sign up for that service, to now use your service? That's expecting a lot from an end user! Recently I looked into different ways of building your own authentication service for your application and it was a bit simpler to setup then I'd originally thought. Using a package called bcrypt, a password hashing package that was first developed back in the 90s, I was able to build a mock database of user information very quickly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;To start, I made a basic express service using the &lt;code&gt;npm init&lt;/code&gt; command to start my project and then &lt;code&gt;npm i express bcrypt nodemon&lt;/code&gt; to install the necessary dependencies.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, use command &lt;code&gt;touch server.js&lt;/code&gt; to create your server file. At the top of server.js, import express and bcrypt.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create your express app and use the &lt;code&gt;.json()&lt;/code&gt; middleware to parse incoming json.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create your database that will hold all of your user information. It will contain an array of user objects. Typically you'd use some type of database like mongo or sql to house this data, but for the sake of this example I will be using a local &lt;code&gt;users&lt;/code&gt; array.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const port = 3000; // &amp;lt;--- run the app an any unused port
const app = express(); // &amp;lt;--- create express app
app.use(express.json()) // &amp;lt;--- middleware to parse incoming JSON
app.listen(port, ()=&amp;gt;{
  console.log(`Server listening 👂 http://localhost:${port}`)
})

const users = []; // &amp;lt;--- fake local database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The hard part is done! Now, for the final part we need to ensure we have a script for you in your &lt;code&gt;package.json&lt;/code&gt; file to run your server, and keep it running while we work!&lt;br&gt;
If you've been following along you should have a "test" script in your &lt;code&gt;package.json&lt;/code&gt; file. We're going to rename that script "start" and pass it a value of "nodemon server.js"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "start": "nodemon server.js"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test your script by running &lt;code&gt;npm start&lt;/code&gt; in the terminal.&lt;/p&gt;

&lt;p&gt;Now, we just need to build out a few endpoints for your server to hit and test some information. Paste these functions into your &lt;code&gt;server.js&lt;/code&gt; file under your database declaration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/', (req, res) =&amp;gt; {
  res.status(200).send('Your server is working!');
})

app.get('/users', (req, res) =&amp;gt; {
  if (users.length &amp;gt; 0) {
    res.status(200).send(users);
  } else {
    res.status(418).send('No users currently.')
  }
})

app.post('/users', async (req, res) =&amp;gt; {
  try {
    const salt = await bcrypt.genSalt(); // &amp;lt;-- value can be incremented for more encryption.
    const hashedPassword = await bcrypt.hash(req.body.password, salt); // &amp;lt;--can be modified to take in # of 'rounds' instead of salt (default 10)
    console.log(salt);
    console.log(hashedPassword);
    const user = {
      name: req.body.name,
      password: hashedPassword,
      email: req.body.email
    }
    users.push(user);
    res.status(201).send(user);
  } catch {
    res.status(500).send();
  }
})

app.post('/users/login', async (req, res) =&amp;gt; {
  const user = users.find( user =&amp;gt; user.name = req.body.name );
  if (user === undefined) {
    return res.status(400).send('Username not found. Please check your credentials.')
  }
  try {
    if (await bcrypt.compare(req.body.password, user.password)) { //passwords match
      res.send('You\'ve successfully logged-in.');
    } else  { //passwords don't match
      res.send('Login failed, please check your credentials.');
    }; // &amp;lt;-- compare is secure to avoid 'timing attacks' bcrypt handles for you
  } catch {
    res.status(500).send();
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have these functions written, we have a few endpoints we can hit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;GET '/'&lt;/code&gt; Should return a status 200 and a message letting you know your server is working.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;GET '/users'&lt;/code&gt; Should return a status of 200 and the entire array of users.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;POST '/users'&lt;/code&gt; Should take in a user object with a name, password, and email property. This endpoint will salt and hash your password, as well as create a user in the users array and store the users information + salted/hashed password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;POST '/users/login&lt;/code&gt; Should also take in a name, password, and email address. This endpoint will first check if the name exists in the database, then if it does it will attempt to check if the password provided matches the de-hashed password stored in the users database. Will return status 400 and message that username doesn't exist if name isn't in the database. Will return message stating successful login on successful password/username match. Will return message stating login failed on unsuccessful password match.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've included some comments in the code itself to try to help explain some of the hashing/seeding methods. For more information check &lt;a href="https://www.npmjs.com/package/bcrypt"&gt;this link &lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Vim? Vim who?</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Mon, 06 Jun 2022 11:17:08 +0000</pubDate>
      <link>https://forem.com/iamgjert/vim-vim-who-n93</link>
      <guid>https://forem.com/iamgjert/vim-vim-who-n93</guid>
      <description>&lt;h2&gt;
  
  
  Preface
&lt;/h2&gt;

&lt;p&gt;There are a plethora of terminal editors out there to choose from and if you'd like to explore a few more thoroughly I'd recommend checking out &lt;a href="https://www.tecmint.com/best-open-source-linux-text-editors/"&gt;this list&lt;/a&gt; published last year by Aaron Kili. At the end of the day most editors accomplish he same goal and the one you use is up to personal preference. I am still learning everyday and by tomorrow my opinion could be completely different!&lt;/p&gt;

&lt;p&gt;Over the course of the last few weeks the projects I've worked on have had me editing files directly in the terminal. At first, the terminal editors I used was dictated by what tutorial video I was watching and whether or not they had me download some editor. Now, when I need to edit a file directly in the terminal I almost always use Vim. Vim is available on any Linux machine and is a powerful text editor. I've taken a little time to learn the basics of Vim to quickly navigate and edit specific lines in my files. Even knowing just the simplest of commands that the Vim editor has to offer has made it a tool that I use daily as a developer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TddIj5bR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v1a2ecfk3ht8tqvnp52.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TddIj5bR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v1a2ecfk3ht8tqvnp52.PNG" alt="code snippet in VIM editor" width="880" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  History of the Vim editor
&lt;/h2&gt;

&lt;p&gt;Interestingly, Vim wasn't always intended to replace vi. Vim started out as "Vi IMitation" on systems as early as "Amiga", a personal computer introduced in 1985. Vi was originally written way back in 1976 by a programmer named Bill Joy, but since around 1992 when Vim was first released it has been almost completely replaced. Over time Vim was renamed to "Vi IMproved" as it was ported throughout many other platforms. Vim's original author and, according to &lt;a href="https://en.wikipedia.org/wiki/Bram_Moolenaar"&gt;this Wiki article&lt;/a&gt;, "benevolent dictator for life of Vim" is Bram Moolenaar. (pictured below)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2BAPKPgD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gty2kuscel5sghgekzwb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2BAPKPgD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gty2kuscel5sghgekzwb.jpg" alt="the dictator himself" width="800" height="1060"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Learning all that Vim has to offer could take a long time, but could be highly beneficial as a programmer if you've got the time. There are hundreds of commands and it's highly customizable. It has a shallow memory fingerprint and it's commands can perform highly complex tasks with just a few keystrokes. With just a few basic tutorials I was surprised how easily I could manipulate text documents easily in environments that I wasn't able to access a UI. I can also rest well knowing that most all machines I access will have the Vim editor pre-installed and I can use the commands I've learned on these systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Most useful commands
&lt;/h2&gt;

&lt;p&gt;Some of the commands I find myself using the most are &lt;code&gt;gg&lt;/code&gt; and &lt;code&gt;G&lt;/code&gt;. These commands bring you to the first and last line of the document respectively. Traversing the vim terminal may seem tedious at first, but commands like &lt;code&gt;5gg&lt;/code&gt; or &lt;code&gt;5G&lt;/code&gt; will bring you directly to line 5. Since by default you can't just click where you'd like your cursor to be memorizing some of the commands to move around the terminal will speed up your hacking time. If you lose your cursor &lt;code&gt;zz&lt;/code&gt; will center it on the screen. Pressing &lt;code&gt;i&lt;/code&gt; puts you into 'insert' mode so you can type at the position where you cursor was, and &lt;code&gt;I&lt;/code&gt; does the same, but at the start of the line your cursor is on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enable mouse in vim
&lt;/h2&gt;

&lt;p&gt;Vim actually does have mouse support, you just have to know how to enable it! navigate to your &lt;code&gt;.vimrc&lt;/code&gt; file and add a line. It's that simple! There are a few different options on what line you can add to give your mouse functionality in the different modes that vim has. The commands below enable special use cases as you see fit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = all
n = normal mode
v = visual mode
i = insert mode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are plenty of other commands you can enable if you want. To view them all use the help command or click &lt;a href="https://vim.rtorr.com/"&gt;this link&lt;/a&gt; to view a command cheat sheet.&lt;/p&gt;

</description>
      <category>vim</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>editor</category>
    </item>
    <item>
      <title>A Virtual Machine a day keeps the Docker away</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Mon, 02 May 2022 13:07:55 +0000</pubDate>
      <link>https://forem.com/iamgjert/a-virtual-machine-a-day-keeps-the-docker-away-227i</link>
      <guid>https://forem.com/iamgjert/a-virtual-machine-a-day-keeps-the-docker-away-227i</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is docker?&lt;/strong&gt;&lt;br&gt;
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. These containers can run reliably in any environment. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does that mean?&lt;/strong&gt;&lt;br&gt;
When you've build an app on your machine running windows and you now need to test your app with one of your testers, but they are using an entirely different system. How can replicate the environment your software needs on any machine? That's where Docker, or any other containerization platform comes in.&lt;/p&gt;

&lt;p&gt;Once upon a time if you wanted to run or start any web application you'd have to start off buying a physical server. Once your server was configured and running your application, you may want to expand and setup multiple servers to help manage traffic to your application and ensure you don't crash, so you buy and setup more physical servers. Well, that process was all taken into the virtual world with the introduction of cloud based computing. We were able to find a way to setup these physical servers, virtually in the form of virtual machines. We would use software called hypervisors to divide our server's physical resources into separate self contained virtual machines, each with their own OS, CPU, Memory resource, and most importantly, it's own kernel (the core of a system's operating system. Operating System is a system software. Kernel is system software that is part of the operating system. Operating System provides interface between &lt;strong&gt;user and hardware&lt;/strong&gt;. Kernel provides interface between &lt;strong&gt;applications and hardware&lt;/strong&gt;.).  Now lets say we wanted to do that for 3 different applications on our server, if would look something like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_FHnheIg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4szfgprnzik1zmfn7ti.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_FHnheIg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4szfgprnzik1zmfn7ti.PNG" alt="virtual machine description" width="721" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All those virtual machines take up a lot of resources and also take a while to start and setup, each needing it's own copy of various libraries to lay the groundwork for your applications. The introduction of Docker Containers changed that. Instead, Docker containers are able to carry a lot less resources while still maintaining it's ability to run the application quickly, and in a quarantined state by allowing all the resources to flow through one kernel. The Docker Engine uses something called the docker daemon (which in my understanding, functions similarly to the hypervisors with virtual machines) to act as a sort of 'brain' for your docker. It will manage the docker image itself and help allocate resources from your host machine, looking something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vjzIN0KC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mgcvfcfz8dkbuhx5wib.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vjzIN0KC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mgcvfcfz8dkbuhx5wib.PNG" alt="docker container description" width="724" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since each docker container doesn't have to contain it's own OS, the docker daemon is able to communicate directly with the host machine's OS and allocate the appropriate resources for running each container. It also ensures each container is still isolated from the host machine and other containers. We're saving a ton of disk space by not saving a separate OS in each container.&lt;/p&gt;

&lt;p&gt;These containers are ultra portable. A container has all of the information and dependencies needed for your application to run and can be run on any system environment with the same result. You can now send your container to your testers and regardless of the system they're running your app should perform as expected on the host machine.&lt;/p&gt;

&lt;p&gt;Similar to how NPM is both an application and a library, Docker offers an extensive library of applications and builds that come pre-packaged for you  as a docker container called the Docker Hub. The Docker Hub is a public repo of Docker images that boasts over 100,000 container images from software vendors, open-source projects, and individual developers alike. One day, even you could have your very own application image hosted on the Docker Hub for other users to pull down and tinker around with. I hope this brief explanation of Docker and it's uses has shed some light on the power of docker and it's uses in web development and deployment. &lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Rumor is there's an "event bubbling" up!</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Mon, 25 Apr 2022 12:36:47 +0000</pubDate>
      <link>https://forem.com/iamgjert/rumor-is-theres-an-event-bubbling-up-kj1</link>
      <guid>https://forem.com/iamgjert/rumor-is-theres-an-event-bubbling-up-kj1</guid>
      <description>&lt;p&gt;I'm sure at this point we've all got a &lt;em&gt;pretty good&lt;/em&gt; idea what an event is: something that happens. That could mean hovering your mouse, a keystroke, a click, etc. Tracking events help us make our webpages interactive. That being said, have you ever heard of "&lt;strong&gt;&lt;u&gt;Event Bubbling&lt;/u&gt;&lt;/strong&gt;?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Event Bubbling&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt; is a term used to describe the fact that when an event happens in a child node, that same event is tracked throughout it's parent nodes all the way to the top. Since we're already talking about bubbles, I'm going to use a water/diver analogy to help explain what I mean by &lt;strong&gt;event bubbling&lt;/strong&gt;. In this analogy the top or surface of our webpage will be the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;, and all &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; inside will be divers of different experience levels.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;img src="/images/surface.png" width="300" height="100"&amp;gt;
    &amp;lt;div&amp;gt;
      &amp;lt;img src="/images/beginnerDiver.png" width="100"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;img src="/images/experiencedDiver.png" width="100"&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;img src="/images/expertDiver.png" width="100"&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hBNkmmeK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a29oybbkt7dlz0oofyxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hBNkmmeK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a29oybbkt7dlz0oofyxs.png" alt="sampleImage" width="517" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the top level, we have our body/surface. Nested one level lower we have the beginner diver. One level lower then that, we have the experienced diver. Finally, in the deepest depths, we have our expert diver.&lt;/p&gt;

&lt;p&gt;Now that we have our webpage, let's add some events! The simplest would be a click event, so I'll go ahead add an &lt;code&gt;onclick&lt;/code&gt; event to the surface level. Since the surface level is the body of the webpage, clicking anywhere should trigger this click event. I'm also going to add a click event to the expert diver level. This is what our code looks like now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body onclick="alert('Surface')"&amp;gt;
    &amp;lt;img src="/images/surface.png" width="300" height="100"&amp;gt;
    &amp;lt;div&amp;gt;
      &amp;lt;img src="/images/beginnerDiver.png" width="100"&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;img src="/images/experiencedDiver.png" width="100"&amp;gt;
        &amp;lt;div onclick="alert('Expert')"&amp;gt;
          &amp;lt;img src="/images/expertDiver.png" width="100"&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The experienced diver is nested pretty deep down! If he was to let up a bubble (in this case: the click event) what do you think would happen? If you guessed that it will alert "Expert" you'd be partially correct!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ta78bPHF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p92tj24hc7uwdndw8f6t.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ta78bPHF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p92tj24hc7uwdndw8f6t.gif" alt="bubbleGifExplanation" width="544" height="461"&gt;&lt;/a&gt; &lt;br&gt;
&lt;strong&gt;We also get an alert for the surface level!&lt;/strong&gt; &lt;br&gt;
The reason being, both alerts are tied to the same event; in this situation the event was a click. That event "bubbled" its way from the expert diver to each of it's parent nodes (experience diver and beginner diver), but neither of those nodes had a click event so nothing happened. It reached the top and that same click event bubbled through the surface click event and alerted us! If I was to add an &lt;code&gt;onclick&lt;/code&gt; event to each level of the nest and then click on one level, you'd see it execute at each level and then it's parents shortly after.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body onclick="alert('Surface')"&amp;gt;
    &amp;lt;img src="/images/surface.png" width="300" height="100"&amp;gt;
    &amp;lt;div onclick="alert('Beginner')"&amp;gt;
      &amp;lt;img src="/images/beginnerDiver.png" width="100"&amp;gt;
      &amp;lt;div onclick="alert('Experienced')"&amp;gt;
        &amp;lt;img src="/images/experiencedDiver.png" width="100"&amp;gt;
        &amp;lt;div onclick="alert('Expert')"&amp;gt;
          &amp;lt;img src="/images/expertDiver.png" width="100"&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n_OxBgg4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocna4io4vw8hawj9ss20.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n_OxBgg4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocna4io4vw8hawj9ss20.gif" alt="finalBubbleGif" width="500" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That, in a nutshell, is event bubbling!&lt;/p&gt;

</description>
      <category>eventbubbling</category>
      <category>begginner</category>
      <category>html</category>
    </item>
    <item>
      <title>What is NPM?</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Mon, 18 Apr 2022 12:52:42 +0000</pubDate>
      <link>https://forem.com/iamgjert/what-is-npm-2bh4</link>
      <guid>https://forem.com/iamgjert/what-is-npm-2bh4</guid>
      <description>&lt;p&gt;Starting out in my JavaScript journey there were a few things I was told to just "accept" and not worry about how they work. There are plenty of processes and moving parts when writing code and one that I never quite understood was NPM. NPM stands for Node Package Manager, and is used in a few ways. NPM provides an online database of 'packages' or JavaScript tools that can be published by anyone and used in your projects. On top of being an online database, NPM is also a command line tool used to interact with that database and install/manage the packages you install from the database!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a package, though?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0MoHS8TM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3wg64fvbmnjknij58k9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0MoHS8TM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3wg64fvbmnjknij58k9.jpg" alt="packages" width="600" height="325"&gt;&lt;/a&gt;&lt;br&gt;
Think of packages like the brick and mortar of your applications. You can install and combine multiple packages together in order to create the most efficient program for your end users and all those packages are easily maintained by NPM. The NPM database helps keep all your packages up to date by allowing the packages to be managed and updated by their publishers and other developers. Whenever an update or improvement is made to a package and uploaded to NPM's database, all users who currently use that package can easily fetch those updates from the server and always keep their packages up to date. NPM also helps handle package dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a dependency?
&lt;/h2&gt;

&lt;p&gt;Some packages are built directly upon other packages in NPM and 'depend' on them to function properly; these relationships are called dependencies. Dependencies would typically cause problems when trying to use different packages, but NPM handles all the hard work for you. When installing packages through NPM the service will automatically search for and install all required dependencies for any packages you're attempting to use/install. &lt;/p&gt;

&lt;h2&gt;
  
  
  In conclusion:
&lt;/h2&gt;

&lt;p&gt;NPM is a wonderful tool for developers to not only share reusable code, but to keep that code updated and working for all future projects. There are hundreds of packages to chooses from and plenty that can be built and expanded upon. Who knows, maybe one day you'll be posting and updating a package of your own for the world to use!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CHjdV_Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/raduus03on2iwdu3gfr5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CHjdV_Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/raduus03on2iwdu3gfr5.jpg" alt="library" width="825" height="533"&gt;&lt;/a&gt;&lt;br&gt;
A few of the most popular libraries (in no particular order, just ones I'd heard of or used before) are:&lt;br&gt;
&lt;strong&gt;jQuery:&lt;/strong&gt; a small and fast feature-rich JavaScript library making HTML document traversal, manipulation, and event handling much easier.&lt;br&gt;
&lt;strong&gt;Express:&lt;/strong&gt; noted as one of the best NPM packages offering a server framework for web applications.&lt;br&gt;
&lt;strong&gt;Lodash:&lt;/strong&gt; A particularly useful tool, especially when working with lots of numbers or arrays. Makes the creation of complex functions much easier.&lt;br&gt;
&lt;strong&gt;React:&lt;/strong&gt; a declarative, efficient, and flexible JavaScript library for building user interfaces.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>node</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Copy by Value vs Reference</title>
      <dc:creator>iAmGjert</dc:creator>
      <pubDate>Fri, 18 Feb 2022 19:15:30 +0000</pubDate>
      <link>https://forem.com/iamgjert/copy-by-value-vs-reference-1bd3</link>
      <guid>https://forem.com/iamgjert/copy-by-value-vs-reference-1bd3</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Intro&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
There are two ways to pass a value to a variable in JavaScript and understanding how they operate is fundamental to your success at manipulating data in your code. In this short blog I will explain the differences between the two and provide examples along the way. Variables will either be passed a &lt;strong&gt;copy of the value&lt;/strong&gt; of they're being assigned, or be passed a &lt;strong&gt;reference to the value&lt;/strong&gt; they're being assigned.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr5kibnwkd6g73ucf5ozy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr5kibnwkd6g73ucf5ozy.png" alt="sample variable"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Copy by Value&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
When working with primitive data types (numbers, strings, Booleans, null, and undefined) your variables will be making a copy of the value they're being assigned and represent that specific copy of the value. Any changes to the original data will not effect the copy that was made and stored in the variable we've created. Vice versa, these values stored into our variable can be manipulated without any changes to the original data.&lt;/p&gt;

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

&lt;p&gt;In the image above, &lt;u&gt;b&lt;/u&gt; is being assigned the value stored in the &lt;u&gt;a&lt;/u&gt; variable. Since the &lt;u&gt;a&lt;/u&gt; variable is storing a primitive data type &lt;u&gt;b&lt;/u&gt; is &lt;strong&gt;assigned a copy&lt;/strong&gt; of that value. Any changes made to &lt;u&gt;a&lt;/u&gt; later on will not effect &lt;u&gt;b&lt;/u&gt;'s value. &lt;br&gt;
&lt;code&gt;a === 1 //true&lt;/code&gt; &lt;code&gt;b === 1 //true&lt;/code&gt;&lt;/p&gt;

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

a = undefined;
console.log(b); // prints 1, not effected by a being reassigned.


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Copy by Reference&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
When working with complex data types (Objects, arrays, functions) your variables &lt;strong&gt;will not make a copy&lt;/strong&gt; of the value they're being assigned to, but instead &lt;strong&gt;will make a reference&lt;/strong&gt; to that data. Any manipulation of our variable will effect the original data since our variable is just a reference to the original data. Similarly, any changes to the original data &lt;em&gt;will&lt;/em&gt; effect our variable as well.&lt;/p&gt;

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

let a = {
   name: 'Object',
   color: 'blue'
}
let b = a;


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

&lt;/div&gt;

&lt;p&gt;In the code above, the &lt;u&gt;a&lt;/u&gt; variable has been assigned to an object with two properties. Just under that, we've assigned the &lt;u&gt;b&lt;/u&gt; variable to the &lt;u&gt;a&lt;/u&gt; variable. When the &lt;u&gt;b&lt;/u&gt; variable is assigned here, it will be &lt;strong&gt;assigned a reference&lt;/strong&gt; to the same object the &lt;u&gt;a&lt;/u&gt; variable is already assigned to. Any changes to the &lt;u&gt;b&lt;/u&gt; variable will effect the original data stored in the &lt;u&gt;a&lt;/u&gt; variable.&lt;br&gt;
&lt;code&gt;b.color = 'orange'&lt;/code&gt;&lt;br&gt;
Since both variables point to the same object, the color of the object both variables point to will be assigned to 'orange'.&lt;/p&gt;

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

console.log(a); // prints {name: 'Object, color: 'orange'} 
console.log(b); // prints {name: 'Object, color: 'orange'}


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

&lt;/div&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;u&gt;In Summary&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00irkh2jsmre37ngzdgt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00irkh2jsmre37ngzdgt.gif" alt="coffee cups"&gt;&lt;/a&gt;It's important to know whether the data you're working with is a copy or a reference. If you're working with a copy it's less detrimental to the overall program as your changes are localized to that copy of the data. When working with a reference your changes effect the overall data and can produce unwanted changes later in your code if not caught.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>reference</category>
      <category>value</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
