<?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: AMANI Eric</title>
    <description>The latest articles on Forem by AMANI Eric (@ericus123).</description>
    <link>https://forem.com/ericus123</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%2F520249%2F438d24a4-5bf6-4eea-893e-d182b3386c0c.jpeg</url>
      <title>Forem: AMANI Eric</title>
      <link>https://forem.com/ericus123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ericus123"/>
    <language>en</language>
    <item>
      <title>Fading an LED with Arduino</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Fri, 26 Jan 2024 14:06:27 +0000</pubDate>
      <link>https://forem.com/ericus123/fading-an-led-with-arduino-24ac</link>
      <guid>https://forem.com/ericus123/fading-an-led-with-arduino-24ac</guid>
      <description>&lt;p&gt;In this tutorial I will show you how you can make an LED fade using Arduino.&lt;/p&gt;

&lt;p&gt;Materials Needed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Arduino Board (e.g., uno)&lt;/li&gt;
&lt;li&gt; Breadboard and jumper wires&lt;/li&gt;
&lt;li&gt; LED&lt;/li&gt;
&lt;li&gt; Resistor (270Ω)&lt;/li&gt;
&lt;li&gt; USB cable for Arduino&lt;/li&gt;
&lt;li&gt; Arduino IDE installed on your computer&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 1: Set Up the Hardware:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; Connect the short leg (cathode) of the LED to GND on the Arduino.&lt;/li&gt;
&lt;li&gt;Connect the long leg (anode) of the LED to a resistor (270Ω) and to pin 13 on the Arduino. (Use a jumper wire for it to reach the Arduino pin)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before we continue, here is how I arranged the components on the breadboard. (Insert an image of the new circuit)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa67bvgqy4z5qg6w3to4y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa67bvgqy4z5qg6w3to4y.jpg" alt="Image description" width="800" height="602"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd3nmv0yb2c3765y9k48.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd3nmv0yb2c3765y9k48.jpg" alt="Image description" width="800" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Connect your Arduino board to your computer:
&lt;/h3&gt;

&lt;p&gt;Use the appropriate cable for your Arduino board.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Writing the Code:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Fading a single LED&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Pin number for the LED&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Set the LED pin as an output&lt;/span&gt;

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

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&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="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;brightness&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="n"&gt;brightness&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;brightness&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="n"&gt;analogWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;brightness&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;delay&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;span class="c1"&gt;// Adjust the delay for the desired fade speed&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Fade out&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;brightness&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;brightness&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;brightness&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="n"&gt;analogWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;brightness&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;delay&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;span class="c1"&gt;// Adjust the delay for the desired fade speed&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;h3&gt;
  
  
  Step 4: Uploading the Code:
&lt;/h3&gt;

&lt;p&gt;Make sure that in your Arduino IDE, the correct board is selected, and click on the upload button.&lt;/p&gt;

&lt;p&gt;Your code should be uploaded successfully.&lt;/p&gt;

&lt;p&gt;Test Your Fading LED:&lt;br&gt;
Run the uploaded code on your Arduino board, and you should observe the LED fading in and out, creating a smooth fading effect.&lt;/p&gt;

&lt;p&gt;Happy coding! ✨&lt;/p&gt;

&lt;p&gt;You can what a demo here at the end of this &lt;a href="https://amanieric.com/blog/fading-an-led-with-arduino"&gt;article&lt;/a&gt; &lt;/p&gt;

</description>
      <category>iot</category>
      <category>programming</category>
      <category>arduino</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Blink multiple LEDs with Arduino</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Fri, 26 Jan 2024 13:56:10 +0000</pubDate>
      <link>https://forem.com/ericus123/blink-multiple-leds-with-arduino-2ahm</link>
      <guid>https://forem.com/ericus123/blink-multiple-leds-with-arduino-2ahm</guid>
      <description>&lt;p&gt;In this tutorial, we'll go through the process of blinking multiple LEDs using the Arduino uno R4 WIFI (steps same for most Arduino boards) and a breadboard.&lt;/p&gt;

&lt;p&gt;Before we get started check previous article on &lt;br&gt;
how to blink a single LED 👉🏾 &lt;a href="https://amanieric.com/blog/blinking-an-led-with-arduino"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Materials Needed:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; Arduino Board (Ex: uno)&lt;/li&gt;
&lt;li&gt; Breadboard and jumper wires(x6)&lt;/li&gt;
&lt;li&gt; LEDs (x5)&lt;/li&gt;
&lt;li&gt; Resistor (270Ω) (x5)&lt;/li&gt;
&lt;li&gt; USB cable for Arduino&lt;/li&gt;
&lt;li&gt; Arduino IDE installed on your computer&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Step 1: Set Up the Hardware:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Connect the short leg (cathode) of the LED to GND on the Arduino.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect the long leg (anode) of the LED to  resistor ( 270Ω) and to pin 13 on the Arduino. (Use a jumper wire for it to reach to Arduino pin)&lt;br&gt;
repeat the same for other Arduino digital pins as well &lt;strong&gt;12&lt;/strong&gt;, &lt;strong&gt;11&lt;/strong&gt;, &lt;strong&gt;10&lt;/strong&gt;, &lt;strong&gt;9&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can connect the components differently on breadboard as long as you follow the same circuit its fine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxd7t5k7mg0zqm6wkuwer.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxd7t5k7mg0zqm6wkuwer.jpg" alt="Image description" width="800" height="602"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Connect your Arduino board to your computer
&lt;/h3&gt;

