<?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: Joseph Giwa</title>
    <description>The latest articles on Forem by Joseph Giwa (@giwajossy).</description>
    <link>https://forem.com/giwajossy</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%2F441232%2F5b735e29-82a3-40e2-bc53-6a8d59f7d80f.jpeg</url>
      <title>Forem: Joseph Giwa</title>
      <link>https://forem.com/giwajossy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/giwajossy"/>
    <language>en</language>
    <item>
      <title>Understanding WebSocket: Real-Time Communication Made Easy</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Tue, 11 Feb 2025 22:07:19 +0000</pubDate>
      <link>https://forem.com/giwajossy/understanding-websocket-real-time-communication-made-easy-5904</link>
      <guid>https://forem.com/giwajossy/understanding-websocket-real-time-communication-made-easy-5904</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;A Simple Analogy&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine you are at a restaurant and place an order. In a traditional setup [like HTTP requests], you call the waiter over, place your order, and then wait. If you want an update on your food, you have to keep waving them down and asking, "Is my food ready yet?"&lt;/p&gt;

&lt;p&gt;Now, imagine a different approach—when you order, the waiter gives you a small pager. Instead of you having to ask repeatedly, the pager buzzes the moment your food is ready. This is how WebSocket works—once a connection is established, the server can push updates to the client in real-time, without the client having to check back constantly.  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What is WebSocket?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;WebSocket is a &lt;a href="https://www.totalphase.com/blog/2022/10/difference-between-half-duplex-vs-full-duplex/" rel="noopener noreferrer"&gt;full-duplex&lt;/a&gt; communication protocol that allows real-time data exchange between a client [e.g., browser] and a server over a persistent connection. Unlike traditional HTTP, where the client must request updates, WebSocket allows the server to push updates instantly when new data is available.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Practical Use Cases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chat Applications&lt;/strong&gt;: Instant messaging platforms rely on WebSocket for real-time message delivery. [e.g., WhatsApp, Slack, Messenger]&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Notifications&lt;/strong&gt;: Updates like stock prices, sports scores, or breaking news leverage WebSocket for instant alerts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiplayer Games&lt;/strong&gt;: Real-time interactions between players depend on WebSocket’s low-latency communication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaborative Tools&lt;/strong&gt;: Tools like shared documents or whiteboards use WebSocket to synchronize changes instantly among users. [e.g., Google Docs, whiteboards, live code editors]&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;The Chatbot on &lt;a href="https://send247.uk" rel="noopener noreferrer"&gt;Send247's website&lt;/a&gt; is another solid example. &lt;/p&gt;

&lt;p&gt;Send247 facilitates fast, reliable, and affordable door-to-door deliveries for individuals and businesses across select areas in London. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Demo] user interacting with the Chatbot to book a delivery request.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://player.vimeo.com/video/1055660041" width="710" height="399"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Setting Up WebSocket in Node.js&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s implement a basic WebSocket server using &lt;strong&gt;Node.js&lt;/strong&gt; with the &lt;code&gt;ws&lt;/code&gt; package.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1: Install Dependencies&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To get started, install the &lt;code&gt;ws&lt;/code&gt; library, which provides WebSocket support in Node.js.&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="nb"&gt;install &lt;/span&gt;ws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: Create a WebSocket Server&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This simple WebSocket server listens for incoming connections and messages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;WebSocket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ws&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Create a WebSocket server on port 8080&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;wss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;WebSocket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;wss&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;connection&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;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="s1"&gt;New client connected&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Send a welcome message when a client connects&lt;/span&gt;
    &lt;span class="nx"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Welcome to WebSocket Server!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;

    &lt;span class="c1"&gt;// Listen for messages from the client&lt;/span&gt;
    &lt;span class="nx"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Received: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Broadcast message to all connected clients&lt;/span&gt;
        &lt;span class="nx"&gt;wss&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clients&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;WebSocket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OPEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Echo: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Handle client disconnection&lt;/span&gt;
    &lt;span class="nx"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;close&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="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="s1"&gt;Client disconnected&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="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="s1"&gt;WebSocket server is running on ws://localhost:8080&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple WebSocket server:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;accepts new client connections
