<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Bolaji Ayodeji - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Bolaji Ayodeji - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 30 May 2026 22:25:04 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/bolajiayodeji/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ SSH Keygen Tutorial – How to Generate an SSH Public Key for RSA Login ]]>
                </title>
                <description>
                    <![CDATA[ Cryptography uses encryption and decryption to conceal messages. This introduces secrecy in information security. The purpose of cryptography is to ensure secure communication between two people or devices who are connecting through insecure channels... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/ssh-keygen-how-to-generate-an-ssh-public-key-for-rsa-login/</link>
                <guid isPermaLink="false">66d84e28ec0a9800d5b8e6b5</guid>
                
                    <category>
                        <![CDATA[ Cryptography ]]>
                    </category>
                
                    <category>
                        <![CDATA[ cybersecurity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ information security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ssh ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Tue, 30 Aug 2022 15:51:22 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/08/article-banner.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Cryptography uses encryption and decryption to conceal messages. This introduces secrecy in information security.</p>
<p>The purpose of cryptography is to ensure secure communication between two people or devices who are connecting through insecure channels.</p>
<p>The sender often employs an encryption key to lock the message, while the recipient uses a decryption key to unlock the message.</p>
<p>In general, cryptography employs two strategies:</p>
<ol>
<li><p><strong>Symmetric-key Cryptography (Private key):</strong> With this technique, the encryption and decryption keys are both known to the sender and receiver. Some examples of algorithms that use this technique include One Time Pad cipher, Vernam cipher, Playfair, Row column cipher, and Data Encryption Standard (DES).</p>
</li>
<li><p><strong>Asymmetric Key Cryptography (Public key):</strong> With this technique, each person has two keys: the Private (secret and accessible to the creator) and Public keys (freely available to anyone). The sender and receiver use different keys for encryption and decryption. Some examples of algorithms that use this technique include the Rivest–Shamir–Adleman algorithm (RSA), Diffie - Hellman Key Exchange (DHE), and the Digital Signature Algorithm (DSA).</p>
</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/06/Cryptography--2-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>The Encryption Model for Secured Data Transmission</em></p>
<p>Software engineers generally have to authenticate with servers or other services like GitHub for version control.</p>
<p>As opposed to using password authentication, they can use public key authentication to generate and store a pair of cryptographic keys on their computer. Then they can configure the server running on another computer to recognize and accept those keys.</p>
<p>This is the asymmetric key cryptography technique flow we discussed earlier and it is a more secure authentication process.</p>
<p>In this tutorial, you will learn how it all works, what SSH means, and how to generate SSH keys with an RSA algorithm using SSH keygen.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p>A working computer running on any operating system.</p>
</li>
<li><p>Basic knowledge of navigating around the command-line.</p>
</li>
<li><p>A smile on your face :)</p>
</li>
</ul>
<h2 id="heading-brief-introduction-to-ssh-secure-shell-protocol">Brief Introduction to SSH (<strong>S</strong>ecure <strong>Sh</strong>ell Protocol)</h2>
<p>Public key authentication using SSH is a more secure approach for logging into services than passwords. Understanding SSH is easier once you understand how cryptography works from the above intro.</p>
<p>Here's a helpful basic definition:</p>
<blockquote>
<p>"The <strong>S</strong>ecure <strong>Sh</strong>ell Protocol is a <strong>cryptographic network protocol</strong> for operating network services securely <strong>over an unsecured network</strong>." (<a target="_blank" href="https://en.wikipedia.org/wiki/Secure_Shell">Source</a>)</p>
</blockquote>
<p>SSH is used between a client and a server both running on the SSH protocol to remotely login into the server and access certain resources through the command line.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/06/image-197.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Source: SSH Academy</em></p>
<p>There is an open-source version of the SSH protocol (version 2) with a suite of tools called <a target="_blank" href="https://www.openssh.com">OpenSSH</a> (also known as OpenBSD Secure Shell). This project includes the following tools:</p>
<ul>
<li><p>Remote operations: <a target="_blank" href="https://man.openbsd.org/ssh.1">ssh</a>, <a target="_blank" href="https://man.openbsd.org/scp.1">scp</a>, and <a target="_blank" href="https://man.openbsd.org/sftp.1">sftp</a>.</p>
</li>
<li><p>Key generation: <a target="_blank" href="https://man.openbsd.org/ssh-add.1">ssh-add</a>, <a target="_blank" href="https://man.openbsd.org/ssh-keysign.8">ssh-keysign</a>, <a target="_blank" href="https://man.openbsd.org/ssh-keyscan.1">ssh-keyscan</a>, and <a target="_blank" href="https://man.openbsd.org/ssh-keygen.1"><strong>ssh-keygen</strong></a>.</p>
</li>
<li><p>Service side: <a target="_blank" href="https://man.openbsd.org/sshd.8">sshd</a>, <a target="_blank" href="https://man.openbsd.org/sftp-server.8">sftp-server</a>, and <a target="_blank" href="https://man.openbsd.org/ssh-agent.1">ssh-agent</a>.</p>
</li>
</ul>
<h2 id="heading-how-to-generate-an-ssh-public-key-for-rsa-login">How to Generate an SSH Public Key for RSA Login</h2>
<p>Our goal is to use ssh-keygen to generate an SSH public key using the RSA algorithm. This will create a key pair containing a private key (saved to your local computer) and a public key (uploaded to your chosen service).</p>
<p>Now to proceed, follow the steps below to achieve this:</p>
<ol>
<li>Install OpenSSH if you don't have it installed already using the command below:</li>
</ol>
<pre><code class="lang-python">// <span class="hljs-keyword">for</span> mac

brew install openssh

// <span class="hljs-keyword">for</span> linux

sudo apt install openssh-client &amp;&amp; sudo apt install openssh-server
</code></pre>
<ol start="2">
<li>Create a private/public key pair with an RSA algorithm (2046-bit encryption by default), using the command:</li>
</ol>
<pre><code class="lang-python">ssh-keygen -t rsa
</code></pre>
<ol start="3">
<li>Or, if you want to create with an RSA algorithm with 4096-bit encryption, use the command:</li>
</ol>
<pre><code class="lang-python">ssh-keygen -t rsa -b <span class="hljs-number">4096</span>
</code></pre>
<ol start="4">
<li><p>Enter a file location to save the key to (by default it will save to your users directory (for example, <code>(/Users/bolajiayodeji/.ssh/id_rsa)</code> ).</p>
</li>
<li><p>Enter a passphrase for extra security to your private key. Generally, a good passphrase should have at least 15 characters (including at least one upper case letter, lower case letters, numerical digits, and special characters) and must be difficult to guess. You can use one of those password generators online or use hexdump to generate a paraphrase easily like so:</p>
</li>
</ol>
<pre><code class="lang-python">hexdump -vn16 -e<span class="hljs-string">'4/4 "%08X" 1 "\n"'</span> /dev/urandom
</code></pre>
<ol start="6">
<li>Once you've successfully created your password, your private key will be saved in <code>/&lt;your_chosen_directory&gt;/.ssh/id_rsa</code> and your public key will be saved in <code>/&lt;your_chosen_directory&gt;/.ssh/id_rsa.pub</code>.</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/08/Screenshot-2022-08-30-at-1.18.15-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now you can copy the created key into the authorized_keys file of the server you want to connect to using ssh-copy-id (this tool is a part of openSSH) like so:</p>
<pre><code class="lang-python">ssh-copy-id username@remote_host
</code></pre>
<p>Alternatively, you'd want to add your SSH private key to the ssh-agent and store your passphrase in the keychain. You can then add the SHH key to your server's account via a dashboard UI or so (for example, using tools like Git or GitHub).</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Although a strong password helps prevent brute-force attacks, public key authentication provides a much more secure authentication process using cryptography.</p>
<p>I hope you found this article helpful. In addition, you can check out the <a target="_blank" href="https://man.openbsd.org/ssh-keygen.1">ssh-keygen manual page</a> and the following resources for further learning:</p>
<ul>
<li><p><a target="_blank" href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh">Connecting to GitHub with SSH</a></p>
</li>
<li><p><a target="_blank" href="https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse">Get started with OpenSSH for Windows</a></p>
</li>
</ul>
<p>Cheers! 💙</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Linux List Processes – How to Check Running Processes ]]>
                </title>
                <description>
                    <![CDATA[ Every day, developers use various applications and run commands in the terminal. These applications can include a browser, code editor, terminal, video conferencing app, or music player. For each of these software applications that you open or comman... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/linux-list-processes-how-to-check-running-processes/</link>
                <guid isPermaLink="false">66d84e24f6b5e038a1bde7cd</guid>
                
                    <category>
                        <![CDATA[ command line ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Tue, 29 Jun 2021 19:47:13 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/06/article-banner.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Every day, developers use various applications and run commands in the terminal. These applications can include a browser, code editor, terminal, video conferencing app, or music player.</p>
<p>For each of these software applications that you open or commands you run, it creates a <em>process</em> or <em>task</em>.</p>
<p>One beautiful feature of the Linux operating system and of modern computers in general is that they provide support for multitasking. So multiple programs can run at the same time.</p>
<p>Have you ever wondered how you can check all the programs running on your machine? Then this article is for you, as I'll show you how to list, manage, and kill all the running processes on your Linux machine.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p>A Linux distro installed.</p>
</li>
<li><p>Basic knowledge of navigating around the command-line.</p>
</li>
<li><p>A smile on your face :)</p>
</li>
</ul>
<h2 id="heading-a-quick-introduction-to-linux-processes">A Quick Introduction to Linux Processes</h2>
<p>A process is an instance of a running computer program that you can find in a software application or command.</p>
<p>For example, if you open your Visual Studio Code editor, that creates a process which will only stop (or die) once you terminate or close the Visual Studio Code application.</p>
<p>Likewise, when you run a command in the terminal (like <code>curl ifconfig.me</code>), it creates a process that will only stop when the command finishes executing or is terminated.</p>
<h2 id="heading-how-to-list-running-processes-in-linux-using-the-ps-command">How to List Running Processes in Linux using the <code>ps</code> Command</h2>
<p>You can list running processes using the <code>ps</code> command (ps means <em>process status</em>). The <code>ps</code> command displays your currently running processes in real-time.</p>
<p>To test this, just open your terminal and run the <code>ps</code> command like so:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/Screenshot-2021-06-28-at-3.25.33-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This will display the process for the current shell with four columns:</p>
<ul>
<li><p><strong>PID</strong> returns the unique process ID</p>
</li>
<li><p><strong>TTY</strong> returns the terminal type you're logged into</p>
</li>
<li><p><strong>TIME</strong> returns the total amount of CPU usage</p>
</li>
<li><p><strong>CMD</strong> returns the name of the command that launched the process.</p>
</li>
</ul>
<p>You can choose to display a certain set of processes by using any combination of options (like <code>-A</code> <code>-a</code>, <code>-C</code>, <code>-c</code>, <code>-d</code>, <code>-E</code>, <code>-e</code>, <code>-u</code>, <code>-X</code>, <code>-x</code>, and others).</p>
<p>If you specify more than one of these options, then all processes which are matched by at least one of the given options will be displayed.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/Screenshot-2021-06-28-at-3.55.10-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>The</em> <code>ps</code> command manual page.</p>
<blockquote>
<p>Type <code>man ps</code> in your terminal to read the manual for the <code>ps</code> command, which has a complete reference for all options and their uses.</p>
</blockquote>
<p>To display all running processes for all users on your machine, including their usernames, and to show processes not attached to your terminal, you can use the command below:</p>
<pre><code class="lang-python">ps aux
</code></pre>
<p>Here's a breakdown of the command:</p>
<ul>
<li><p><code>ps</code>: is the process status command.</p>
</li>
<li><p><code>a</code>: displays information about other users' processes as well as your own.</p>
</li>
<li><p><code>u</code>: displays the processes belonging to the specified usernames.</p>
</li>
<li><p><code>x</code>: includes processes that do not have a controlling terminal.</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/Screenshot-2021-06-28-at-4.39.05-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This will display the process for the current shell with eleven columns:</p>
<ul>
<li><p><strong>USER</strong> returns the username of the user running the process</p>
</li>
<li><p><strong>PID</strong> returns the unique process ID</p>
</li>
<li><p><strong>%CPU</strong> returns the percentage of CPU usage</p>
</li>
<li><p><strong>%MEM</strong> returns the percentage memory usage</p>
</li>
<li><p><strong>VSV</strong> returns the virtual size in Kbytes</p>
</li>
<li><p><strong>RSS</strong> returns the resident set size</p>
</li>
<li><p><strong>TT</strong> returns the control terminal name</p>
</li>
<li><p><strong>STAT</strong> returns the symbolic process state</p>
</li>
<li><p><strong>STARTED</strong> returns the time started</p>
</li>
<li><p><strong>CMD</strong> returns the command that launched the process.</p>
</li>
</ul>
<h2 id="heading-how-to-list-running-processes-in-linux-using-the-top-and-htop-commands">How to List Running Processes in Linux using the <code>top</code> and <code>htop</code> Commands</h2>
<p>You can also use the <code>top</code> task manager command in Linux to see a real-time sorted list of top processes that use the most memory or CPU.</p>
<p>Type <code>top</code> in your terminal and you'll get a result like the one you see in the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/Screenshot-2021-06-28-at-4.27.28-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<blockquote>
<p>You can type <code>q</code> to exit the session.</p>
</blockquote>
<p>An alternative to <code>top</code> is <code>htop</code> which provides an interactive system-monitor to view and manage processes. It also displays a real-time sorted list of processes based on their CPU usage, and you can easily search, filter, and kill running processes.</p>
<p><code>htop</code> is not installed on Linux by default, so you need to install it using the command below or <a target="_blank" href="https://htop.dev/downloads.html#binaries">download the binaries</a> for your preferred Linux distro.</p>
<pre><code class="lang-python">sudo apt update &amp;&amp; sudo apt install htop
</code></pre>
<p>Just type <code>htop</code> in your terminal and you'll get a result like the one you see in the screenshot below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/06/Screenshot-2021-06-29-at-4.49.09-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-kill-running-processes-in-linux">How to Kill Running Processes in Linux</h2>
<p>Killing a process means that you terminate a running application or command. You can kill a process by running the <code>kill</code> command with the process ID or the <code>pkill</code> command with the process name like so:</p>
<pre><code class="lang-python">kill [PID]
</code></pre>
<p>or</p>
<pre><code class="lang-python">pkill [COMMAND]
</code></pre>
<p>To find the process ID of a running process, you can use the <code>pgrep</code> command followed by the name of the process like so:</p>
<pre><code class="lang-python">pgrep iTerm2
</code></pre>
<p>To kill the iTerm2 process in the screenshot above, we will use any of the commands below. This will automatically terminate and close the iTerm2 process (application).</p>
<pre><code class="lang-python">kill <span class="hljs-number">25781</span>
</code></pre>
<p>or</p>
<pre><code class="lang-python">kill iTerm2
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>When you list running processes, it is usually a long and clustered list. You can pipe it through less to display the command output one page at a time in your terminal like so:</p>
<pre><code class="lang-python">ps aux | less
</code></pre>
<p>or display only a specific process that matches a particular name like so:</p>
<pre><code class="lang-python">ps aux | grep Chrome
</code></pre>
<p>I hope that you now understand what Linux processes are and how to manage them using the <code>ps</code>, <code>top</code>, and <code>htop</code> commands.</p>
<p>Make sure to check out the manual for each command by running <code>man ps</code>, <code>man top</code>, or <code>man htop</code> respectively. The manual includes a comprehensive reference you can check if you need any more help at any point.</p>
<p>Thanks for reading – cheers! 💙</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Git Reset to Remote Head – How to Reset a Remote Branch to Origin ]]>
                </title>
                <description>
                    <![CDATA[ Branching is a core concept in Git. It can help you set up a distributed workflow for team collaboration and makes your development process more efficient. When you're using version control and you're distributing features across branches, there's a ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/git-reset-to-remote-head-how-to-reset-a-remote-branch-to-origin/</link>
                <guid isPermaLink="false">66d84e1339c4dccc43d4d475</guid>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Mon, 08 Mar 2021 20:14:39 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/03/article-banner--1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Branching is a core concept in Git. It can help you set up a distributed workflow for team collaboration and makes your development process more efficient.</p>
<p>When you're using version control and you're distributing features across branches, there's a lot of communication between your local computer and your online repository on GitHub. During this process, you might need to reset back to the project's original copy.</p>
<p>If resetting a branch scares you, then don't worry – this article will introduce you to remote branches, remote head, and how you can easily reset a remote branch to remote head.</p>
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<ul>
<li><p>Basic knowledge of how to use the terminal.</p>
</li>
<li><p>Git installed (Learn <a target="_blank" href="https://www.freecodecamp.org/news/git-clone-branch-how-to-clone-a-specific-branch/#how-to-install-git-on-windows">how to install Git here</a> if you haven't already).</p>
</li>
<li><p>Basic knowledge of GitHub and repositories.</p>
</li>
<li><p>A grin on your face. 😉</p>
</li>
</ul>
<h2 id="heading-what-is-a-branch-in-git">What is a Branch in Git?</h2>
<p>A branch is a core concept in Git and GitHub that you'll use all the time. Branches help you manage different versions of one project.</p>
<p>The <code>main</code> branch is always the default branch in a repository and is considered "production and deployable code". You can create new branches like <code>prod-staging</code> or <code>prod-current</code> from the <code>main</code> branch.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/Screenshot-2021-02-27-at-7.19.26-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>All branches in https://github.com/freeCodeCamp/freeCodeCamp</em></p>
<h3 id="heading-what-is-a-remote-branch-in-git">What is a Remote Branch in Git?</h3>
<p>A <strong>remote branch</strong> is a reference to the state of the branches in a remote repository (a version of your project hosted on the internet or on a network like GitHub).</p>
<p>When you clone a repository, you pull data from a repository on the internet or an internal server known as the <strong>remote</strong> (it looks something like <code>(remote)/(branch)</code>).</p>
<h2 id="heading-what-is-origin-or-remote-head-in-git">What is Origin (or Remote Head) in Git?</h2>
<p>The word origin is an alias that Git created to replace the remote URL of a remote repository. It represents the default branch on a remote and is a local ref representing a local copy of the HEAD in the remote repository.</p>
<p>In summary, origin/HEAD represents the default branch on the remote, which is defined automatically when you clone a repository from the internet.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/03/Screenshot-2021-03-08-at-8.23.47-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-reset-a-remote-branch-to-origin-in-git">How to Reset a Remote Branch to Origin in Git</h2>
<p>Now that you have background knowledge of how remotes and branches work, let's solve our problem and reset a remote branch to origin using the <code>git reset --hard</code> command.</p>
<p>Before you do this (if this your first time), make sure that you back up your branch before you reset it in case something goes wrong. You can back it up like so:</p>
<pre><code class="lang-bash">git commit -a -m <span class="hljs-string">"Branch backup"</span>
git branch branch-backup
</code></pre>
<p>Now run the command below to reset your remote branch to origin. If you have a different remote and default branch name (not <code>origin</code> or <code>main</code>, respectively), just replace them with the appropriate name.</p>
<pre><code class="lang-bash">git fetch origin
git reset --hard origin/main
</code></pre>
<p>If you have created some new files or directories, they may still remain after resetting. You can use the command below to clean up the working tree by recursively removing files from the previous branch that are not under version control.</p>
<pre><code class="lang-python">git clean -xdf
</code></pre>
<ul>
<li><p>The <code>-x</code> flag removes all untracked files, including ignored build directories.</p>
</li>
<li><p>The <code>-d</code> flag allows Git to recurse into untracked directories when no path is specified.</p>
</li>
<li><p>The <code>-f</code> flag overwrites the default Git clean configuration and starts cleaning untracked files and directories.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>If your remote repository’s name is not “origin” and the branch named is not “main” ​in the remote repository, don't forget to update the commands above with the appropriate names. You can always run <code>git remote show origin</code> to check this.</p>
<p>I hope this article has made you more comfortable with working with and resetting branches. You should also join the new <a target="_blank" href="https://www.freecodecamp.org/news/introducing-freecodecamp-chat">freeCodeCamp chat server</a> to network with other learners and ask questions. Thanks for reading! 💙</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Linux LS Command – How to List Files in a Directory + Option Flags ]]>
                </title>
                <description>
                    <![CDATA[ Since the creation of Unix in the 1970s, a lot of operating systems have used it as their foundation. Many of these operating systems failed, while others succeeded. Linux is one of the most popular Unix based operating systems. It's open source, and... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-linux-ls-command-how-to-list-files-in-a-directory-with-options/</link>
                <guid isPermaLink="false">66d84e2ac15439a8d5631e49</guid>
                
                    <category>
                        <![CDATA[ command ]]>
                    </category>
                
                    <category>
                        <![CDATA[ command line ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Thu, 03 Sep 2020 07:59:30 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/09/article-banner-7.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Since the creation of Unix in the 1970s, a lot of operating systems have used it as their foundation. Many of these operating systems failed, while others succeeded.</p>
<p>Linux is one of the most popular Unix based operating systems. It's open source, and is used all over the world across many industries.</p>
<p>One amazing feature of the Linux operating system is the Command Line Interface (CLI) which allows users to interact with their computer from a shell. The Linux shell is a REPL (<strong>R</strong>ead, <strong>E</strong>valuate, <strong>P</strong>rint, <strong>L</strong>oop) environment where users can enter a command and the shell runs it and returns a result.</p>
<p>The <code>ls</code> command is one of the many Linux commands that allow a user to list files or directories from the CLI.</p>
<p>In this article, we'll go in depth on the <code>ls</code> command and some of the most important flags you'll need day-to-day.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p>A computer with directories and files</p>
</li>
<li><p>Have one of the Linux distros installed</p>
</li>
<li><p>Basic knowledge of navigating around the CLI</p>
</li>
<li><p>A smile on your face :)</p>
</li>
</ul>
<h2 id="heading-the-linux-ls-command">The Linux ls Command</h2>
<p>The <code>ls</code> command is used to list files or directories in Linux and other Unix-based operating systems.</p>
<p>Just like you navigate in your <em>File explorer</em> or <em>Finder</em> with a GUI, the <code>ls</code> command allows you to list all files or directories in the current directory by default, and further interact with them via the command line.</p>
<p>Launch your terminal and type <code>ls</code> to see this in action:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-20-at-9.40.29-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-list-files-in-a-directory-with-options">How to list Files in a Directory with Options</h2>
<p>The <code>ls</code> command also accepts some flags (also known as options) which are additional information that changes how files or directories are listed in your terminal.</p>
<p>In other words, flags change how the <code>ls</code> command works:</p>
<pre><code class="lang-python"> ls [flags] [directory]
</code></pre>
<blockquote>
<p>PS: The word <strong>contents</strong> used in throughout the article refers to the <strong>files and directories</strong> being listed, not the actual contents of the files/directories ?</p>
</blockquote>
<h3 id="heading-list-files-in-the-current-working-directory">List files in the current working directory</h3>
<p>Type the <code>ls</code> command to list the contents of the current working directory:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-20-at-9.40.29-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-in-another-directory">List files in another directory</h3>
<p>Type the <code>ls [directory path here]</code> command to list the contents of another directory:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-20-at-10.32.52-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-in-the-root-directory">List files in the root directory</h3>
<p>Type the <code>ls /</code> command to list the contents of the root directory:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-20-at-10.46.10-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-in-the-parent-directory">List files in the parent directory</h3>
<p>Type the <code>ls ..</code> command to list the contents of the parent directory one level above. Use <code>ls ../..</code> for contents two levels above:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-20-at-10.48.22-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-in-the-users-home-directory-homeuser">List files in the user's home directory (/home/user)</h3>
<p>Type the <code>ls ~</code> command to list the contents in the users's home directory:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-20-at-10.51.19-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-only-directories">List only directories</h3>
<p>Type the <code>ls -d */</code> command to list only directories:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-12.53.05-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-with-subdirectories">List files with subdirectories</h3>
<p>Type the <code>ls *</code> command to list the contents of the directory with it's subdirectories:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-1.07.54-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-recursively">List files recursively</h3>
<p>Type the <code>ls -R</code> command to list all files and directories with their corresponding subdirectories down to the last file:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/09/Screenshot-2020-09-01-at-9.04.56-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<blockquote>
<p>If you have a lot of files, this can take a very long time to complete as every single file in each directory will be printed out. You can instead specify a directory to run this command in, like so: <code>ls Downloads -R</code></p>
</blockquote>
<h3 id="heading-list-files-with-their-sizes">List files with their sizes</h3>
<p>Type the <code>ls -s</code> command (the <strong>s</strong> is lowercase) to list files or directories with their sizes:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-12.30.19-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-in-long-format">List files in long format</h3>
<p>Type the <code>ls -l</code> command to list the contents of the directory in a table format with columns including:</p>
<ul>
<li><p>content permissions</p>
</li>
<li><p>number of links to the content</p>
</li>
<li><p>owner of the content</p>
</li>
<li><p>group owner of the content</p>
</li>
<li><p>size of the content in bytes</p>
</li>
<li><p>last modified date / time of the content</p>
</li>
<li><p>file or directory name</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-20-at-10.52.37-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-in-long-format-with-readable-file-sizes">List files in long format with readable file sizes</h3>
<p>Type the <code>ls -lh</code> command to list the files or directories in the same table format above, but with another column representing the size of each file/directory:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-12.14.33-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Note that sizes are listed in bytes (B), megabytes (MB), gigabytes (GB), or terabytes (TB) when the file or directory's size is larger than 1024 bytes.</p>
<h3 id="heading-list-files-including-hidden-files">List files including hidden files</h3>
<p>Type the <code>ls -a</code> command to list files or directories including hidden files or directories. In Linux, anything that begins with a <code>.</code> is considered a hidden file:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-11.12.26-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-in-long-format-including-hidden-files">List files in long format including hidden files</h3>
<p>Type the <code>ls -l -a</code> or <code>ls -a -l</code> or <code>ls -la</code> or <code>ls -al</code> command to list files or directories in a table format with extra information including hidden files or directories:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-12.17.01-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-and-sort-by-date-and-time">List files and sort by date and time</h3>
<p>Type the <code>ls -t</code> command to list files or directories and sort by last modified date in descending order (biggest to smallest).</p>
<p>You can also add a <code>-r</code> flag to reverse the sorting order like so: <code>ls -tr</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-12.20.09-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-and-sort-by-file-size">List files and sort by file size</h3>
<p>Type the <code>ls -S</code> (the <strong>S</strong> is uppercase) command to list files or directories and sort by size in descending order (biggest to smallest).</p>
<p>You can also add a <code>-r</code> flag to reverse the sorting order like so: <code>ls -Sr</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/08/Screenshot-2020-08-21-at-12.20.38-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-list-files-and-output-the-result-to-a-file">List files and output the result to a file</h3>
<p>Type the <code>ls &gt; output.txt</code> command to print the output of the preceding command into an <code>output.txt</code> file. You can use any of the flags discussed before like <code>-la</code> — the key point here is that the result will be outputted into a file and not logged to the command line.</p>
<p>Then you can use the file as you see fit, or log the contents of the file with <code>cat output.txt</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/09/Screenshot-2020-09-01-at-9.12.59-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>.</em></p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>There are tons of other commands and combinations you can explore to list out files and directories based on your needs. One thing to remember is the ability to combine multiple commands together at once.</p>
<p>Imagine you want to list a file in long format, including hidden files, and sort by file size. The command would be <code>ls -alS</code>, which is a combination of <code>ls -l</code>, <code>ls -a</code>, and <code>ls -S</code>.</p>
<p>If you forget any command or are unsure about what to do, you can run <code>ls --help</code> or <code>man ls</code> which will display a manual with all possible options for the <code>ls</code> command:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/09/Screenshot-2020-09-01-at-9.57.37-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Thanks for reading!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Git Clone Branch – How to Clone a Specific Branch ]]>
                </title>
                <description>
                    <![CDATA[ Unlike older centralized version control systems such as SVN and CVS, Git is distributed. Every developer has the full history and control of their code locally or remotely. They can also access or manipulate several parts of the code as they deem fi... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/git-clone-branch-how-to-clone-a-specific-branch/</link>
                <guid isPermaLink="false">66d84e0f29e30bc0ad477548</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ programing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ terminal ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Tue, 30 Jun 2020 18:56:31 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/06/article-banner--1-.gif" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Unlike older centralized version control systems such as SVN and CVS, Git is distributed. Every developer has the full history and control of their code locally or remotely. They can also access or manipulate several parts of the code as they deem fit from different locations.</p>
<p>Since Linus Torvalds (the famous creator of the Linux operating system kernel) created Git in 2005 for Linux kernel development, it has become the most widely used modern version control system in the world.</p>
<p>In this article, I'll introduce you to the Git clone and Git branch workflows and I'll show you how you can clone a specific branch based on your needs. Let's begin! ?</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p>Basic knowledge of the terminal</p>
</li>
<li><p>Ability to type commands in the terminal</p>
</li>
<li><p>Git installed (I'll still show you how)</p>
</li>
<li><p>A GitHub account</p>
</li>
<li><p>A smile on your face (Put up that smile friend ?)</p>
</li>
</ul>
<h2 id="heading-quick-introduction-to-git-and-github">Quick Introduction to Git and GitHub</h2>
<p>According to <a target="_blank" href="https://en.wikipedia.org/wiki/Git">Wikipedia</a>,</p>
<blockquote>
<p><strong>Git</strong> is a distributed version control system designed to track changes to a project (code) in software development. It is intended to enforce coordination, collaboration, speed, and efficiency among developers.</p>
</blockquote>
<p><strong>GitHub,</strong> on the other hand, is a web-based hosting service for version control using Git. It offers all of the distributed version control and source code management functionality of Git as well as adding more features for computer code.</p>
<h2 id="heading-how-to-install-git-on-windows">How to Install Git on Windows</h2>
<p>Download and install the latest <a target="_blank" href="https://git-for-windows.github.io/">Git for Windows Installer here.</a></p>
<h2 id="heading-how-to-install-git-on-linux">How to Install Git on Linux</h2>
<p>Here are the commands based on your Linux distro:</p>
<h3 id="heading-debian-or-ubuntu">Debian or Ubuntu</h3>
<pre><code class="lang-python">sudo apt-get update
sudo apt-get install git
</code></pre>
<h3 id="heading-fedora">Fedora</h3>
<pre><code class="lang-python">sudo dnf install git
</code></pre>
<h3 id="heading-centos">CentOS</h3>
<pre><code class="lang-python">sudo yum install git
</code></pre>
<h3 id="heading-arch-linux">Arch Linux</h3>
<pre><code class="lang-python">sudo pacman -Sy git
</code></pre>
<h3 id="heading-gentoo">Gentoo</h3>
<pre><code class="lang-python">sudo emerge --ask --verbose dev-vcs/git
</code></pre>
<h2 id="heading-how-to-install-git-on-a-mac">How to Install Git on a Mac</h2>
<p>Download and install the latest <a target="_blank" href="https://sourceforge.net/projects/git-osx-installer/files/">Git for Mac installer here</a>.</p>
<p>Or you can type this command:</p>
<pre><code class="lang-python">brew install git
</code></pre>
<p>Now that we've got Git installed, let's move on to the tutorial.</p>
<h2 id="heading-introduction-to-git-clone">Introduction to Git Clone</h2>
<p>Git allows you to manage and version your project(s) in a "repository". This repository is stored on a web-based hosting service for version control, like GitHub.</p>
<p>You can then clone this repository to your local machine and have all the files and branches locally (I'll explain more about branches soon).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-23-at-5.47.48-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>For example, you can clone freeCodeCamp's repository with SSH like so:</p>
<pre><code class="lang-python">git clone git@github.com:freeCodeCamp/freeCodeCamp.git
</code></pre>
<h2 id="heading-introduction-to-git-branches">Introduction to Git Branches</h2>
<p>When working on a project, you will likely have different features. And multiple contributors will be working on this project and its features.</p>
<p>Branches allow you to create a "playground" with the same files in the <code>master</code> branch. You can use this branch to build independent features, test new features, make breaking changes, create fixes, write docs or try out ideas without breaking or affecting the production code. When you're done, you merge the branch into the production <code>master</code> branch.</p>
<p>Branching is a core concept in Git which is also used in GitHub to manage workflows of different versions of one project. The <code>master</code> branch is always the default branch in a repository that is most often considered "production and deployable code". New branches like <code>passwordless-auth</code> or <code>refactor-signup-ux</code> can be created from the <code>master</code> branch.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-22-at-2.47.53-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>All branches in freeCodeCamp's repository</em></p>
<h2 id="heading-how-to-clone-git-branches">How to Clone Git Branches</h2>
<p>While you can clone repositories with the <code>git clone</code> command, keep in mind that this clones the branch and the remote <code>HEAD</code>. This is usually <code>master</code> by default and includes all other branches in the repository.</p>
<p>So when you clone a repository, you clone the <code>master</code> and all other branches. This means you will have to checkout another branch yourself.</p>
<p>Let's say your task on a project is to work on a feature to add passwordless authentication to a user dashboard. And this feature is in the <code>passwordless-auth</code> branch.</p>
<p>You really don't need the <code>master</code> branch since your "feature branch" will be merged into <code>master</code> afterward. How then do you clone this <code>passwordless-auth</code> branch without fetching all other branches with "a bunch of files you don't need"?</p>
<p>I created this sample repository to explain this. This repository holds a simple blog built with Nextjs and has four dummy branches:</p>
<ul>
<li><p>master</p>
</li>
<li><p>dev</p>
</li>
<li><p>staging</p>
</li>
<li><p>passwordless-auth</p>
</li>
</ul>
<p>In Nextjs, any file inside the folder <code>pages/api</code> is mapped to the <code>/api/*</code> path and will be treated as an API endpoint instead of a <code>page</code>. In our repository, I have created different dummy APIs <a target="_blank" href="https://github.com/BolajiAyodeji/nextjs-blog/tree/master/pages/api">in this directory</a> to make each branch different.</p>
<p>The <code>master</code> branch holds the file <strong>pages/api/hello.js</strong> while <code>passwordless-auth</code> holds the file <strong>pages/api/auth.js</strong>. Each file just returns a dummy text response. See <code>master</code>'s hello API response <a target="_blank" href="https://nextjs-blog.bolajiayodeji.vercel.app/api/hello">here</a> (with a special message for you ?).</p>
<p>Let's clone the repository:</p>
<pre><code class="lang-python">git clone git@github.com:BolajiAyodeji/nextjs-blog.git
</code></pre>
<p>This gives us access to all branches in this repository and you can easily toggle between each to see each version and its files.</p>
<pre><code class="lang-python">git branch -a
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-22-at-4.51.56-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Wondering where the <strong>remotes/origin/..</strong> branches came from?</p>
<p>When you clone a repository, you pull data from a repository on the internet or an internal server known as the <strong>remote</strong>. The word origin is an alias created by your Git to replace the remote URL (you can change or specify another alias if you want).</p>
<p>These <strong>remotes/origin/..</strong> branches point you back to the origin repository you cloned from the internet so you can still perform pull/push from the origin.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-23-at-5.24.43-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>So when you clone <code>master</code> onto your machine, <code>remotes/origin/master</code> is the original <code>master</code> branch on the internet, and <code>master</code> is on your local machine. So you will pull/push from and to the <code>remotes/origin/master</code>.</p>
<p>In summary <strong>Remote</strong> is the URL that points you to the repository on the internet while <strong>Origin</strong> is an alias for this remote URL.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-23-at-5.28.06-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-clone-a-specific-branch">How to Clone a Specific Branch</h2>
<p>Now let's clone a specific branch from our demo repository. There are two ways to clone a specific branch. You can either:</p>
<ul>
<li><p>Clone the repository, fetch all branches, and checkout to a specific branch immediately.</p>
</li>
<li><p>Clone the repository and fetch only a single branch.</p>
</li>
</ul>
<h3 id="heading-option-one">Option One</h3>
<pre><code class="lang-python">git clone --branch &lt;branchname&gt; &lt;remote-repo-url&gt;
</code></pre>
<p>or</p>
<pre><code class="lang-python">git clone -b &lt;branchname&gt; &lt;remote-repo-url&gt;
</code></pre>
<p>With this, you fetch all the branches in the repository, checkout to the one you specified, and the specific branch becomes the configured local branch for <code>git push</code> and <code>git pull</code> . But you still fetched all files from each branch. This might not be what you want right? ?</p>
<p>Let's test it:</p>
<pre><code class="lang-python"> git clone -b passwordless-auth git@github.com:BolajiAyodeji/nextjs-blog.git
</code></pre>
<p>This automatically configures <code>passwordless-auth</code> as the local branch but still tracks other branches.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-23-at-5.30.01-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-30-at-3.27.31-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-option-two">Option Two</h3>
<pre><code class="lang-python">git clone --branch &lt;branchname&gt; --single-branch &lt;remote-repo-url&gt;
</code></pre>
<p>or</p>
<pre><code class="lang-python">git clone -b &lt;branchname&gt; --single-branch &lt;remote-repo-url&gt;
</code></pre>
<p>This performs the same action as option one, except that the <code>--single-branch</code> option was introduced in Git version 1.7.10 and later. It allows you to only fetch files from the specified branch without fetching other branches.</p>
<p>Let's test it:</p>
<pre><code class="lang-python">git clone -b passwordless-auth --single-branch git@github.com:BolajiAyodeji/nextjs-blog.git
</code></pre>
<p>This automatically configures <code>passwordless-auth</code> as the local branch and only tracks this branch.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-23-at-5.31.12-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/06/Screenshot-2020-06-30-at-3.29.07-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you run <code>cd pages/api</code> you'll find the <code>auth.js</code> file in the <code>passwordless-auth</code> branch as expected from the previous setup.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>You might be running out of internet or storage space but you need to work on a task in a specific branch. Or you might want to clone a specific branch with limited files for various reasons. Fortunately, Git provides you the flexibility to do this. Flex your muscles and try it out, there's much more "Git" to learn.</p>
<p>One at a time, yeah? ✌?</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Ask Effective Questions: A Practical Guide for Developers ]]>
                </title>
                <description>
                    <![CDATA[ Learning is a journey that never ends. At every point in your career, you will keep learning, re-learning, and un-learning. The ability to find answers to problems is key, and these answers can be gotten by either debugging, googling or asking questi... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/asking-effective-questions-a-practical-guide-for-developers/</link>
                <guid isPermaLink="false">66d84e095a0b456f4d321437</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ career advice ]]>
                    </category>
                
                    <category>
                        <![CDATA[ debugging ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Developer ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Google ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Problem Solving ]]>
                    </category>
                
                    <category>
                        <![CDATA[ programing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ research ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Tue, 12 May 2020 08:20:49 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/asking-effectively.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Learning is a journey that never ends. At every point in your career, you will keep learning, re-learning, and un-learning.</p>
<p>The ability to find answers to problems is key, and these answers can be gotten by either debugging, googling or asking questions. These are skills everyone should learn.</p>
<p>While asking questions is great, doing it the wrong or less effective way might lead to many hours of unproductive work. In this article show you how to ask effective questions, become a better googler, and hone your problem-solving skills.</p>
<h2 id="heading-the-read-search-ask-method">The Read Search Ask Method</h2>
<p>freeCodeCamp came up with this amazing method for their students called the <a target="_blank" href="https://www.freecodecamp.org/forum/t/how-to-get-help-when-you-are-stuck-coding/19514">Read Search Ask</a> method where you can solve your problems efficiently while respecting other people’s time, too.</p>
<p>It is expected that you follow these steps in order before you ask a question.</p>
<ul>
<li><p><strong>Read</strong> the error or documentation</p>
</li>
<li><p><strong>Search</strong> Google or Stackoverflow</p>
</li>
<li><p><strong>Ask</strong> for help</p>
</li>
</ul>
<h3 id="heading-read-your-errors">Read your errors</h3>
<p>The first step to finding a solution(s) to your problem is to understand the problem itself. Many developers ask questions without understanding the problem. Remember you want to ask questions efficiently and also respect the time of the individual you will be asking.</p>
<p>Most often, the answers to your bugs are in the errors itself. It's not considerate to ask questions that you could have solved yourself if you had read the error itself.</p>
<p>One great way to debug your errors is to log the error on your console or terminal and read the errors. Five things can happen at this stage:</p>
<ul>
<li><p>You identify the bug</p>
</li>
<li><p>You determine the location of the bug (possible a file or section of your code)</p>
</li>
<li><p>You understand the cause(s) of the bug</p>
</li>
<li><p>You outline possible fixes of the bug</p>
</li>
<li><p>You implement the possible fixes</p>
</li>
</ul>
<p>Most often, just this step alone can help you solve your problem. The more you practice this, the better you become at debugging and fixing issues. Some bugs might be more complex than your capacity, and then you need to seek external help or resources.</p>
<h3 id="heading-read-the-documentation">Read the Documentation</h3>
<p>Let's assume you couldn't fix your issues from the first step (but you were able to identify the bug at least). Then you need to read some documentation.</p>
<p>This might not apply to all bugs, but make sure to run your issue through this step before moving to the next. After identifying your bug, it's time to determine the cause and outline possible fixes.</p>
<blockquote>
<p>Documentation is a set of documents provided on paper, or online, or on digital or analogue media, such as audio tape or CDs. Examples are user guides, white papers, on-line help, quick-reference guides. Paper or hard-copy documentation has become less common. ~ <a target="_blank" href="https://en.wikipedia.org/wiki/Documentation">Wikipedia</a></p>
</blockquote>
<p>Documentation serves as the official guide of a particular programming language, framework, library or technology. The best place to get the first-hand resource on a specific issue is to check the official help guide of the technology.</p>
<p>You might have misconfigured something, installed some wrong package or forgot to import something. But when you read the docs of the tech responsible for the bug it can help you find a fix quickly.</p>
<p>Recently I was working on a Gatsby project, and I ran into some console errors and blank white page in production. But this didn't occur in development.</p>
<pre><code class="lang-python">TypeError: t.test <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> a function
</code></pre>
<p>So vague right? After identifying the bug location, reading the docs and trying out several fixes, I discovered something: in the Gatsby Google analytics plugin configuration, I left the array meant to avoid sending pageview hits from custom paths empty.</p>
<pre><code class="lang-python">plugins: [
    {
      resolve: `gatsby-plugin-google-analytics`,
      options: {
        trackingId: <span class="hljs-string">'UA-XXXXXXXX-1'</span>,
        head: false,
        anonymize: true,
        respectDNT: true,
        exclude: [<span class="hljs-string">''</span>],
        pageTransitionDelay: <span class="hljs-number">0</span>,
      }
]
</code></pre>
<p>After 3 hours of reading the error, trying to identify the bug and reading Gatsby docs, I figured out that the <code>exclude[]</code> option had no values in it. Removing this fixed my issue since I didn't need to exclude any page after all.</p>
<p>This shows why you should spend some time debugging. It might take some time, and it will be frustrating. The bug might look stupid, the fix might be simple, but it's worth it. The more time you spend debugging, the better you become and the faster you will fix even more complex bugs next time.</p>
<h3 id="heading-search">Search</h3>
<p>Now if you have read your errors and several docs, but your bug is becoming more complex, it's time to search the web "effectively".</p>
<p>One of the best places to search for solutions to your issues is <a target="_blank" href="https://google.com">Google</a> since it already crawls content from numerous webpages, dev communities, and docs like <a target="_blank" href="https://stackoverflow.com/">StackOverflow</a>, <a target="_blank" href="https://hashnode.com/">Hashnode</a>, <a target="_blank" href="https://www.freecodecamp.org/news/">freeCodeCamp News</a>, <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web">MDN</a>, <a target="_blank" href="https://css-tricks.com/">CSS tricks</a>, <a target="_blank" href="https://hackernoon.com/">Hackernoon</a>, and many others.</p>
<p>Here are some helpful Google search tips you can try to get answers more efficiently:</p>
<ul>
<li>Add a specific domain to channel your search to a particular website and save some time. You can append the <code>site: sitename</code> to your search, and it'll return only results from that website.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1589268176790/vwk3EmzK9.png" alt="Screen Shot 2020-05-12 at 12.49.06 PM.png" width="3104" height="1978" loading="lazy"></p>
<ul>
<li>Search for specific title and text in specific sites. This will allow your results to include resources related to the title or text keyword you specified.</li>
</ul>
<blockquote>
<p>intitle:axe</p>
<p>intitle:axe intext:web ui testing</p>
<p>intitle:axe intext:web ui testing site:bolajiayodeji.com</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1589268185857/KA_B5_TTq.png" alt="Screen Shot 2020-05-12 at 12.48.59 PM.png" width="3104" height="1978" loading="lazy"></p>
<ul>
<li><p>Add specific keywords to your search and pull out individual details like file paths. If your bug is related to Python, add it to your search query. If it is related to objects, add that too. This will streamline the results to a wider range of possible resources related to your bug, since there are objects in just about every programming language.</p>
</li>
<li><p>Google automatically omits most non-alphanumeric characters from your queries. Symbols like <strong>`!@#$%^&amp;*(){}[]&lt;&gt;</strong> are not included in your search. So you can focus on more specific keywords, as discussed above.</p>
</li>
<li><p>Copy and paste your errors (removing specific information); there is a 99.9% chance that someone else has encountered the same error and has maybe opened some issue or written an article about it. Never underestimate the power of StackOverflow and GitHub issues.</p>
</li>
<li><p>Search within the past few years since programming changes pretty quickly. This will ensure you don't hit redundant resources.</p>
</li>
<li><p>Reiterate, try different keywords and more general keywords multiple times, and open multiple tabs until you find an answer. This might be awkward at first, but as you consistently do this, you'll get better, and with time it will take you less time and fewer tabs to find an answer.</p>
</li>
</ul>
<h3 id="heading-ask">Ask</h3>
<p>Now comes the sought-after diamond. I would advise, before you ask ANY questions, that you make sure you have completed steps 1 and 2.</p>
<p>This might be hard, but the earlier you get used to this, the better you grow. I've had people ask me questions, and when I copy and paste their question into Google, the first result answers the question 100%. This doesn't feel great.</p>
<p>Most often, I'll have to send the link to them. Meanwhile, they could have done this themselves and saved me some time while increasing their problem-solving skills.</p>
<p>Even if your next-door neighbour works at Google, if your dad is a Software Engineer, if your close friend has two more years experience beyond you, try not to ask them questions until you have invested time into finding solutions yourself. This will help you:</p>
<ul>
<li><p>Build more self-confidence, as you won't need to rely so much on others. (What if that close friend is unavailable to respond to you someday, what will you do?!)</p>
</li>
<li><p>Save the time of whomever you are planning to ask questions. There are tons of developers around the world, and you might not be the only one asking that same person questions. By completing steps 1 and 2 first, you are also helping others with less experience or more complex problems get answers quickly.</p>
</li>
<li><p>Build your problem-solving, debugging, research and googling skills. These are essential skills that will help you become a better developer. You only master a skill when you consistently practice it, so try to practice this regularly and watch yourself grow and master the art.</p>
</li>
</ul>
<div class="embed-wrapper">
        <blockquote class="twitter-tweet">
          <a href="https://twitter.com/iambolajiayo/status/1255694731482365952"></a>
        </blockquote>
        <script defer="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div>
<p> </p>
<p>But let's say that you have completed both steps, and you still need external help from a mentor, senior developer, team lead, the local community, group, or friend. How then do you ask questions effectively?</p>
<ul>
<li><p>Complete step 1 and make sure you understand the problem already</p>
</li>
<li><p>Complete step 2 so you might at least have gotten some insights into possible causes and solutions of the problem</p>
</li>
<li><p>Now do some research: you are either asking the question in dev communities like <a target="_blank" href="https://stackoverflow.com/">Stackoverflow</a> or <a target="_blank" href="https://hashnode.com/">Hashnode</a> or requesting help from an individual you feel has more experience than you.</p>
</li>
<li><p>Developers answering questions on dev communities are sacrificing their time to help you. Help them also by asking "clear and concise questions". You should choose your words deliberately and precisely, constructing your sentences carefully to avoid confusion. From step 1 and step 2, properly draft your questions based on:</p>
<ul>
<li><p>The "problem" you have encountered</p>
</li>
<li><p>Your thoughts on what you think might be wrong "based on your research."</p>
</li>
<li><p>Proof of research efforts (Devs will be happier to help you once they see you have made some effort already). Add links to resources you have checked and solutions you have tried already.</p>
</li>
<li><p>Be conversant with tools like <a target="_blank" href="https://codepen.io/">CodePen</a>, <a target="_blank" href="https://codesandbox.io/">CodeSandBox</a>, <a target="_blank" href="https://gist.github.com/">GitHub Gist</a>, <a target="_blank" href="https://repl.it/">Repl.it</a>, and <a target="_blank" href="https://github.com/">GitHub</a> so you can easily provide a link to a snippet of your code, a working project or <a target="_blank" href="https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05d70ff">mimimal reproduction</a> without having to type so much text. <strong>Please try as much as possible not to paste code that is more than one line in chat.</strong></p>
</li>
<li><p>Take clean and clear screenshots where necessary. Most often, you can take a snapshot of your console errors for smaller issues. Try not to strain your helper's eyes. Take specific and clear screenshots related to your error.</p>
</li>
</ul>
</li>
<li><p>Be sure you're asking the right person or community. Don't ask a python related question to someone who knows just Java. Your research from the previous step will help you here. It's also great to bookmark specific communities, individuals or groups where you will regularly ask questions based on how helpful their responses have been to you.</p>
</li>
<li><p>Now don't be afraid to ask. I've had my share of toxic responses from people who respond with comments like "this is simple", "come on, google it", "you should know this", and you might get that too :(. The internet is a combination of good and toxic individuals who might be or not welcoming. Be confident in yourself, you have done your part by completing steps 1 and 2, so ask the question freely.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>You don't need to "know it all", you just need to "know it and know how and where to find more knowledge."</p>
<p>Dear 10x, Senior, "It's Simple", Engineer: please note that you're discouraging developers who are asking these questions. I had to battle so much with my self-confidence some years ago, and it took me a while to get over it.</p>
<p>There is so much for learners to battle with already (learning, imposter syndrome, and personal issues), so please don't add to it. Be welcoming, make them feel like they belong here, and support them.</p>
<p>Your response can intentionally or unintentionally influence someone's decision to ask questions freely next time. If you can't or won't be available, you can either not respond at all or respond in a friendly way with feedback.</p>
<p>Refer people to your friends if you don't have the time or capabilities to attend to them, give constructive criticism, and try not to leave a question without feedback or impact.</p>
<blockquote>
<p>Beginner developers need support. Learning to code is hard, especially if you're doing it alone. If you're learning in a traditional classroom, be sure to network with the other students. Do homework together. Discuss the problems. If you're learned online, it's very easy to get discouraged. Find chat spaces with others who are on a similar journey and use that space to encourage one another. Twitter also makes the experts accessible to you (reason #49948 why I love Twitter). Find the experts in whatever it is you're learning and consume their content. Ask them questions if you need to. The key is not to do it alone. ~ <a target="_blank" href="https://townhall.hashnode.com/women-in-tech-angie-jones-cjyodxwfc003ls8s10syrzvq7">Angie Jones</a></p>
</blockquote>
<p>The industry is growing daily. We are all trying to learn and get better at different levels. A lot of developer <a target="_blank" href="https://bolajiayodeji.com/best-developer-communities-to-be-part-of-in-2020-ck7ugplig01a9zis174d7zrnk">communities</a> are supportive and make their resources available for consumption. Make sure you are a part of this movement, consume those available resources, contribute to these resources, and be a helper in any way you can.</p>
<p>Thank you to all the amazing developers across the globe, creating and sharing contents/ projects. Your contributions are the pillars holding up the tech ecosystem today. ??</p>
<blockquote>
<p>Quick note, I interview awesome women in tech on the <a target="_blank" href="https://hashnode.com/series/she-inspires-cjt0d02lq001e7ps2wo420g15">She Inspires</a> at <a target="_blank" href="https://hasnode.com">Hashnode</a> where I understand the current health of the tech industry, get insights from their personal and career growth, and inspire other women to become better. Read all past interviews <a target="_blank" href="https://hashnode.com/series/she-inspires-cjt0d02lq001e7ps2wo420g15">here</a>, trust me it's worth your time. :)</p>
</blockquote>
<p>Don't spend your entire life waiting for the best time to make that move – write that article, build that side-project, apply for that job or ask that question today. The best time is always now!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Best Developer Communities to Join in 2020 ]]>
                </title>
                <description>
                    <![CDATA[ If you want to grow as a developer, I can't over-emphasize the benefits of joining a developer community. There are many advantages, from peer-programming to sharing knowledge, mentorship, sharing support, sharing tools, code reviews, answering quest... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/best-developer-communities-to-be-part-of-in-2020/</link>
                <guid isPermaLink="false">66d84e0b7211ea6be29e1b3f</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ code newbie ]]>
                    </category>
                
                    <category>
                        <![CDATA[ community ]]>
                    </category>
                
                    <category>
                        <![CDATA[ community building ]]>
                    </category>
                
                    <category>
                        <![CDATA[ developers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ mentorship ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Wed, 11 Mar 2020 11:23:26 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/03/banner-dev-community-high-res-v5.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you want to grow as a developer, I can't over-emphasize the benefits of joining a developer community. There are many advantages, from peer-programming to sharing knowledge, mentorship, sharing support, sharing tools, code reviews, answering questions, and much more.</p>
<p>Communities are usually built on shared struggles of individuals learning in a particular region, and the goals of each community differ per the individual's collective needs.</p>
<p>Over the years, these developer communities have grown across the world with different goals and missions but still with the general aim of providing a platform for developers to learn, interact, share ideas, support each other and grow.</p>
<p>"If you want to go quickly, go alone. If you want to go far, go together." – African Proverb</p>
<p>To better help those looking out for communities to join, I have put together a list of 20 best communities in no particular order ranging from Engineering, Design, Data Science, Machine Learning, Developer Relations, Technical Writing, and more.</p>
<p>If you know any more communities you have found helpful, please share them in the comments section for the benefit of all :).</p>
<h2 id="heading-1-women-who-codehttpswwwwomenwhocodecom">1. <a target="_blank" href="https://www.womenwhocode.com">Women Who Code</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583767022913/Bl9cmrbm3.png" alt="Screen Shot 2020-03-09 at 8.17.55 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Women Who Code is an international nonprofit organization that provides a global community for women in tech with events, coding resources, jobs, mentorship, and more. They aim to inspire, support, and help women develop technical skills and excel in their careers.</p>
<p>Join now to get exclusive access to their community, events, scholarships, free event tickets, job boards, and more.</p>
<h2 id="heading-2-hashnodehttphashnodecom">2. <a target="_blank" href="http://hashnode.com/">Hashnode</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583767029246/Wc8I44ICK.png" alt="Screen Shot 2020-03-09 at 8.18.13 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Hashnode is an online community where developers share knowledge and grow their careers. Developers from around the world participate in consequential discussions on Hashnode. You can write stories, ask open-ended questions as well as technical questions, ask questions anonymously, and start polls. You can also <a target="_blank" href="https://hashnode.com/amas">ask popular tech teams and developer influencers questions</a> or learn from <a target="_blank" href="https://hashnode.com/series/she-inspires-cjt0d02lq001e7ps2wo420g15">stories of awesome women in tech</a>.</p>
<p><a target="_blank" href="https://hashnode.com/devblog">Hashnode's Devblog</a> platform enables you to create your personal blog on your custom domain in a few simple steps with everything you need to grow as a blogger. (No Paywall, Free domain, SSL, Automatic backup of posts, Markdown, AMP Support and more). <a target="_blank" href="https://hashnode.com/post/hey-developers-own-your-canonical-ck1ggpmgs000cd9s1323ltbo7">Own your canonical</a>, make your contents independent and build your domain authority.</p>
<h2 id="heading-3-freecodecamphttpswwwfreecodecamporg">3. <a target="_blank" href="https://www.freecodecamp.org/">Freecodecamp</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583767049767/y7Zt2QlNH.png" alt="Screen Shot 2020-03-09 at 8.18.25 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>freeCodeCamp is a nonprofit organization that helps people learn to code for free through <a target="_blank" href="https://youtube.com/freecodecamp">thousands of videos</a>, <a target="_blank" href="https://www.freecodecamp.org/news/">articles</a>, <a target="_blank" href="https://www.freecodecamp.org/learn">interactive coding lessons</a> and thousands of freeCodeCamp study groups around the world.</p>
<p>You learn by completing coding challenges and building projects alongside verified certifications.</p>
<h2 id="heading-4-stackoverflowhttpsstackoverflowcom">4. <a target="_blank" href="https://stackoverflow.com">StackOverflow</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583822554757/loF0gg6C_.png" alt="Screen Shot 2020-03-10 at 11.54.48 AM.png" width="3104" height="1978" loading="lazy"></p>
<p>Stack Overflow is a question and answer site for programmers with tons of questions and answers on a wide range of topics in computer programming.</p>
<p>You can learn from already asked and answered questions, share your programming knowledge by answering asked questions or share your issues/bugs here.</p>
<h2 id="heading-5-hackernewshttpsnewsycombinatorcom">5. <a target="_blank" href="https://news.ycombinator.com/">HackerNews</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583767082088/Q0YqW1SYH.png" alt="Screen Shot 2020-03-09 at 8.18.37 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Hacker News is a social news website focusing on computer science and entrepreneurship, where you can submit a link to technical content.</p>
<p>This is a great place to promote your contents to a wide range of viewers and find amazing contents from other technical geeks.</p>
<h2 id="heading-6-hackernoonhttpshackernooncom">6. <a target="_blank" href="https://hackernoon.com/">Hackernoon</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583767188926/VJpYpPvXb.png" alt="Screen Shot 2020-03-09 at 8.19.24 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Hackernoon is a tech media site that delivers stories and opinions written by real tech professionals and read by Technologists, Software Developers, Bitcoiners, Blockchain Enthusiasts.</p>
<p>You can write technical articles here and learn from a wide range of available unfettered technical contents.</p>
<h2 id="heading-7-sitepoint-communityhttpswwwsitepointcomcommunity">7. <a target="_blank" href="https://www.sitepoint.com/community/">SitePoint Community</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583767313026/icmkWaWra.png" alt="Screen Shot 2020-03-09 at 8.20.43 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>SitePoint community is a community for web designers and developers to discuss everything web development from HTML, CSS, JavaScript, PHP, Photoshop, SEO, and more.</p>
<p>Similar to StackOverflow, you can ask and answer all web development questions here.</p>
<h2 id="heading-8-kagglehttpswwwkagglecom">8. <a target="_blank" href="https://www.kaggle.com/">Kaggle</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583770714229/a2TMmsGxG.png" alt="Screen Shot 2020-03-09 at 8.21.33 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Kaggle is an online community of data scientists and machine learning practitioners with a vast repository of community published data and code with over 19,000 public datasets and 200,000 open notebooks. Kaggle also offers courses on Machine Learning, Pandas, Python, Deep Learning, Data Visualization, SQL alongside competitions, and discussions to help you grow.</p>
<h2 id="heading-9-indie-hackershttpswwwindiehackerscom">9. <a target="_blank" href="https://www.indiehackers.com/">Indie Hackers</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583770977312/nts0ka4KJ.png" alt="Screen Shot 2020-03-09 at 8.21.51 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>An Indie hacker is "a person building an online project that can generate revenue." Indie Hackers is a global community of developers who are sharing their projects, strategies, and revenue statistics behind their companies and side projects.</p>
<p>You get to learn from the founders behind hundreds of successful online businesses and connect with others who are starting and growing their own companies through their global meetups, discussions, articles, and more.</p>
<h2 id="heading-10-code-newbiehttpswwwcodenewbieorg">10. <a target="_blank" href="https://www.codenewbie.org/">Code Newbie</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583771054882/r0_JMdQwj.png" alt="Screen Shot 2020-03-09 at 8.22.04 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Code Newbie is the most supportive community of programmers and people learning to code. It started as a weekly Twitter chat made to provide much-needed support to people learning to code. It has since grown into a supportive, international community of people learning to code.</p>
<h2 id="heading-11-digital-ocean-communityhttpswwwdigitaloceancomcommunity">11. <a target="_blank" href="https://www.digitalocean.com/community">Digital Ocean Community</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583772555970/XEc8qjO3o.png" alt="Screen Shot 2020-03-09 at 8.22.24 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>This is an inclusive place where developers can find or lend support and contribute to the community of DevOps and cloud computing enthusiasts. The community provides comprehensive guides, tutorials, trends for developers, Q/A sessions, and much more.</p>
<h2 id="heading-12-product-hunthttpswwwproducthuntcom">12. <a target="_blank" href="https://www.producthunt.com/">Product Hunt</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583772958688/KokPlSTVo.png" alt="Screen Shot 2020-03-09 at 8.22.39 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Product Hunt is an exciting community of featured amazing products launched every day. It's a place for product-loving enthusiasts to share and find out about the latest mobile applications, websites, hardware projects, and tech creations.</p>
<h2 id="heading-13-reddithttpsredditcom">13. <a target="_blank" href="https://reddit.com">Reddit</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583773710321/fw0VeFcpX.png" alt="Screen Shot 2020-03-09 at 8.23.05 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Reddit is global community of thousands sub communities, endless conversations, and authentic networking with tons of never-ending streams for developers like <a target="_blank" href="https://www.reddit.com/r/reactjs">r/reactjs</a>, <a target="_blank" href="https://www.reddit.com/r/vuejs/">r/vuejs</a>, <a target="_blank" href="https://www.reddit.com/r/JAMstack_dev/">r/JAMstack_dev</a>, <a target="_blank" href="https://www.reddit.com/r/Python/">r/Python</a> and more.</p>
<h2 id="heading-14-devcareershttpsdevcareerio">14. <a target="_blank" href="https://devcareer.io/">DevCareers</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583773250536/xZ3rsqt_7.png" alt="Screen Shot 2020-03-09 at 8.23.24 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>DevCareer is a nonprofit organization that is focused on supporting upcoming developers with mentorship and resources to enable them to become world-class developers. They provide laptops, co-working space, resources, mentorship, and job placements for software developers in Africa who pass through the program.</p>
<h2 id="heading-15-the-interaction-design-foundation-communityhttpswwwinteraction-designorgcommunity">15. <a target="_blank" href="https://www.interaction-design.org/community">The Interaction Design Foundation Community</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583773574041/SE2sSQD65.png" alt="Screen Shot 2020-03-09 at 8.23.47 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>The Interaction Design Foundation Community provides an exciting opportunity for designers to create and hone their portfolio while getting ready for a new User Experience job. They offer courses from UX experts, local UX Design Meet-ups in cities across the world, UX discussions, collaboration, and much more.</p>
<h2 id="heading-16-daily-uihttpswwwdailyuico">16. <a target="_blank" href="https://www.dailyui.co/">Daily UI</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583773673814/PHOWpfSjm.png" alt="Screen Shot 2020-03-09 at 8.24.01 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Daily UI is a free series of daily UI design challenges, design inspiration, and surprise rewards to make you become a better designer in 100 days. Their amazing daily reminders will motivate you to keep learning.</p>
<h2 id="heading-17-devtohttpsdevto">17. <a target="_blank" href="https://dev.to/">Dev.to</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583800152076/8iPX4fMzG.png" alt="Screen Shot 2020-03-09 at 8.24.23 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>DEV is a community of software developers helping one another out. DEV provides a place for developers to collaborate and network while learning and sharing their knowledge.</p>
<h2 id="heading-18-devrel-collectivehttpsdevrelcollectivefun">18. <a target="_blank" href="https://devrelcollective.fun/">DevRel Collective</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583800172125/BB1LuPI5q.png" alt="Screen Shot 2020-03-09 at 8.24.39 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>DevRel Collective is a community of developer relations enthusiasts that exists to facilitate sharing information, resources, and encouragement among the DevRel community.</p>
<p>If you are actively involved in developer communities, advocacy, or event management, you should join this community.</p>
<h2 id="heading-19-facebook-developer-circleshttpsdevelopersfacebookcomdevelopercircles">19. <a target="_blank" href="https://developers.facebook.com/developercircles/">Facebook Developer Circles</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583800225775/y_xlf62k8.png" alt="Screen Shot 2020-03-09 at 8.25.54 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>Developer Circles from Facebook is a program designed to create locally organized communities for developers. These communities educate and provide a forum for discussion and knowledge sharing around topics that are top-of-mind for developers in a particular market.</p>
<p><a target="_blank" href="https://developers.facebook.com/developercircles/find">Find a local Developer Circle nearest to you here</a>.</p>
<h2 id="heading-20-google-developers-groupshttpsdevelopersgooglecomcommunitygdg">20. <a target="_blank" href="https://developers.google.com/community/gdg">Google Developers Groups</a></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1583800247570/gnodVTzig.png" alt="Screen Shot 2020-03-09 at 8.26.13 PM.png" width="3104" height="1978" loading="lazy"></p>
<p>GDG brings software developers with similar interests together to meet through meetups and hands-on workshops. The community welcomes everyone and anyone interested in tech from beginners to experienced professionals.``</p>
<p><a target="_blank" href="https://developers.google.com/community/gdg/groups">Find a GDG chapter nearest to you here</a></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>"There is no power for change greater than a community discovering what it cares about." – Margaret J. Wheatley</p>
<p>The bond in developer communities has grown from just "technical groups" to "family groups" where everyone is passionate about sharing knowledge, giving back, and helping everyone reach higher heights.</p>
<p>Isn't this just amazing? Cheers to the new age where sharing knowledge and togetherness become the order of the day. ??</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Write Good Commit Messages: A Practical Git Guide ]]>
                </title>
                <description>
                    <![CDATA[ To create a useful revision history, teams should first agree on a commit message convention to use. This also applies to personal projects. Recently on Hashnode I asked, "Which commit message convention do you use at work?" and I got some amazing re... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/writing-good-commit-messages-a-practical-guide/</link>
                <guid isPermaLink="false">66d84e2c29e30bc0ad477553</guid>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Thu, 28 Nov 2019 21:23:53 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/11/article-banner.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>To create a useful revision history, teams should first agree on a commit message convention to use. This also applies to personal projects.</p>
<p>Recently on <a target="_blank" href="https://hashnode.com">Hashnode</a> I asked, <strong>"Which commit message convention do you use at work?"</strong> and I got some amazing responses with users explaining the conventions they use at work and for their personal projects.</p>
<div class="embed-wrapper">
        <blockquote class="twitter-tweet">
          <a href="https://twitter.com/iambolajiayo/status/1198903055372165120"></a>
        </blockquote>
        <script defer="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div>
<p> </p>
<p>In this article, I'll go over how to write good commit messages and why you should.</p>
<p>I published this article, along with many others, on my blog <a target="_blank" href="https://blog.bolajiayodeji.com/writing-good-commit-messages-a-practical-guide">here</a>.</p>
<h2 id="heading-introduction-to-version-control-with-git">Introduction to version control with Git</h2>
<p>Version control software is an essential part of modern-day software developer practices.</p>
<p>By far, <a target="_blank" href="https://git-scm.com/">Git</a> is the most widely used version control system in the world. It is a distributed and actively maintained open source project originally developed in 2005 by <a target="_blank" href="https://en.wikipedia.org/wiki/Linus_Torvalds">Linus Torvalds</a>, the famous creator of the Linux operating system kernel.</p>
<p>New to Git? Check out the official <a target="_blank" href="https://git-scm.com/book/en/v1/Getting-Started">getting started guide</a> or <a target="_blank" href="https://slides.com/bolajiayodeji/introduction-to-version-control-with-git-and-github">this slide</a> from a past talk I gave.</p>
<h2 id="heading-what-is-a-commit-message">What is a commit message?</h2>
<p>The <strong>commit</strong> command is used to save changes to a local repository after staging in Git. However, before you can save changes in Git, you have to tell Git which changes you want to save as you might have made tons of edits. A great way to do that is by adding a <strong>commit message</strong> to identify your changes.</p>
<h3 id="heading-commit-options">Commit Options</h3>
<ul>
<li><strong>-m</strong></li>
</ul>
<p>This option sets the commit's message.</p>
<pre><code class="lang-bash">git add static/admin/config.yml
git commit -m <span class="hljs-string">"Setup multiple roles for netlify-cms git gateway"</span>
</code></pre>
<ul>
<li><strong>-a or --all</strong></li>
</ul>
<p>This option automatically commits all (including new) tracked, modified or deleted files.</p>
<pre><code class="lang-bash">git commit -a -m <span class="hljs-string">"Add a new role for netlify-cms git gateway"</span>
</code></pre>
<ul>
<li><strong>--amend</strong></li>
</ul>
<p>This option rewrites the very last commit with any currently staged changes or a new commit message and should only be performed on commits that have not been pushed to a remote repository, yet.</p>
<pre><code class="lang-bash">git add .
git commit --amend -m <span class="hljs-string">"Update roles for netlify-cms git gateway"</span>
</code></pre>
<h2 id="heading-why-should-you-write-good-commit-messages">Why should you write good commit messages?</h2>
<p>You might say, "It's just a personal project." Yes, you work alone now, but what happens when you work with a team or contribute to open source?</p>
<p>A well-crafted Git commit message is the best way to communicate context about a change to other developers working on that project, and indeed, to your future self.</p>
<p>Have you ever tried running <code>git log</code> on one of your old projects to see the "weird" commit messages you have used since its inception? It can be hard to understand why you made some changes in the past, and you'll wish you read this article earlier :).</p>
<p>Commit messages can adequately communicate why a change was made, and understanding that makes development and collaboration more efficient.</p>
<h2 id="heading-how-to-write-commit-messages-with-git">How to write commit messages with Git</h2>
<p>Before now, I only used <code>git commit -m "Fix X to allow Y to use Z"</code> on my personal projects with just a subject and no extra description. This is great for small and clear fixes like <code>git commit -m "Fix typo in README.md</code>, but in cases of more extensive changes, you would need to add some extra details.</p>
<h3 id="heading-editor-method">Editor method</h3>
<p>Run <code>git commit</code> without a message or option and it'll open up your default text editor to write a commit message.</p>
<p>To configure your "default" editor:</p>
<pre><code class="lang-python">git config --<span class="hljs-keyword">global</span> core.editor nano
</code></pre>
<p>This would configure Git to use nano as your default editor. Replace "nano" with "emacs," "vim," or whatever your preference is.</p>
<p>In the opened editor, the first line is the subject (short description), leave a blank line after it, and everything else is the extended description (body).</p>
<pre><code class="lang-bash">&lt;Summarize change(s) <span class="hljs-keyword">in</span> around 50 characters or less&gt;

&lt;More detailed explanatory description of the change wrapped into about 72
characters&gt;
</code></pre>
<h3 id="heading-command-line-method">Command Line method</h3>
<pre><code class="lang-python">git commit -m <span class="hljs-string">"Subject"</span> -m <span class="hljs-string">"Description..."</span>
</code></pre>
<p>The first <code>-m</code> option is the subject (short description), and the next is the extended description (body).</p>
<h2 id="heading-how-to-write-good-commit-messages">How to write good commit messages</h2>
<p>There are several conventions used by different teams and developers to write good commit messages. I'll only outline some general rules and tips for writing commit messages–you have to decide what convention you want to follow. And if you work for a company or contribute to open source, you have to adapt to their convention :).</p>
<p>For consistency, you can use one convention for work and another for personal projects as you might change jobs sometime, and the convention might also change.</p>
<p>Be sure to check out <a target="_blank" href="https://hashnode.com/post/which-commit-message-convention-do-you-use-at-work-ck3e4jbdd00zyo4s1h7mc7e0g">this thread</a> for some amazing commit message conventions or add yours to help someone make a decision.</p>
<p>Here's a great template of a good commit message originally written by <a target="_blank" href="https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html">Tim pope</a></p>
<pre><code class="lang-bash">Capitalized, short (50 chars or less) summary

More detailed explanatory text, <span class="hljs-keyword">if</span> necessary.  Wrap it to about 72
characters or so.  In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body.  The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused <span class="hljs-keyword">if</span> you run the
two together.

Write your commit message <span class="hljs-keyword">in</span> the imperative: <span class="hljs-string">"Fix bug"</span> and not <span class="hljs-string">"Fixed bug"</span>
or <span class="hljs-string">"Fixes bug."</span>  This convention matches up with commit messages generated
by commands like git merge and git revert.

Further paragraphs come after blank lines.

- Bullet points are okay, too

- Typically a hyphen or asterisk is used <span class="hljs-keyword">for</span> the bullet, followed by a
  single space, with blank lines <span class="hljs-keyword">in</span> between, but conventions vary here

- Use a hanging indent

If you use an issue tracker, add a reference(s) to them at the bottom,
like so:

Resolves: <span class="hljs-comment">#123</span>
</code></pre>
<p>Looks great, right? Here's how you can make yours great too:</p>
<ol>
<li>Specify the type of commit:</li>
</ol>
<ul>
<li><p>feat: The new feature you're adding to a particular application</p>
</li>
<li><p>fix: A bug fix</p>
</li>
<li><p>style: Feature and updates related to styling</p>
</li>
<li><p>refactor: Refactoring a specific section of the codebase</p>
</li>
<li><p>test: Everything related to testing</p>
</li>
<li><p>docs: Everything related to documentation</p>
</li>
<li><p>chore: Regular code maintenance.[ You can also use emojis to represent commit types]</p>
</li>
</ul>
<ol start="2">
<li><p>Separate the subject from the body with a blank line</p>
</li>
<li><p>Your commit message should not contain any whitespace errors</p>
</li>
<li><p>Remove unnecessary punctuation marks</p>
</li>
<li><p>Do not end the subject line with a period</p>
</li>
<li><p>Capitalize the subject line and each paragraph</p>
</li>
<li><p>Use the imperative mood in the subject line</p>
</li>
<li><p>Use the body to explain what changes you have made and why you made them.</p>
</li>
<li><p>Do not assume the reviewer understands what the original problem was, ensure you add it.</p>
</li>
<li><p>Do not think your code is self-explanatory</p>
</li>
<li><p>Follow the commit convention defined by your team</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The most important part of a commit message is that it should be clear and meaningful. In the long run, writing good commit messages shows how much of a collaborator you are. The benefits of writing good commit messages are not only limited to your team, but indeed expand to yourself and future contributors.</p>
<p>Want to learn more about Git and become a professional "version controller"? Check out these excellent resources:</p>
<ul>
<li><p><a target="_blank" href="https://try.github.io/">https://try.github.io/</a></p>
</li>
<li><p><a target="_blank" href="https://git-scm.com/book/en/v2">https://git-scm.com/book/en/v2</a></p>
</li>
<li><p><a target="_blank" href="https://www.git-tower.com/learn/">https://www.git-tower.com/learn/</a></p>
</li>
<li><p><a target="_blank" href="https://learngitbranching.js.org/">https://learngitbranching.js.org/</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/commitizen/cz-cli">https://github.com/commitizen/cz-cli</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to compile your C++ code in Visual Studio Code ]]>
                </title>
                <description>
                    <![CDATA[ C++ is a statically-typed, free-form, (usually) compiled, multi-paradigm, intermediate-level general-purpose middle-level programming language. In simple terms, C++ is a sophisticated, efficient, general-purpose programming language based on C. It wa... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-compile-your-c-code-in-visual-studio-code/</link>
                <guid isPermaLink="false">66d84e18c15439a8d5631e45</guid>
                
                    <category>
                        <![CDATA[ C++ ]]>
                    </category>
                
                    <category>
                        <![CDATA[ compilers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Visual Studio Code ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Mon, 07 Oct 2019 05:14:17 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/10/banner-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>C++ is a statically-typed, free-form, (usually) compiled, multi-paradigm, intermediate-level general-purpose middle-level programming language.</p>
<p>In simple terms, C++ is a sophisticated, efficient, general-purpose programming language based on C.</p>
<p>It was developed by <a target="_blank" href="http://www.stroustrup.com/">Bjarne Stroustrup</a> in 1979.</p>
<p>One of C++'s main features is the compiler. This is used to compile and run C++ code.</p>
<blockquote>
<p>A compiler is a special program that processes statements written in a particular programming language like C++ and turns them into machine language or "code" that a computer's processor uses. (<a target="_blank" href="https://en.wikipedia.org/wiki/Compiler">Source</a>)</p>
</blockquote>
<p>I actually wrote this article because I had a C++ assignment which required using a compiler. As usual, everyone was using the <a target="_blank" href="http://www.codeblocks.org/">CodeBlocks IDE</a> and <a target="_blank" href="https://visualstudio.microsoft.com/">Visual Studio IDE</a>. But I was already used to Visual Studio Code for all my programming stuff.</p>
<p>I then set out to find a way of compiling C++ directly inside my own VsCode Editor, hence this article :).</p>
<p>In this article, I'll show you how to set up your compiler in VsCode and give you some links to some of the best C++ resources.</p>
<p><img src="https://media0.giphy.com/media/3o7TKUM3IgJBX2as9O/giphy.gif" alt="Image" width="267" height="200" loading="lazy"></p>
<h1 id="heading-prerequisites">Prerequisites</h1>
<ul>
<li><p>Prior knowledge of C++<br>  (I assume you're learning C++, about to start learning, or just reading this for fun. This article is not a C++ 101 tutorial – some understanding of C++ is needed.)</p>
</li>
<li><p>Visual Studio Code Editor<br>  Download <a target="_blank" href="https://code.visualstudio.com/#alt-downloads">here</a> and read the setup docs for <a target="_blank" href="https://code.visualstudio.com/docs/?dv=win">Windows</a>, <a target="_blank" href="https://code.visualstudio.com/docs/?dv=linux64_deb">Linux</a> and <a target="_blank" href="https://code.visualstudio.com/docs/?dv=osx">Mac</a></p>
</li>
<li><p><strong>Internet connection (!important)</strong></p>
</li>
</ul>
<h3 id="heading-disclaimer"><strong>Disclaimer!</strong></h3>
<p>I will be using a Windows OS throughout this article, but I'll provide links to resources that will help those using other operating systems.</p>
<p>Now let's get started!</p>
<h1 id="heading-download-and-install-a-c-compiler">Download and install a C++ compiler</h1>
<ul>
<li>Head to www.mingw.org and click the “Download/Installer” link to download the MinGW setup file, or click <a target="_blank" href="https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/">here</a> for Windows, <a target="_blank" href="http://www.mingw.org/wiki/LinuxCrossMinGW">here</a> for Linux, and <a target="_blank" href="https://brewinstall.org/Install-mingw-w64-on-Mac-with-Brew/">here</a> for Mac</li>
</ul>
<blockquote>
<p>MinGW, a contraction of "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications. (<a target="_blank" href="https://mingw.osdn.io/">Source</a>)</p>
</blockquote>
<ul>
<li>After downloading, install MinGW and wait for the “MinGW Installation Manager” to show up.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/Capture1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>When the “MinGW Installation Manager” shows up, click on <code>mingw32-gcc-g++</code> then select “Mark for Installation”</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/Capture2.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>In the menu at the top left corner, click on “Installation &gt; Apply Changes”</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/Capture3.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Wait and allow to install completely. Ensure you have a stable internet connection during this process.</li>
</ul>
<h1 id="heading-edit-your-path-environment-variable-to-include-the-directory-where-the-c-compiler-is-located">Edit your PATH environment variable to include the directory where the C++ compiler is located</h1>
<blockquote>
<p>PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting. - <a target="_blank" href="https://en.wikipedia.org/wiki/PATH_(variable)">Wikipedia</a></p>
</blockquote>
<p>After installing MinGW, it can be found in <code>C:\MinGW\bin</code>. Now you have to include this directory in your environment variable PATH. If you've been using computers for a while now you should know how to do this already, but if you don't, here are a few resources:</p>
<ul>
<li><p>Click <a target="_blank" href="https://www.computerhope.com/issues/ch000549.htm">here</a> for a Windows OS guide</p>
</li>
<li><p>Click <a target="_blank" href="https://www.cyberciti.biz/faq/unix-linux-adding-path/">here</a> for Linux</p>
</li>
<li><p>Click <a target="_blank" href="https://hathaway.cc/2008/06/how-to-edit-your-path-environment-variables-on-mac/">here</a> for a Mac OS guide</p>
</li>
</ul>
<h1 id="heading-install-code-runner-extension-in-vs-code">Install Code Runner extension in VS Code</h1>
<p>Now we have our compiler set up, let's install Code Runner</p>
<p>Code Runner allows you to Run code snippet or code file for multiple languages:</p>
<blockquote>
<p>C, C++, Java, JavaScript, PHP, Python, Perl, Perl 6, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, F# (.NET Core), C# Script, C# (.NET Core), VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml Script, R, AppleScript, Elixir, Visual Basic .NET, Clojure, Haxe, Objective-C, Rust, Racket, AutoHotkey, AutoIt, Kotlin, Dart, Free Pascal, Haskell, Nim, D, Lisp, Kit, and custom command.</p>
</blockquote>
<ul>
<li><p>Click <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner">here</a> to download</p>
</li>
<li><p>Or search in VsCode marketplace tab</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/Capture4.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li><p>After installing restart VsCode</p>
</li>
<li><p>Open your C++ file in Vscode. Here's a basic hello world program below:</p>
</li>
</ul>
<pre><code class="lang-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;iostream&gt;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> 
</span>{
    <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Hello world!"</span>;
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<p>Save this file as <code>test.cpp</code></p>
<h1 id="heading-run-your-code-using-code-runner">Run your code using Code Runner</h1>
<ul>
<li><p>Use the shortcut <code>Ctrl+Alt+N</code></p>
</li>
<li><p>Or press F1 and then select/type Run Code</p>
</li>
<li><p>Or right-click the Text Editor and then click Run Code in the editor context menu</p>
</li>
</ul>
<p>The code will run and the output will be shown in the Output Window. Open the output window with `Ctrl+ shortcut.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/Capture5.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-to-stop-the-running-code">To stop the running code</h1>
<ul>
<li><p>Use the shortcut <code>Ctrl+Alt+M</code></p>
</li>
<li><p>Or press F1 and then select/type Stop Code Run</p>
</li>
<li><p>Or right-click the Output Channel and then click Stop Code Run in the context menu</p>
</li>
</ul>
<p>Hurray, you just successfully set up your C++ environment in VsCode!</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Here's a quick hint: By default, VsCode's output terminal is read-only. If you're running code that requires user input like:</p>
<pre><code class="lang-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;iostream&gt;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>;

<span class="hljs-keyword">const</span> <span class="hljs-keyword">double</span> pi = <span class="hljs-number">3.14159</span>; 

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">calculate</span><span class="hljs-params">()</span>
</span>{
  <span class="hljs-keyword">double</span> area; 
  <span class="hljs-keyword">double</span> radius;

  <span class="hljs-built_in">cout</span>&lt;&lt;<span class="hljs-string">"Enter Radius: "</span>&lt;&lt;<span class="hljs-built_in">endl</span>; 
  <span class="hljs-built_in">cin</span>&gt;&gt;radius;

  area = pi * radius * radius; 

  <span class="hljs-built_in">cout</span>&lt;&lt;<span class="hljs-string">"area is: "</span>&lt;&lt;area&lt;&lt;<span class="hljs-built_in">endl</span>;
 }

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>
</span>{
  calculate(); 
  <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<p>you won't be able to type into the terminal, <code>Cannot edit in read-only terminal</code>.<br>To fix this, you need to manually enable read-write.</p>
<ul>
<li><p>In VsCode, Go to File &gt; Preference &gt; Setting.</p>
</li>
<li><p>In the User tab on the left panel, find the extensions section</p>
</li>
<li><p>Scroll and find 'Run Code Configuration'</p>
</li>
<li><p>Scroll and find a checkbox <code>Run in Terminal</code> (Whether to run code in Integrated Terminal) Check the box.</p>
</li>
</ul>
<p>OR</p>
<ul>
<li>In your <code>setting.json</code> file, add:</li>
</ul>
<pre><code class="lang-python"><span class="hljs-string">"code-runner.runInTerminal"</span>: true
</code></pre>
<p>Hurray, you're done and ready to roll :).</p>
<h1 id="heading-c-resources">C++ resources</h1>
<p>Here are some C++ resources you can use to get started with learning C++</p>
<ul>
<li><p><a target="_blank" href="https://www.learncpp.com/">https://www.learncpp.com/</a></p>
</li>
<li><p><a target="_blank" href="https://www.codecademy.com/learn/learn-c-plus-plus">https://www.codecademy.com/learn/learn-c-plus-plus</a></p>
</li>
<li><p><a target="_blank" href="https://www.udemy.com/free-learn-c-tutorial-beginners/">https://www.udemy.com/free-learn-c-tutorial-beginners/</a></p>
</li>
<li><p><a target="_blank" href="https://www.sololearn.com/Course/CPlusPlus/">https://www.sololearn.com/Course/CPlusPlus/</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=vLnPwxZdW4Y">https://www.youtube.com/watch?v=vLnPwxZdW4Y</a></p>
</li>
<li><p><a target="_blank" href="https://www.tutorialspoint.com/cplusplus/cpp_useful_resources.htm">https://www.tutorialspoint.com/cplusplus/cpp_useful_resources.htm</a></p>
</li>
<li><p><a target="_blank" href="https://www.tutorialspoint.com/cplusplus/cpp_useful_resources.htm">https://makeawebsitehub.com/learning-c/</a></p>
</li>
</ul>
<h1 id="heading-credits">Credits</h1>
<ul>
<li><p><a target="_blank" href="http://www.mingw.org/">MinGW Project</a></p>
</li>
<li><p><a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner">Code Runner</a> by <a target="_blank" href="https://marketplace.visualstudio.com/publishers/formulahendry">Jun Han</a></p>
</li>
</ul>
<p>Thank you for reading!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to deploy a Node Application and Database to Heroku ]]>
                </title>
                <description>
                    <![CDATA[ Heroku is a cloud-based, fully-managed platform as a service (PaaS) for building, running, and managing apps. The platform is flexible and designed with DX support for you and your team’s preferred development style and to help you stay focused and p... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-deploy-a-node-application-and-database-to-heroku/</link>
                <guid isPermaLink="false">66d84e1bbfb3c4f0b376afcb</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ deployment ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Heroku ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Node.js ]]>
                    </category>
                
                    <category>
                        <![CDATA[ terminal ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Sat, 28 Sep 2019 05:02:42 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/09/banner.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Heroku is a cloud-based, fully-managed platform as a service (PaaS) for building, running, and managing apps. The platform is flexible and designed with DX support for you and your team’s preferred development style and to help you stay focused and productive.</p>
<p>Developers, teams, and businesses of all sizes use Heroku to deploy, manage, and scale apps. Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly.</p>
<p>With features like Heroku Runtime, Heroku Postgres (SQL), Heroku Redis, Add-ons, Data Clips, App metrics, Smart containers, Enterprise-grade support, GitHub Integration and lots more, Heroku gives developers the freedom to focus on their core product without the distraction of maintaining servers, hardware, or infrastructure.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku.png" alt="Image" width="600" height="400" loading="lazy"></p>
<hr>
<p>One of Heroku's core feature is deploying, managing, and scaling apps with your favorite languages [Node, Ruby, Python, Java, PHP, Go, and more].<br>In this article, I'll show you how to take an existing Node.js app and deploy it to Heroku – everything from creating your Heroku account to adding a database to your deployed application.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>In my previous article, I wrote about "<a target="_blank" href="https://bolajiayodeji.com/building-a-slackbot-with-nodejs-and-slackbotsjs-cjz8gh7zg000exfs1tq2z5zzu">Building a SlackBot with Node.js and SlackBots.js</a>" and I promised to write a follow-up article to show how to host the SlackBot on either Heroku, Zeit or Netlify and publish it to the Slack Apps store. Well, this is the follow-up article but without the "Publishing to Slack Apps" part. We'll cover that in another article.</p>
<p>I assume you have/ know the following already:</p>
<ul>
<li><p>Read my <a target="_blank" href="https://bolajiayodeji.hashnode.dev/building-a-slackbot-with-nodejs-and-slackbotsjs-cjz8gh7zg000exfs1tq2z5zzu">previous article</a></p>
</li>
<li><p>Built the <a target="_blank" href="https://github.com/BolajiAyodeji/inspireNuggetsSlackBot">inspireNuggets SlackBot</a></p>
</li>
<li><p>Git, Node, and npm installed</p>
</li>
<li><p>A free <a target="_blank" href="https://signup.heroku.com/">Heroku account</a></p>
</li>
<li><p><a target="_blank" href="https://devcenter.heroku.com/articles/heroku-cli">Heroku CLI</a> installed</p>
</li>
</ul>
<h2 id="heading-bonus">Bonus</h2>
<p>If you don't have npm, Node, and Heroku CLI installed or a Heroku account already, here's a quick bonus [ Yes, you're welcome :) ].</p>
<h3 id="heading-installing-npm-and-node">Installing npm and Node</h3>
<ul>
<li><p><a target="_blank" href="https://nodejs.org">Node.js</a> is a JavaScript runtime built on <a target="_blank" href="https://v8.dev/">Chrome's V8 JavaScript engine</a>.</p>
</li>
<li><p><a target="_blank" href="https://www.npmjs.com/">npm</a> is the package manager for Node.js. An open-source project created to help JavaScript developers easily share packaged modules of code.</p>
</li>
</ul>
<p>You can simply download Node.js <a target="_blank" href="https://nodejs.org/en/">here</a>. Don't worry, npm comes with Node.js, so doing this installs both ✨</p>
<h3 id="heading-creating-a-free-heroku-account">Creating a free Heroku account</h3>
<p>Kindly head <a target="_blank" href="https://signup.heroku.com/">here</a> and fill the Signup form. It's pretty simple.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-signup.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-installing-heroku-cli">Installing Heroku CLI</h3>
<p>The Heroku Command Line Interface (CLI) makes it easy to create and manage your Heroku apps directly from the terminal. It’s an essential part of using Heroku. [ Well, you can decide to use the GitHub integration feature and Heroku Dashboard but yes you should learn how to use the CLI ]<br>Heroku CLI requires Git, the popular version control system. If you don’t already have Git installed, I wrote <a target="_blank" href="https://www.bolajiayodeji.com/setting-up-git-first-time/">this article</a> to help you.</p>
<h4 id="heading-heroku-cli-for-mac-os">Heroku CLI for Mac OS</h4>
<pre><code class="lang-python">brew tap heroku/brew &amp;&amp; brew install heroku
</code></pre>
<p>or <a target="_blank" href="https://devcenter.heroku.com/articles/heroku-cli">download the installer</a>.</p>
<h4 id="heading-heroku-cli-for-ubuntu">Heroku CLI for Ubuntu</h4>
<pre><code class="lang-python">sudo snap install --classic heroku
</code></pre>
<h4 id="heading-heroku-cli-for-windows">Heroku CLI for Windows</h4>
<p>Download the installer for <a target="_blank" href="https://cli-assets.heroku.com/heroku-x64.exe">64-Bit</a> or <a target="_blank" href="https://cli-assets.heroku.com/heroku-x86.exe">32-Bit</a>.</p>
<h4 id="heading-other-installation-methods">Other installation methods</h4>
<p>Please read <a target="_blank" href="https://devcenter.heroku.com/articles/heroku-cli#other-installation-methods">this</a>.</p>
<h4 id="heading-getting-started-with-heroku-cli">Getting started with Heroku CLI</h4>
<ul>
<li>Verify your installation</li>
</ul>
<pre><code class="lang-python">heroku --version
</code></pre>
<p>heroku/7.30.1 linux-x64 node-v11.14.0</p>
<ul>
<li>Login to your Heroku account</li>
</ul>
<p>There are two ways to do this:</p>
<ul>
<li><strong>Web based auth</strong></li>
</ul>
<pre><code class="lang-python">heroku login
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-web-auth.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Follow the instructions and login via your web browser then return to your terminal.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-web-auth2.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li><strong>CLI auth</strong></li>
</ul>
<p>This is a safer option as it saves your email address and an API token to <code>~/.netrc</code> for future use.</p>
<pre><code class="lang-python">heroku login -i
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-cli-auth-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<hr>
<h3 id="heading-deploying-your-nodejs-app">Deploying your Node.js App</h3>
<p>I presume you've built the SlackBot already. If you haven't, please clone the <a target="_blank" href="https://github.com/BolajiAyodeji/inspireNuggetsSlackBot">finished project</a>.</p>
<p>The project is a simple Slackbot that displays random inspiring techie quotes and jokes for developers/designers.</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/BolajiAyodeji/inspireNuggetsSlackBot.git &amp;&amp; <span class="hljs-built_in">cd</span> inspireNuggetsSlackBot
</code></pre>
<p>Now let's deploy our app to Heroku ??. I'll show you two ways to do this:</p>
<h4 id="heading-deploy-via-the-heroku-git">Deploy via the Heroku Git</h4>
<p>This is done via the Heroku CLI.</p>
<h5 id="heading-checklist"><strong>☑️ Checklist</strong></h5>
<ul>
<li>Specify the version of Node.js that will be used to run your application on Heroku in your <code>package.json</code> file.</li>
</ul>
<pre><code class="lang-python"><span class="hljs-string">"engines"</span>: {
    <span class="hljs-string">"node"</span>: <span class="hljs-string">"10.16.0"</span>
  },
</code></pre>
<ul>
<li>Specify your start script.<br>  Simply create a <code>Procfile</code> (without any file extension) and add</li>
</ul>
<pre><code class="lang-python">web: node index.js
</code></pre>
<p>Heroku first looks for this Procfile. If none is found, Heroku will attempt to start a default web process via the start script in your <code>package.json</code>.</p>
<ul>
<li>Start your app locally using the heroku local command to be sure everything works fine</li>
</ul>
<pre><code class="lang-python">heroku local web
</code></pre>
<p>Your app should now be running on <a target="_blank" href="http://localhost:5000">http://localhost:5000</a>.</p>
<ul>
<li>Don't forget to <code>.gitignore</code></li>
</ul>
<pre><code class="lang-python">/node_modules
.DS_Store
/*.env
</code></pre>
<h5 id="heading-lets-deploy"><strong>? Let's Deploy</strong></h5>
<p>How this works is, you have the project working on local already and you've pushed to GitHub already.</p>
<ul>
<li>Run <code>heroku create</code></li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-create.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Basically, this command creates a new Heroku app for you with some randomly generated domain and adds Heroku to your local Git repository.</p>
<ul>
<li>Now run <code>git push heroku master</code></li>
</ul>
<p>This is the magic command, it pushes your app to Heroku, installs it there, and launches it on your allocated domain.</p>
<p>In the example above, it's <a target="_blank" href="https://lit-cove-58897.herokuapp.com/">https://lit-cove-58897.herokuapp.com/</a></p>
<p>You can always make changes to your app settings and domains in your <a target="_blank" href="https://dashboard.heroku.com/">Heroku Dashboard</a></p>
<ul>
<li>Now visit your app in your browser</li>
</ul>
<pre><code class="lang-python">heroku open
</code></pre>
<ul>
<li>You can also view information about your running app using one of the logging commands. This is very useful in debugging errors.</li>
</ul>
<pre><code class="lang-python">heroku logs --tail
</code></pre>
<h4 id="heading-deploy-via-github-integration">Deploy via GitHub integration</h4>
<p>You can configure GitHub integration in the Deploy tab of apps in the <a target="_blank" href="https://dashboard.heroku.com">Heroku Dashboard</a>.</p>
<h5 id="heading-checklist-1"><strong>☑️ Checklist</strong></h5>
<ul>
<li>All previous checklists apply here – ensure you have the app deployed to GitHub already</li>
</ul>
<h5 id="heading-lets-deploy-1"><strong>? Let's Deploy</strong></h5>
<p>How this method works is that you push your entire project to GitHub and integrate it to Heroku. Every time you push, it deploys from GitHub to Heroku. Pretty cool right?</p>
<ul>
<li>Login to your Heroku Dashboard and create a new app</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/create-app.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Select your app name and region</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/new-app.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now your app has successfully been created</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-dash.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Click the deploy tab and scroll to the <strong>Deployment method</strong> section</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-deploy.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Click the <strong>Connect to GitHub</strong> button</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-github.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Now you have the <strong>Connect to GitHub section</strong>, search for the repository and deploy.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-search.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Now your app was deployed successfully</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-200.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h4 id="heading-automatic-deploys">Automatic deploys</h4>
<p>Now your app is deployed but you'll have to keep deploying manually. You need to enable automatic deploys for a GitHub branch, so Heroku builds and deploys all pushes to that branch.</p>
<ul>
<li>Scroll to the <strong>Automatic Deploys</strong> section</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-auto.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Select the branch you want to deploy. Ideally, this should be the <code>master</code> branch but change this according to your preference.</p>
<p>Now every push to <code>master</code> (or the branch you chose) will deploy a new version of this app.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-auto-200.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h4 id="heading-nodejs-buildpack">Node.js Buildpack</h4>
<p>In Heroku, Buildpacks are scripts that are run when your app is deployed. They are used to install dependencies for your app and configure your environment.</p>
<p>After deploying your app, ensure you add a Node.js buildpack to your project.</p>
<ul>
<li>Go to <strong>Settings</strong> and scroll to the <strong>Buildpack section</strong></li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-buildpack.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Click the <strong>Add Buildpack</strong> button and select Node.js in the Popup modal.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/heroku-add-build.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Now the new buildpack configuration will be used when this app is next deployed. Make some changes to your app and push to GitHub – it will automatically deploy.</li>
</ul>
<h3 id="heading-adding-a-database-to-your-deployed-app">Adding a Database to your deployed App'</h3>
<p>The Heroku add-on marketplace has a large number of data stores, from Redis and MongoDB providers, to Postgres and MySQL.</p>
<p>Heroku provides three managed data services to all customers in the form of Add-ons:</p>
<ul>
<li><p><a target="_blank" href="https://elements.heroku.com/addons/heroku-postgresql">Heroku Postgres</a></p>
</li>
<li><p><a target="_blank" href="https://elements.heroku.com/addons/heroku-redis">Heroku Redis</a></p>
</li>
<li><p><a target="_blank" href="https://elements.heroku.com/addons/cloudkarafka">Apache Kafka on Heroku</a></p>
</li>
</ul>
<p>Writing about this three will make this article too long. It's pretty simple and I'll add some links to the Heroku Docs.</p>
<ul>
<li><p><a target="_blank" href="https://devcenter.heroku.com/categories/postgres-basics">Heroku Postgresql Docs</a></p>
</li>
<li><p><a target="_blank" href="https://devcenter.heroku.com/articles/heroku-redis">Heroku Redis Docs</a></p>
</li>
<li><p><a target="_blank" href="https://devcenter.heroku.com/articles/kafka-on-heroku">Apache Kafka on Heroku Docs</a></p>
</li>
</ul>
<hr>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Every Heroku account is allocated a pool of free dyno hours. Heroku (free) dynos are great for hosting apps and personal projects. The downside, however, is that your app will fall asleep if it doesn't receive any web traffic within 30-minutes :(.</p>
<p>You can use external tools to ping your server periodically so it never falls asleep.</p>
<p>Here are some to consider:</p>
<ul>
<li><p><a target="_blank" href="https://www.npmjs.com/package/pingmydyno">Pingmydyno</a></p>
</li>
<li><p><a target="_blank" href="https://www.npmjs.com/package/heroku-self-ping">Heroku self ping</a></p>
</li>
<li><p><a target="_blank" href="http://wakemydyno.com/">Wakemydyno</a></p>
</li>
<li><p><a target="_blank" href="https://kaffeine.herokuapp.com/">Kaffeine</a></p>
</li>
</ul>
<hr>
<blockquote>
<p>Heroku is meticulously designed to help developers be as productive as possible. The platform removes frustrating obstacles and mundane tasks, so you can stay free of distraction in your development flow. Wherever you are on the learning path, Heroku helps you love app development even more. - Heroku</p>
</blockquote>
<p>The Heroku experience provides services, tools, workflows, and polyglot support—all designed to enhance developer productivity. There is more to using Heroku and I hope you explore more and build amazing stuff with Heroku.</p>
<p>If you're a student, Kindly register for the <a target="_blank" href="https://education.github.com/pack">GitHub Student Developer Pack</a> to get One free <a target="_blank" href="https://www.heroku.com/pricing">Hobby Dyno</a> for up to two years.</p>
<p>The pack give students free access to the best developer tools in one place so you can learn by doing.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to build a SlackBot with Node.js and SlackBots.js ]]>
                </title>
                <description>
                    <![CDATA[ Slack is an American cloud-based set of proprietary team collaboration software tools and online services, developed by Slack Technologies. Slack is a workspace where teams can communicate and collaborate. Teamwork in Slack happens in channels — a si... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/building-a-slackbot-with-node-js-and-slackbots-js/</link>
                <guid isPermaLink="false">66d84e0d7211ea6be29e1b41</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ api ]]>
                    </category>
                
                    <category>
                        <![CDATA[ bots ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Node.js ]]>
                    </category>
                
                    <category>
                        <![CDATA[ slack ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Mon, 12 Aug 2019 14:01:46 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/article-banner--4-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Slack is an American cloud-based set of proprietary team collaboration software tools and online services, developed by Slack Technologies. Slack is a workspace where teams can communicate and collaborate.</p>
<p>Teamwork in Slack happens in channels — a single place for messaging, tools and files — helping everyone save time and collaborate.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/organize-conversations-slack-product-desktop.png" alt="Image" width="600" height="400" loading="lazy"></p>
<hr>
<p>One of the awesome features of Slack is <a target="_blank" href="https://slack.com/apps">Slack Apps</a>, integrations and <a target="_blank" href="https://api.slack.com/bot-users">Slack Bots</a>.</p>
<p>A Slack bot is a type of Slack App designed to interact with users via conversation. Your bot can send DMs, it can be mentioned by users, it can post messages or upload files, and it can be invited to channels. Cool right?</p>
<p>If you use Slack already, you should be familiar with some creative Slack bots like <a target="_blank" href="https://standupbot.com/">Standupbot</a>, <a target="_blank" href="https://birthdaybot.io/">Birthdaybot</a> and more.</p>
<p>In this article, I'll walk you through building your first Slack bot from start to finish with <a target="_blank" href="http://nodejs.org/">Node.js</a> and <a target="_blank" href="https://github.com/mishk0/slack-bot-api">SlackBots.js</a></p>
<blockquote>
<p>PS: This article was published <a target="_blank" href="https://www.bolajiayodeji.com/building-a-slackbot-with-node-js-and-slackbots-js/">on my blog first</a>.</p>
</blockquote>
<h1 id="heading-slackbot-description">SlackBot Description</h1>
<p>We're going to build a simple Slackbot that displays random inspiring techie quotes and jokes for developers/designers.</p>
<p>I built a <a target="_blank" href="https://github.com/BolajiAyodeji/inspireNuggets">chrome extension</a> that displays random inspiring techie quotes for developers/designers on your new tab (you can download it <a target="_blank" href="https://chrome.google.com/webstore/detail/inspirenuggets-for-chrome/acnfgdioohhajabdofaadfdhmlkphmlb">here</a>). We'll be using the quotes JSON from this extension as our quotes API and the <a target="_blank" href="https://api.chucknorris.io/">Chuck Norris Jokes API</a> for the jokes.</p>
<p>When a user mentions our bot and adds <strong>inspire me</strong>, the bot returns a random quote from <a target="_blank" href="https://chrome.google.com/webstore/detail/inspirenuggets-for-chrome/acnfgdioohhajabdofaadfdhmlkphmlb">inspireNuggets</a>. When the user types <strong>random joke</strong>, it returns a random joke from the <a target="_blank" href="https://api.chucknorris.io/">Chuck Norris</a> API. And when the user types help, it returns the instruction guide.</p>
<blockquote>
<p>@inspirenuggets inspire me</p>
<p>@inspirenuggets random joke</p>
<p>@inspirenuggets help</p>
</blockquote>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture2.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This article is not really about what we'll be building - it's just to show you the concept behind Slack bots and how to build yours. After you go through it, you can think about something else and build a different bot, as there're many possibilities.</p>
<p>You can clone or fork the final project <a target="_blank" href="https://github.com/BolajiAyodeji/inspireNuggetsSlackBot">here</a>.</p>
<p>Pretty interesting right? Let's get started.</p>
<h1 id="heading-prerequisites">Prerequisites</h1>
<p>We'll build this bot with Node.js and SlackBots.js. You don't need to know how to write Node.js, since I'll walk you through it. Still, knowing it is an advantage. You should also have</p>
<ul>
<li><p>Basic JavaScript knowledge</p>
</li>
<li><p>ES6 JavaScript</p>
</li>
<li><p>Slack workspace</p>
</li>
<li><p>Some experience with Slack</p>
</li>
<li><p>Some version control skills</p>
</li>
</ul>
<h1 id="heading-setup-environment">Setup environment</h1>
<p>Let's set up and install Node.js and Npm first.</p>
<ul>
<li><p>Download node <a target="_blank" href="https://nodejs.org/en/">here</a>. If you have it installed already, skip this step. If you prefer to use a package manager to install, read <a target="_blank" href="https://nodejs.org/en/download/package-manager/#windows">this</a> for all operating systems.</p>
</li>
<li><p>Check if you have Node installed</p>
</li>
</ul>
<pre><code class="lang-python">node -v
</code></pre>
<ul>
<li>Node.js comes with Npm, so you don't have to install that again.</li>
</ul>
<pre><code class="lang-python">npm -v
</code></pre>
<p>Now that we have Node.js setup, let's initialize our project.</p>
<p>Create your project directory (I called mine Slackbot) and initialize git:</p>
<pre><code class="lang-python">git init
</code></pre>
<p>Next, create an <code>index.js</code> file:</p>
<pre><code class="lang-python">touch index.js
</code></pre>
<p>And initialize Npm:</p>
<pre><code class="lang-python">npm init
</code></pre>
<p>Simply answer all questions that come afterwards. If you're having issues, here's my own <code>package.json</code>:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"name"</span>: <span class="hljs-string">"slackbot"</span>,
  <span class="hljs-attr">"version"</span>: <span class="hljs-string">"1.0.0"</span>,
  <span class="hljs-attr">"description"</span>: <span class="hljs-string">"A simple Slackbot that displays random inspiring techie quotes for developers/designers."</span>,
  <span class="hljs-attr">"main"</span>: <span class="hljs-string">"index.js"</span>,
  <span class="hljs-attr">"scripts"</span>: {
    <span class="hljs-attr">"start"</span>: <span class="hljs-string">"index.js"</span>
  },
  <span class="hljs-attr">"repository"</span>: {
    <span class="hljs-attr">"type"</span>: <span class="hljs-string">"git"</span>,
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"git+https://github.com/BolajiAyodeji/slackbot.git"</span>
  },
  <span class="hljs-attr">"author"</span>: <span class="hljs-string">"Bolaji Ayodeji"</span>,
  <span class="hljs-attr">"license"</span>: <span class="hljs-string">"MIT"</span>,
  <span class="hljs-attr">"bugs"</span>: {
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://github.com/BolajiAyodeji/slackbot/issues"</span>
  },
  <span class="hljs-attr">"homepage"</span>: <span class="hljs-string">"https://github.com/BolajiAyodeji/slackbot#readme"</span>
}
</code></pre>
<h1 id="heading-install-dependencies">Install Dependencies</h1>
<p><strong>Now let's install and setup all the libraries we need.</strong></p>
<h2 id="heading-slackbotsjs">SlackBots.js</h2>
<p><a target="_blank" href="https://github.com/mishk0/slack-bot-api">SlackBots.js</a> is a Node.js library for easy operation with the Slack API.</p>
<pre><code class="lang-python">npm install slackbots
</code></pre>
<p>In <code>index.js</code>:</p>
<pre><code class="lang-python">const SlackBot = require(<span class="hljs-string">'slackbots'</span>);
</code></pre>
<h2 id="heading-axios">Axios</h2>
<p><a target="_blank" href="https://github.com/axios/axios">Axios</a> is a promise-based HTTP client for the browser and node.js. If you know Fetch or AJAX, this is just a library that does the same thing with way cooler features. You can see them <a target="_blank" href="https://github.com/axios/axios">here</a>.</p>
<pre><code class="lang-python">npm install axios
</code></pre>
<p>In <code>index.js</code>:</p>
<pre><code class="lang-python">const axios = require(<span class="hljs-string">'axios'</span>)
</code></pre>
<h2 id="heading-nodemon">Nodemon</h2>
<p>To run a script in Node.js, you have to run <code>node index.js</code>. Whenever you make changes to this file, you have to rerun <code>node index.js</code>. This sucks when you're making so many changes like we'll be doing. That's why we need <a target="_blank" href="https://github.com/remy/nodemon">nodemon</a>, a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.</p>
<pre><code class="lang-python">npm install -g nodemon
</code></pre>
<p>In <code>package.json</code>, locate the scripts section and add a new start script:</p>
<pre><code class="lang-python"><span class="hljs-string">"scripts"</span>: {
    <span class="hljs-string">"start"</span>: <span class="hljs-string">"node index.js"</span>
  }
</code></pre>
<p>If you run <code>npm start</code>, the file will run but won't restart on change. To fix this, use the nodemon we installed instead of node like so:</p>
<pre><code class="lang-python"><span class="hljs-string">"scripts"</span>: {
    <span class="hljs-string">"start"</span>: <span class="hljs-string">"nodemon index.js"</span>
  }
</code></pre>
<h1 id="heading-dotenv">Dotenv</h1>
<p>I won't explain this in-depth. In a few days, I'll publish an article around environmental variables, but for now just know that we use this to hide secret keys and tokens like the Slack Access Token we would be using. This way you don't have to push your secret keys to GitHub.</p>
<p>There are several ways to do this, but I prefer using dotenv. <a target="_blank" href="https://github.com/motdotla/dotenv">Dotenv</a> is a zero-dependency module that loads environment variables from a .env file into process.env.</p>
<pre><code class="lang-python">npm install dotenv
</code></pre>
<p>In <code>index.js</code>:</p>
<pre><code class="lang-python">const dotenv = require(<span class="hljs-string">'dotenv'</span>)

dotenv.config()
</code></pre>
<p>After all installation, your <code>package.json</code> should look like this:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"name"</span>: <span class="hljs-string">"inspireNuggetsSlackBot"</span>,
  <span class="hljs-attr">"version"</span>: <span class="hljs-string">"1.0.0"</span>,
  <span class="hljs-attr">"description"</span>: <span class="hljs-string">"A simple Slackbot that displays random inspiring techie quotes and jokes for developers/designers."</span>,
  <span class="hljs-attr">"main"</span>: <span class="hljs-string">"index.js"</span>,
  <span class="hljs-attr">"scripts"</span>: {
    <span class="hljs-attr">"start"</span>: <span class="hljs-string">"nodemon index.js"</span>
  },
  <span class="hljs-attr">"repository"</span>: {
    <span class="hljs-attr">"type"</span>: <span class="hljs-string">"git"</span>,
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"git+https://github.com/BolajiAyodeji/inspireNuggetsSlackBot.git"</span>
  },
  <span class="hljs-attr">"author"</span>: <span class="hljs-string">"Bolaji Ayodeji"</span>,
  <span class="hljs-attr">"license"</span>: <span class="hljs-string">"MIT"</span>,
  <span class="hljs-attr">"bugs"</span>: {
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://github.com/BolajiAyodeji/inspireNuggetsSlackBot/issues"</span>
  },
  <span class="hljs-attr">"homepage"</span>: <span class="hljs-string">"https://github.com/BolajiAyodeji/inspireNuggetsSlackBot#readme"</span>,
  <span class="hljs-attr">"devDependencies"</span>: {
    <span class="hljs-attr">"dotenv"</span>: <span class="hljs-string">"^8.0.0"</span>
  },
  <span class="hljs-attr">"dependencies"</span>: {
    <span class="hljs-attr">"axios"</span>: <span class="hljs-string">"^0.19.0"</span>,
    <span class="hljs-attr">"slackbots"</span>: <span class="hljs-string">"^1.2.0"</span>
  }
}
</code></pre>
<h1 id="heading-create-your-slack-workspace">Create your Slack workspace</h1>
<p>Now that we have that all set up, we need a Slack workspace to run our bot in development. Creating a workspace is pretty easy, read <a target="_blank" href="https://get.slack.help/hc/en-us/articles/206845317-Create-a-Slack-workspace">this</a> to learn more.</p>
<h1 id="heading-register-your-slack-bot">Register your Slack Bot</h1>
<p>Now that you have a workspace, you should have a Slack URL with your workspace name. Mine is <code>mekafindteam.slack.com</code>.</p>
<p>Now you'll need to create a Slack App. Create one <a target="_blank" href="https://api.slack.com/apps/new">here</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture5.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Enter your App name and ensure you're in the workspace you created if you're in multiple workspaces.</p>
<p>Now you'll see the settings &gt; Basic Information page. Click the first tab <code>Add features and functionality</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture6.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Since we're building a bot, select the <strong>Bots</strong> field.</p>
<p>Now you'll see the Bot user page:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture7.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Click the <code>Add a Bot User</code> button.</p>
<p>Your display name will automatically be filled in from your already chosen App name. You can update it, but I'll advise you use the same name everywhere with the same alphabet case to avoid errors.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture8.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now, toggle the <code>Always Show My Bot as Online</code> switch to always show your bot as Online. Remember this bot is just like a user in your workspace. Afterwards, click the <code>Add Bot User</code> button.</p>
<p>Save all changes now:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture9.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Next, return to the <code>Basic Information</code> page and select the <code>Install your app to your workspace</code> tab.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture10.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Click the <code>Install App to Workspace</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture11.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Click allow and wait to be redirected back to the <code>Basic Information</code> page.</p>
<p>Note the <code>Manage distribution</code> tab: this section is needed when you want to make your Bot available for installation by others. For now we're just building in development and I won't be covering distribution in this article. In my next article, I'll show you how to deploy your Slack bot and make it available as an App to other workspaces.</p>
<p>If you check your Slack workspace now, you should see the App installed in the Apps section.</p>
<p>For now, it's offline - once we start building the bot, we'll turn this on.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture15.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-customize-your-slack-bot">Customize your Slack bot</h1>
<p>Now we've created our bot, let's do some customization.</p>
<p>Still, on the <code>Basic Information</code> page, scroll down to the <code>Display Information</code> section:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture12.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>This is basic stuff: just upload a logo, change your background color, and add a short description.</p>
<p>Your icon should be <code>512x512px</code> or bigger and your background color should be in HEX. Read more on the App guidelines <a target="_blank" href="https://api.slack.com/docs/slack-apps-guidelines">here</a>.</p>
<p>Here's what mine looks like after customization:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture13.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-slack-bot-oauth-tokens">Slack bot OAuth Tokens</h1>
<p>Now that we have our Slack bot setup, let's grab out token keys.</p>
<p>In the navigation bar, locate the Features section and click the <code>OAuth &amp; Permission</code> tab:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture16.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You'll see two Access Tokens:</p>
<ul>
<li><p>OAuth Access Token</p>
</li>
<li><p>Bot User OAuth Access Token</p>
</li>
</ul>
<p>Copy the <strong>Bot User OAuth Access Token.</strong></p>
<p>This will change every time you re-install this app or when you install it in another workspace. The token should start with <code>xoxb-</code>.</p>
<blockquote>
<p>Keeping credentials secure is important whether you're developing open source libraries and tools, internal integrations for your workspace, or Slack apps for distribution to workspaces across the world. - Slack</p>
</blockquote>
<p>This is why we have installed Dotenv - we'll set that up in the next section.</p>
<h1 id="heading-building-the-bot">Building the bot</h1>
<p>Now let's build our bot :).</p>
<h3 id="heading-first-lets-keep-our-access-token-somewhere">First, let's keep our Access Token somewhere.</h3>
<p>Create a <code>.env</code> file and add this:</p>
<pre><code class="lang-python">BOT_TOKEN=YOUR_SLACK_ACCESS_TOKEN_HERE
</code></pre>
<p>Now let's start our SlackBot.js:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> bot = <span class="hljs-keyword">new</span> SlackBot({
    <span class="hljs-attr">token</span>: <span class="hljs-string">`<span class="hljs-subst">${process.env.BOT_TOKEN}</span>`</span>,
    <span class="hljs-attr">name</span>: <span class="hljs-string">'inspirenuggets'</span>
})
</code></pre>
<p>We've just created a bot variable that initializes a new SlackBot instance which has two values, our token and app name.</p>
<p>I used the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals">ES6 template string syntax</a> to bring in our token key from our <code>.env</code> file. dotenv has this covered for us.</p>
<p>Make sure you use the same name you used while creating your Slack app, or else you'll have authentication errors.</p>
<p>Now start the app:</p>
<pre><code class="lang-python">npm start
</code></pre>
<p>nodemon should be running now and our Slack app should be online too.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture17.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture18.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-start-handler">Start handler</h3>
<p>Our Bot does nothing now even though it's running. Let's return a message.</p>
<pre><code class="lang-javascript">bot.on(<span class="hljs-string">'start'</span>, <span class="hljs-function">() =&gt;</span> {
    <span class="hljs-keyword">const</span> params = {
        <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':robot_face:'</span>
    }

    bot.postMessageToChannel(
        <span class="hljs-string">'random'</span>,
        <span class="hljs-string">'Get inspired while working with @inspirenuggets'</span>,
        params
    );
})
</code></pre>
<p>The <code>bot.on</code> handler sends the welcome message. We passed two parameters, the <code>'start'</code> and a function which holds a params variable which also holds the slack emoji. Slack emoji have codes, and you can find them <a target="_blank" href="https://slackmojis.com/">here</a>. I used <code>:robot_face:</code>, but you can change this to your preferred emoji.</p>
<p>We also initialized the <code>bot.postMessageToChannel</code> function which is a SlackBot.js method to post a message to a channel. In this function, we pass the channel name we want to post to, the message in a string, and the params variable we declared earlier for the emoji. I used the <strong>#random</strong> channel and sent <code>Get inspired while working with @inspirenuggets</code> to it. Your app should restart automatically and your bot should do this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture19.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Cool right?<br>You can also post messages to users and groups.</p>
<pre><code class="lang-javascript">    <span class="hljs-comment">// define existing username instead of 'user_name'</span>
    bot.postMessageToUser(<span class="hljs-string">'user_name'</span>, <span class="hljs-string">'Hello world!'</span>, params); 


    <span class="hljs-comment">// define private group instead of 'private_group', where bot exist</span>
    bot.postMessageToGroup(<span class="hljs-string">'private_group'</span>, <span class="hljs-string">'Hello world!'</span>, params);
</code></pre>
<h3 id="heading-error-handler">Error Handler</h3>
<p>Let's also write a function to check for errors and return them:</p>
<pre><code class="lang-javascript">bot.on(<span class="hljs-string">'error'</span>, <span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(err);
})
</code></pre>
<h3 id="heading-message-handler">Message Handler</h3>
<p>Now let's build the main bot functionality.</p>
<p>Like I said earlier, we'll be using the quotes JSON from the extension I built as our quotes API. The JSON can be found with this URL: <code>https://raw.githubusercontent.com/BolajiAyodeji/inspireNuggets/master/src/quotes.json</code></p>
<p>When a user mentions our bot and adds <strong>inspire me</strong>, the bot returns a random quote from <a target="_blank" href="https://chrome.google.com/webstore/detail/inspirenuggets-for-chrome/acnfgdioohhajabdofaadfdhmlkphmlb">inspireNuggets</a>. When the user types <strong>random joke</strong>, it returns a random joke from the <a target="_blank" href="https://api.chucknorris.io/">Chuck Norris</a> API. And when the user types <strong>help</strong>, it returns the instruction guide.</p>
<p>First, let's check for our command words from the user message (<strong>inspire me</strong>, <strong>random joke,</strong> and <strong>help</strong>):</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleMessage</span>(<span class="hljs-params">message</span>) </span>{
    <span class="hljs-keyword">if</span>(message.includes(<span class="hljs-string">' inspire me'</span>)) {
        inspireMe()
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(message.includes(<span class="hljs-string">' random joke'</span>)) {
        randomJoke()
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(message.includes(<span class="hljs-string">' help'</span>)) {
        runHelp()
    }
}
</code></pre>
<p>Now let's create the three function we need</p>
<p><strong>inspireMe()</strong></p>
<p>Our demo JSON is not really an API, it's just some JSON I used in the Chrome Extension. We're only accessing it from GitHub raw contents. You can use any API you prefer, you'll just have to iterate differently to get your data depending on if your API returns an array or object - whichever it returns, it's not a big deal.</p>
<p>Check out my previous articles on:</p>
<ul>
<li><p><a target="_blank" href="https://www.bolajiayodeji.com/manipulating-arrays-in-javascript/">Manipulating Arrays in JavaScript</a> and</p>
</li>
<li><p><a target="_blank" href="https://www.bolajiayodeji.com/iterating-through-javascript-objects-5-techniques-and-performance-tests/">Iterating through JavaScript Objects  -  5 Techniques and Performance Tests.</a></p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">inspireMe</span>(<span class="hljs-params"></span>) </span>{
    axios.get(<span class="hljs-string">'https://raw.githubusercontent.com/BolajiAyodeji/inspireNuggets/master/src/quotes.json'</span>)
      .then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> {
            <span class="hljs-keyword">const</span> quotes = res.data;
            <span class="hljs-keyword">const</span> random = <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * quotes.length);
            <span class="hljs-keyword">const</span> quote = quotes[random].quote
            <span class="hljs-keyword">const</span> author = quotes[random].author

            <span class="hljs-keyword">const</span> params = {
                <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':male-technologist:'</span>
            }

            bot.postMessageToChannel(
                <span class="hljs-string">'random'</span>,
                <span class="hljs-string">`:zap: <span class="hljs-subst">${quote}</span> - *<span class="hljs-subst">${author}</span>*`</span>,
                params
            );

      })
}
</code></pre>
<p>We just used Axios to get the JSON file which returns some data:</p>
<pre><code class="lang-json">[
    {
        <span class="hljs-attr">"number"</span>: <span class="hljs-string">"1"</span>,
        <span class="hljs-attr">"author"</span>: <span class="hljs-string">"Von R. Glitschka"</span>,
        <span class="hljs-attr">"quote"</span>: <span class="hljs-string">"The client may be king, but he's not the art director."</span>
    },
    {
        <span class="hljs-attr">"number"</span>: <span class="hljs-string">"2"</span>,
        <span class="hljs-attr">"author"</span>: <span class="hljs-string">"Frank Capra"</span>,
        <span class="hljs-attr">"quote"</span>: <span class="hljs-string">"A hunch is creativity trying to tell you something."</span>
    },
.
.
.
.
]
</code></pre>
<p>This JSON currently contains 210 quotes and I update them frequently. So we want to get a random quote plus the author name every time the user request it. From our Axios response, we just do this:</p>
<pre><code class="lang-javascript">
<span class="hljs-keyword">const</span> quotes = res.data;
<span class="hljs-keyword">const</span> random = <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * quotes.length);
<span class="hljs-keyword">const</span> quote = quotes[random].quote
<span class="hljs-keyword">const</span> author = quotes[random].author
</code></pre>
<p>And just like we did with the welcome message, we just return the quote and author instead of a string message:</p>
<pre><code class="lang-javascript"><span class="hljs-string">`:zap: <span class="hljs-subst">${quote}</span> - *<span class="hljs-subst">${author}</span>*`</span>
</code></pre>
<p>Let's test this:</p>
<p>Type <code>@inspirenuggets inspire me</code></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture20.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Yayyy! It worked!</p>
<p>PS: You can always change the emoji type for every request. If you noticed I changed the <code>inspireMe()</code> to <code>:male-technologist:</code></p>
<p><strong>randomJoke()</strong></p>
<p>We're getting the jokes from the Chuck Norris API from this endpoint <code>https://api.chucknorris.io/jokes/random</code>.</p>
<pre><code class="lang-json">{
<span class="hljs-attr">"categories"</span>: [],
<span class="hljs-attr">"created_at"</span>: <span class="hljs-string">"2016-05-01 10:51:41.584544"</span>,
<span class="hljs-attr">"icon_url"</span>: <span class="hljs-string">"https://assets.chucknorris.host/img/avatar/chuck-norris.png"</span>,
<span class="hljs-attr">"id"</span>: <span class="hljs-string">"6vUvusBeSVqdsU9C5-ZJZw"</span>,
<span class="hljs-attr">"updated_at"</span>: <span class="hljs-string">"2016-05-01 10:51:41.584544"</span>,
<span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://api.chucknorris.io/jokes/6vUvusBeSVqdsU9C5-ZJZw"</span>,
<span class="hljs-attr">"value"</span>: <span class="hljs-string">"Chuck Norris once choked a wildcat to death with his sphincter muscle."</span>
}
</code></pre>
<p>This is a real API that returns a random joke on every request, so we don't have to do <code>Math.floor()</code> again.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">randomJoke</span>(<span class="hljs-params"></span>) </span>{
    axios.get(<span class="hljs-string">'https://api.chucknorris.io/jokes/random'</span>)
      .then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> {
            <span class="hljs-keyword">const</span> joke = res.data.value;

            <span class="hljs-keyword">const</span> params = {
                <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':smile:'</span>
            }

            bot.postMessageToChannel(
                <span class="hljs-string">'random'</span>,
                <span class="hljs-string">`:zap: <span class="hljs-subst">${joke}</span>`</span>,
                params
            );

      })
}
</code></pre>
<p>By now, you should understand how this works already. Make a post with the channel name, message and params.</p>
<p><strong>runHelp()</strong></p>
<p>This is similar to our welcome message: we just want to return a custom text when the user adds <strong>help</strong> to the request.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">runHelp</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> params = {
        <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':question:'</span>
    }

    bot.postMessageToChannel(
        <span class="hljs-string">'random'</span>,
        <span class="hljs-string">`Type *@inspirenuggets* with *inspire me* to get an inspiring techie quote, *random joke* to get a Chuck Norris random joke and *help* to get this instruction again`</span>,
        params
    );
}
</code></pre>
<p>Now let's test all three commands:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/capture2-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Everything works fine now, congratulations!!!! You just built your SlackBot.</p>
<hr>
<p>There are an endless number of possibilities of Bots you can build with this to automate your own work or teamwork.</p>
<p>You can build a bot that:</p>
<ul>
<li><p>Fetches your tasks from somewhere and reminds you when you type <code>hey what next</code>,</p>
</li>
<li><p>Welcomes every user to your workspace (I built this during one of the <a target="_blank" href="https://hng.tech/">HNG Internship's</a>),</p>
</li>
<li><p>Gives you football matches updates while you're working,</p>
</li>
<li><p>Tells your team when you hit a milestone in number of registered users,</p>
</li>
</ul>
<p>and many more...</p>
<p>It's just about having somewhere to get the data from, and some basic iteration skills and the <code>bot.postMessageToChannel()</code> method.</p>
<p>Automation is one thing we should learn as developers. We have a lot to do, so we should automate the simpler tasks so we have time for the more difficult ones. I hope with this you can automate your tasks and I look forward to the creative ideas you'll bring to life.</p>
<hr>
<h1 id="heading-final-code">Final Code</h1>
<p>Here's our final <code>index.js</code></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> SlackBot = <span class="hljs-built_in">require</span>(<span class="hljs-string">'slackbots'</span>);
<span class="hljs-keyword">const</span> axios = <span class="hljs-built_in">require</span>(<span class="hljs-string">'axios'</span>)
<span class="hljs-keyword">const</span> dotenv = <span class="hljs-built_in">require</span>(<span class="hljs-string">'dotenv'</span>)

dotenv.config()

<span class="hljs-keyword">const</span> bot = <span class="hljs-keyword">new</span> SlackBot({
    <span class="hljs-attr">token</span>: <span class="hljs-string">`<span class="hljs-subst">${process.env.BOT_TOKEN}</span>`</span>,
    <span class="hljs-attr">name</span>: <span class="hljs-string">'inspirenuggets'</span>
})

<span class="hljs-comment">// Start Handler</span>
bot.on(<span class="hljs-string">'start'</span>, <span class="hljs-function">() =&gt;</span> {
    <span class="hljs-keyword">const</span> params = {
        <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':robot_face:'</span>
    }

    bot.postMessageToChannel(
        <span class="hljs-string">'random'</span>,
        <span class="hljs-string">'Get inspired while working with @inspirenuggets'</span>,
        params
    );
})

<span class="hljs-comment">// Error Handler</span>
bot.on(<span class="hljs-string">'error'</span>, <span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(err);
})

<span class="hljs-comment">// Message Handler</span>
bot.on(<span class="hljs-string">'message'</span>, <span class="hljs-function">(<span class="hljs-params">data</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span>(data.type !== <span class="hljs-string">'message'</span>) {
        <span class="hljs-keyword">return</span>;
    }
    handleMessage(data.text);
})

<span class="hljs-comment">// Response Handler</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleMessage</span>(<span class="hljs-params">message</span>) </span>{
    <span class="hljs-keyword">if</span>(message.includes(<span class="hljs-string">' inspire me'</span>)) {
        inspireMe()
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(message.includes(<span class="hljs-string">' random joke'</span>)) {
        randomJoke()
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(message.includes(<span class="hljs-string">' help'</span>)) {
        runHelp()
    }
}

<span class="hljs-comment">// inspire Me</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">inspireMe</span>(<span class="hljs-params"></span>) </span>{
    axios.get(<span class="hljs-string">'https://raw.githubusercontent.com/BolajiAyodeji/inspireNuggets/master/src/quotes.json'</span>)
      .then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> {
            <span class="hljs-keyword">const</span> quotes = res.data;
            <span class="hljs-keyword">const</span> random = <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * quotes.length);
            <span class="hljs-keyword">const</span> quote = quotes[random].quote
            <span class="hljs-keyword">const</span> author = quotes[random].author

            <span class="hljs-keyword">const</span> params = {
                <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':male-technologist:'</span>
            }

            bot.postMessageToChannel(
                <span class="hljs-string">'random'</span>,
                <span class="hljs-string">`:zap: <span class="hljs-subst">${quote}</span> - *<span class="hljs-subst">${author}</span>*`</span>,
                params
            );

      })
}

<span class="hljs-comment">// Random Joke</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">randomJoke</span>(<span class="hljs-params"></span>) </span>{
    axios.get(<span class="hljs-string">'https://api.chucknorris.io/jokes/random'</span>)
      .then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> {
            <span class="hljs-keyword">const</span> joke = res.data.value;

            <span class="hljs-keyword">const</span> params = {
                <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':smile:'</span>
            }

            bot.postMessageToChannel(
                <span class="hljs-string">'random'</span>,
                <span class="hljs-string">`:zap: <span class="hljs-subst">${joke}</span>`</span>,
                params
            );

      })
}

<span class="hljs-comment">// Show Help</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">runHelp</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> params = {
        <span class="hljs-attr">icon_emoji</span>: <span class="hljs-string">':question:'</span>
    }

    bot.postMessageToChannel(
        <span class="hljs-string">'random'</span>,
        <span class="hljs-string">`Type *@inspirenuggets* with *inspire me* to get an inspiring techie quote, *random joke* to get a Chuck Norris random joke and *help* to get this instruction again`</span>,
        params
    );
}
</code></pre>
<h1 id="heading-what-next">What Next?</h1>
<p>Our bot only runs in development now, and to use it we always have to <code>npm start</code>.</p>
<p>This isn't cool, right? We'll want to host it somewhere it can run every time. In my next article, I'll show you how to host this on either <a target="_blank" href="https://herokuapp.com/">Heroku</a>, <a target="_blank" href="https://zeit.co/">Zeit</a> or <a target="_blank" href="https://netlify.com">Netlify</a> and publish it to the Slack Apps store so anyone around the world can use it.<br>Also, don't forget to add this in your <code>.gitignore</code> before pushing to GitHub:</p>
<pre><code class="lang-python">
/.env
/node_modules
</code></pre>
<blockquote>
<p><strong>Subscribe to my</strong> <a target="_blank" href="https://tinyletter.com/bolajiayodeji/"><strong>newsletter</strong></a> <strong>to get updated.</strong></p>
</blockquote>
<h1 id="heading-useful-resources">Useful Resources</h1>
<ul>
<li><p><a target="_blank" href="https://api.slack.com/">Slack API</a></p>
</li>
<li><p><a target="_blank" href="https://api.slack.com/#read_the_docs">Slack API Docs</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/slackapi/node-slack-sdk">SlackBot.js</a></p>
</li>
<li><p><a target="_blank" href="https://slack.com/intl/en-in/apps">Slack Apps</a></p>
</li>
<li><p><a target="_blank" href="https://api.slack.com/docs/slack-apps-guidelines">Slack Apps Guidelines</a></p>
</li>
<li><p><a target="_blank" href="https://api.slack.com/start/overview">An introduction to Slack apps</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/BolajiAyodeji/inspireNuggets">inspireNuggets</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/BolajiAyodeji/inspireNuggetsSlackBot">inspireNuggetsSlackBot</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Handle Static Forms - The Client-side Way ]]>
                </title>
                <description>
                    <![CDATA[ Forms are interactive elements used to get input from the user for further processing. Most times, forms are just used to receive input that requires no processing but rather just receiving data, this might be a contact form, RSVP, get a quote e.t.c ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/handling-static-forms-the-client-side-way/</link>
                <guid isPermaLink="false">66d84e16ef84e4cc27cfbe27</guid>
                
                    <category>
                        <![CDATA[ forms ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JAMstack ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Sun, 21 Jul 2019 20:58:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/07/1_NjU8ApeQC0wK4NgIaOjALw.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Forms are interactive elements used to get input from the user for further processing. Most times, forms are just used to receive input that requires no processing but rather just receiving data, this might be a contact form, RSVP, get a quote e.t.c</p>
<p>Traditionally, forms are managed with the help of a server (also known as server side), but this is more efficient when you’re processing the data from the form, maybe a user registration form where the form data is validated, authenticated and saved in a database.</p>
<p>When you’re building a simple form where you’re only receiving data from the user and not processing (i.e contact form) the goal is to get the data from the form and send to your company support email (e.g info@…, support@…)</p>
<p>Using a server here is not ideal and is only an overkill, a very common way of doing this is via <a target="_blank" href="https://github.com/PHPMailer/PHPMailer">PHPMailer</a> ( The classic email sending library for PHP). PHPMailer is used with PHP and requires a lot of boring server configurations. What if you’re just building a static site? There should be an easier way of doing this client side right?</p>
<p>In this article, I’ll introduce you to two methods of handling form data client side in static sites. There are other methods but I’ve used these two and considered them to be the best and easiest (no hard feelings :) ).</p>
<p>NO hectic configurations, NO servers, NO serious stuff, just build your form, do some little tweaks, the user submits and bingo it heads straight to your designated email. :)</p>
<h3 id="heading-starter-form">STARTER FORM</h3>
<p>For the purpose of this article, I’ve built a basic form with HTML5 and Bootstrap 4, you can fork it from the <a target="_blank" href="https://codepen.io/iambolajiayo/pen/MdGdex">Codepen below.</a></p>
<div class="embed-wrapper">
        <iframe width="100%" height="350" src="https://codepen.io/iambolajiayo/embed/MdGdex" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="CodePen embed" scrolling="no" allowtransparency="true" allowfullscreen="true" loading="lazy"></iframe></div>
<p> </p>
<p>Currently, this form uses none of the methods we’ll talk about, at the end of the article, I’ll provide the full <code>code</code> for both methods, you can then update the form and test. I’ve added a little validation, don’t worry about that</p>
<p>Now, let’s get started!!</p>
<h3 id="heading-method-one">METHOD ONE</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/image-12.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><a target="_blank" href="http://formspree.io/">Formspree</a> provides functional HTML forms via their platform with no PHP or JavaScript. Send your form to their URL and it’ll be forwarded to your email. No PHP, Javascript or sign up required — perfect for static sites!</p>
<p>Wait!, wait!!, wait!!! it’s <a target="_blank" href="https://github.com/formspree/formspree">Open Sourced</a> too</p>
<h4 id="heading-form-handling-with-formspree">FORM HANDLING WITH FORMSPREE</h4>
<ul>
<li>Build your form, <a target="_blank" href="https://codepen.io/iambolajiayo/pen/MdGdex?editors=1010">we’ve done that already</a></li>
</ul>
<p>(Follow the next step and update this form to use this method)</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">"https://formspree.io/you@email.com"</span> <span class="hljs-attr">method</span>=<span class="hljs-string">"POST"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"hidden"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"_subject"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Bolaji's Form"</span>&gt;</span>                 
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"hidden"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"_next"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"/thanks.html"</span> &gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"_replyto"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"phone"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Send"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<p>Now let’s go over the new stuff added above.</p>
<ul>
<li><p>We changed the form’s action-attribute to <code>[https://formspree.io/you@email.com](https://formspree.io/you@email.com)</code> [replace <a target="_blank" href="mailto:your@email.com">your@email.com</a> with your own email.] This is simply sending your form data to formspree then to your email. Formspree is acting as a third party here.</p>
</li>
<li><p>I’ve added some name attributes to the input fields. This is just configuring each field so we can grab the data and send to formspree.</p>
</li>
</ul>
<p>— For Email address, I added a <strong>_replyto attribute</strong> (This just mean, you’ll be able to quickly reply to the user who originally submitted via email)</p>
<p>— I’ve added a <strong>_subject</strong> attribute. This value is used for the email’s subject so that you can quickly reply to submissions without having to edit the subject line each time.</p>
<p>— I’ve added a <strong>_next</strong> attribute. By default, after submitting a form the user is shown the Formspree “Thank You” page. You can provide an alternative URL for that page like so: <code>&lt;input type=”hidden” name=”_next” value=”/thanks.html" /&gt;</code></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*M2O2tR08URl1I2i5bVGU5Q.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/1_M2O2tR08URl1I2i5bVGU5Q.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>formspree default success page</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/1_nLA5m3_yjx4mmmJAmuu8Yg.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>custom success page I built for a client.</em></p>
<ul>
<li>We added a value attribute to the send button [<strong>value=”Send”</strong>]</li>
</ul>
<p>This is our Thanos, one snap at this button and your form is erased and its data sent to your email.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/1_hnEhoz4pSb4pNtzXD0pDpw.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>That’s all to using formspree :) Although there are other configuration settings for several other features, you can check <a target="_blank" href="https://formspree.io/">here</a>.</p>
<h4 id="heading-things-to-note">THINGS TO NOTE!</h4>
<ul>
<li><p>You don’t need to signup to use formspree, just add your action attribute and you’re good to go. You only signup if you want a <a target="_blank" href="https://formspree.io/plans">Paid plan</a>.</p>
</li>
<li><p>Make sure your form has the <code>method=”POST”</code> attribute</p>
</li>
<li><p>Formspree uses reCAPTCHA to identify spam submissions. After a user clicks our <em>Thanos</em>, they’ll have to do some CAPTCHA verification. Cool way of stopping spam submissions.</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/1_0mq3GFJ4_fRWnR5_vX1L5g.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li><p>After that, the form is sent to your designated email and the custom success page is displayed!</p>
</li>
<li><p>Formspree does not read your form data, they have no access to it, they’re just a delivery service, you send your parcel sealed to them, they deliver to your customer, cool right? :)</p>
</li>
<li><p>Formspree is free for 50 submissions per form per month ONLY! Need more, you can upgrade to the <a target="_blank" href="https://formspree.io/plans">Paid plan</a>.</p>
</li>
<li><p>Formspree has both Free and Paid plans. Paid plans have several other features like admin dashboard, unlimited submissions, AJAX handling e.t.c Paid plans and their features can be found <a target="_blank" href="https://formspree.io/plans">here</a></p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/1_UZwPE17ZnWZym5qaDkYIwA.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you’re building a basic site, you shouldn’t worry about Paid plans, Paid plans are mostly needed by Enterprise applications and companies, the Free plan would cover all your needs. I use this for some client projects too :)</p>
<ul>
<li>Formspree premium users can submit forms via AJAX. Just set the Accept header to application/json. If you’re using jQuery this can be done like so:</li>
</ul>
<pre><code class="lang-js">    $.ajax({
        <span class="hljs-attr">url</span>: <span class="hljs-string">"https://formspree.io/FORM_ID"</span>,
        <span class="hljs-attr">method</span>: <span class="hljs-string">"POST"</span>,
        <span class="hljs-attr">data</span>: {<span class="hljs-attr">message</span>: <span class="hljs-string">"hello!"</span>},
        <span class="hljs-attr">dataType</span>: <span class="hljs-string">"json"</span>
    });
</code></pre>
<p>Well, this is for paid users :)</p>
<p>If you don’t use jQUERY like me and you’re tired of the lengthy AJAX default syntax, check out <a target="_blank" href="https://github.com/BolajiAyodeji/simple-ajax-library">simpleAJAX library</a>, a simple library I built for handling HTTP requests. Like so:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> http = <span class="hljs-keyword">new</span> simpleAJAX;

<span class="hljs-keyword">const</span> data = {
    <span class="hljs-string">"name"</span>: <span class="hljs-string">"Bolaji Ayodeji"</span>,
    <span class="hljs-string">"email"</span>: <span class="hljs-string">"hi@bolajiayodeji.com"</span>,
    <span class="hljs-string">"message"</span>: <span class="hljs-string">"hi"</span>
};
http.post(<span class="hljs-string">'https://formspree.io/FORM_ID'</span>, data,
<span class="hljs-function">(<span class="hljs-params">err, user</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span>(err) {
     <span class="hljs-built_in">console</span>.log(err)
    } <span class="hljs-keyword">else</span> {
     <span class="hljs-built_in">console</span>.log(user);
   }
 });
</code></pre>
<p>A star would make me happy! :)</p>
<p>If you're into React, <a target="_blank" href="https://zeit.co/">ZEIT</a> has a comprehensive guide on using Formspree with <a target="_blank" href="https://zeit.co/guides/deploying-react-forms-using-formspree-with-zeit-now">Create React App</a>, complete with deployment instructions. Highly recommended!</p>
<h3 id="heading-method-two">METHOD TWO</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/image-13.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><a target="_blank" href="https://www.netlify.com/">Netlify</a> offers form handling for sites deployed on their platform.</p>
<h4 id="heading-form-handling-with-netlify">FORM HANDLING WITH NETLIFY</h4>
<ul>
<li>Create an account on Netlify and deploy your site there.</li>
</ul>
<p>Please watch this 14min video by <a target="_blank" href="https://twitter.com/jamesqquick">@JamesQuick</a> below if you don’t know what Netlify is. Learn about all of the awesome features in Netlify like Continuous Deployment, Lambda Functions, Split Testing, Preview Branches, and more!</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/qAUX2A-W4Bc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<ul>
<li>Now that you have deployed your site, let’s create the form again</li>
</ul>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">"/thanks.html"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"Bolaji's form"</span> <span class="hljs-attr">method</span>=<span class="hljs-string">"POST"</span> <span class="hljs-attr">data-netlify</span>=<span class="hljs-string">"true"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"phone"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<p>Now let’s go over the new stuff I added above.</p>
<ul>
<li><p>Netlify is quite easier, you simply add the <code>netlify</code> attribute <code>data-netlify="true"</code>to the <code>&lt;form&gt;</code> tag, and you can start receiving submissions in your Netlify site admin panel.</p>
</li>
<li><p>Here, the <code>action</code> attribute serves as your custom success page</p>
</li>
</ul>
<p>That’s all, your form submissions goes straight to your Netlify admin panel</p>
<p>Settings &gt; Build &amp; deploy &gt; Environment &gt; Environment variables</p>
<p>(Watch the video above if you don’t understand what the panel means)</p>
<p><strong>Things to note!</strong></p>
<ul>
<li><p>Your site must be hosted on netlify to use this method</p>
</li>
<li><p>You must add the netlify attribute for the form to work</p>
</li>
<li><p>You can find all submissions to your Netlify forms in the Forms tab of your site dashboard. <strong>Settings &gt; Forms</strong></p>
</li>
<li><p>Netlify has free and paid plans too</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/1__sg2Fo1r5gniCilQjBcMhA.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><a target="_blank" href="https://www.netlify.com/pricing/#features"><em>https://www.netlify.com/pricing</em></a></p>
<ul>
<li><p>Netlify has several built-in notification options for verified form submissions, including email and Slack notifications. <strong>(Only available in Paid plans)</strong>. You can find them in <strong>Settings &gt; Forms &gt; Form notifications</strong>.</p>
</li>
<li><p>Netlify also integrates with <a target="_blank" href="https://zapier.com/app/dashboard">Zapier</a>, so you can set up triggers that send your verified form submissions to any of the 500+ applications in their catalogue.</p>
</li>
<li><p>All notification emails are sent from <code>team@netlify.com</code>, and any replies to a notification will go to that address. If you would like to respond to a form submitter, you will need to enter their address manually.</p>
</li>
<li><p>Netlify Forms can receive files uploads via form submissions too :).</p>
</li>
</ul>
<p>To do this, add an input with <code>type="file"</code> to any form. When a form is submitted, a link to each uploaded file will be included in the form submission details.</p>
<ul>
<li>Netlify is limited to 100 submissions per month and 10MB uploads per month for the FREE plan, If you want more, you’ll need to upgrade</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/09/1_XaWaJi_I6eQq06_ogPEHUg.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>form submissions in the admin panel</em></p>
<p>And that’s all!!</p>
<h3 id="heading-final-html-form-code">FINAL HTML FORM CODE</h3>
<pre><code class="lang-html"><span class="hljs-comment">&lt;!--formspree.html--&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">"https://formspree.io/you@email.com"</span> <span class="hljs-attr">method</span>=<span class="hljs-string">"POST"</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"hidden"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"_subject"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Bolaji's Form"</span>&gt;</span>                 
   <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"hidden"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"_next"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"/thanks.html"</span> &gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Name:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Name"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"invalid-feedback"</span>&gt;</span>
         Name must be between 2 and 20 characters
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Email:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Email address"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"invalid-feedback"</span>&gt;</span>
         Enter a valid email address
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Telephone:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"phone"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Phone number"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"invalid-feedback"</span>&gt;</span>
         Enter a valid number
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Send"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"btn btn-info btn-block"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<pre><code class="lang-html"><span class="hljs-comment">&lt;!--netlify.html--&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">"/thanks.html"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"Bolaji's form"</span> <span class="hljs-attr">method</span>=<span class="hljs-string">"POST"</span> <span class="hljs-attr">data-netlify</span>=<span class="hljs-string">"true"</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Name:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Name"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"invalid-feedback"</span>&gt;</span>
         Name must be between 2 and 20 characters
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Email:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Email address"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"invalid-feedback"</span>&gt;</span>
         Enter a valid email address
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Telephone:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"phone"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Phone number"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"invalid-feedback"</span>&gt;</span>
         Enter a valid number
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Send"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"btn btn-info btn-block"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<h3 id="heading-conclusion">CONCLUSION</h3>
<p>One thing to note about formspree is that the free version leaves your email address exposed to scrapers and bots so you might want to set up a temporary disposable email address while you use it. If you want to hide your email address by default, you’ll need to upgrade your plan.</p>
<p>Do you want extra practice? Watch this tutorial video below by <a target="_blank" href="https://medium.com/u/861216ad5921">Brad Traversy</a> and learn how to add a contact or any type of form to your website by using the Netlify form feature including file uploads and spam filtering. [Full guide + practical code]</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/6ElQ689HRcY" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<h3 id="heading-useful-links">Useful Links</h3>
<ul>
<li><p><a target="_blank" href="https://hashnode.com/util/redirect?url=https://www.netlify.com/docs/form-handling/">netlify.com/docs/form-handling</a></p>
</li>
<li><p><a target="_blank" href="https://hashnode.com/util/redirect?url=https://forestry.io/blog/5-ways-to-handle-forms-on-your-static-site/">forestry.io/blog/5-ways-to-handle-forms-on-..</a></p>
</li>
<li><p><a target="_blank" href="https://hashnode.com/util/redirect?url=https://gridsome.org/docs/guide-forms/">gridsome.org/docs/guide-forms</a></p>
</li>
<li><p><a target="_blank" href="https://hashnode.com/util/redirect?url=https://zeit.co/guides/deploying-react-forms-using-formspree-with-zeit-now">zeit.co/guides/deploying-react-forms-using-..</a></p>
</li>
<li><p><a target="_blank" href="https://hashnode.com/util/redirect?url=https://zeit.co/guides/deploying-statickit-with-zeit-now">zeit.co/guides/deploying-statickit-with-zei..</a></p>
</li>
</ul>
<p>Thanks for reading!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to fix Git always asking for user credentials ]]>
                </title>
                <description>
                    <![CDATA[ Have you ever encountered Git asking you for your username and password every time you try to interact with GitHub even after configuring it? Well, this is a very common problem among users who use the HTTPS clone URL for their repository. In this ar... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-fix-git-always-asking-for-user-credentials/</link>
                <guid isPermaLink="false">66d84e1d5a0b456f4d32143b</guid>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ terminal ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Sun, 21 Jul 2019 20:50:38 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/article-banner--10-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Have you ever encountered Git asking you for your username and password every time you try to interact with GitHub even after configuring it? Well, this is a very common problem among users who use the HTTPS clone URL for their repository. In this article, I’ll show you how to fix this.</p>
<p>The <code>https://</code> clone URLs are available on all public and private repositories. These URLs work everywhere, even if you are behind a firewall or proxy.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/10/clone.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>When you interact with a remote repository using HTTPS URLs on the command line, you’ll be asked for your GitHub username and password, this sucks right?</p>
<p>Well using an HTTPS remote URL has some advantages: it’s easier to set up than SSH :), and usually works through strict firewalls and proxies. However, it also prompts you to enter your GitHub user credentials every time you pull or push a repository :(.</p>
<h4 id="heading-you-can-fix-this-by-configuring-git-to-store-your-password-for-you">You can fix this by configuring Git to store your password for you.</h4>
<p>Here’s how:</p>
<ul>
<li>Update the URL of origin remote using SSH instead of HTTPS;</li>
</ul>
<pre><code class="lang-python">git remote set-url origin git@github.com:username/repo.git
</code></pre>
<p>or</p>
<ul>
<li>Make Git store the username and password and it will never ask for them.</li>
</ul>
<pre><code class="lang-python">git config --<span class="hljs-keyword">global</span> credential.helper store
</code></pre>
<ul>
<li>Save the username and password for a session (cache it);</li>
</ul>
<pre><code class="lang-python">git config --<span class="hljs-keyword">global</span> credential.helper cache
</code></pre>
<ul>
<li>You can also set a timeout for the above setting</li>
</ul>
<pre><code class="lang-python">git config --<span class="hljs-keyword">global</span> credential.helper <span class="hljs-string">'cache --timeout=600'</span>
</code></pre>
<p>Bingo, you just fixed it, Git will never ask for your credentials again.</p>
<hr>
<h1 id="heading-conclusion">CONCLUSION</h1>
<p>However, due to security reasons, it is advisable that you use SSH to interact with GitHub, especially if you work for a company or you’re using a computer that isn’t yours.</p>
<p>Using the SSH protocol, you can connect to GitHub without supplying your username or password every time.</p>
<p>Learn how to connect to GitHub with SSH <a target="_blank" href="https://help.github.com/en/articles/connecting-to-github-with-ssh">here</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Git first time setup ]]>
                </title>
                <description>
                    <![CDATA[ Git is a Free and Open Source Distributed Version Control System. By far, Git is the most widely used modern version control system in the world today. Git is a distributed and actively maintained open source project originally developed in 2005 by L... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/git-first-time-setup/</link>
                <guid isPermaLink="false">66d84e12d592ae8435de7154</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Bash ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Sun, 21 Jul 2019 20:49:25 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/05/article-banner--9-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Git is a Free and Open Source Distributed Version Control System.</p>
<p>By far, Git is the most widely used modern version control system in the world today. Git is a distributed and actively maintained open source project originally developed in 2005 by <a target="_blank" href="https://en.wikipedia.org/wiki/Linus_Torvalds">Linus Torvalds</a>, the famous creator of the Linux operating system kernel.</p>
<p>Unlike older centralized version control systems such as SVN and CVS, Git is distributed: every developer has the full history of their code repository locally. Git also works well on a wide range of operating systems and IDEs (Integrated Development Environments).</p>
<p>In this article, I’ll show you how to install Git, set it up for the first time, useful tips and resources to learn more/ learn advanced git concepts. Let’s roll!</p>
<p>I assume you already know what Version control is, if you don’t, kindly check out this <a target="_blank" href="http://slides.com/bolajiayodeji/introduction-to-version-control-with-git-and-github">slide</a> to learn more.</p>
<p>Here’s a quick recap of what Version control means: Version Control is: the process of managing changes to source code or set of files over time.</p>
<p>Version control is the process of managing changes to source code or set of files over time.</p>
<p>Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can restore and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members or contributors.</p>
<hr>
<p>Now that you know what Version Control and Git mean, let’s install it.</p>
<h3 id="heading-for-mac-os">FOR MAC OS:</h3>
<p><a target="_blank" href="http://git-scm.com/download/mac">Download Git for macOS</a> or install using <a target="_blank" href="https://brew.sh/">Homebrew</a></p>
<pre><code class="lang-python">brew install git
</code></pre>
<h3 id="heading-for-linux-os">FOR LINUX OS:</h3>
<p><a target="_blank" href="https://git-scm.com/download/linux">Download Git for Linux</a> or<br>Install for Debian-based Linux systems</p>
<pre><code class="lang-python">sudo apt-get update
 sudo apt-get upgrade
 sudo apt-get install git
</code></pre>
<p>or<br>Install for Red Hat-based Linux systems</p>
<pre><code class="lang-python">sudo yum upgrade
 sudo yum install git
</code></pre>
<h3 id="heading-for-windows-os">FOR WINDOWS OS:</h3>
<p><a target="_blank" href="https://git-scm.com/download/win">Download Git for Windows</a></p>
<h4 id="heading-heres-a-more-detailed-installation-guide-for-different-systems-on-git-official-docshttpsgit-scmcombookenv2getting-started-installing-git">HERE’S A MORE DETAILED INSTALLATION GUIDE FOR DIFFERENT SYSTEMS ON <a target="_blank" href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">GIT OFFICIAL DOCS</a></h4>
<hr>
<p>Now that you have Git on your system, let’s set up the Git environment.<br>Git comes with a tool called <code>git config</code> that lets you get and set configuration variables that control all aspects of how Git looks and operates.</p>
<ul>
<li>First set your identity, your name and email address like so:</li>
</ul>
<pre><code class="lang-python">git config --<span class="hljs-keyword">global</span> user.name <span class="hljs-string">"bolajiayodeji"</span>
 git config --<span class="hljs-keyword">global</span> user.email mailtobolaji@gmail.com
</code></pre>
<p>the <code>--global</code> option makes sure these values are used throughout your system</p>
<ul>
<li>Next set up the default text editor you’ll use whenever you need to enter a message in Git. This is not compulsory, if you don’t configure this, Git will use your default editor. If you want to use something else, configure like so:</li>
</ul>
<pre><code class="lang-python">git config --<span class="hljs-keyword">global</span> core.editor emacs
</code></pre>
<ul>
<li>Next, set up colors for your Git console.</li>
</ul>
<p>For Linux OS users, you can use third pary Zsh configurators like <a target="_blank" href="https://ohmyz.sh/">oh my zsh</a> to customize your terminal look with themes :).<br>To configure this, do this:</p>
<pre><code class="lang-python">git config --<span class="hljs-keyword">global</span> color.ui true
</code></pre>
<p>The color.ui is a meta configuration that includes all the various color.* configurations available with git commands.</p>
<p>Now Git is ready for use.</p>
<h2 id="heading-check-your-settings">CHECK YOUR SETTINGS</h2>
<pre><code class="lang-python">git config --list
</code></pre>
<pre><code class="lang-python">user.name=bolajiayodeji
 user.email=mailtobolaji@gmail.com
 color.ui=true
</code></pre>
<hr>
<p>Want to learn some super Git commands?</p>
<p>I wrote an article: <a target="_blank" href="https://www.bolajiayodeji.com/git-cheat-sheet/">Git Cheat Sheet</a> that covers some important Git commands you’ll need.</p>
<h1 id="heading-conclusion">CONCLUSION</h1>
<p>Version control software is an essential part of the every-day of modern-day software developer practices. Once accustomed to the powerful benefits of version control systems, many developers wouldn’t consider working without it even for non-software projects.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Manipulate Arrays in JavaScript ]]>
                </title>
                <description>
                    <![CDATA[ An important part of any programming language. Most times we need to do several operations on arrays, hence this article. In this article, I would show you various methods of manipulating arrays in JavaScript [^^] What are Arrays in JavaScript? Befor... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/manipulating-arrays-in-javascript/</link>
                <guid isPermaLink="false">66d84e26f6b5e038a1bde7cf</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ arrays ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ES6 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Bolaji Ayodeji ]]>
                </dc:creator>
                <pubDate>Thu, 13 Jun 2019 12:51:09 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/06/1_EK3RyHqvMS-ZIy9UyNMxTA--1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>An important part of any programming language. Most times we need to do several operations on arrays, hence this article.</p>
<p>In this article, I would show you various methods of manipulating arrays in JavaScript [^^]</p>
<h3 id="heading-what-are-arrays-in-javascript">What are Arrays in JavaScript?</h3>
<p>Before we proceed, you need to understand what arrays really mean.</p>
<blockquote>
<p><em>In JavaScript, an array is a variable that is used to store different data types. It basically stores different elements in one box and can be later assesssed with the variable.</em></p>
</blockquote>
<p>Declaring an array:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> myBox = [];   <span class="hljs-comment">// Initial Array declaration in JS</span>
</code></pre>
<p>Arrays can contain multiple data types</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> myBox = [<span class="hljs-string">'hello'</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-literal">true</span>, <span class="hljs-string">'hi'</span>];
</code></pre>
<p>Arrays can be manipulated by using several actions known as <strong>methods.</strong> Some of these methods allow us to add, remove, modify and do lots more to arrays.</p>
<p>I would be showing you a few in this article, let’s roll :)</p>
<blockquote>
<p><em>NB: I used</em> <strong><em>Arrow functions</em></strong> in this post, If you don’t know what this means, you should read <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">here</a>. Arrow function is an <strong>ES6 feature</strong>.</p>
</blockquote>
<h3 id="heading-tostring">toString()</h3>
<p>The JavaScript method <code>toString()</code> converts an array to a string separated by a comma.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> colors = [<span class="hljs-string">'green'</span>, <span class="hljs-string">'yellow'</span>, <span class="hljs-string">'blue'</span>];

<span class="hljs-built_in">console</span>.log(colors.toString()); <span class="hljs-comment">// green,yellow,blue</span>
</code></pre>
<h3 id="heading-join">join()</h3>
<p>The JavaScript <code>join()</code> method combines all array elements into a string.</p>
<p>It is similar to <code>toString()</code> method, but here you can specify the separator instead of the default comma.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> colors = [<span class="hljs-string">'green'</span>, <span class="hljs-string">'yellow'</span>, <span class="hljs-string">'blue'</span>];

<span class="hljs-built_in">console</span>.log(colors.join(<span class="hljs-string">'-'</span>)); <span class="hljs-comment">// green-yellow-blue</span>
</code></pre>
<h3 id="heading-concat">concat</h3>
<p>This method combines two arrays together or add more items to an array and then return a new array.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> firstNumbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> secondNumbers = [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>];
<span class="hljs-keyword">let</span> merged = firstNumbers.concat(secondNumbers);
<span class="hljs-built_in">console</span>.log(merged); <span class="hljs-comment">// [1, 2, 3, 4, 5, 6]</span>
</code></pre>
<h3 id="heading-push">push()</h3>
<p>This method adds items to the end of an array and <strong>changes</strong> the original array.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> browsers = [<span class="hljs-string">'chrome'</span>, <span class="hljs-string">'firefox'</span>, <span class="hljs-string">'edge'</span>];
browsers.push(<span class="hljs-string">'safari'</span>, <span class="hljs-string">'opera mini'</span>);
<span class="hljs-built_in">console</span>.log(browsers); 
<span class="hljs-comment">// ["chrome", "firefox", "edge", "safari", "opera mini"]</span>
</code></pre>
<h3 id="heading-pop">pop()</h3>
<p>This method removes the last item of an array and <strong>returns</strong> it.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> browsers = [<span class="hljs-string">'chrome'</span>, <span class="hljs-string">'firefox'</span>, <span class="hljs-string">'edge'</span>];
browsers.pop(); <span class="hljs-comment">// "edge"</span>
<span class="hljs-built_in">console</span>.log(browsers); <span class="hljs-comment">// ["chrome", "firefox"]</span>
</code></pre>
<h3 id="heading-shift">shift()</h3>
<p>This method removes the first item of an array and <strong>returns</strong> it.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> browsers = [<span class="hljs-string">'chrome'</span>, <span class="hljs-string">'firefox'</span>, <span class="hljs-string">'edge'</span>];
browsers.shift(); <span class="hljs-comment">// "chrome"</span>
<span class="hljs-built_in">console</span>.log(browsers); <span class="hljs-comment">// ["firefox", "edge"]</span>
</code></pre>
<h3 id="heading-unshift">unshift()</h3>
<p>This method adds an item(s) to the beginning of an array and <strong>changes</strong> the original array.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> browsers = [<span class="hljs-string">'chrome'</span>, <span class="hljs-string">'firefox'</span>, <span class="hljs-string">'edge'</span>];
browsers.unshift(<span class="hljs-string">'safari'</span>);
<span class="hljs-built_in">console</span>.log(browsers); <span class="hljs-comment">//  ["safari", "chrome", "firefox", "edge"]</span>
</code></pre>
<blockquote>
<p><em>You can also add multiple items at once</em></p>
</blockquote>
<h3 id="heading-splice">splice()</h3>
<p>This method <strong>changes</strong> an array, by adding, removing and inserting elements.</p>
<p>The syntax is:</p>
<pre><code class="lang-python">array.splice(index[, deleteCount, element1, ..., elementN])
</code></pre>
<ul>
<li><p><code>**Index**</code> here is the starting point for removing elements in the array</p>
</li>
<li><p><code>**deleteCount**</code> is the number of elements to be deleted from that index</p>
</li>
<li><p><code>**element1, …, elementN**</code> is the element(s) to be added</p>
</li>
</ul>
<p><strong><em>Removing items</em></strong></p>
<blockquote>
<p><em>after running</em> <strong><em>splice()</em></strong> , it returns the array with the item(s) removed and removes it from the original array.</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> colors = [<span class="hljs-string">'green'</span>, <span class="hljs-string">'yellow'</span>, <span class="hljs-string">'blue'</span>, <span class="hljs-string">'purple'</span>];
colors.splice(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>);
<span class="hljs-built_in">console</span>.log(colors); <span class="hljs-comment">// ["purple"]</span>
<span class="hljs-comment">// deletes ["green", "yellow", "blue"]</span>
</code></pre>
<blockquote>
<p><strong><em>NB</em></strong>: The deleteCount does not include the last index in range.</p>
</blockquote>
<p>If the second parameter is not declared, every element starting from the given index will be removed from the array:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> colors = [<span class="hljs-string">'green'</span>, <span class="hljs-string">'yellow'</span>, <span class="hljs-string">'blue'</span>, <span class="hljs-string">'purple'</span>];
colors.splice(<span class="hljs-number">3</span>);
<span class="hljs-built_in">console</span>.log(colors); <span class="hljs-comment">// ["green", "yellow", "blue"]</span>
<span class="hljs-comment">// deletes ['purple']</span>
</code></pre>
<p>In the next example we will remove 3 elements from the array and replace them with more items:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> schedule = [<span class="hljs-string">'I'</span>, <span class="hljs-string">'have'</span>, <span class="hljs-string">'a'</span>, <span class="hljs-string">'meeting'</span>, <span class="hljs-string">'tommorrow'</span>];
<span class="hljs-comment">// removes 4 first elements and replace them with another</span>
schedule.splice(<span class="hljs-number">0</span>, <span class="hljs-number">4</span>, <span class="hljs-string">'we'</span>, <span class="hljs-string">'are'</span>, <span class="hljs-string">'going'</span>, <span class="hljs-string">'to'</span>, <span class="hljs-string">'swim'</span>);
<span class="hljs-built_in">console</span>.log(schedule); 
<span class="hljs-comment">// ["we", "are", "going", "to", "swim", "tommorrow"]</span>
</code></pre>
<p><strong><em>Adding items</em></strong></p>
<p>To add items, we need to set the <code>deleteCount</code> to zero</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> schedule = [<span class="hljs-string">'I'</span>, <span class="hljs-string">'have'</span>, <span class="hljs-string">'a'</span>, <span class="hljs-string">'meeting'</span>, <span class="hljs-string">'with'</span>];
<span class="hljs-comment">// adds 3 new elements to the array</span>
schedule.splice(<span class="hljs-number">5</span>, <span class="hljs-number">0</span>, <span class="hljs-string">'some'</span>, <span class="hljs-string">'clients'</span>, <span class="hljs-string">'tommorrow'</span>);
<span class="hljs-built_in">console</span>.log(schedule); 
<span class="hljs-comment">// ["I", "have", "a", "meeting", "with", "some", "clients", "tommorrow"]</span>
</code></pre>
<h3 id="heading-slice">slice()</h3>
<blockquote>
<p><em>This method is similar to</em> <code>splice()</code> but very different. It returns subarrays instead of substrings.</p>
</blockquote>
<p>This method <strong>copies</strong> a given part of an array and returns that copied part as a new array. <strong>It does not change the original array.</strong></p>
<p>The syntax is:</p>
<pre><code class="lang-python">array.slice(start, end)
</code></pre>
<p>Here’s a basic example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>]
numbers.slice(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>)
<span class="hljs-comment">// returns [1, 2, 3]</span>
<span class="hljs-built_in">console</span>.log(numbers) <span class="hljs-comment">// returns the original array</span>
</code></pre>
<p>The best way to use <code>slice()</code> is to assign it to a new variable.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> message = <span class="hljs-string">'congratulations'</span>
<span class="hljs-keyword">const</span> abbrv = message.slice(<span class="hljs-number">0</span>, <span class="hljs-number">7</span>) + <span class="hljs-string">'s!'</span>; 
<span class="hljs-built_in">console</span>.log(abbrv) <span class="hljs-comment">// returns "congrats!"</span>
</code></pre>
<h3 id="heading-split">split()</h3>
<p>This method is used for <strong>strings</strong>. It divides a string into substrings and returns them as an array.</p>
<p>Here’s the syntax:string.split(separator, limit);</p>
<ul>
<li><p>The <code>**separator**</code> here defines how to split a string either by a comma.</p>
</li>
<li><p>The <code>**limit**</code> determines the number of splits to be carried out</p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> firstName = <span class="hljs-string">'Bolaji'</span>;
<span class="hljs-comment">// return the string as an array</span>
firstName.split() <span class="hljs-comment">// ["Bolaji"]</span>
</code></pre>
<p>another example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> firstName = <span class="hljs-string">'hello, my name is bolaji, I am a dev.'</span>;
firstName.split(<span class="hljs-string">','</span>, <span class="hljs-number">2</span>); <span class="hljs-comment">// ["hello", " my name is bolaji"]</span>
</code></pre>
<blockquote>
<p><strong><em>NB:</em></strong> <em>If we declare an empty array, like this</em> <code>firstName.split('');</code> <em>then each item in the string will be divided as substrings</em>:</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> firstName = <span class="hljs-string">'Bolaji'</span>;
firstName.split(<span class="hljs-string">''</span>) <span class="hljs-comment">// ["B", "o", "l", "a", "j", "i"]</span>
</code></pre>
<h3 id="heading-indexof">indexOf()</h3>
<p>This method looks for an item in an array and returns <strong>the index</strong> where it was found else it returns <code>-1</code></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'orange'</span>, <span class="hljs-literal">false</span>, <span class="hljs-number">3</span>]
fruits.indexOf(<span class="hljs-string">'orange'</span>); <span class="hljs-comment">// returns 1</span>
fruits.indexOf(<span class="hljs-number">3</span>); <span class="hljs-comment">// returns 3</span>
friuts.indexOf(<span class="hljs-literal">null</span>); <span class="hljs-comment">// returns -1 (not found)</span>
</code></pre>
<h3 id="heading-lastindexof">lastIndexOf()</h3>
<p>This method works the same way <strong>indexOf()</strong> does except that it works from right to left. It returns the last index where the item was found</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'orange'</span>, <span class="hljs-literal">false</span>, <span class="hljs-number">3</span>, <span class="hljs-string">'apple'</span>]
fruits.lastIndexOf(<span class="hljs-string">'apple'</span>); <span class="hljs-comment">// returns 4</span>
</code></pre>
<h3 id="heading-filter">filter()</h3>
<p>This method creates a new array if the items of an array pass a certain condition.</p>
<p>The syntax is:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> results = array.filter(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">item, index, array</span>) </span>{
  <span class="hljs-comment">// returns true if the item passes the filter</span>
});
</code></pre>
<p>Example:</p>
<p>Checks users from Nigeria</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> countryCode = [<span class="hljs-string">'+234'</span>, <span class="hljs-string">'+144'</span>, <span class="hljs-string">'+233'</span>, <span class="hljs-string">'+234'</span>];
<span class="hljs-keyword">const</span> nigerian = countryCode.filter( <span class="hljs-function"><span class="hljs-params">code</span> =&gt;</span> code === <span class="hljs-string">'+234'</span>);
<span class="hljs-built_in">console</span>.log(nigerian); <span class="hljs-comment">// ["+234", "+234"]</span>
</code></pre>
<h3 id="heading-map">map()</h3>
<p>This method creates a new array by manipulating the values in an array.</p>
<p>Example:</p>
<p>Displays usernames on a page. (Basic friend list display)</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> userNames = [<span class="hljs-string">'tina'</span>, <span class="hljs-string">'danny'</span>, <span class="hljs-string">'mark'</span>, <span class="hljs-string">'bolaji'</span>];
<span class="hljs-keyword">const</span> display = userNames.map(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> {
<span class="hljs-keyword">return</span> <span class="hljs-string">'&lt;li&gt;'</span> + item + <span class="hljs-string">'&lt;/li&gt;'</span>;
})
<span class="hljs-keyword">const</span> render = <span class="hljs-string">'&lt;ul&gt;'</span> + display.join(<span class="hljs-string">''</span>) + <span class="hljs-string">'&lt;/ul&gt;'</span>;
<span class="hljs-built_in">document</span>.write(render);
</code></pre>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*obuBZKFb5vKmUP7D4TX2XA.png" alt="Image" width="344" height="134" loading="lazy"></p>
<p>another example:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// adds dollar sign to numbers</span>
<span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">10</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">6</span>];
<span class="hljs-keyword">const</span> dollars = numbers.map( <span class="hljs-function"><span class="hljs-params">number</span> =&gt;</span> <span class="hljs-string">'$'</span> + number);
<span class="hljs-built_in">console</span>.log(dollars);
<span class="hljs-comment">// ['$10', '$3', '$4', '$6'];</span>
</code></pre>
<h3 id="heading-reduce">reduce()</h3>
<p>This method is good for calculating totals.</p>
<p><strong>reduce()</strong> is used to calculate a single value based on an array.</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> value = array.reduce(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">previousValue, item, index, array</span>) </span>{
  <span class="hljs-comment">// ...</span>
}, initial);
</code></pre>
<p>example:</p>
<blockquote>
<p><em>To loop through an array and sum all numbers in the array up, we can use the for of loop.</em></p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">100</span>, <span class="hljs-number">300</span>, <span class="hljs-number">500</span>, <span class="hljs-number">70</span>];
<span class="hljs-keyword">let</span> sum = <span class="hljs-number">0</span>;
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> n <span class="hljs-keyword">of</span> numbers) {
sum += n;
}
<span class="hljs-built_in">console</span>.log(sum);
</code></pre>
<p>Here’s how to do same with <code>reduce()</code></p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">100</span>, <span class="hljs-number">300</span>, <span class="hljs-number">500</span>, <span class="hljs-number">70</span>];
<span class="hljs-keyword">const</span> sum = numbers.reduce(<span class="hljs-function">(<span class="hljs-params">accummulator, value</span>) =&gt;</span>
accummulator + value
, <span class="hljs-number">0</span>);
<span class="hljs-built_in">console</span>.log(sum); <span class="hljs-comment">// 970</span>
</code></pre>
<blockquote>
<p><em>If you omit the initial value, the total will by default start from the first item in the array.</em></p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">100</span>, <span class="hljs-number">300</span>, <span class="hljs-number">500</span>, <span class="hljs-number">70</span>];
<span class="hljs-keyword">const</span> sum = numbers.reduce(<span class="hljs-function">(<span class="hljs-params">accummulator, value</span>) =&gt;</span> accummulator + value);
<span class="hljs-built_in">console</span>.log(sum); <span class="hljs-comment">// still returns 970</span>
</code></pre>
<p>The snippet below shows how the <strong>reduce()</strong> method works with all four arguments.</p>
<p><strong>source: MDN Docs</strong></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*Cbd9qR_vy71qZjEQCFpCLQ.png" alt="Image" width="800" height="476" loading="lazy"></p>
<p>More insights into the <strong>reduce()</strong> method and various ways of using it can be found <a target="_blank" href="https://medium.freecodecamp.org/reduce-f47a7da511a9">here</a> and <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce">here</a>.</p>
<h3 id="heading-foreach">forEach()</h3>
<p>This method is good for iterating through an array.</p>
<p>It applies a function on all items in an array</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> colors = [<span class="hljs-string">'green'</span>, <span class="hljs-string">'yellow'</span>, <span class="hljs-string">'blue'</span>];
colors.forEach(<span class="hljs-function">(<span class="hljs-params">item, index</span>) =&gt;</span> <span class="hljs-built_in">console</span>.log(index, item));
<span class="hljs-comment">// returns the index and the every item in the array</span>
<span class="hljs-comment">// 0 "green"</span>
<span class="hljs-comment">// 1 "yellow"</span>
<span class="hljs-comment">// 2 "blue"</span>
</code></pre>
<p>iteration can be done without passing the index argument</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> colors = [<span class="hljs-string">'green'</span>, <span class="hljs-string">'yellow'</span>, <span class="hljs-string">'blue'</span>];
colors.forEach(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> <span class="hljs-built_in">console</span>.log(item));
<span class="hljs-comment">// returns every item in the array</span>
<span class="hljs-comment">// "green"</span>
<span class="hljs-comment">// "yellow"</span>
<span class="hljs-comment">// "blue"</span>
</code></pre>
<h3 id="heading-every">every()</h3>
<p>This method checks if all items in an array pass the specified condition and return<code>true</code> if passed, else <code>false</code>.</p>
<blockquote>
<p><em>check if all numbers are positive</em></p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">-1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> allPositive = numbers.every(<span class="hljs-function">(<span class="hljs-params">value</span>) =&gt;</span> {
<span class="hljs-keyword">return</span> value &gt;= <span class="hljs-number">0</span>;
})
<span class="hljs-built_in">console</span>.log(allPositive); <span class="hljs-comment">// would return false</span>
</code></pre>
<h3 id="heading-some">some()</h3>
<p>This method checks if an item (one or more) in an array pass the specified condition and return true if passed, else false.</p>
<blockquote>
<p><em>c_hecks if at least one number is positive</em>_</p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">-1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> atLeastOnePositive = numbers.some(<span class="hljs-function">(<span class="hljs-params">value</span>) =&gt;</span> {
<span class="hljs-keyword">return</span> value &gt;= <span class="hljs-number">0</span>;
})
<span class="hljs-built_in">console</span>.log(atLeastOnePositive); <span class="hljs-comment">// would return true</span>
</code></pre>
<h3 id="heading-includes">includes()</h3>
<p>This method checks if an array contains a certain item. It is similar to <code>.some()</code>, but instead of looking for a specific condition to pass, it checks if the array contains a specific item.</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> users = [<span class="hljs-string">'paddy'</span>, <span class="hljs-string">'zaddy'</span>, <span class="hljs-string">'faddy'</span>, <span class="hljs-string">'baddy'</span>];
users.includes(<span class="hljs-string">'baddy'</span>); <span class="hljs-comment">// returns true</span>
</code></pre>
<p>If the item is not found, it returns <code>false</code></p>
<hr>
<p>There are more array methods, this is just a few of them. Also, there are tons of other actions that can be performed on arrays, try checking MDN docs <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/">here</a>for deeper insights.</p>
<h3 id="heading-summary">Summary</h3>
<ul>
<li><p><strong>toString()</strong> converts an array to a string separated by a comma.</p>
</li>
<li><p><strong>join()</strong> combines all array elements into a string.</p>
</li>
<li><p><strong>concat</strong> combines two arrays together or add more items to an array and then return a new array.</p>
</li>
<li><p><strong>push()</strong> adds item(s) to the end of an array and <strong>changes</strong> the original array.</p>
</li>
<li><p><strong>pop()</strong> removes the last item of an array and <strong>returns</strong> it</p>
</li>
<li><p><strong>shift()</strong> removes the first item of an array and <strong>returns</strong> it</p>
</li>
<li><p><strong>unshift()</strong> adds an item(s) to the beginning of an array and <strong>changes</strong> the original array.</p>
</li>
<li><p><strong>splice()</strong> c<strong>hanges</strong> an array, by adding, removing and inserting elements.</p>
</li>
<li><p><strong>slice()</strong> copies a given part of an array and returns that copied part as a new array. <strong>It does not change the original array.</strong></p>
</li>
<li><p><strong>split()</strong> divides a string into substrings and returns them as an array.</p>
</li>
<li><p><strong>indexOf()</strong> looks for an item in an array and returns <strong>the index</strong> where it was found else it returns <code>-1</code></p>
</li>
<li><p><strong>lastIndexOf()</strong> looks for an item from right to left and returns the last index where the item was found.</p>
</li>
<li><p><strong>filter()</strong> creates a new array if the items of an array pass a certain condition.</p>
</li>
<li><p><strong>map()</strong> creates a new array by manipulating the values in an array.</p>
</li>
<li><p><strong>reduce()</strong> calculates a single value based on an array.</p>
</li>
<li><p><strong>forEach()</strong> iterates through an array, it applies a function on all items in an array</p>
</li>
<li><p><strong>every()</strong> checks if all items in an array pass the specified condition and return true if passed, else false.</p>
</li>
<li><p><strong>some()</strong> checks if an item (one or more) in an array pass the specified condition and return true if passed, else false.</p>
</li>
<li><p><strong>includes()</strong> checks if an array contains a certain item.</p>
</li>
</ul>
<hr>
<p>Let’s wrap it here; Arrays are powerful and using methods to manipulate them creates the Algorithms real-world applications use.</p>
<p>Let's do a create a small function, one that converts a post title into a urlSlug.</p>
<blockquote>
<p><strong><em>URL slug</em></strong> is the exact address of a specific page or post on your site.</p>
</blockquote>
<p>When you write an article on <strong>Freecodecamp News</strong> or any other writing platform, your post title is automatically converted to a slug with white spaces removed, characters turned to lowercase and each word in the title separated by a hyphen.</p>
<p>Here’s a basic function that does that using some of the methods we learnt just now.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> url = <span class="hljs-string">'https://bolajiayodeji.com/'</span>
<span class="hljs-keyword">const</span> urlSlug = <span class="hljs-function">(<span class="hljs-params">postTitle</span>) =&gt;</span> {
<span class="hljs-keyword">let</span> postUrl = postTitle.toLowerCase().split(<span class="hljs-string">' '</span>);
<span class="hljs-keyword">let</span> postSlug = <span class="hljs-string">`<span class="hljs-subst">${url}</span>`</span> + postUrl.join(<span class="hljs-string">'-'</span>);
<span class="hljs-keyword">return</span> postSlug;
}
<span class="hljs-keyword">let</span> postTitle = <span class="hljs-string">'Introduction to Chrome Lighthouse'</span>
<span class="hljs-built_in">console</span>.log(urlSlug(postTitle));
<span class="hljs-comment">// https://bolajiayodeji.com/introduction-to-chrome-lighthouse</span>
</code></pre>
<p>in <code>postUrl</code>, we convert the string to lowercase then we use the **split()**method to convert the string into substrings and returns it in an array</p>
<pre><code class="lang-python">[<span class="hljs-string">"introduction"</span>, <span class="hljs-string">"to"</span>, <span class="hljs-string">"chrome"</span>, <span class="hljs-string">"lighthouse"</span>]
</code></pre>
<p>in <code>post slug</code> we join the returned array with a hyphen and then concatenate it to the category string and main <code>url</code>.</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> postSlug = <span class="hljs-string">`<span class="hljs-subst">${url}</span>`</span> + postUrl.join(<span class="hljs-string">'-'</span>);
postUrl.join(<span class="hljs-string">'-'</span>) <span class="hljs-comment">// introduction-to-chrome-lighthouse</span>
</code></pre>
<p>That’s it, pretty simple, right? :)</p>
<hr>
<p>If you’re just getting started with JavaScript, you should check this repository <a target="_blank" href="https://github.com/BolajiAyodeji/js-code-snippets">here</a>, I’m compiling a list of basic JavaScript snippets ranging from</p>
<ul>
<li><p>Arrays</p>
</li>
<li><p>Control flow</p>
</li>
<li><p>Functions</p>
</li>
<li><p>Objects</p>
</li>
<li><p>Operators</p>
</li>
</ul>
<p>Don’t forget to Star and share! :)</p>
<p>PS: This article was first published on my blog <a target="_blank" href="https://www.bolajiayodeji.com/manipulating-arrays-in-javascript/">here</a></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