&lt;p&gt;Cables can be different depending on Arduino board. Some can use USB and others Type-C cables. Can connect depending on your board.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Writing the codes
&lt;/h3&gt;

&lt;p&gt;In your Arduino IDE add those codes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Blinking multiple LEDs&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Pin number for the LED1&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Pin number for the LED2&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Pin number for the LED3&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Pin number for the LED4&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin5&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Pin number for the LED5&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Set the LED1 pin as an output&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Set the LED2 pin as an output&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Set the LED3 pin as an output&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Set the LED4 pin as an output&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Set the LED5 pin as an output&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED1 on&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED1 off&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED2 on&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED2 off&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED3 on&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED3 off&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED4 on&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED4 off&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED5 on&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED5 off&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 50 milliseconds&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Uploading the codes
&lt;/h3&gt;

&lt;p&gt;Now, make sure that in your Arduino IDE the correct board is selected and click on the upload button.&lt;/p&gt;

&lt;p&gt;Your codes should be uploaded successfully.&lt;/p&gt;

&lt;p&gt;If the steps above were followed, the led will be blinking every one second 🎉&lt;/p&gt;

&lt;p&gt;You can read more on the article and check demo  👉🏾&lt;a href="https://amanieric.com/blog/blinking-multiple-leds-with-arduino"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>iot</category>
      <category>arduino</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Blinking an LED with Arduino</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Thu, 25 Jan 2024 14:33:23 +0000</pubDate>
      <link>https://forem.com/ericus123/blinking-an-led-with-arduino-2hh1</link>
      <guid>https://forem.com/ericus123/blinking-an-led-with-arduino-2hh1</guid>
      <description>&lt;p&gt;Blinking an LED is a fundamental project for Arduino enthusiasts. In this tutorial, we'll go through the process of blinking an LED using the Arduino uno R4 WIFI (steps same for most Arduino boards) and a breadboard. Let's get started!&lt;/p&gt;

&lt;h3&gt;
  
  
  Materials Needed:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; Arduino Board (Ex: uno)&lt;/li&gt;
&lt;li&gt; Breadboard and jumper wires&lt;/li&gt;
&lt;li&gt; LED&lt;/li&gt;
&lt;li&gt; Resistor (270Ω)&lt;/li&gt;
&lt;li&gt; USB cable for Arduino&lt;/li&gt;
&lt;li&gt; Arduino IDE installed on your computer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yrj5uron75jeif4h4vk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yrj5uron75jeif4h4vk.jpg" alt="Image description" width="800" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Set Up the Hardware:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Connect the short leg (cathode) of the LED to GND on the Arduino.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect the long leg (anode) of the LED to  resistor ( 270Ω) and to pin 13 on the Arduino.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can connect the components differently on breadboard as long as you follow the same circuit its fine.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Step 2: Connect your Arduino board to your computer
&lt;/h3&gt;

&lt;p&gt;Cables can be different depending on Arduino board. Some can use USB and others Type-C cables. Can connect depending on your board.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Writing the codes
&lt;/h3&gt;

&lt;p&gt;In your Arduino IDE add those codes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Blinking a single LED&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Pin number for the LED&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Sets the LED pin as an output&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED on&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 1 second&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Turn the LED off&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Wait for 1 second&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Uploading the codes
&lt;/h3&gt;

&lt;p&gt;Now, make sure that in your Arduino IDE the correct board is selected and click on the upload button.&lt;/p&gt;

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

&lt;p&gt;Your codes should be uploaded successfully.&lt;/p&gt;

&lt;p&gt;If the steps above were followed, the led will be blinking every one second 🎉&lt;/p&gt;

&lt;p&gt;You can read more on the article 👉🏾&lt;a href="https://amanieric.com/blog/blinking-an-led-with-arduino"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you liked this post, you might as well like to checkout on fading an LED.&lt;br&gt;
&lt;a href="https://dev.to/ericus123/fading-an-led-with-arduino-24ac"&gt;Fading an LED&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>iot</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A fatal error occurred: Unable to verify flash chip connection (No serial data received.)</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Wed, 10 Jan 2024 11:49:50 +0000</pubDate>
      <link>https://forem.com/ericus123/a-fatal-error-occurred-unable-to-verify-flash-chip-connection-no-serial-data-received-4l1b</link>
      <guid>https://forem.com/ericus123/a-fatal-error-occurred-unable-to-verify-flash-chip-connection-no-serial-data-received-4l1b</guid>
      <description>&lt;p&gt;Recently, I acquired an ESP32-S3 UNO, and upon receiving it, I proceeded to test its functionality. Although it powered on normally, I encountered an issue while attempting to upload my code, receiving the error message: "A fatal error occurred: Unable to verify flash chip connection (No serial data received.)"&lt;/p&gt;