&lt;/li&gt;
&lt;li&gt;sends a welcome message to each client
&lt;/li&gt;
&lt;li&gt;listens for messages from clients and echoes them back
&lt;/li&gt;
&lt;li&gt;broadcasts messages to all connected clients
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Creating a WebSocket Client (Browser)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To connect to the WebSocket server from a web page, you can use the built-in &lt;code&gt;WebSocket&lt;/code&gt; API in JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;socket&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;WebSocket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ws://localhost:8080&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Listen for messages from the server&lt;/span&gt;
&lt;span class="nx"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onmessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;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="s1"&gt;Server says:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Send a message to the server&lt;/span&gt;
&lt;span class="nx"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onopen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="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="s1"&gt;Connected to WebSocket server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, WebSocket Server!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Handle connection close&lt;/span&gt;
&lt;span class="nx"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onclose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="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="s1"&gt;Disconnected from WebSocket server&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Enhancing the WebSocket Server: Real-Time Notifications&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s modify the server to &lt;strong&gt;send periodic real-time updates&lt;/strong&gt; [e.g., stock price updates].&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="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stockPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Generate a random stock price&lt;/span&gt;

    &lt;span class="nx"&gt;wss&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clients&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;WebSocket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OPEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`AAPL: $&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;stockPrice&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
        &lt;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="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Send updates every 5 seconds&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, all connected clients receive real-time stock price updates every 5 seconds.  &lt;/p&gt;




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

&lt;p&gt;Whether you are developing a chat app, live notifications, multiplayer games, or collaborative tools, WebSocket enables seamless, efficient, and interactive user experiences. By reducing latency and optimizing resource usage, it powers modern applications that demand real-time engagement.&lt;/p&gt;

&lt;p&gt;If you are looking to enhance your web application with instant communication, WebSocket is the technology to consider. Now that you have a working knowledge of how it functions, it’s time to explore its full potential in your own projects!&lt;/p&gt;

</description>
      <category>websocket</category>
      <category>chatbot</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Resolving the "zsh: command not found: yarn" Error on macOS</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Thu, 06 Jun 2024 07:47:55 +0000</pubDate>
      <link>https://forem.com/giwajossy/resolving-the-zsh-command-not-found-yarn-error-on-macos-1fnk</link>
      <guid>https://forem.com/giwajossy/resolving-the-zsh-command-not-found-yarn-error-on-macos-1fnk</guid>
      <description>&lt;p&gt;For new Mac users transitioning from a Windows environment, you will encounter some initial challenges while setting up your development environment. One of the primary issues you will face is running the &lt;code&gt;yarn&lt;/code&gt; command in the terminal. Here's a step-by-step account of resolving the &lt;code&gt;zsh: command not found: yarn&lt;/code&gt; error.&lt;/p&gt;

&lt;p&gt;😑 &lt;strong&gt;Problem:&lt;/strong&gt; &lt;code&gt;zsh: command not found: yarn&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After cloning your project repository and navigating into the directory, you tried running yarn to install dependencies but got the error below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zsh: command not found: yarn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;😊 &lt;strong&gt;Solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This error indicates that yarn is not installed on your system. To fix this, use Homebrew, a package manager for macOS, to install yarn.&lt;/p&gt;

&lt;p&gt;1) &lt;strong&gt;Install Homebrew&lt;/strong&gt; (if not already installed):&lt;br&gt;
Homebrew simplifies the installation of software on macOS. Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) &lt;strong&gt;Install yarn&lt;/strong&gt;:&lt;br&gt;
With Homebrew installed, you can now install yarn by running:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;3) &lt;strong&gt;Verify yarn installation:&lt;/strong&gt;&lt;br&gt;
After the installation, verify that Yyrn is installed by running:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;😑 &lt;strong&gt;Problem:&lt;/strong&gt; &lt;code&gt;env: node: No such file or directory&lt;/code&gt;&lt;br&gt;
While verifying yarn installation, you encountered another error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;env: node: No such file or directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This error indicates that yarn is installed, but it cannot find Node.js. Yarn depends on Node.js to run.&lt;/p&gt;

&lt;p&gt;😊 &lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
To resolve this, you need to install Node.js using Homebrew:&lt;/p&gt;

&lt;p&gt;1) Install 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;brew install node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Verify both yarn and Node.js Installation as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node -v
yarn -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time, the command should work without any issues, and you can proceed with installing dependencies and running your application.&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>macos</category>
      <category>programming</category>
      <category>node</category>
    </item>
    <item>
      <title>Understanding TypeScript &amp; Using it in Your Node Environment.</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Mon, 15 Nov 2021 19:59:29 +0000</pubDate>
      <link>https://forem.com/giwajossy/understanding-typescript-using-it-in-your-node-environment-3355</link>
      <guid>https://forem.com/giwajossy/understanding-typescript-using-it-in-your-node-environment-3355</guid>
      <description>&lt;p&gt;I struggled with this concept a lot, but let me save you the stress, and explain as simply as I can.&lt;/p&gt;

&lt;p&gt;Typescript is just a secure way of writing JavaScript code. Do not get confused by the fancy terminologies people throw around it.&lt;/p&gt;

&lt;p&gt;The good news is, if you know JavaScript, you already know ~90% of Typescript. The additional layer only forces you to be a lot more intentional about your variables and data types.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Typescript?
&lt;/h3&gt;

&lt;p&gt;Simple answer? To catch errors early in your editor. &lt;br&gt;
Typescript detects silly bugs at runtime; bugs you probably wouldn’t notice until it’s too late when using pure JavaScript.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;
&lt;h3&gt;
  
  
  Here's sample JavaScript code:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;company&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GYRO Design Lab&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isPublished&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;mandem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dexter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Mide&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Emmy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

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

&lt;/div&gt;


&lt;p&gt;But the unfortunate thing here is that, at some point later in your code, the variable &lt;code&gt;company&lt;/code&gt; - for instance, could be re-assigned to a value of an entirely different data type, which would be unexpected behavior. &lt;br&gt;
Sadly, JavaScript will not throw an error, and this poses a compounding threat to your App. &lt;br&gt;
Thankfully, popular code editors like &lt;em&gt;&lt;strong&gt;VScode&lt;/strong&gt;&lt;/em&gt; now use Typescript under the hood, to spot errors like these.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;
&lt;h3&gt;
  
  
  Sample Typescript code
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; 
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GYRO Design Lab&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isPublished&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="c1"&gt;// Here, the variable "x" can later be re-assigned a value of different datatype&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;any&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; 

&lt;span class="c1"&gt;// This is an array of numbers. This - "Number[]", tells the system that the variable "ids" is expected to be an array of numbers. So if you try to push a string in the array, you will get an error.&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; 

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

&lt;/div&gt;


&lt;p&gt;As you can see, with Typescript, you have to explicitly define your Types.&lt;/p&gt;

&lt;p&gt;...&lt;br&gt;
When creating an &lt;em&gt;&lt;strong&gt;object&lt;/strong&gt;&lt;/em&gt;, for instance, you get to create an &lt;em&gt;&lt;strong&gt;interface&lt;/strong&gt;&lt;/em&gt; that defines the shape of your &lt;em&gt;&lt;strong&gt;object&lt;/strong&gt;&lt;/em&gt;;&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;// interface declaration&lt;/span&gt;
&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Javascript object which conforms to the shape of the interface. &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Janet&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// Typescript will warn you if it doesn't match.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...&lt;/p&gt;

&lt;h3&gt;
  
  
  So what exactly happens under the hood?
&lt;/h3&gt;

&lt;p&gt;Typescript code transpiles to JavaScript, which runs anywhere JavaScript runs: In a browser, on NodeJS, and in your apps.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“Transpiling is a specific term for taking source code written in one language and transforming into another language that has a similar level of abstraction”&lt;/em&gt; - &lt;em&gt;&lt;strong&gt;stackoverflow.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;...&lt;br&gt;
When setting up your Typescript+NodeJS project, your entire project files are usually in a folder, including your Typescript [&lt;em&gt;&lt;strong&gt;.ts&lt;/strong&gt;&lt;/em&gt;] files. &lt;/p&gt;

&lt;p&gt;However, your browser will not run &lt;em&gt;&lt;strong&gt;.ts&lt;/strong&gt;&lt;/em&gt; files, this is why the Typescript engine automatically generates a new project folder containing the transpiled version of our entire project, which we can now run and test.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h3&gt;
  
  
  Now let's create a simple NodeJS App, and configure Typescript.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Initialize your project&lt;br&gt;
&lt;code&gt;npm init -y&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Typescript as dev dependency.&lt;br&gt;
&lt;code&gt;npm install -D typescript&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate a configuration file - &lt;em&gt;&lt;strong&gt;tsconfig.json&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;code&gt;npx tsc --init&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now open the &lt;em&gt;&lt;strong&gt;tsconfig.json&lt;/strong&gt;&lt;/em&gt; file, you will see a bunch of commented-out codes; no worries, look for the properties below, and make these changes to them.&lt;br&gt;
&lt;strong&gt;Note&lt;/strong&gt;: Some of the properties below are commented-out by default in the &lt;em&gt;&lt;strong&gt;tsconfig.json&lt;/strong&gt;&lt;/em&gt; file, you will have to uncomment them.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;”Target": "es6”&lt;/code&gt;&lt;br&gt;
&lt;code&gt;”rootDir": "./src”&lt;/code&gt; "src" will be the name of your project folder &lt;br&gt;
&lt;code&gt;”outDir": "./build”&lt;/code&gt; "build" is the auto-generated folder that will holds your transpiled files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In your package.json file, add the following tags into your &lt;code&gt;"scripts"&lt;/code&gt; key like so;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&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;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&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;span class="s2"&gt;"tsc"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run build &amp;amp;&amp;amp; node build/index.js"&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;p&gt;&lt;code&gt;"build" : "tsc"&lt;/code&gt; is responsible for transpiling the Typescript codes to JavaScript, and &lt;code&gt;"dev": "npm run build &amp;amp;&amp;amp; node build/index.js"&lt;/code&gt; runs the program when you type &lt;code&gt;"npm run dev"&lt;/code&gt; in you console.&lt;/p&gt;

&lt;p&gt;...&lt;br&gt;
We have successfully integrated Typescript to our app. Now let's see it in action. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;At the moment, your root directory should contain &lt;em&gt;/node_modules&lt;/em&gt;, &lt;em&gt;package.json.lock&lt;/em&gt;, &lt;em&gt;package.json&lt;/em&gt;, and a &lt;em&gt;tsconfig.json&lt;/em&gt; file. Create a new folder - &lt;em&gt;src&lt;/em&gt;. Your first Typescript file goes in here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;create an &lt;em&gt;index.ts&lt;/em&gt; file inside the &lt;em&gt;src&lt;/em&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Paste the entire typescript snippet shown at the beginning of this article, into your &lt;em&gt;index.ts&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally run &lt;code&gt;npm run dev&lt;/code&gt; in your terminal. You will notice a newly generated folder &lt;em&gt;/build&lt;/em&gt;, which contains a transpile version of your Typescript code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope you find this helpful.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>node</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Creating Your First Chrome Extension.</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Fri, 16 Jul 2021 22:00:33 +0000</pubDate>
      <link>https://forem.com/giwajossy/creating-your-first-chrome-extension-26l</link>
      <guid>https://forem.com/giwajossy/creating-your-first-chrome-extension-26l</guid>
      <description>&lt;p&gt;Every four seconds, this chrome extension replaces images on any webpage I visit, with random pictures of some of my friends and family. &lt;/p&gt;

&lt;p&gt;Totally enjoyed the building process.&lt;br&gt;
Here's what it looks like when activated on YouTube 👀. &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%2Ffjd63vo1swnf1a79xs2y.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%2Ffjd63vo1swnf1a79xs2y.jpg" alt="Youtube" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;
&lt;h3&gt;
  
  
  Getting started
&lt;/h3&gt;

&lt;p&gt;A fairly solid understanding of the DOM [Document Object Model] goes a long way when building browser extensions, as you would have to do lots of DOM manipulation.&lt;/p&gt;

&lt;p&gt;The project folder contains two files; &lt;strong&gt;manifest.json&lt;/strong&gt; and &lt;strong&gt;content.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Project Folder/&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;manifest.json&lt;/em&gt;&lt;br&gt;
&lt;em&gt;content.js&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;...&lt;br&gt;
&lt;strong&gt;manifest.json&lt;/strong&gt;&lt;br&gt;
This is the entry point of every chrome extension. It handles permissions, routes, and holds necessary information like the extension name, version, description, icons, etc.&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;"manifest_version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&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;"FriendsFX"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Converts every image on a webpage to random pictures of some of my friends"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"content_scripts"&lt;/span&gt;&lt;span class="p"&gt;:&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;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"matches"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;all_urls&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"js"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"content.js"&lt;/span&gt;&lt;span class="p"&gt;]&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;span class="p"&gt;]&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;p&gt;Most of the keys in the snippet above are self-explanatory, but let's talk about the &lt;code&gt;"content_scripts"&lt;/code&gt; key. &lt;/p&gt;

&lt;p&gt;It holds an array of one object - containing two key elements; &lt;code&gt;"matches"&lt;/code&gt; and &lt;code&gt;"js"&lt;/code&gt;, with values of &lt;code&gt;["&amp;lt;all_urls&amp;gt;"]&lt;/code&gt; and &lt;code&gt;["content.js"]&lt;/code&gt; respectively.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;["&amp;lt;all_urls&amp;gt;"]&lt;/code&gt; basically matches any URL that starts with a permitted scheme; &lt;em&gt;http:, https:, file:, ftp:, or chrome-extension:.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;These permissions are required if your code wants to interact with the code running on webpages.&lt;/p&gt;

&lt;p&gt;...&lt;br&gt;
&lt;strong&gt;content.js&lt;/strong&gt;&lt;br&gt;
Here goes the code that replaces every image on a webpage with the selected pictures.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 1:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I had uploaded the pictures to cloudinary, a tool that automatically optimizes and delivers media files.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NOTE: You do not have to use cloudinary. Your friends' pictures must be somewhere on the internet, so you can just grab the links whenever you need them&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Below, I created an array - &lt;code&gt;imagesLinks&lt;/code&gt;, containing links to those pictures.&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;// An array of pictures to randomly select from&lt;/span&gt;
&lt;span class="c1"&gt;// You can have as many links/pictures as you want&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;imagesLinks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511199/friendsFX/IMG20201223190841_1_gsz2dc.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511198/friendsFX/IMG20201223184904_tj8u3d.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511192/friendsFX/IMG20201223182200_xglqvv.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511189/friendsFX/IMG20201223191703_wnindo.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://res.cloudinary.com/dd3hmuucq/image/upload/v1625511184/friendsFX/IMG20201223182912_er8kil.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="p"&gt;]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&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;// fetches all &amp;lt;img&amp;gt; tags on the webpage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;imageTags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;img&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final Step:&lt;/strong&gt;&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;// Loops through each of the &amp;lt;img&amp;gt; tags on the webpage&lt;/span&gt;
&lt;span class="c1"&gt;// Replaces the 'src' attribute with a random link from the imageLinks array &lt;/span&gt;
&lt;span class="c1"&gt;// Do this every 4 seconds&lt;/span&gt;

&lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;imageTags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;randomArrayIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;imagesLinks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;imageTags&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;imagesLinks&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;randomArrayIndex&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="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's test out the extension.
&lt;/h3&gt;

&lt;p&gt;1) Upload the extension to your browser extension library.&lt;br&gt;&lt;br&gt;
Type this 👉🏼 &lt;em&gt;chrome://extensions/&lt;/em&gt; in your browser&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%2F8ni0pdd9k7bvhr5tnjye.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%2F8ni0pdd9k7bvhr5tnjye.jpg" alt="Access chrome extensions library" width="699" height="38"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Activate "Developer mode" at the top right corner&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%2Ffbtio50k03l3jdmu77bi.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%2Ffbtio50k03l3jdmu77bi.jpg" alt="Activate " width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3) Click "Load unpacked" and select the project folder. &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%2Fbc1usixzzdjqe0cpbssh.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%2Fbc1usixzzdjqe0cpbssh.jpg" alt="Click " width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4) The extension gets added and is immediately activated.&lt;/p&gt;

&lt;p&gt;5) Now go to any webpage, hold on for about 4 seconds and watch the selected pictures appear.&lt;/p&gt;

&lt;p&gt;...&lt;br&gt;
...&lt;/p&gt;

&lt;p&gt;Let me know if you found this helpful.&lt;br&gt;
You can also get the code on &lt;a href="https://github.com/giwajossy/FriendsCRX" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>chrome</category>
      <category>extension</category>
      <category>browser</category>
    </item>
    <item>
      <title>innerHTML Vs. textContent: The subtle difference.</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Fri, 13 Nov 2020 00:40:39 +0000</pubDate>
      <link>https://forem.com/giwajossy/innerhtml-vs-textcontent-the-subtle-difference-4ik0</link>
      <guid>https://forem.com/giwajossy/innerhtml-vs-textcontent-the-subtle-difference-4ik0</guid>
      <description>&lt;p&gt;At first glance, both properties look like they do the same thing.&lt;/p&gt;

&lt;p&gt;While &lt;code&gt;innerHTML&lt;/code&gt; provides a simple and convenient way to create HTML templates as strings and inject them into the DOM [Document Object Model], &lt;code&gt;textContent&lt;/code&gt; only lets you create plain texts as strings.&lt;/p&gt;

&lt;p&gt;Now, let's break it down.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;textContent&lt;/code&gt; in action:
&lt;/h3&gt;

&lt;p&gt;Say we want to output "I love JavaScript"&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;p id="output"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;script&amp;gt;
    document.getElementById("output").textContent = "I love Javascript";
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;innerHTML&lt;/code&gt; in action:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;innerHTML&lt;/code&gt; can do everything &lt;code&gt;textContent&lt;/code&gt; can, plus a higher level of DOM manipulation. For instance;&lt;/p&gt;

&lt;p&gt;Let's output "&lt;em&gt;I&lt;/em&gt; &lt;strong&gt;love&lt;/strong&gt; JavaScript"&lt;br&gt;
Note: "I" is Italicised, "love" is bold, and let's assume "JavaScript" is in red&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;p id="output"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;script&amp;gt;
    document.getElementById("output").innerHTML = "&amp;lt;em&amp;gt;I&amp;lt;/em&amp;gt; &amp;lt;strong&amp;gt;love&amp;lt;/strong&amp;gt; &amp;lt;span style='color: red;'&amp;gt;JavaScript&amp;lt;/span&amp;gt;";
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;innerHTML&lt;/code&gt; is richer, as you can get more fanciful with it.&lt;br&gt;
But if you only aim to return text content, go ahead with &lt;code&gt;textContent&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hope you find this helpful.&lt;/p&gt;

&lt;p&gt;Happy to learn from you.&lt;/p&gt;

&lt;p&gt;How would you use these properties?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>design</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Forcing Your Website To Serve Secure Content</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Tue, 28 Jul 2020 04:41:15 +0000</pubDate>
      <link>https://forem.com/giwajossy/forcing-your-website-to-serve-secure-content-39m8</link>
      <guid>https://forem.com/giwajossy/forcing-your-website-to-serve-secure-content-39m8</guid>
      <description>&lt;p&gt;While most hosting plans include an &lt;a href="https://www.ssl.com/faqs/faq-what-is-ssl/" rel="noopener noreferrer"&gt;SSL [Secure Sockets Layer]&lt;/a&gt; certificate, they are not automatically activated, as you sometimes have to manually install the certificate via the cPanel.&lt;/p&gt;

&lt;p&gt;Once installed, you should force a redirect to &lt;a href="https://en.wikipedia.org/wiki/HTTPS" rel="noopener noreferrer"&gt;HTTPS&lt;/a&gt;. This encrypts and secures your website’s data, and traffic. It will encourage visitors to engage your site content because they feel safe, and reassured – especially if you’ll be requesting some personal information.&lt;/p&gt;

&lt;h4&gt;
  
  
  First of all, you need to install the SSL Certificate via the cPanel
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click “SSL/TLS” in the Security category.&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fone.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fone.png" alt="GYRO Design Lab" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click “Manage SSL sites”&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Ftwo-1024x426.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Ftwo-1024x426.png" alt="GYRO Design Lab" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now click “Browse Certificate”&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fbrowse-certificate-1024x517.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fbrowse-certificate-1024x517.png" alt="GYRO Design Lab" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A window pops up; choose from the list of certificates and click “&lt;strong&gt;Use Certificate&lt;/strong&gt;“. The form-fields get automatically filled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now scroll all the way down, and “&lt;strong&gt;Install Certificate&lt;/strong&gt;“&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Certificate Installed!
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Finally! Force a redirect to HTTPS using any of these 2 methods;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Method 1: &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Is it a wordpress site?&lt;/p&gt;

&lt;p&gt;Go to your dashboard and open up the &lt;strong&gt;Settings › General&lt;/strong&gt; tab. You’ll find two fields called &lt;strong&gt;WordPress Address (URL)&lt;/strong&gt; and &lt;strong&gt;Site Address (URL)&lt;/strong&gt;.  Now replace the &lt;strong&gt;HTTP&lt;/strong&gt; prefix in both fields with &lt;strong&gt;HTTPS&lt;/strong&gt;, and save the changes to your settings: That’s all it takes to configure WordPress to use HTTPS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Method 2: &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Edit the .htaccess file&lt;/p&gt;

&lt;p&gt;Type the following code into your .htaccess file; create one if you don’t already have one. If you can’t locate it, see how here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Either of these two should help you load serve secure content.&lt;/p&gt;

&lt;p&gt;However, enabling HTTPS on your website isn’t enough. If you have mixed content loading over a secure HTTPS connection, you’ll continue to receive mixed or insecure content warnings and push people away. So, take the time to check and monitor your site for insecure content. Because you can bet that even though some site visitors will still risk visiting your site with mixed content warnings, popular browsers like Chrome are going to continue to crack down on insecure sites and prevent users from engaging with them the way you’d like.&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Migrating Your WordPress Website To A New Domain</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Tue, 28 Jul 2020 04:23:05 +0000</pubDate>
      <link>https://forem.com/giwajossy/migrating-your-wordpress-website-to-a-new-domain-1ffl</link>
      <guid>https://forem.com/giwajossy/migrating-your-wordpress-website-to-a-new-domain-1ffl</guid>
      <description>&lt;p&gt;Imagine having to rebuild your WordPress website all over again because you got a new domain name.&lt;/p&gt;

&lt;p&gt;On several occasions, I have had to build WordPress websites on temporary domains, and then move them to the permanent domain when ready. &lt;/p&gt;

&lt;p&gt;The right tool for this is the “All-in-One WP Migration” plugin which currently has over 2 million active installs. This plugin exports your entire website – including the database, and imports into the  new domain.&lt;/p&gt;

&lt;p&gt;Once installed and activated in the old wordpress dashboard, A menu for the newly installed plugin appears on the sidebar. Hover over it, then;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click “Export”&lt;/li&gt;
&lt;li&gt;Select “Export to” &amp;gt; &lt;strong&gt;File&lt;/strong&gt;
&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fselect-export-to-file-1024x559.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fselect-export-to-file-1024x559.png" alt="GYRO Design Lab" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once the archive process is complete, click to download.&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fdownload-archived-file-1024x554.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fdownload-archived-file-1024x554.png" alt="GYRO Design Lab" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now go to the wordpress dashboard of the new domain&lt;/li&gt;
&lt;li&gt;Install and activate the “All-in-One WP Migration” plugin. Again, you will find the link to the newly installed plugin on the side panel. Hover over it:&lt;/li&gt;
&lt;li&gt;Click “Import”&lt;/li&gt;
&lt;li&gt;Select “Import to” &amp;gt; &lt;strong&gt;File&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, recent installations of All-in-One WP Migration only allows you a 128mb upload limit while previous installs on the same server allowed 520mb uploads. If your website exceeds the limit, you need install and activate the &lt;a href="https://import.wp-migration.com/" rel="noopener noreferrer"&gt;All-in-One WP File extension plugin&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Now go ahead and import your downloaded 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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fimport-archive-file-1024x561.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fimport-archive-file-1024x561.png" alt="GYRO Design Lab" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once your website is successfully imported, the page reloads, and you will be required to enter your login details to re-access your dashboard.&lt;/p&gt;

&lt;p&gt;You’re good to go&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Understanding Git and GitHub</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Tue, 28 Jul 2020 04:13:27 +0000</pubDate>
      <link>https://forem.com/giwajossy/understanding-git-and-github-4eld</link>
      <guid>https://forem.com/giwajossy/understanding-git-and-github-4eld</guid>
      <description>&lt;p&gt;First of all, Git is to GitHub – what porn is to pornhub.&lt;/p&gt;

&lt;p&gt;Let me tell you a story.&lt;/p&gt;

&lt;p&gt;Back when i started out coding, and had to collaborate with another developer, i would send the backend guy a zipped version of my frontend code – either in a flash drive, or via email, and whenever i needed to make further UI changes, he would send back the codebase [including his backend code], and I would have to navigate the codebase to make my changes without messing up my guy’s backend code.&lt;/p&gt;

&lt;p&gt;So Rookie! But hey! We got the job done. Most importantly, I had fun doing it.&lt;/p&gt;

&lt;p&gt;Imagine the horror if it was a large project – with over 15 developers working on it.&lt;/p&gt;

&lt;p&gt;By the way, I started out doing web design – using HTML, CSS, and jQuery because it was the only coding space I felt I could immediately see the effect of my code.&lt;/p&gt;

&lt;p&gt;For some reason, the resources I could lay my hands on – made zero reference to Git or GitHub, so I had no idea what those terms meant. Even after I finally got to know of them, the concepts got more and more confusing than I’d like to admit. &lt;/p&gt;

&lt;h4&gt;
  
  
  Now that I understand the concepts, it has been a fun ride.
&lt;/h4&gt;

&lt;p&gt;Git and GitHub are two very different entities, and can not be used interchangeably.&lt;/p&gt;

&lt;p&gt;Git is a distributed version control system; this means It allows us to track changes in an application, in a folder, in a single file – over time, across different users, and different computers. &lt;/p&gt;

&lt;p&gt;GitHub is like a social network or platform for Git repositories; a repository is a set of files for a project. GitHub allows us to share our repositories with team members, publish things online, and collaborate on open-source projects.&lt;/p&gt;

&lt;p&gt;Git can be used on it’s own. It is the main technology, while GitHub is the platform to share it and collaborate using Git.&lt;/p&gt;

&lt;p&gt;The first step to becoming a Git-GitHub rockstar is to try out this simple task;&lt;/p&gt;

&lt;h4&gt;
  
  
  Let’s create a simple repository containing a readme.txt file
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Download Git &lt;a href="https://git-scm.com/downloads" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Register on &lt;a href="https://github.com" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, and create a repository.&lt;/li&gt;
&lt;li&gt;Now create a “readme.txt” file in a folder on your desktop.&lt;/li&gt;
&lt;li&gt;Open this folder &amp;gt; Right click &amp;gt; Now click the “Git Bash Here” option to open the terminal.&lt;/li&gt;
&lt;li&gt;In the terminal, type &lt;code&gt;git init&lt;/code&gt; then press enter&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git add readme.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git commit -m "first commit message"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git remote add origin URL&lt;/code&gt; [copy this URL from the your repository page]&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git push -u origin master&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We have successfully created our first repository containing a readme.txt file.&lt;/p&gt;

&lt;p&gt;This can be shared with team members so they can make changes within the file, or even create new folders which would be accessible to you.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Creating a GitHub README Profile</title>
      <dc:creator>Joseph Giwa</dc:creator>
      <pubDate>Mon, 27 Jul 2020 19:32:20 +0000</pubDate>
      <link>https://forem.com/giwajossy/creating-a-github-readme-profile-19c3</link>
      <guid>https://forem.com/giwajossy/creating-a-github-readme-profile-19c3</guid>
      <description>&lt;p&gt;GitHub recently released a feature that lets you introduce yourself to the GitHub community, using more visual contents such as pictures, GIFs, links, and everything else you can add to a normal README file, because it is markdown, which means you control the display of the document.&lt;/p&gt;

&lt;p&gt;Now, there is a chance to give visitors a broad snapshot of who we are, as we highlight our skills and projects.&lt;/p&gt;

&lt;p&gt;I will show you how to unlock this feature, and also share interesting use cases by users around the world.&lt;/p&gt;

&lt;h4&gt;
  
  
  To unlock this feature…
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/new" rel="noopener noreferrer"&gt;Create a new repository&lt;/a&gt; using the exact name as your GitHub username. For instance, my username is giwajossy, so the new repository had to be giwajossy.&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fstep_one-1024x499.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fstep_one-1024x499.png" alt="Alt Text" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
Note: The naming is case-sensitive – at the time of this writing. Also, repositories are public by default, if you make it private, it won’t work.&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fstep_three-1024x499.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2Fstep_three-1024x499.png" alt="Alt Text" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
Repository successfully  created!&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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2FGithub.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%2Fgyrodesignlab.com%2Fwp-content%2Fuploads%2F2020%2F07%2FGithub.png" alt="Alt Text" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
So I designed a banner, and placed it atop my new bio. Nothing too fancy!&lt;/p&gt;


&lt;h4&gt;
  
  
  Some Interesting use cases by other GitHub users
&lt;/h4&gt;



&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1281111778290786310-774" src="https://platform.twitter.com/embed/Tweet.html?id=1281111778290786310"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1281111778290786310-774');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1281111778290786310&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1281435464474324993-415" src="https://platform.twitter.com/embed/Tweet.html?id=1281435464474324993"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1281435464474324993-415');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1281435464474324993&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1282326538990563329-246" src="https://platform.twitter.com/embed/Tweet.html?id=1282326538990563329"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1282326538990563329-246');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1282326538990563329&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1281699715466199040-275" src="https://platform.twitter.com/embed/Tweet.html?id=1281699715466199040"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1281699715466199040-275');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1281699715466199040&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1281146411736694784-334" src="https://platform.twitter.com/embed/Tweet.html?id=1281146411736694784"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1281146411736694784-334');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1281146411736694784&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1281026687103168512-745" src="https://platform.twitter.com/embed/Tweet.html?id=1281026687103168512"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1281026687103168512-745');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1281026687103168512&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1265773172520914944-315" src="https://platform.twitter.com/embed/Tweet.html?id=1265773172520914944"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1265773172520914944-315');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1265773172520914944&amp;amp;theme=dark"
  }



&lt;/p&gt;

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

&lt;p&gt;Hope you find this helpful.&lt;/p&gt;

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