&lt;p&gt;Assuming a potential fault with one of the boards, I tested a second, identical board, only to encounter the same error. &lt;/p&gt;

&lt;p&gt;This led me to conclude that the issue might lie elsewhere.&lt;/p&gt;

&lt;p&gt;I experimented with various Type-C cables, connected to different ports, and ensured that the correct board was selected in the Arduino IDE. Despite these efforts, the issue persisted.&lt;/p&gt;

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

&lt;p&gt;Numerous solutions found online proved unhelpful. However, during my research, I came across a discussion on the Arduino Forum related to a similar issue Arduino Forum Link. While the forum provided valuable insights, none of the suggested solutions seemed to work. Nonetheless, it's worth exploring these resources as your situation might differ.&lt;/p&gt;

&lt;p&gt;Importantly, I want to note that there was no issue with my codes. I had a simple blinking LED program as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my continued troubleshooting efforts, I discovered a resolution that worked:&lt;/p&gt;

&lt;p&gt;I changed the upload speed in the Arduino IDE tools settings from &lt;strong&gt;921600&lt;/strong&gt; to &lt;strong&gt;115200&lt;/strong&gt; and it worked.&lt;/p&gt;

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

&lt;p&gt;Happy coding! 🎉&lt;/p&gt;

&lt;p&gt;You can also read article on my blog and feel free to drop questions or issues if you need help. 👉🏽 &lt;a href="https://amanieric.com/blog/a-fatal-error-occurred-unable-to-verify-flash-chip-connection-no-serial-data-received"&gt;A fatal error occurred: Unable to verify flash chip connection (No serial data received.)&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Parallel Execution with async/await in JavaScript (Node.js) for Beginners</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Tue, 25 Jul 2023 14:47:26 +0000</pubDate>
      <link>https://forem.com/ericus123/mastering-parallel-execution-with-asyncawait-in-javascript-nodejs-for-beginners-1i7d</link>
      <guid>https://forem.com/ericus123/mastering-parallel-execution-with-asyncawait-in-javascript-nodejs-for-beginners-1i7d</guid>
      <description>&lt;p&gt;&lt;strong&gt;Asynchronous programming&lt;/strong&gt; can be intimidating for beginners, but fear not! JavaScript comes to the rescue with its async/await syntax, offering a more approachable way to handle asynchronous tasks. &lt;/p&gt;

&lt;p&gt;In this beginner-friendly blog post, we will demystify parallel execution using async/await in a Node.js environment. Let's dive in and unlock the power of running tasks concurrently with JavaScript!&lt;/p&gt;

&lt;h3&gt;
  
  
  Embracing the Simplicity of async/await:
&lt;/h3&gt;

&lt;p&gt;Async/await, introduced in ECMAScript 2017, allows us to write asynchronous code in a more intuitive and synchronous-like manner. It simplifies the handling of promises and asynchronous operations, making our code easier to read and understand.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unlocking Parallel Execution:
&lt;/h3&gt;

&lt;p&gt;To unleash the potential of async/await in parallel execution, we can tap into JavaScript's Promise API. A handy method called Promise.all() comes to the rescue, enabling us to run multiple tasks concurrently. Let's explore a beginner-friendly example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;runTasksInParallel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;task1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;asyncTask1&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;task2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;asyncTask2&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;task3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;asyncTask3&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;task1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;task2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;task3&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;Congratulations! All tasks completed successfully.&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="nf"&gt;runTasksInParallel&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, asyncTask1(), asyncTask2(), and asyncTask3() represent individual asynchronous functions. By utilizing Promise.all(), we can await the completion of all tasks concurrently, resulting in better performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Navigating Error Handling:
&lt;/h3&gt;

&lt;p&gt;When working with parallel execution, it's crucial to handle errors effectively. With async/await, we can use the trusty try/catch statement to gracefully manage errors. Let's enhance our previous example to include error handling:&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="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;runTasksInParallel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&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;task1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;asyncTask1&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;task2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;asyncTask2&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;task3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;asyncTask3&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;task1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;task2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;task3&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;Congratulations! All tasks completed successfully.&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="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Oops! An error occurred while running tasks:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&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="nf"&gt;runTasksInParallel&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By encapsulating the entire async function within a try block and catching any errors in the catch block, we ensure that any errors during the parallel execution are handled gracefully.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unleashing Performance with Parallelism:
&lt;/h3&gt;

&lt;p&gt;Parallel execution can significantly boost performance, especially when dealing with time-consuming operations like making multiple API calls or processing large amounts of data. By harnessing the power of async/await and parallel execution, we can tap into JavaScript's full potential for efficient and optimized code execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Promise.allSettled():
&lt;/h3&gt;

&lt;p&gt;When working with multiple asynchronous tasks, you might come across scenarios where you need to know when all the tasks have settled, regardless of whether they succeeded or failed. JavaScript provides a helpful method called Promise.allSettled() that allows you to handle such situations. Let's explore it in detail:&lt;/p&gt;

&lt;p&gt;The Promise.allSettled() method takes an iterable of promises and returns a single promise that is fulfilled with an array of promise settlement results. These settlement results provide information about each individual promise, indicating whether they were fulfilled or rejected.&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;promises&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;promise1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;promise2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;promise3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;allSettled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;promises&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;results&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;results&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;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fulfilled&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;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;`Promise &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; was fulfilled with value:`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&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;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rejected&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;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;`Promise &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; was rejected with reason:`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reason&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above ☝🏾, promises represents an array of asynchronous tasks as promises. By using Promise.allSettled(), we can wait for all the promises to settle. The resulting array results contains settlement information for each promise, including the status (either "fulfilled" or "rejected") and the corresponding value or reason.&lt;/p&gt;

&lt;p&gt;Congratulations ✨, you've embarked on a journey to master parallel execution with async/await in JavaScript! With async/await's simplicity and the power of Promise.all(), you're now equipped to write cleaner, more readable, and high-performing code. &lt;/p&gt;

&lt;p&gt;As you continue your coding adventures in Node.js, remember to embrace parallel execution to unlock new levels of efficiency and deliver outstanding user experiences. Happy coding! 🎉&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why you should use Clamp over Media Queries</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Tue, 25 Jul 2023 14:37:54 +0000</pubDate>
      <link>https://forem.com/ericus123/why-you-should-use-clamp-over-media-queries-8og</link>
      <guid>https://forem.com/ericus123/why-you-should-use-clamp-over-media-queries-8og</guid>
      <description>&lt;p&gt;In the ever-evolving landscape of web design, responsiveness has become a key consideration. As a beginner, you may have heard of media queries as the go-to solution for achieving responsiveness. However, there's an emerging technique that offers a more streamlined approach: clamp. &lt;/p&gt;

&lt;p&gt;In this article, we'll delve into the benefits of using clamp over media queries, providing clear examples that will empower you to take your responsiveness game to the next level.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unleashing Responsive Magic:
&lt;/h3&gt;

&lt;p&gt;Media queries can be complex, requiring multiple lines of code to handle various screen sizes. Using Clamp is a game-changing technique with a simple syntax that condenses your code and offers limitless potential. Let's explore a practical example to witness Clamp's magic in action:&lt;/p&gt;

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

&lt;span class="c"&gt;/* Media Queries */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;768px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;.element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;14px&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="c"&gt;/* Clamp */&lt;/span&gt;
&lt;span class="nc"&gt;.element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;12px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;By using clamp ☝🏾 , we specify a range of acceptable values for the font size. The 4vw unit allows the font size to scale proportionally with the viewport width. With just a single line of code, we achieve a fluid and responsive typography that adapts seamlessly to different screen sizes.&lt;/p&gt;

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

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;24px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;6vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;48px&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;h3&gt;
  
  
  Dynamic Element Sizing:
&lt;/h3&gt;

&lt;p&gt;While media queries are suitable for handling layout changes, they often require predefined breakpoints, leaving room for inconsistencies. Clamp offers a more flexible approach to sizing elements by allowing you to define a range. Let's explore a scenario:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;By using clamp, the container width is set to span 50% of the available space but never exceeding 600 pixels or falling below &lt;br&gt;
300 pixels. This ensures the element maintains a balanced and visually pleasing size, irrespective of the viewport dimensions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Browser Support
&lt;/h3&gt;

&lt;p&gt;Clamp has gained significant traction in the web development community. With solid support from major browsers, including Chrome, Firefox, Safari, and Edge (source: Can I use), clamp has become a go-to solution for achieving responsiveness. Its widespread adoption showcases its effectiveness in simplifying design and enhancing user experiences.&lt;br&gt;
Check full report  &lt;a href="https://caniuse.com/?search=clamp()" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fch5s5jpfkqpiq2deqphe.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%2Fch5s5jpfkqpiq2deqphe.png" alt="clamp browser support"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Harmonious Blend:
&lt;/h3&gt;

&lt;p&gt;While clamp proves to be a game-changer in responsiveness, it doesn't render media queries obsolete. In fact, these techniques complement each other perfectly. Media queries excel in handling broader layout changes, while clamp enhances the finer details. &lt;/p&gt;

&lt;p&gt;By employing a hybrid approach, you can create a responsive design that covers both structural and visual aspects.&lt;/p&gt;

&lt;p&gt;Responsive web design is no longer a luxury; 💎 it's an essential aspect of modern web development. As a beginner, embracing Clamp as an alternative to media queries can unlock a world of possibilities. &lt;/p&gt;

&lt;p&gt;By simplifying your code, achieving fluid typography, enabling dynamic element sizing, and leveraging a combined approach, you'll be on your way to crafting exceptional user experiences that seamlessly adapt to any device. So, why settle for static designs when you can embrace the power of clamp and elevate your responsiveness to new heights?&lt;/p&gt;

&lt;p&gt;You can also read article on my blog and feel free to drop questions or issues if you need help. 👉🏽 &lt;a href="https://amanieric.com/blog/why-you-should-use-clamp-over-media-queries" rel="noopener noreferrer"&gt;Why you should use Clamp over Media Queries&lt;/a&gt;&lt;/p&gt;

</description>
      <category>clamp</category>
      <category>css</category>
      <category>frontend</category>
      <category>html</category>
    </item>
    <item>
      <title>How to expose PostgreSQL connection in ubuntu</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Wed, 11 Jan 2023 08:08:46 +0000</pubDate>
      <link>https://forem.com/ericus123/how-to-expose-postgresql-connection-in-ubuntu-339m</link>
      <guid>https://forem.com/ericus123/how-to-expose-postgresql-connection-in-ubuntu-339m</guid>
      <description>&lt;p&gt;If you have a PostgreSQL database instance running on an Ubuntu server, you might want &lt;br&gt;
to access it from outside the server.&lt;br&gt;
In this article, I'm going to show you how you can do it.&lt;/p&gt;

&lt;p&gt;The default Postgres connection port is usually 5432. We are going to expose our connection through this port.&lt;br&gt;
You can use your other port if not using the default one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Allow Postgres port in the firewall (&lt;code&gt;5432&lt;/code&gt; in our case)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw allow 5432/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;strong&gt;Open your Postgres config file&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/postgresql/&amp;lt;postgres_version&amp;gt;/main/pg_hba.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that I used ../14/.. . That's because I have PostgreSQL version 14 installed. Change it to your installed version&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%2Frki3j1m0l5nqtg0qfvzo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frki3j1m0l5nqtg0qfvzo.png" alt="Image description" width="617" height="136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will open your PostgreSQL config file.&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%2F9ktoh6vkfm897lvtctpe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ktoh6vkfm897lvtctpe.png" alt="Image description" width="611" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By default, the allowed address to access the Postgres connection is &lt;code&gt;127.0.0.1/32&lt;/code&gt;.&lt;br&gt;
That means you can only be connected if you are on the same server.&lt;/p&gt;

&lt;p&gt;We have to change that since we want the connection to be public.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Change the IP address from &lt;code&gt;127.0.0.1:32&lt;/code&gt;  =&amp;gt;  &lt;code&gt;0.0.0.0/0&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;What we did is allow any IP address at any port to access ur connection.&lt;/p&gt;

&lt;p&gt;Now you can connect to the database from anywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;N.B&lt;/strong&gt;: Changing from  &lt;code&gt;127.0.0.1/32&lt;/code&gt;  in your configs to  &lt;code&gt;0.0.0.0/0&lt;/code&gt;  means you are allowing any device from any.&lt;br&gt;
This is insecure. If you want to be more secure, you can change it from  &lt;code&gt;127.0.0.1/32&lt;/code&gt;  to  &lt;code&gt;your_trusted_ip/your_trusted_ip_port&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Construct a connection string like this and connect it to your database.&lt;/p&gt;

&lt;p&gt;👉🏽 &lt;code&gt;postgresql://[user[:password]@][our_server_ip][:our_postgres_server_ip][/dbname]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also test the connection with &lt;a href="https://www.pgadmin.org/download" rel="noopener noreferrer"&gt;PGAdmin&lt;/a&gt; which is a powerful Postgres client.&lt;/p&gt;

&lt;p&gt;You should be able to access your database 🎉&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How to integrate Google AdSense in NextJS</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Tue, 10 Jan 2023 08:54:57 +0000</pubDate>
      <link>https://forem.com/ericus123/how-to-integrate-google-adsense-in-nextjs-29db</link>
      <guid>https://forem.com/ericus123/how-to-integrate-google-adsense-in-nextjs-29db</guid>
      <description>&lt;p&gt;If you are having a blog, you might want to monetize it. Adding ads to your blog is among the effective ways to monetize it.&lt;/p&gt;

&lt;p&gt;In this article, I will show you how you can integrate Google AdSense into your NextJs app.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I get my site approved for google AdSense?
&lt;/h2&gt;

&lt;p&gt;To have your site approved for showing Google ads, there are steps to follow carefully.&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%2Fznroevfikqcro56pd6up.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznroevfikqcro56pd6up.png" alt="Image description" width="542" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can check these eligibility criteria &lt;a href="https://support.google.com/adsense/answer/9724" rel="noopener noreferrer"&gt;here&lt;/a&gt; carefully to avoid being rejected &lt;br&gt;
in the first place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip&lt;/strong&gt;: Before you request Google Adsense approval, make sure your website has at least 10 dynamic  articles (content should be changing regularly) and a proper domain name. &lt;/p&gt;

&lt;p&gt;If your site is eligible for google AdSense, you will get a response from google on how to get started.&lt;/p&gt;

&lt;p&gt;It takes a few days to get approved but in some cases, it might take between 2 and 4 weeks.&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%2F4d7hk4kn7e8hvvvnuxff.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4d7hk4kn7e8hvvvnuxff.png" alt="Image description" width="557" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your site is approved for google AdSense, follow the following steps to integrate it into your NextJs app &lt;br&gt;
and start showing ads.&lt;/p&gt;

&lt;p&gt;Add your client in the NextJs _document script&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;pages/_document.tsx&lt;/em&gt;&lt;/strong&gt; 👇🏽&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Html&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Head&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NextScript&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/document&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Script&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/script&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Head&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Script&lt;/span&gt;
          &lt;span class="na"&gt;async&lt;/span&gt;
          &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_GOOGLE_ADS_CLIENT_ID&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"lazyOnload"&lt;/span&gt;
          &lt;span class="na"&gt;crossOrigin&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"anonymous"&lt;/span&gt;
        &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Head&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Main&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;NextScript&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;change  &lt;strong&gt;NEXT_PUBLIC_GOOGLE_ADS_CLIENT_ID&lt;/strong&gt;. to the env variable containing your ads client id (ca-pub-*********)&lt;/p&gt;

&lt;h3&gt;
  
  
  Create an ad banner component
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;components/AdBanner.tsx&lt;/strong&gt;&lt;/em&gt; 👇🏽&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AdBanner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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="nf"&gt;useEffect&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;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;adsbygoogle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;adsbygoogle&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[]).&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&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="nx"&gt;err&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="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ins&lt;/span&gt;
      &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"adsbygoogle adbanner-customize"&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;block&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&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="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;data-ad-client&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_GOOGLE_ADS_CLIENT_ID&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AdBanner&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get Google ads block codes from your adsense dashboard.
&lt;/h3&gt;

&lt;p&gt;Notice that we are using the default code from the ad banner component above ☝🏾&lt;/p&gt;

&lt;p&gt;&lt;em&gt;adsense dashboard amanieric.com&lt;/em&gt;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  let's try with Display ads .
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;click on display ads card&lt;/p&gt;
&lt;/blockquote&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%2Fkj4wsrnuvb1yn1lvutyk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkj4wsrnuvb1yn1lvutyk.png" alt="Image description" width="679" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Choose your ad layout (depends on the place you want to place it)&lt;/p&gt;
&lt;/blockquote&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%2F8f9qai77b82g5imaz7ka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8f9qai77b82g5imaz7ka.png" alt="Image description" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy these codes (Ignore the rest. we already have them defined in our banner component) and click done &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%2F2uzvge99kp8ufhdtqs0a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2uzvge99kp8ufhdtqs0a.png" alt="Image description" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Import the ad banner component anywhere your want this kind of ad to show and ad the codes copies above as props to the ad banner.&lt;/p&gt;

&lt;p&gt;Our ad banner component imported will look like this 👇🏽&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;       &lt;span class="nx"&gt;AdBanner&lt;/span&gt;
          &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;ad&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;slot&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;7434970023&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;ad&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;auto&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;full&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;responsive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deploy the changes and on the hosted version of your app , the add banner will be showing the ad where your placed the component ✨&lt;/p&gt;

&lt;p&gt;Feel free to drop any issue in the comments if you need help &lt;/p&gt;

&lt;p&gt;You can also read article on my blog and feel free to drop questions or issues if you need help. 👉🏽 &lt;a href="https://amanieric.com/blog/how-to-integrate-google-ad-sense-in-next-js" rel="noopener noreferrer"&gt;How to integrate Google AdSense in NextJS&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why your web app should have ssl certificate</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Tue, 10 Jan 2023 08:40:11 +0000</pubDate>
      <link>https://forem.com/ericus123/why-your-web-app-should-have-ssl-certificate-4di8</link>
      <guid>https://forem.com/ericus123/why-your-web-app-should-have-ssl-certificate-4di8</guid>
      <description>&lt;p&gt;In this article, I will show you how you can add a free SSL certificate to your Nginx server with Certbot.&lt;/p&gt;

&lt;p&gt;Before we start, let's understand what SSL is.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is SSL?
&lt;/h2&gt;

&lt;p&gt;SSL(Secure Socket Layer) is a protocol for establishing authenticated and encrypted links/connections between connected computers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is SSL certificate and why do we need it?
&lt;/h2&gt;

&lt;p&gt;An SSL certificate (also known as a TLS or SSL/TLS certificate) is a digital document that binds the identity of a website to a cryptographic key pair consisting of a public key and a private key.&lt;/p&gt;

&lt;p&gt;The public key, included in the certificate, allows a web browser to initiate an encrypted communication session with a web server via the TLS and HTTPS protocols. The private key is kept secure on the server and is used to digitally sign web pages and other documents (such as images and JavaScript files)&lt;br&gt;
(source: ssl.com )&lt;/p&gt;

&lt;h2&gt;
  
  
  Reasons your web page/application should have an SSL certificate:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;It protects you and your web page/app users against hackers.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Since the connection is secured in a way that the information from your app's visitors' devices and your app is encrypted, it's hard for a hacker to know the information being shared.&lt;/p&gt;

&lt;p&gt;When you buy something online, you share your payment information with the site you are using (credit cards, PayPal,…). &lt;/p&gt;

&lt;p&gt;Ex: In this case, if the site is not using SSL, it's easier for a hacker to grab the information being shared.&lt;br&gt;
But in the other case where you are using a secure connection (SSL), even though the hacker can be able to intercept the connection, he can't be able to know the information being shared since it's encrypted. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Increases trustworthy in your users&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Users trust your page/app more since they are confident that the information they share with or &lt;br&gt;
through it is secure.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Improves your app's SEO&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;It's no secret that having an SSL certificate ranks your site higher in search engines like Google.&lt;br&gt;
Some browsers like chrome block unsecure apps by default from being accessed  (to protect users' online privacy)and that can lead to poor performance for your app and poor SEO.&lt;/p&gt;

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

&lt;p&gt;You can learn more about SSL by using these resources.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ssl.com"&gt;ssl.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ssl</category>
      <category>security</category>
      <category>programming</category>
    </item>
    <item>
      <title>Assign a free SSL certificate to an nginx server with certbot</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Tue, 10 Jan 2023 08:32:07 +0000</pubDate>
      <link>https://forem.com/ericus123/assign-a-free-ssl-certificate-to-an-nginx-server-with-certbot-23ic</link>
      <guid>https://forem.com/ericus123/assign-a-free-ssl-certificate-to-an-nginx-server-with-certbot-23ic</guid>
      <description>&lt;p&gt;In this article, I will show you how you can add a free SSL certificate to your Nginx server with Certbot.&lt;/p&gt;

&lt;p&gt;Before we start, check my previous article to understand more about SSL, and check here about serving a static app with Nginx.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is certbot?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Certbot&lt;/strong&gt; is an open-source automated software that generates Let's Encrypt Certificates. SSL&lt;br&gt;
certificates are provided free of cost by the Internet Security Research Group(ISRG).&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's get started 💎
&lt;/h2&gt;

&lt;p&gt;Considering we already have our app being served by Nginx on our server, we can proceed to install certbot first.&lt;/p&gt;

&lt;p&gt;Before you get started, I assume that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are familiar with Nginx&lt;/li&gt;
&lt;li&gt;You have Nginx running on an ubuntu Linux server&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Install certbot
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ apt-get update 
$ sudo apt-get install certbot 
$ apt-get install python-certbot-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Get SSL/TLS certificate&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo certbot --nginx -d example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here example.com ☝🏾 is referring to the domain Nginx is using to serve our app.&lt;/p&gt;

&lt;p&gt;If successful, you should get a response like below 👇🏽&lt;/p&gt;

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

&lt;p&gt;Open the browser and visit your app. &lt;br&gt;
It should be using HTTPS with a valid SSL/TLS certificate ⚡️&lt;/p&gt;

&lt;p&gt;Also check 👉🏽 &lt;a href="https://amanieric.com/blog/serve-a-static-app-with-nginx" rel="noopener noreferrer"&gt;Serve a static app with Nginx&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>Serve a static app with nginx</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Sun, 08 Jan 2023 18:32:30 +0000</pubDate>
      <link>https://forem.com/ericus123/serve-a-static-app-with-nginx-nem</link>
      <guid>https://forem.com/ericus123/serve-a-static-app-with-nginx-nem</guid>
      <description>&lt;h1&gt;
  
  
  What is Nginx?
&lt;/h1&gt;

&lt;p&gt;NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. &lt;/p&gt;

&lt;p&gt;It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers.&lt;/p&gt;

&lt;p&gt;In this article I'm going to show you how you can serve a static app like react using nginx.&lt;/p&gt;

&lt;p&gt;Let's get started 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install Nginx (Ubuntu)
&lt;/h2&gt;

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

sudo apt update
sudo apt install nginx


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  2. Deploy your react app
&lt;/h2&gt;

&lt;p&gt;Clone your react app&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

git clone https://github.com/&amp;lt;your username&amp;gt;/&amp;lt;your react app repo&amp;gt;.git


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

&lt;/div&gt;

&lt;p&gt;Install packages&lt;/p&gt;

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

sudo yarn install


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

&lt;/div&gt;

&lt;p&gt;Build the app&lt;/p&gt;

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

sudo yarn build


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  3. Create an Nginx configuration file
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

cd /etc/nginx/sites-available


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

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

sudo nano react.conf


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

&lt;/div&gt;

&lt;p&gt;Paste this codes&lt;/p&gt;

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


server {
    listen 80;
    server_name your_IP_or_Domain;
    root /home/username/path_to_your_react_app/build;
    index index.html index.htm;
    location / {
        try_files $uri/index.html=404;
}


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

&lt;/div&gt;

&lt;p&gt;Create an nginx virtual host file.&lt;br&gt;
we are going to do this by creating symlink to our config file for nginx to recognize it&lt;/p&gt;

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

sudo ln -s /etc/nginx/sites-available/react.conf  /etc/nginx/sites-enabled


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

&lt;/div&gt;

&lt;p&gt;Now that we are done with our configurations, let's test it.&lt;br&gt;
To test if the configurations have no errors we run the command below.&lt;/p&gt;

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

sudo nginx -t


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

&lt;/div&gt;

&lt;p&gt;if successful, you should see this in your terminal 🦾&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%2F6mlyser8olm3uemok0se.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%2F6mlyser8olm3uemok0se.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;let's test our static app.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;this restart our nginx service&lt;/em&gt;&lt;/p&gt;

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

sudo service nginx restart


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

&lt;/div&gt;

&lt;p&gt;Then open your browser and visit your_ip or domain as used in &lt;br&gt;
our config file.&lt;/p&gt;

&lt;p&gt;You should see the app running  ✨&lt;/p&gt;

&lt;h2&gt;
  
  
  Some helpful resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ubuntu.com/tutorials/install-and-configure-nginx#2-installing-nginx" rel="noopener noreferrer"&gt;Installing nginx on ubuntu&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.nginx.com/resources/glossary/nginx" rel="noopener noreferrer"&gt;About nginx&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;can check the article &lt;a href="https://amanieric.com/blog/serve-a-static-app-with-nginx" rel="noopener noreferrer"&gt;here&lt;/a&gt; as well &lt;/p&gt;

</description>
      <category>nginx</category>
      <category>react</category>
      <category>ubuntu</category>
      <category>hosting</category>
    </item>
    <item>
      <title>Task-Force week five experience</title>
      <dc:creator>AMANI Eric</dc:creator>
      <pubDate>Sun, 03 Oct 2021 09:59:22 +0000</pubDate>
      <link>https://forem.com/ericus123/task-force-week-five-experience-321</link>
      <guid>https://forem.com/ericus123/task-force-week-five-experience-321</guid>
      <description>&lt;p&gt;As today marks the end of the fifth week in Task-Force, I'm going to share with you the experience so far.&lt;/p&gt;

&lt;p&gt;This week involved a lot of activities and there were many things to learn. &lt;/p&gt;

&lt;p&gt;The session on Thursday was the most amazing as I got to learn about Agile Methodology deeply.&lt;/p&gt;

&lt;p&gt;I was not my first time using/knowing about Agile methodology but I found out that there is more to Agile Methodology than what I knew before.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hijxdpb2kzn59kbfxl1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hijxdpb2kzn59kbfxl1.jpeg" alt="Agile Methodology" width="600" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We played short games to help us understand Agile Methodology better, where some teammates were acting as SCRUM Masters, Developers, Product Owner, Client and so..on.&lt;/p&gt;

&lt;p&gt;This helped me to understand how each party plays a role in Agile Methodology and also understand its best practices.&lt;/p&gt;

&lt;p&gt;This was a long day but fruitful. I enjoyed every moment of the Thursday session.&lt;/p&gt;

&lt;p&gt;During this week, we also worked on some coding challenges. &lt;br&gt;
Coding challenges can be fun and also helpful as you are learning and developing your problem-solving skills.&lt;/p&gt;

&lt;p&gt;In programming, there are many alternatives to a solution but optimization of your solution also matters.&lt;br&gt;
Coding challenges help you on this. It's good if you start a week with coding challenges to refresh your mind :)&lt;/p&gt;

&lt;p&gt;Coming to Friday, we had to brainstorm and come up with an idea for our final project. The idea had to be solving a real problem and had to be unique. &lt;/p&gt;

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

&lt;p&gt;After a brief discussion, we came up with ideas for our project and chose the best one to work on. &lt;/p&gt;

&lt;p&gt;Generally, this week was amazing but Thursday was another thing. It was super amazing. I can't wait to see how next week is going to be like :)&lt;/p&gt;

</description>
      <category>agilemethodology</category>
      <category>brainstorming</category>
      <category>codeofafrica</category>
      <category>awesomitylab</category>
    </item>
  </channel>
</rss>
