<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Alan Constantino</title>
    <description>The latest articles on Forem by Alan Constantino (@alanjc).</description>
    <link>https://forem.com/alanjc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F306529%2F9501a1e2-6a73-45df-8ef3-dd3018c0f28d.jpeg</url>
      <title>Forem: Alan Constantino</title>
      <link>https://forem.com/alanjc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/alanjc"/>
    <language>en</language>
    <item>
      <title>How to Create and Host Your First Website With Github</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Sun, 06 Feb 2022 18:02:39 +0000</pubDate>
      <link>https://forem.com/alanjc/how-to-create-and-host-your-first-website-with-github-3ga4</link>
      <guid>https://forem.com/alanjc/how-to-create-and-host-your-first-website-with-github-3ga4</guid>
      <description>&lt;p&gt;&lt;a href="https://blog.alanjc.com/donate.html" rel="noopener noreferrer"&gt;&lt;em&gt;If you found this article useful consider donating.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com" rel="noopener noreferrer"&gt;&lt;em&gt;This article was originally published on my blog.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article I'll teach you how to create your very own website and host it through GitHub completely for free. Let's get started!&lt;/p&gt;

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

&lt;p&gt;Firstly, you'll need to create a &lt;a href="https://github.com/signup" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; account if you don't have one already.&lt;/p&gt;

&lt;p&gt;Once that is complete you'll want to create a new public repository with the following name (case sensitivity doesn't matter):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;your_github_username&amp;gt;.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Now that you've created the repository you'll want to clone it to your local machine with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/&amp;lt;username&amp;gt;/&amp;lt;username&amp;gt;.github.io.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;If you don't have &lt;code&gt;git&lt;/code&gt; installed you can follow the instructions &lt;a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git" rel="noopener noreferrer"&gt;here&lt;/a&gt; to install it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now we can move on to actually creating the website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Website Creation
&lt;/h2&gt;

&lt;p&gt;You can write your own HTML and CSS to create your website however, for the purposes of this tutorial I'll be using a template from &lt;a href="https://html5up.net/" rel="noopener noreferrer"&gt;HTML5Up&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://html5up.net/" rel="noopener noreferrer"&gt;HTML5Up&lt;/a&gt; is a place where you can download and use premade HTML5 website templates for your own purposes completely for free.&lt;/p&gt;

&lt;p&gt;After choosing and downloading your template, I'll be using the &lt;a href="https://html5up.net/aerial/download" rel="noopener noreferrer"&gt;Aerial&lt;/a&gt; theme, you'll want to unzip the contents of the file to the GitHub directory you just cloned onto your machine.&lt;/p&gt;

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

&lt;p&gt;Now your repository should look something like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;username&amp;gt;.github.io/
├── assets/
├── index.html
├── LICENSE.txt
└── README.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can go ahead and customize the HTML and CSS files to your liking but for this tutorial I'll just leave them as is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Uploading Your Files to Your Repository
&lt;/h2&gt;

&lt;p&gt;You're almost done! Now you need to push your changes up to your GitHub repository.&lt;/p&gt;

&lt;p&gt;To push your changes to your repository you'll want to use either the &lt;a href="https://docs.github.com/en/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line" rel="noopener noreferrer"&gt;command line&lt;/a&gt; or &lt;a href="https://desktop.github.com/" rel="noopener noreferrer"&gt;GitHub Desktop&lt;/a&gt; which is a GUI interface for working with GitHub repositories.&lt;/p&gt;

&lt;p&gt;For the sake of simplicity I'll use GitHub Desktop to push the changes to my repository.&lt;/p&gt;

&lt;p&gt;Upon launching GitHub Desktop you'll want to sign in and towards the top left of the application under the "File" option, you'll want to click on "Add local repository" and choose the repository you just cloned to your machine not too long ago.&lt;/p&gt;

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

&lt;p&gt;Next you'll want to commit your changes to your main branch by clicking the blue button towards the bottom left side.&lt;/p&gt;

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

&lt;p&gt;Great! Finally, you'll want to publish your branch by clicking on the "Publish branch" button towards the top left side of the application so your changes appear on GitHub.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Checking Your Website
&lt;/h2&gt;

&lt;p&gt;Now you should be done! Congrats!&lt;/p&gt;

&lt;p&gt;GitHub should be smart enough to publish your website automatically.&lt;/p&gt;

&lt;p&gt;To make sure our website is live, go to the repository on GitHub and under the "Settings" tab, go to the "Pages" section.&lt;/p&gt;

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

&lt;p&gt;If you don't see a green alert box saying your website is published (i.e. it's still a blue alert box) you just have to wait.&lt;/p&gt;

&lt;p&gt;After a couple of minutes, GitHub should publish your website automatically at the following address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://&amp;lt;username&amp;gt;.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If for some reason GitHub didn't detect your page automatically, you'll simply want to update the branch GitHub pages is pointing to. You have to make sure it points to the &lt;code&gt;main&lt;/code&gt; branch and the &lt;code&gt;root&lt;/code&gt; folder.&lt;/p&gt;

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

&lt;p&gt;Congratulations, you have now published your very first website!&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Optional: Custom Domain Name
&lt;/h2&gt;

&lt;p&gt;As an optional step, I'll be showing you how to add a custom domain to your website.&lt;/p&gt;

&lt;p&gt;First you'll want to buy your domain. My go to place for buying domains is &lt;a href="https://www.namecheap.com/" rel="noopener noreferrer"&gt;NameCheap&lt;/a&gt; but you can use any domain provider.&lt;/p&gt;

&lt;p&gt;Once you've bought your domain, you'll want to configure your domain provider's DNS settings to point to the GitHub servers by adding the following four IP addresses as &lt;code&gt;A Record&lt;/code&gt;'s:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;





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

&lt;/div&gt;





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

&lt;/div&gt;





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

&lt;/div&gt;



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

&lt;p&gt;Next you'll want to create a &lt;code&gt;CNAME&lt;/code&gt; and make sure it points to your GitHub website like so:&lt;/p&gt;

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

&lt;p&gt;Now head over to the local GitHub repository you cloned and add a file called &lt;code&gt;CNAME&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Make sure it doesn't have a file extension and it's just the name &lt;code&gt;CNAME&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;Now inside of &lt;code&gt;CNAME&lt;/code&gt; add the name of the domain you just purchased.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then you want to go to GitHub Desktop and&lt;br&gt;
commit and publish your changes just like we did when we initially published our website.&lt;/p&gt;

&lt;p&gt;You're almost done!&lt;/p&gt;

&lt;p&gt;Finally you'll want to head over to your repository on GitHub and under the Settings tab in the Pages section, make sure that the custom domain listed is the one you wrote in the &lt;code&gt;CNAME&lt;/code&gt; file.&lt;/p&gt;

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

&lt;p&gt;Congratulations! Now you have a website with a custom domain!&lt;/p&gt;

&lt;p&gt;If you're still unsure or are stuck in adding a custom domain to your website you can go &lt;a href="https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site" rel="noopener noreferrer"&gt;here&lt;/a&gt; for a more detailed explanation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com/donate.html" rel="noopener noreferrer"&gt;&lt;em&gt;If you found this article useful consider donating.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com" rel="noopener noreferrer"&gt;&lt;em&gt;This article was originally published on my blog.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>Creating Aliases on Linux and Mac</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Wed, 13 Jan 2021 05:23:36 +0000</pubDate>
      <link>https://forem.com/alanjc/creating-aliases-on-linux-and-mac-11ol</link>
      <guid>https://forem.com/alanjc/creating-aliases-on-linux-and-mac-11ol</guid>
      <description>&lt;p&gt;&lt;a href="https://www.patreon.com/alanjc"&gt;If you found this article useful consider donating.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note: The following steps should also apply to MacOS as well.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Are you tired of typing long commands into the terminal? Did you misremember a flag causing an error making you pull out your hair for 2 minutes only to realize that flag doesn't exist? Well worry no more because I'll be showing you how to create aliases for all of those pesky hard-to-remember commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are aliases?
&lt;/h2&gt;

&lt;p&gt;An alias is just a fancy term for nicknaming a certain command.&lt;/p&gt;

&lt;p&gt;They are very useful because instead of typing out a long command with several flags and options, you can nickname it to a shorter command (i.e. give it an alias) and simply remember the shorter command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Editing the ".bashrc" File
&lt;/h2&gt;

&lt;p&gt;The first step in creating aliases is to open up a new terminal window and head over to your user's directory like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /home/&amp;lt;username&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note: By convention, you would usually define your aliases inside of the ".bashrc" file but because defining all of your aliases here can get out of hand pretty quick, we'll be creating a separate file in which we'll be defining our aliases.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From here, you'll want to open up the ".bashrc" file like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano .bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside of ".bashrc" you'll want to paste in the following snippet of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Alias&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; ~/.bash_aliases &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;.&lt;/span&gt; ~/.bash_aliases
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The snippet of code above simply tells bash that if the file ".bash_aliases" exists then load it and run it.&lt;/p&gt;

&lt;p&gt;Now, enter CTRL + X then Y then ENTER to save the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Aliases
&lt;/h2&gt;

&lt;p&gt;Inside of the "/home/" directory, you'll want to create a new file called ".bash_aliases." You can do so with the following command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;It's in this file that you'll want to create your aliases. Open up the ".bash_aliases" file like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano .bash_aliases
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, to create an alias you can do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# MAKING AN ALIAS&lt;/span&gt;
&lt;span class="c"&gt;## alias &amp;lt;name of alias&amp;gt;="&amp;lt;bash command&amp;gt;"&lt;/span&gt;
&lt;span class="c"&gt;##&lt;/span&gt;
&lt;span class="c"&gt;## Example:&lt;/span&gt;
&lt;span class="c"&gt;## alias l="ls -lah"&lt;/span&gt;
&lt;span class="c"&gt;##&lt;/span&gt;
&lt;span class="c"&gt;## To apply changes run the following:&lt;/span&gt;
&lt;span class="c"&gt;## source ~/.bashrc&lt;/span&gt;

&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;l&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ls -lah"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To save your file you can do CTRL + X then Y then ENTER.&lt;/p&gt;

&lt;p&gt;Now, enter one last command to load our aliases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it!&lt;/p&gt;

&lt;p&gt;Now, if you type in your custom alias into the terminal, it would be like if you were actually typing the longer command that you aliased.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note: Every time you edit the ".bash_aliases" file you will have to reload the ".bashrc" file or start a new terminal session for the changes to take effect.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks and have a good one!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.patreon.com/alanjc"&gt;If you found this article useful consider donating.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>bash</category>
    </item>
    <item>
      <title>Creating Your Own Deepfakes Without Coding Experience</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Fri, 14 Aug 2020 17:49:34 +0000</pubDate>
      <link>https://forem.com/alanjc/creating-your-own-deepfakes-without-coding-experience-5f2m</link>
      <guid>https://forem.com/alanjc/creating-your-own-deepfakes-without-coding-experience-5f2m</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://www.patreon.com/alanjc"&gt;If you've found this article useful, consider donating.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://blog.alanjc.com/articles/creating-your-own-deepfakes-without-coding-experience.html"&gt;This article was originally published at my blog.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Deepfake Video Examples&lt;/li&gt;
&lt;li&gt;Background&lt;/li&gt;
&lt;li&gt;Things you'll need&lt;/li&gt;
&lt;li&gt;
Before starting

&lt;ul&gt;
&lt;li&gt;Sign into your Google account&lt;/li&gt;
&lt;li&gt;Connecting to the Google Colab&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Creating your own deepfakes

&lt;ul&gt;
&lt;li&gt;(Step 1) Cloning the Repo&lt;/li&gt;
&lt;li&gt;(Step 2) Change your directory&lt;/li&gt;
&lt;li&gt;(Step 3) Mounting your Google drive folder on Colab&lt;/li&gt;
&lt;li&gt;(Step 4) Downloading the checkpoint (".pth.tar") files&lt;/li&gt;
&lt;li&gt;(Step 5) Create a folder called "first-order-model-motion" in your Google Drive&lt;/li&gt;
&lt;li&gt;(Step 6) Loading your image and video&lt;/li&gt;
&lt;li&gt;(Step 7) Creating the model and loading the checkpoints&lt;/li&gt;
&lt;li&gt;(Step 8) Creating the deepfake&lt;/li&gt;
&lt;li&gt;(Step 9) Saving your deepfake&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Errors&lt;/li&gt;
&lt;li&gt;Using your own image&lt;/li&gt;
&lt;li&gt;Using your own video&lt;/li&gt;
&lt;li&gt;Video tutorials&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Deepfake Video Examples
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=GkOA0X-A58Q"&gt;The Mona Lisa and Elon Musk&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=QmdbtEPlOVA"&gt;Kim Kardashian and Dr. K&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=wSlC39NYenY"&gt;Woman and Edward Snowden&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;In case you don't know, deepfakes are faked media that mimic another person's likeness, &lt;a href="https://www.youtube.com/watch?v=_OqMkZNHWPo"&gt;like so&lt;/a&gt;. This process is achieved through something called &lt;a href="https://en.wikipedia.org/wiki/Deep_learning"&gt;"deep learning,"&lt;/a&gt; hence the name &lt;em&gt;deepfake&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Creating your own deepfakes has been possible for a while now but the problem was that it required a lot of data, computing power, and time.&lt;/p&gt;

&lt;p&gt;But now, thanks to the researchers Aliaksandr Siarohin, Stéphane Lathuilière, Sergey Tulyakov, Elisa Ricci and Nicu Sebe, their paper &lt;a href="https://aliaksandrsiarohin.github.io/first-order-model-website/"&gt;"First Order Motion Model for Image Animation,"&lt;/a&gt; and their &lt;a href="https://github.com/AliaksandrSiarohin/first-order-model"&gt;implementation&lt;/a&gt;, we are now able to create a deepfakes with a single image.&lt;/p&gt;

&lt;p&gt;Better yet, not only can we create deepfakes with a single image, but they also don't take hours or days to make, now they take only mere seconds and at most a couple of minutes. In addition, no coding experience is required.&lt;/p&gt;

&lt;p&gt;If you'd like to understand more of how this works, you can watch this &lt;a href="https://www.youtube.com/watch?v=mUfJOQKdtAk"&gt;video  by Two Minute Papers&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Things you'll need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;a href="https://accounts.google.com/signup?hl=en"&gt;Google account&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;An image of what you want to animate

&lt;ul&gt;
&lt;li&gt;We'll be using a picture of The Mona Lisa&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;A video to extract the animation from

&lt;ul&gt;
&lt;li&gt;We'll be using a video of Leonardo DiCaprio's face&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Some free time&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Before starting
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Sign into your Google account
&lt;/h3&gt;

&lt;p&gt;Once you go to the &lt;a href="https://colab.research.google.com/github/AliaksandrSiarohin/first-order-model/blob/master/demo.ipynb?authuser=1#scrollTo=UCMFMJV7K-ag"&gt;Google colab&lt;/a&gt;, you'll be greeted with a page that looks like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lI5yVNxQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zqjtsg2nmpvw4my8pi3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lI5yVNxQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zqjtsg2nmpvw4my8pi3s.png" alt="Google Colab" width="880" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll need to sign in to your Google account to interact with this document.&lt;/p&gt;

&lt;p&gt;I'd suggest you create a new &lt;a href="https://accounts.google.com/signup?hl=en"&gt;Google account here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Connecting to the Google Colab
&lt;/h3&gt;

&lt;p&gt;After you have signed in, you'll want to actually connect to the Colab.&lt;/p&gt;

&lt;p&gt;To do so click on the connect button at the top right of the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zSaiT-HG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c9dq8ug5v5rp24j2f1s5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zSaiT-HG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c9dq8ug5v5rp24j2f1s5.png" alt="Connecting to the colab" width="880" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don't get any error messages, you can skip straight to (Step 3).&lt;/p&gt;

&lt;p&gt;If you get the following message, that means that you won't be able to use Google's GPU which essentially means you can't follow the tutorial at this time because all the GPUs are being used.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yGtITvlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3e5twskjp1pryt1bpqzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yGtITvlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3e5twskjp1pryt1bpqzc.png" alt="Can't connect to GPU" width="855" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix this, you can either (1) wait and come back later, (2) upgrade to &lt;a href="https://colab.research.google.com/signup"&gt;colab pro&lt;/a&gt;, (3) &lt;a href="https://github.com/AliaksandrSiarohin/first-order-model"&gt;run this repository&lt;/a&gt; locally on your own machine (not covered in this tutorial but you can go &lt;a href="https://www.youtube.com/watch?v=ICvNnrWKHmc"&gt;here&lt;/a&gt; to follow a tutorial), or (4) create another Google account and try again.&lt;/p&gt;

&lt;p&gt;If you click "Connect Without GPU" then, later on, you'll encounter the following error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MBgKc-Nk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hknos7rvw63kictqmpy2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MBgKc-Nk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hknos7rvw63kictqmpy2.png" alt="Error, no GPU" width="880" height="388"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating your own deepfakes
&lt;/h2&gt;

&lt;p&gt;Let's get started creating our own deepfakes.&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 1) Cloning the Repo
&lt;/h3&gt;

&lt;p&gt;Once you are signed in, you'll want to hover over the brackets under the "Clone Repository" header.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qmd6cGCp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vvub12tzbsvtd7v3ghqz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qmd6cGCp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vvub12tzbsvtd7v3ghqz.png" alt="Play button" width="880" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll want to click on that play button to clone their repository.&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 2) Change your directory
&lt;/h3&gt;

&lt;p&gt;Once you finish cloning the repository, you'll want to change your current directory to "first-order-model" by clicking on the next play button like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7rn-59Wz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k9lnrzzp5f28i4ekvcbc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7rn-59Wz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k9lnrzzp5f28i4ekvcbc.png" alt="cd into first-order-model" width="880" height="57"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 3) Mounting your Google drive folder on Colab
&lt;/h3&gt;

&lt;p&gt;Next, you'll want to mount your google drive folder on the colab by clicking the next play button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GJIu8WS1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yz5x2v30tx7607l0q8jr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GJIu8WS1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yz5x2v30tx7607l0q8jr.png" alt="mounting" width="880" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before this can actually happen however, you have to click the link allowing the permission to do so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Lh2wPAU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6v89f7gdoxxcgxynm9bf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Lh2wPAU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6v89f7gdoxxcgxynm9bf.png" alt="Click on the link" width="880" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you'll be prompted to sign in to your Google account again. Sign in to the same google account you originally signed into since starting this tutorial.&lt;/p&gt;

&lt;p&gt;You will then see the following page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GAdXS9b---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ai5rs24r3dyyuiuht46f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GAdXS9b---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ai5rs24r3dyyuiuht46f.png" alt="Auth code" width="880" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy and paste the authorization code into the colab like so and hit enter:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eROFSJVG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g7rv8ffv334ul8v6uwli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eROFSJVG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g7rv8ffv334ul8v6uwli.png" alt="Pasting auth code" width="880" height="158"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 4) Downloading the checkpoint (".pth.tar") files
&lt;/h3&gt;

&lt;p&gt;Now you'll want to click on the following link:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qHjzqxE6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u4ixlh6zn20izcrl79mn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qHjzqxE6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u4ixlh6zn20izcrl79mn.png" alt="Link for downloading .pth.tar files" width="880" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll then get sent to a Google drive that will have several files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8vZWoq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ytnwffk1lble894u1mg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8vZWoq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ytnwffk1lble894u1mg9.png" alt="Drive with .tar files" width="880" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You only need to download the files called "vox-adv-cpk.pth.tar" and "vox-cpk.pth.tar" but I would also suggest you download a video and an image from here too.&lt;/p&gt;

&lt;p&gt;For the purposes of this tutorial, I'll be downloading the aforementioned files as well as "05.png," which is an image of The Mona Lisa, and "10.mp4," which is a video of Leonardo DiCaprio's face.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Downloading the files may take some time so just be patient.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 5) Create a folder called "first-order-model-motion" in your Google Drive
&lt;/h3&gt;

&lt;p&gt;Now you'll want to navigate to your Google Drive and create a folder called "first-order-motion-model" like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r3KooZkj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/57o5qse378d3kvesjkkw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r3KooZkj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/57o5qse378d3kvesjkkw.png" alt="Creating a folder in your Google Drive" width="880" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's in this folder that you'll want to upload the files you just downloaded.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: You can also upload your own video and images but just make sure they are cropped to 256px by 256px.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For the purposes of this tutorial, we'll just be using an image of The Mona Lisa and  a video of Leonardo DiCaprio's face.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gMNGMf7f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/scgwq1ikswlthaqmxrst.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gMNGMf7f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/scgwq1ikswlthaqmxrst.png" alt="Uploaded files" width="880" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This will also take some time so just be patient.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 6) Loading your image and video
&lt;/h3&gt;

&lt;p&gt;Now you want to go back to the Google Colab and under the "Load driving video and source image" header, make sure that 'source_image' and 'driving_video' point to the image and video you uploaded to your google drive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eaMDbaK3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bw5lru7yxgt96kl2lc4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eaMDbaK3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bw5lru7yxgt96kl2lc4a.png" alt="Checking paths" width="880" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Just make sure that the ending of the path has the correct name, i.e. '.../your_image_file.png' and '.../your_video_file.mp4'&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now you want to go ahead and click the play button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7L9TLTgH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o6nllp0sjsqkj0psyy6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7L9TLTgH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o6nllp0sjsqkj0psyy6u.png" alt="Loading your own video and image" width="880" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will take a couple of seconds but once that's done, scroll down and you should see something like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Esx31lhR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b0c6k9npdb579vwvc3zf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Esx31lhR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b0c6k9npdb579vwvc3zf.png" alt="Mona Lisa and DiCaprio" width="709" height="378"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 7) Creating the model and loading the checkpoints
&lt;/h3&gt;

&lt;p&gt;If you scroll down a bit further you should see the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FDYE6Ijh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ri6cfp55uew94dh2aygb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FDYE6Ijh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ri6cfp55uew94dh2aygb.png" alt="Creating the model" width="880" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In the image above you see a square icon because I was already running it but you should see a play icon.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Click on the play button and wait for it to finish.&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 8) Creating the deepfake
&lt;/h3&gt;

&lt;p&gt;Now is the moment you've been waiting for, actually creating the deepfake.&lt;/p&gt;

&lt;p&gt;Scroll down until you see the header "Perform image animation" and click on the play button like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2VxaFjxF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/um6p65gim6k3vbdbfpiq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2VxaFjxF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/um6p65gim6k3vbdbfpiq.png" alt="Creating the deepfake" width="880" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you'll have to wait a little more but once that finished you should see something like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wjce5WqO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/80tzkgttu49a6dz6iqwp.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wjce5WqO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/80tzkgttu49a6dz6iqwp.gif" alt="Deepfake" width="756" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congrats! You just created your first deepfake!&lt;/p&gt;
&lt;h3&gt;
  
  
  (Step 9) Saving your deepfake
&lt;/h3&gt;

&lt;p&gt;Now to actually save it, hover over the video and you should see an icon with three vertical dots.&lt;/p&gt;

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

&lt;p&gt;Click on the icon with three vertical dots and then click download.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PcUblhy1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/utstvmznfop85mvvgxd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PcUblhy1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/utstvmznfop85mvvgxd8.png" alt="Downloading the deepfake" width="880" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And voila, you're done!&lt;/p&gt;
&lt;h2&gt;
  
  
  Errors
&lt;/h2&gt;

&lt;p&gt;If you encounter any errors, you can try to reset the runtime by doing the following:&lt;/p&gt;

&lt;p&gt;Click on the "Runtime" tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nH_w_bN8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qu5gr6xfsve9t8rmxa26.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nH_w_bN8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qu5gr6xfsve9t8rmxa26.png" alt="Runtime 1" width="880" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on "Factory reset runtime."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vz4eMAJU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bede4c7qkc70psb9q441.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vz4eMAJU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bede4c7qkc70psb9q441.png" alt="Runtime 2" width="880" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Yes" and reload the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bRUqLrBi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bjqb4doh49uicqncuem0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bRUqLrBi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bjqb4doh49uicqncuem0.png" alt="Runtime 3" width="880" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you still encounter errors you can watch this video &lt;a href="https://www.youtube.com/watch?v=YsghMCWSa90"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using your own image
&lt;/h2&gt;

&lt;p&gt;To use your own image, simply grab any facial image and crop it to 256px by 256px.&lt;/p&gt;

&lt;p&gt;Also, make sure it's saved in the ".png" format.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Other image types may work, such as .jpg, but .png will give you the best results, at least in my experience.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Using your own video
&lt;/h2&gt;

&lt;p&gt;If you want to use your own video you also have to crop it to 256px by 256px.&lt;/p&gt;

&lt;p&gt;The Google colab provides a tool for you to do this.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Before we can actually crop our own video, we have to upload our video to our Google drive.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Scroll down to the header that says "Running on your data"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PPQGByTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/equi8fffwyoi0awzb9fj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PPQGByTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/equi8fffwyoi0awzb9fj.png" alt="Running on your data" width="880" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll want to paste the following line making sure you replace ".../my_video_file.mp4" to match your file name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!ffmpeg -i /content/gdrive/My\ Drive/first-order-motion-model/my_video_file.mp4 -s 256x256 -c:a copy /content/gdrive/My\ Drive/first-order-motion-model/result.mp4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you should see a video called "result.mp4" in your google drive.&lt;/p&gt;

&lt;p&gt;You can then use this video in step 6 and onward making sure that you use the name "result.mp4" for the video.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The video result can be a hit or miss. I'd suggest you crop the video yourself using video editing software.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Video tutorials
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=peOKeRBU_uQ"&gt;6-minute video tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;In this tutorial, he makes you paste the following line of code: '!pip install PyYAML==5.3.1' at the beginning of Step 1. This line is not necessary.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=zZr3EHLBm4g"&gt;20-minute video tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=ICvNnrWKHmc"&gt;Creating a deepfake without using Google Colab&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>beginners</category>
      <category>ai</category>
    </item>
    <item>
      <title>Water Your Plant Using a Raspberry Pi and Python</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Tue, 10 Mar 2020 07:18:57 +0000</pubDate>
      <link>https://forem.com/alanjc/water-your-plant-using-a-raspberry-pi-and-python-2ddb</link>
      <guid>https://forem.com/alanjc/water-your-plant-using-a-raspberry-pi-and-python-2ddb</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://www.patreon.com/alanjc" rel="noopener noreferrer"&gt;If you've found this article useful, consider donating.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com/articles/water-your-plant-using-a-raspberry-pi-and-python.html" rel="noopener noreferrer"&gt;This article was originally published on my blog.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd like to point out that I am by no means an expert in electronics. If you were to ask me to make a circuit diagram or explain the minutiae of how a certain electronic piece works, I'd draw a complete blank. In reality, I completed this project by just tinkering around with electronic components and having a basic understanding of how electricity works. That being said, you should always exercise caution when working with electronics, especially when using external power sources. &lt;strong&gt;Do your own research before attempting to work with electronics and electricity!&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;I suck at taking care of plants, mostly because I forget to water them. So then I started thinking, "I'm sure someone out there has figured out a way to automate this process." Turns out, there are plenty of people who have. Namely in the form of using an Arduino or a Raspberry Pi to automatically water their plants. In this post, I'll be talking about how I used a Raspberry Pi and Python to automatically water my plant.&lt;/p&gt;

&lt;p&gt;The following are the components I used in this project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://amzn.to/2v4127P" rel="noopener noreferrer"&gt;Raspberry Pi 3 Starter Kit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://amzn.to/39Ckg3e" rel="noopener noreferrer"&gt;12v water pump&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://amzn.to/3aEaqOE" rel="noopener noreferrer"&gt;12v power supply&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://amzn.to/2v0dfu2" rel="noopener noreferrer"&gt;5v Relay&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://amzn.to/2xm3dnZ" rel="noopener noreferrer"&gt;An assortment of jumper wires&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://amzn.to/2VVQpig" rel="noopener noreferrer"&gt;Alligator clip jumper wires&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://amzn.to/38E2AmR" rel="noopener noreferrer"&gt;Silicone tubing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The links above are Amazon Affiliate links. By clicking on a link above and purchasing an item, I'd earn a little slice of the sale.&lt;/p&gt;

&lt;p&gt;Once I had all the components I needed, it was time to do some research. The following are the resources I used to hookup the electronics and have a basic understanding of how they function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.dummies.com/education/science/science-electronics/electronics-basics-fundamentals-of-electricity/" rel="noopener noreferrer"&gt;How electricity works&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=5NxVmg8ZFEc" rel="noopener noreferrer"&gt;How to use a relay&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/My1BDB1ei0E?t=173" rel="noopener noreferrer"&gt;Supplying power to the relay from the Raspberry Pi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/51f3ZazNW-w?t=10" rel="noopener noreferrer"&gt;Hooking up the 12v power supply to the relay&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an image of the GPIO pins on the Raspberry Pi:&lt;/p&gt;

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

&lt;p&gt;First, I started out by hooking up the relay to the Raspberry Pi like so:&lt;/p&gt;

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

&lt;p&gt;The red wire (female to female) leads from the JD_VCC pin on the relay board to the 5V pin (pin 2) on the Raspberry Pi. The orange wire (female to female) leads from the VCC pin on the relay board to the 3.3V pin (pin 1) on the Raspberry Pi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0czjwhrothysxiqa7s5o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0czjwhrothysxiqa7s5o.jpg" alt="Relay close up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By hooking up these wires, we are giving the relay board power. To actually control an individual relay, we need to connect two more pins from the relay board to the Raspberry Pi, the GND (ground) pin and the IN1 pin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjmyzere94uzhwutleokx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjmyzere94uzhwutleokx.jpg" alt="Relay close up 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The black wire (female to female) is the ground wire and that leads from the GND pin on the relay board to any ground pin on the Raspberry Pi (I used pin 34). The white wire (female to female) leads from the IN1 pin on the relay board to pin 12 on the Raspberry Pi. The white wire is what will allow us to turn on and off the relay with code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fo6a2r31jzxumdgxbmeuj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fo6a2r31jzxumdgxbmeuj.jpg" alt="Relay pin close up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can wire up the relay and Raspberry Pi however you wish but just remember to change the pin numbers if you use the code I provide.&lt;/p&gt;

&lt;p&gt;After the relay board and the Raspberry Pi are wired up, I then proceeded to connect the 12V adapter to the individual relay. &lt;strong&gt;DON'T CONNECT THE 12V WALL ADAPTER INTO A WALL OUTLET UNTIL AFTER YOU FINISH WIRING UP EVERYTHING, YOU DON'T WANT TO BE WORKING WITH LIVE POWER.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fteq0k5zn0kph74cbgpn2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fteq0k5zn0kph74cbgpn2.jpg" alt="12v adapter wiring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The 12V power supply comes with a handy adapter that you can use to connect wires. I wired up the red wire (male to male) to the + sign of the adapter and the brown wire (male to male) to the - sign of the adapter. I then added an alligator clip (female to male) to the brown wire.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8egremvotcwbjvp1zfkg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8egremvotcwbjvp1zfkg.jpg" alt="12v adapter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The relay board has four individual relays and each relay has three outputs where you can screw in wires. The output in the middle is where you want to connect the positive lead of an external power supply while the output to the left of that is where you want to connect the positive lead of the device you want to power. This is the same for all of the individual relays on the board.&lt;/p&gt;

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

&lt;p&gt;From the 12v adapter, I hooked up the red wire (positive/power) to the relay output in the middle. I then hooked up a new orange wire (male to male) to the leftmost output on the relay and attached an alligator clip (female to male) to the end of the orange wire.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnkxhrw5yzrolsc3dtsas.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnkxhrw5yzrolsc3dtsas.jpg" alt="Relay output wiring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpwvhn5ko0i94ldf8oefn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpwvhn5ko0i94ldf8oefn.jpg" alt="12v adapter to wall"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6xbwnh3lqy2q2lny7s14.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6xbwnh3lqy2q2lny7s14.jpg" alt="Box in wiring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we just need to connect the alligator clips to the water pump. It doesn't matter in which order you connect the alligator clips to the pump, all you're doing is just setting the water flow.&lt;/p&gt;

&lt;p&gt;The way I set up my water pump, I wanted water to flow from left to right so I connected the black alligator clip to the pin that has a red dot next to it and I connected the other alligator clip to the other pin on the pump. If I were to reverse the way in which the alligator clips are connected, the water would flow would be from right to left.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp8uoix6jby0xxxvtu3kd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp8uoix6jby0xxxvtu3kd.jpg" alt="Water pump alligator clips"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ful1q7x5zylf63n6zccsf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ful1q7x5zylf63n6zccsf.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
Water flows in from the left tube, into the pump, out the right tube, and into the plant.



&lt;p&gt;Finally, we come to the part I'm actually good at, the code. To interface with the GPIO pins on the Raspberry Pi, I used the &lt;a href="https://gpiozero.readthedocs.io/en/stable/index.html" rel="noopener noreferrer"&gt;gpiozero library&lt;/a&gt;. It's really easy to use and abstracts away a lot of the lower-level operations you'd usually need to learn in order to get started interfacing with the GPIO pins. You can find a link to the documentation &lt;a href="https://gpiozero.readthedocs.io/en/stable/index.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Before we can actually get started writing code, you have to hook up your Pi to a monitor, mouse, and keyboard or you can &lt;a href="https://www.raspberrypi.org/documentation/remote-access/ssh/" rel="noopener noreferrer"&gt;SSH into your Pi&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you have logged into your Pi, navigate to your Desktop and create a folder called "run." Inside of "run," you'll have another folder called "classes." Now within the "classes" folder, create a file called "Hardware.py" which should look something like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In this file, I just define a new class called Relay that inherits from the class &lt;a href="https://gpiozero.readthedocs.io/en/stable/api_output.html#outputdevice" rel="noopener noreferrer"&gt;OutputDevice&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next, within the "classes" folder, create a new file called "TimeKeeper.py" which should look like the following:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Essentially, the purpose of this class is to keep track of the current time and the last time our plant gets watered.&lt;/p&gt;

&lt;p&gt;Both "Harware.py" and "TimeKeeper.py" are in the folder called "classes." I then created a new file called "water_plant.py" which I placed outside of the "classes" folder.&lt;/p&gt;

&lt;p&gt;The file "water_plant.py" looks something like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;You can change the value of the "WATERING_TIME" and "SECONDS_TO_WATER" variables to whatever you'd like. The first variable determines at what time during the day the plant should receive water while the latter determines how long the plant will receive water.&lt;/p&gt;

&lt;p&gt;I also set up email reminders so you receive an email whenever your plant gets watered as well as an email every Friday to remind you to check your water level. By default, I've disabled these reminders so the program doesn't crash on start, but if you want to enable them you have to do three things: 1) You have to change lines 26 and 27 to include your Gmail and password 2) You then have to uncomment lines 63, 65, and 68 3) You have to go &lt;a href="https://myaccount.google.com/lesssecureapps?pli=1" rel="noopener noreferrer"&gt;here&lt;/a&gt;, log in with the Gmail you want to receive the reminders on, and toggle the switch to "ON" or else you'll receive an error when you try and send an email using your Gmail account. It's also important to note that the email reminders only work with a Gmail account.&lt;/p&gt;

&lt;p&gt;Now that all the files are set up, you should have something that looks like the following directory tree structure:&lt;/p&gt;

&lt;p&gt;run&lt;br&gt;
├── classes&lt;br&gt;
│   ├── Hardware.py&lt;br&gt;
│   └── TimeKeeper.py&lt;br&gt;
└── water_plant.py&lt;/p&gt;

&lt;p&gt;You can place this "run" folder anywhere on the Raspberry Pi but I just decided to keep it on the Desktop.&lt;/p&gt;

&lt;p&gt;Finally, instead of SSHing into the Pi or hooking it up to a monitor every time we want to run the "water_plant.py" script, I wanted the script to run whenever we turn on the Raspberry Pi so that way we can turn the Pi off and move it anywhere. Once we turn it on, we don't have to SSH into the Pi or connect it to a monitor just to run the script. To do this, we need to use the "crontab" command.&lt;/p&gt;

&lt;p&gt;If you open a terminal window on your Pi, either by hooking it up to a monitor or by SSHing into it and you type in the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo crontab -e&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should see something similar to this:&lt;/p&gt;

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

&lt;p&gt;In this file, you're going to append the following code snippet:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@reboot python3 /home/pi/Desktop/run/water_plant.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then save it by doing CTRL+X → Y → Enter&lt;/p&gt;

&lt;p&gt;Essentially, we just told the Pi "Hey whenever you reboot, run the python script 'water_plant.py' inside the 'run' folder located on our Desktop." If you didn't place the 'run' folder on your Desktop, just update the path to wherever you placed your "water_plant.py" script.&lt;/p&gt;

&lt;p&gt;You can view the full code &lt;a href="https://github.com/AlanConstantino/rpi-plant-project" rel="noopener noreferrer"&gt;here&lt;/a&gt; or you can just clone the repository with the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone &lt;a href="https://github.com/AlanConstantino/rpi-plant-project.git" rel="noopener noreferrer"&gt;https://github.com/AlanConstantino/rpi-plant-project.git&lt;/a&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's it! Now you should have a working Raspberry Pi that waters your plants every 24 hours! It even sends you email reminders every time your plant gets watered as well as every Friday reminding you to check your water level.&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>automation</category>
      <category>electronics</category>
    </item>
    <item>
      <title>Keeping the Footer at the Bottom</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Sun, 23 Feb 2020 21:18:07 +0000</pubDate>
      <link>https://forem.com/alanjc/keeping-the-footer-at-the-bottom-2fhi</link>
      <guid>https://forem.com/alanjc/keeping-the-footer-at-the-bottom-2fhi</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://www.patreon.com/alanjc"&gt;If you've found this article useful, consider donating.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com/articles/keep-the-footer-at-the-bottom.html"&gt;This article was originally published on my blog.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So recently I had to use the &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; tag for a website I was building. To be honest, in all of my web development projects that I've made so far, I've never had the need to use the footer. That was until last week.&lt;/p&gt;

&lt;p&gt;What's the big deal? It's just a footer tag that you include before closing out the body tag right? Sure, but the problem with footers is that by default, they don't stay at the bottom. Let me explain.&lt;/p&gt;

&lt;p&gt;If your body tag were to contain the following:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;your footer would be pushed all the way to the top. This happens because there isn't enough content to fill up the page and push the footer down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6LYdv0Du--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f5wkb7i52latej3v30f9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6LYdv0Du--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f5wkb7i52latej3v30f9.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the most part, if your website has enough content to fill up the page, your footer should be pushed down to the bottom. However, on bigger screens, this might still be an issue.&lt;/p&gt;

&lt;p&gt;So, how do we keep that pesky footer at the bottom? Well, today I'll be showcasing three solutions to this problem. The first and simplest solution is using flexbox, the second solution is using grid, and the final solution is using a wrapper. Alright, let's get started.&lt;/p&gt;

&lt;h3&gt;Flex Solution&lt;/h3&gt;

&lt;p&gt;First, the simplest, and in my opinion, the best solution, using flexbox. I'd say this is the simplest because it isn't that much code to write and it's simple to understand.&lt;/p&gt;

&lt;p&gt;This is what our HTML looks like:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The HTML is going to look pretty much the same for all of these solutions, I'll be sure to point out the differences along the way.&lt;/p&gt;

&lt;p&gt;Very briefly, in our &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;, we have a &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, a &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;, and a &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;. Inside our &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;, we have a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; that just holds some lorem ipsum text.&lt;/p&gt;

&lt;p&gt;This is what our CSS looks like:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Again very briefly, I remove all the padding and margin for everything. Our body is displayed as flex, has a 'flex-direction' of column, its minimum height is 100vh or 100 viewport height, and its background color is blue. As for the header, I just colored it green. Finally, I gave the footer a background color of red and I set its top margin to auto. This is important because, without this, the footer wouldn't stay at the bottom.&lt;/p&gt;

&lt;p&gt;Now our footer looks something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ukfHh4oI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4xwx8ib7uhs80balg184.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ukfHh4oI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4xwx8ib7uhs80balg184.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me explain how this works. We set our &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; to be displayed as a flex column and set its minimum height to be the full size of the viewport height. You can think of the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; as a container that expands for the full height of the page. Now by setting our &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;'s top margin to auto, we're essentially telling it to stay at the bottom of the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; container. And that's how you use CSS flex to keep the footer at the bottom.&lt;/p&gt;

&lt;h3&gt;Grid Solution&lt;/h3&gt;

&lt;p&gt;Let's move on to the second solution, using CSS grid. Now I don't know about you but I don't like grid. I'd much rather use flexbox, but, as much as I hate to admit it, sometimes there is just no avoiding it. &lt;/p&gt;

&lt;p&gt;The HTML code will be exactly the same as for the flex solution, the only thing that will differ will be the CSS link tag.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The CSS for the grid solution looks something like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Just like before, we first remove all the padding and margin for everything. Then we make the html height 100% and I made all the text color white. Next, our body has a minimum height of 100% and is displayed as a grid with 3 rows and has a background color of blue. Those rows will be the header, main, and the footer. The header has a background color of green and will start and end in the first row of the three that we defined for the grid. Finally, our footer will have a background color of red and will start and end at the third row of our grid.&lt;/p&gt;

&lt;p&gt;Now let me explain how this works. In the body, we define three rows, the first and last are of size 'auto' while the row in the middle is a set size of 1fr. We use 'auto' for the first and last rows so they only take up the space they need.&lt;/p&gt;

&lt;p&gt;We then set our header to be the first row of the grid keeping it at the top while setting our footer to the last row in our grid keeping it at the bottom. That's it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kU6ltEgP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e80ncbl8oewy8986lt1p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kU6ltEgP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e80ncbl8oewy8986lt1p.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You could manually define main to be in the second row like the following:&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
main {&lt;br&gt;
  grid-row-start: 2;&lt;br&gt;
  grid-row-end: 2;&lt;br&gt;
}
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;but I just didn't do that.&lt;/p&gt;

&lt;h3&gt;Wrapper Solution&lt;/h3&gt;

&lt;p&gt;Finally, we have reached our last solution which is using a wrapper. The HTML for this solution is as follows:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The only difference here is that we use a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; as a wrapper to wrap our &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt; and our &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; tags. We also give the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; a class of "wrapper."&lt;/p&gt;

&lt;p&gt;The CSS for the wrapper solution is the following:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Just like before, we first remove all the padding and margin from everything. Then we assign background colors to the header, main, and footer. The header is green, the main is blue, and the footer is red. Now, we must define both the html and the body as a height of 100%. Next, we make a class called "wrapper" and give it a minimum height of 100%. Now, this is where things get a little... gross.&lt;/p&gt;

&lt;p&gt;In main, we give it a bottom padding of 30px, this will be the size of the footer. Now in our footer, we give it a height of 30px and a top margin of -30px.&lt;/p&gt;

&lt;p&gt;Let me explain why it needs to be done this way. So our main has a bottom padding of 30px. This is so that when there is enough content on the screen, it doesn't overflow into our footer like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0T8sYR4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f60541jd4mp1x2ff636d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0T8sYR4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f60541jd4mp1x2ff636d.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The height of the footer should also be the same height as the bottom padding for our main, 30px. This should also be applied to the top margin but as a negative, if not then you end up with something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KLupOVaE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y3wxc5jvqnqpcl9wehzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KLupOVaE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y3wxc5jvqnqpcl9wehzu.png" alt="Alt Text" width="880" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that there is a space towards the bottom of the screen in between our &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; and our &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; and that's definitely not what we want. That's why we apply the top margin as a negative while making sure it's the same size as the &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; height and the bottom padding of &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;. Now the footer should be displayed properly:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--znxUzFuG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jbr74f8n9rhea2o6y1g8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--znxUzFuG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jbr74f8n9rhea2o6y1g8.png" alt="Alt Text" width="880" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There we go, much better.&lt;/p&gt;

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

&lt;p&gt;In conclusion, there are many ways to keep the footer at the bottom, however, in this article, I just mentioned three, the flex way, the grid way, and finally the wrapper way.&lt;/p&gt;

&lt;p&gt;All of these solutions are great but the best one, in my opinion, is the flex one. It's easy to implement and you don't have to deal with a grid or a wrapper. The grid solution may be best for when you can't use flexbox or you’re stuck using a grid, while the wrapper solution may be best for when you already know how big the size of the footer is going to be.&lt;/p&gt;

&lt;p&gt;You should keep these solutions in mind when thinking about how you're going to keep that pesky footer at the bottom of the page. You should choose the solution that best fits your needs.&lt;/p&gt;

&lt;p&gt;You can check out the full code &lt;a href="https://github.com/AlanConstantino/web-cheat-sheet/tree/master/examples/keep-footer-at-the-bottom"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks for reading and have a good one!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>5 Simple-To-Use APIs for Beginners</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Mon, 10 Feb 2020 00:47:26 +0000</pubDate>
      <link>https://forem.com/alanjc/5-simple-to-use-apis-for-beginners-2e0n</link>
      <guid>https://forem.com/alanjc/5-simple-to-use-apis-for-beginners-2e0n</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://www.patreon.com/alanjc"&gt;If you've found this article useful, consider donating.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com/articles/5-simple-to-use-apis-for-beginners.html"&gt;This article was originally published on my blog.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Hello! In this article I'll be talking about five simple-to-use APIs to help inspire project ideas. The goal of this post is to inspire you to create a project, whether it be simple or complex, and start using APIs.
&lt;/p&gt;

&lt;h3&gt;What Is an API?&lt;/h3&gt;

&lt;p&gt;
    Before talking about APIs you can use, I think we should understand what an API actually is and what it does.
&lt;/p&gt;

&lt;p&gt;
    API stands for Application Programming Interface. Simply put, an API is what allows programs or services to communicate with other programs or services.
&lt;/p&gt;

&lt;p&gt;
    A great example I came across (don't remember the original source) was thinking of an API as a waiter at a restaurant.
&lt;/p&gt;

&lt;p&gt;
    So you, the customer, talk to a waiter to get your food. The waiter then talks to the chef who actually makes your food. The chef gives the food to the waiter. Finally, the waiter then gives the food to you.
&lt;/p&gt;

&lt;p&gt;
    Unpacking this example, the user (customer) sends a request to an API (waiter). The API (waiter) then talks to the service you want to reach, usually a database (chef). That database (chef) then sends data (food) back to the API (waiter). And finally, the API (waiter) then gives you back data (food).
&lt;/p&gt;

&lt;p&gt;
    Great! Now that we know what an API is and have a general understanding of how it works, we can now move on to talking about simple APIs you can use.
&lt;/p&gt;

&lt;h3&gt;&lt;a href="https://github.com/15Dkatz/official_joke_api"&gt;Official Joke API&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;
    The first API I'll be talking about will the simplest one on the list: &lt;a href="https://github.com/15Dkatz/official_joke_api"&gt; The Official Joke
                                API&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
    This API is extremely simple to use, you basically use a URL to connect to one of the API's endpoints and it returns back data in JSON format. Easy! No need for pesky API keys.
&lt;/p&gt;

&lt;p&gt;
    For example, if we wanted a random joke from this API, we would simply use this URL:
    &lt;code&gt;https://official-joke-api.appspot.com/random_joke&lt;/code&gt; and it would return one random joke.
&lt;/p&gt;

&lt;p&gt;
    You can also grab more than one joke by using the following URL:
    &lt;code&gt;https://official-joke-api.appspot.com/random_ten&lt;/code&gt;. Now, the API will return 10 random jokes instead of just one.
&lt;/p&gt;

&lt;p&gt;
    You can check out the full list of endpoints &lt;a href="https://github.com/15Dkatz/official_joke_api#endpoints"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
    I built a simple Discord bot using this API. Basically, whenever you give the bot the following command, $joke, it returns one joke. You can check out the source code and images of the bot &lt;a href="https://github.com/AlanConstantino/discord-joke-bot"&gt;here&lt;/a&gt;. You can also check out a step-by-step guide on how to create the exact same Discord bot &lt;a href="https://blog.alanjc.com/articles/creating-a-discord-bot-with-python.html"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;h3&gt;&lt;a href="https://shibe.online/"&gt;Shibe.Online API&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;
    The next API I'll be talking about will be the shibes.online API. This is similar to the Jokes API I previously mentioned except instead of giving you back jokes it gives you back shibes. And who doesn't like shibes, am I right?
&lt;/p&gt;

&lt;p&gt;
    You can find more info about this API &lt;a href="https://shibe.online/"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
    To use this API you simply have to use this URL:
    &lt;code&gt;http://shibe.online/api/shibes?count=[1-100]&amp;amp;urls=[true/false]&amp;amp;httpsUrls=[true/false]&lt;/code&gt; and replace every "[]" with a parameter.
&lt;/p&gt;

&lt;p&gt;
    An example query would be something like the following:
    &lt;code&gt;http://shibe.online/api/shibes?count=100&amp;amp;urls=true&amp;amp;httpsUrls=true&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
    The URL above would give me 100 links to shibe images in JSON format. It would also make sure that all images are URLs and that those URLs use https instead of http because of the true parameters we pass it.
&lt;/p&gt;

&lt;p&gt;
    I created a simple website that generates shapes based on user input and I used this API to embed images of shibes inside of those shapes. You can find the source code and images of the website I built &lt;a href="https://github.com/AlanConstantino/shiba-shapes"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
    A similar project idea would be to create a random number of circles on a page and have shibe images embedded within each of those circles every time a user visits the site. You can also have those circles move around and bounce off the edge of the screen. And if you think that was too easy, you can try adding collision detection between those circles so they bounce off of each other as well as the sides of the screen.
&lt;/p&gt;

&lt;h3&gt;
&lt;a href="https://wheretheiss.at/w/developer"&gt;
                                Where the ISS At? API
                            &lt;/a&gt;
                        &lt;/h3&gt;

&lt;p&gt;
    This API is probably the coolest on this list in my opinion just because you're' able to track the ISS with it. Yes, you read that right, the International Space Station!
&lt;/p&gt;

&lt;p&gt;
    You can find more info about the API &lt;a href="https://wheretheiss.at/w/developer"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
    This API gives you back data about the ISS in JSON format. You use the following URL
    &lt;code&gt;https://api.wheretheiss.at/v1/satellites/25544&lt;/code&gt; to get back data about the ISS like latitude, longitude, altitude, velocity, etc.
&lt;/p&gt;

&lt;p&gt;
    I built a website that tracks the ISS in real-time every couple of seconds and updates its location marker on a map. You can find images and the source code &lt;a href="https://github.com/AlanConstantino/iss-tracker"&gt;here&lt;/a&gt;. You can also visit the website itself &lt;a href="https://iss.alanjc.com/"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
    A cooler project you can build with this API is to make a website that notifies you whenever the ISS is overhead your current location.
&lt;/p&gt;

&lt;p&gt;
    A similar API you can use if you don't like "Where the ISS At?" is the
    &lt;a href="http://open-notify.org/Open-Notify-API/"&gt;Open
                                Notify API&lt;/a&gt;. It's a little less accurate but it gives you more information like people aboard the ISS as well as its pass times.
&lt;/p&gt;

&lt;h3&gt;&lt;a href="https://pokeapi.co/"&gt;PokeAPI&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;
    Do you like Pokemon? Did you ever want the power of the pokedex right at your fingertips? Well now you can with this API.
&lt;/p&gt;

&lt;p&gt;
    This API gives you back data about Pokemon, their move sets, encounters, evolutions, items, and much more. You can check out the full documentation
    &lt;a href="https://pokeapi.co/docs/v2.html/#info"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
    You can think of this API as a real-life pokedex that contains all the information about Pokemon that you'd ever want.
&lt;/p&gt;

&lt;p&gt;
    To use this API and get information about Pokemon, you can use the following URL
    &lt;code&gt;https://pokeapi.co/api/v2/pokemon/[pokemon_name]&lt;/code&gt;. Now you just replace
    &lt;code&gt;"[pokemon_name]"&lt;/code&gt; with a Pokemon name or its respective pokedex id and you'll receive back information about that Pokemon.
&lt;/p&gt;

&lt;p&gt;
    The project I built using this API was quite simple. I wanted to learn a little bit of jQuery and I also wanted to learn about CSS grid. So, I created a website that gets the original 151 Pokemon using jQuery and displays them on the screen using CSS grid. You can find the source code and and an image of the website &lt;a href="https://github.com/AlanConstantino/pokemon-jquery"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;h3&gt;
                            &lt;a href="https://opentdb.com/api_config.php"&gt;
                                Open Trivia Database API
                            &lt;/a&gt;
                        &lt;/h3&gt;

&lt;p&gt;
    Finally we get to the final API on this list, the Open Trivia Database API. The Open Trivia Database is an assortment of trivia questions and answers and it has an API you can use for your own projects.
&lt;/p&gt;

&lt;p&gt;
    To use this API, you can go &lt;a href="https://opentdb.com/api_config.php"&gt;here&lt;/a&gt; and fill out their API helper to help you generate a link and get back the data you want.
&lt;/p&gt;

&lt;p&gt;
    To get up and running quickly using this API, you can use the following URL:
    &lt;code&gt;https://opentdb.com/api.php?amount=10&lt;/code&gt; to get back 10 random questions and answers based on different categories.
&lt;/p&gt;

&lt;p&gt;
    I created a Quiz Game which you can visit and play
    &lt;a href="https://quiz.alanjc.com/"&gt;here&lt;/a&gt;. Essentially, whenever you click on a category, it will give you 10 questions based on that category and it keeps track of your overall score. At the end, it tells you how many questions you got right out of 10. You can view the source code and images of this project
    &lt;a href="https://github.com/AlanConstantino/quiz-game"&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;h3&gt;More APIs&lt;/h3&gt;

&lt;p&gt;
    Excited about finding more APIs and possibly even trying out more complex APIs, you can head over to this &lt;a href="https://github.com/public-apis/public-apis#index"&gt;GitHub repo&lt;/a&gt; to check and see a plethora of APIs that are open-source and free to use.
&lt;/p&gt;

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

&lt;p&gt;
    Well that was it for this post. You can use one of the aforementioned APIs to create a project whether it be simple or complex.
&lt;/p&gt;

&lt;p&gt;
    Keep in mind that not all APIs are this easy to use. Some require that you dig through their respective documentation to get a hang of how to make API calls. Others require that you use an API key in order to connect to the API.
&lt;/p&gt;

&lt;p&gt;
    The APIs I mentioned here don't really require much documentation reading and certainly don't require any pesky API keys which are perfect for beginners.
&lt;/p&gt;

&lt;p&gt;
    I hope this post inspired you to pick up an API and create a project with it. As always, thanks for reading and good luck!
&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Creating a Discord Bot With Python</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Sun, 02 Feb 2020 05:11:17 +0000</pubDate>
      <link>https://forem.com/alanjc/creating-a-discord-bot-with-python-33f3</link>
      <guid>https://forem.com/alanjc/creating-a-discord-bot-with-python-33f3</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://www.patreon.com/alanjc"&gt;If you've found this article useful, consider buying me a cup of coffee.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com/articles/creating-a-discord-bot-with-python.html"&gt;This article was originally published on my blog.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article we'll create a Discord bot using Python. The bot we'll be creating today will have a simple purpose, telling jokes. We will give the bot a command and it will return a random joke. This should be simple enough, let's get started!&lt;/p&gt;

&lt;h3&gt;Before Starting&lt;/h3&gt;

&lt;p&gt;I think it'll be useful to understand what an API is before we actually get started. API stands for Application Programming Interface. Simply put, an API is what allows programs or services to communicate with other programs or services.&lt;/p&gt;

&lt;p&gt;A great metaphor I came across (don't remember the original source) was thinking of an API as a waiter at a restaurant.&lt;/p&gt;

&lt;p&gt;So you, the customer, talk to a waiter to get your food. The waiter then talks to the chef who actually makes your food. The chef gives the food to the waiter. Finally, the waiter then gives the food to you.&lt;/p&gt;

&lt;p&gt;Unpacking this metaphor, the user (customer) sends a request to an API (waiter). The API (waiter) then talks to the service you want to reach, usually a database (chef). That database (chef) then sends data (food) back to the API (waiter). And finally, the API (waiter) then gives you back data (food).&lt;/p&gt;

&lt;p&gt;Great! Now that we know what an API is and have a general understanding of how it works, we can now move on to using one.&lt;/p&gt;

&lt;h3&gt;Acquiring the Jokes&lt;/h3&gt;

&lt;p&gt;To actually get the jokes, we'll have to use the &lt;a href="https://github.com/15Dkatz/official_joke_api"&gt;Official Joke
                                API&lt;/a&gt;. This API is
                            extremely easy to use, you just use &lt;a href="https://official-joke-api.appspot.com/random_joke"&gt;this link&lt;/a&gt; and every time
                            you call it, it will return a random joke in JSON format. Simple!
                        &lt;/p&gt;

&lt;h3&gt;Creating a Discord Application&lt;/h3&gt;

&lt;p&gt;
To create a Discord bot and invite it into your own Discord server, you can follow &lt;a href="https://discordpy.readthedocs.io/en/latest/discord.html"&gt;these
                                steps here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;You can name it whatever you'd like but I'll just name it "Jokes-Bot."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Re2azFe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vue4mnye4a0e29kqjoxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Re2azFe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vue4mnye4a0e29kqjoxp.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, under the Settings tab to the left, go to "OAuth2" &amp;gt; "Scopes" and tick the bot option. Then in the same page, go to "Bot Permissions" and tick the Administrator box.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yvpq_bU2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mfs9pecft7973iwj2kz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yvpq_bU2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mfs9pecft7973iwj2kz4.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now copy the link from the "Scopes" section and paste it onto your browser to add the bot to your Discord server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--91mucOEM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w7enwmt3g4hiz8hl3ww0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--91mucOEM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w7enwmt3g4hiz8hl3ww0.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cool! Now just take a note of the Discord bot token in the "Bot" tab because we'll be needing it later.&lt;/p&gt;

&lt;h3&gt;Downloading the Discord.py Library&lt;/h3&gt;

&lt;p&gt;We'll be using the Discord.py library to create our Discord bot.&lt;/p&gt;

&lt;p&gt;
                            To install this library onto your machine you can follow &lt;a href="https://discordpy.readthedocs.io/en/latest/intro.html#installing"&gt;these steps&lt;/a&gt;,
                            or simply run the following command on the command line.
                        &lt;/p&gt;

&lt;p&gt;&lt;code&gt;python3 -m pip install -U discord.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;
                            If you don't already have Python and pip installed you can go &lt;a href="https://realpython.com/installing-python/"&gt;here&lt;/a&gt; to install
                            them.
                        &lt;/p&gt;

&lt;h3&gt;Installing the Requests Module&lt;/h3&gt;

&lt;p&gt;
                            Finally we need to download and install one more thing. To actually send requests and
                            receive data from an API using Python we'll need to download and install the python module
                            &lt;a href="https://requests.readthedocs.io/en/master/"&gt;Requests&lt;/a&gt;.
                        &lt;/p&gt;

&lt;p&gt;Simply type in the following command onto the command line to install this module.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip3 install requests&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now it's finally the time you've all been waiting for, the code.&lt;/p&gt;

&lt;h3&gt;Testing the Bot&lt;/h3&gt;

&lt;p&gt;To test that our bot actually works, copy and paste the following code into your favorite text editor.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;
                            To learn more about what this code does go &lt;a href="https://discordpy.readthedocs.io/en/latest/quickstart.html#a-minimal-bot"&gt;here&lt;/a&gt;.
                        &lt;/p&gt;

&lt;p&gt;Now insert your Discord bot token into the last line where it says "your token here." Save your python file as "discord_joke_bot.py" and then input the following command onto the terminal to run and test your bot.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python3 discord_joke_bot.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If all went well you should see something like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mpAoZVqS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d6hoecr6ccmhpbjb5j7c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mpAoZVqS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d6hoecr6ccmhpbjb5j7c.png" alt="Alt Text" width="880" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can type the following command &lt;code&gt;$hello&lt;/code&gt; into our Discord server and the bot should respond back with "Hello!"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BjqWM1KW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/px14l9mrxir5i7fxusmo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BjqWM1KW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/px14l9mrxir5i7fxusmo.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cool so the bot works.&lt;/p&gt;

&lt;p&gt;Also, whenever we make changes to the bot, you'll have to restart the python script by running it again.&lt;/p&gt;

&lt;h3&gt;Making API Requests With Python&lt;/h3&gt;

&lt;p&gt;Now let's take a look at how to actually make API requests with Python and the Requests module.&lt;/p&gt;

&lt;p&gt;The following code is what we'll be using to make requests to the Joke API.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Let me explain what's going on here.&lt;/p&gt;

&lt;p&gt;On line 1 we import the Requests module.&lt;/p&gt;

&lt;p&gt;Line 3 is the URL we'll be using and I just defined it in the global scope.&lt;/p&gt;

&lt;p&gt;Now on line 6, I define a function named "check_valid_status_code" that will check if the status code from the API is successful or not.&lt;/p&gt;

&lt;p&gt;If the status code is equal to 200, meaning it's a successful call, it will return back the request in JSON format. If it's unsuccessful, it will just return false.&lt;/p&gt;

&lt;p&gt;
                            Most of the time, whenever you make an API call, the API will return a status code. These
                            status codes tell you whether an API call was successful or not. To learn more about status
                            codes check out &lt;a href="https://restfulapi.net/http-status-codes/"&gt;this article&lt;/a&gt;.
                        &lt;/p&gt;

&lt;p&gt;Now on line 13 I define another function named "get_joke." This function, as implied by its name will get a joke.&lt;/p&gt;

&lt;p&gt;First it makes a GET request to the URL we pass it. Then it will call "check_valid_response_code" and store whatever it returns into a variable named "data." Finally it returns the variable "data."&lt;/p&gt;

&lt;h3&gt;Adding the $joke Command&lt;/h3&gt;

&lt;p&gt;We can finally move on to actually adding in our "$joke" command.&lt;/p&gt;

&lt;p&gt;First let's import "joke_api.py" into the "discord_joke_bot.py" file with the following line:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import joke_api.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, in the file named "discord_joke_bot.py," we can simply replace the if statement containing the "$hello" parameter on line 16 with the following if statement.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Let me explain what's going on here.&lt;/p&gt;

&lt;p&gt;So first on line 1, we check if the message we type into Discord starts with the "$joke" string.&lt;/p&gt;

&lt;p&gt;Then on line 2 we call "get_joke" function from the "joke_api.py" file and save it into a variable named "joke."&lt;/p&gt;

&lt;p&gt;The variable "joke" stores a dictionary with the following keys: id, type, setup, and punchline.&lt;/p&gt;

&lt;p&gt;The only dictionary keys we are interested in are "setup" and "punchline."&lt;/p&gt;

&lt;p&gt;Now on line 4 we check if the variable "joke" is "False." If so we just return an error message.&lt;/p&gt;

&lt;p&gt;Else, if it's not false we return the joke setup with "joke['setup']" adding a newline character, '\n' and then adding the joke punchline with "joke['punchline']."&lt;/p&gt;

&lt;p&gt;Now if we test this in our Discord server with our bot we should receive a joke from our bot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IOe6TiHf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u2bm5n1y5whlgssx2m03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IOe6TiHf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u2bm5n1y5whlgssx2m03.png" alt="Alt Text" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great! It works.&lt;/p&gt;

&lt;h3&gt;Complete Code&lt;/h3&gt;

&lt;p&gt;In total we should have two files. Namely the "discord_joke_bot.py" file and the "joke_api.py" file.&lt;/p&gt;

&lt;p&gt;The following is the "discord_joke_bot.py" file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The following is the "joke_api.py" file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Congratulations, you just created your first Discord bot using Python!&lt;/p&gt;

&lt;p&gt;
                            You can also find the complete code over at my &lt;a href="https://github.com/AlanConstantino/discord-joke-bot"&gt;Github&lt;/a&gt;.
                        &lt;/p&gt;

&lt;h3&gt;Resources&lt;/h3&gt;

&lt;p&gt;Here is a list of resources that may be helpful:&lt;/p&gt;

&lt;ul&gt;
                            &lt;li&gt;&lt;a href="https://discordpy.readthedocs.io/en/latest/"&gt;Discord.py docs&lt;/a&gt;&lt;/li&gt;
                            &lt;li&gt;&lt;a href="https://requests.readthedocs.io/en/master/"&gt;Requests module docs&lt;/a&gt;&lt;/li&gt;
                            &lt;li&gt;&lt;a href="https://discordapp.com/developers/docs/intro"&gt;Discord Bot docs&lt;/a&gt;&lt;/li&gt;
                            &lt;li&gt;&lt;a href="https://github.com/15Dkatz/official_joke_api"&gt;Official Joke API&lt;/a&gt;&lt;/li&gt;
                        &lt;/ul&gt;

</description>
      <category>python</category>
      <category>codenewbie</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Getting Started with the Terminal</title>
      <dc:creator>Alan Constantino</dc:creator>
      <pubDate>Thu, 09 Jan 2020 11:35:51 +0000</pubDate>
      <link>https://forem.com/alanjc/getting-started-with-the-terminal-h2i</link>
      <guid>https://forem.com/alanjc/getting-started-with-the-terminal-h2i</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://www.patreon.com/alanjc"&gt;If you've found this article useful, consider donating.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.alanjc.com/articles/getting-started-with-the-terminal.html"&gt;An updated version of this article can be found on my blog.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, you want to learn how to use the Terminal. Great! As a developer, sooner or later, you’ll want to learn how to use the Terminal. Not only is this a handy tool to have under your belt, but it will also boost your productivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before Starting
&lt;/h2&gt;

&lt;p&gt;Before actually getting started learning commands, it’s useful to think of the directories (folders) as a hierarchical tree.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wvQLK0iD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gmr6rt95m1okstc6tj02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wvQLK0iD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gmr6rt95m1okstc6tj02.png" width="723" height="528"&gt;&lt;/a&gt;&lt;/p&gt;
The root directory is “/” and inside of “/”, you have the following folders: bin, tmp, usr, and src.



&lt;p&gt;In the illustration above, you can see that the first directory, often referred to as the “root” directory, is named “/”. That directory (folder) contains other directories such as bin, tmp, usr, and src. Those directories can have other directories or files and those child directories can have even more directories or files and so on.&lt;/p&gt;

&lt;p&gt;Of course, the illustration above is just an example, it doesn’t actually reflect the folders and files that reside in your computer.&lt;/p&gt;

&lt;p&gt;Now, what the terminal allows us to do is to traverse and manage the directory tree. This is why the terminal is so powerful, it allows us to quickly sift through folders and files in an efficient manner as well as being able to create, delete, or update a file or directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Opening Your Terminal
&lt;/h2&gt;

&lt;p&gt;To open your terminal, use the following shortcut: “⌘ + Spacebar.” Now type in “Terminal” and then press the “Enter” key.&lt;/p&gt;

&lt;p&gt;Now, you should have something on your screen that looks like &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CGdcNULN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jn2dnckfbqq1emjrozzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CGdcNULN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jn2dnckfbqq1emjrozzu.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the most part, you should be staring at a black window with white text and a cursor itching for your next command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Note
&lt;/h2&gt;

&lt;p&gt;It’s important to note that every directory on Mac/UNIX/LINUX has two hidden directories, namely “.” and “..”&lt;/p&gt;

&lt;p&gt;The “.” means the current directory and “..” means previous or parent directory. Keep this in mind, it will be useful later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commands
&lt;/h2&gt;

&lt;p&gt;Now that we have a terminal window in front of us, it’s finally time to get to the commands.&lt;/p&gt;

&lt;p&gt;The first command you should type into the terminal should be the pwd (print working directory) command.&lt;/p&gt;

&lt;h4&gt;
  
  
  pwd — print working directory
&lt;/h4&gt;



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

&lt;/div&gt;



&lt;p&gt;This command prints the current directory you’re in onto the terminal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U1a_2ab1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rz8q5nqcwy96y1ij2hy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U1a_2ab1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rz8q5nqcwy96y1ij2hy3.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
Currently in the “/Users/alanconstantino” directory.



&lt;p&gt;Congratulations, you just ran your first command on the terminal!&lt;/p&gt;

&lt;p&gt;This command is useful for knowing where you currently are within the directory tree.&lt;/p&gt;

&lt;p&gt;The next command we should try is ls or list.&lt;/p&gt;

&lt;h4&gt;
  
  
  ls — list
&lt;/h4&gt;



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

&lt;/div&gt;



&lt;p&gt;This command lists all the directories and files from your current directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sKz2y7iz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/bpfk8zwak7irgsxsp2cm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sKz2y7iz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/bpfk8zwak7irgsxsp2cm.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
By typing ls, we can see all of the files and directories within the current directory.



&lt;p&gt;Cool, now we can list all of the files and directories from our current directory.&lt;/p&gt;

&lt;p&gt;But what if we want to list all the contents from another directory?&lt;/p&gt;

&lt;p&gt;Simple, just type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls [directory name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UQNorF8S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8kcpmsllsbkd988pbt8s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UQNorF8S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8kcpmsllsbkd988pbt8s.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We list all the files and folders inside of the “Desktop” directory.



&lt;p&gt;Now we can list files and folders from our current directory or other directories.&lt;/p&gt;

&lt;p&gt;But what if we want to change our current directory? That’s where the cd or change directory command comes into play.&lt;/p&gt;

&lt;h4&gt;
  
  
  cd — change directory
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd [directory name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cd command allows you to change your directory to another directory. This is how you’ll actually traverse the directory tree.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The command above changes your current working directory to your root directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V7VspJIQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8xcn33zuz2ulo8x88ya4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V7VspJIQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8xcn33zuz2ulo8x88ya4.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
“cd /” changes your current directory to your root directory.



&lt;p&gt;Now, how do we back out of a directory or go to the previous/parent directory?&lt;/p&gt;

&lt;p&gt;We have to use the following command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;As I mentioned earlier, the “..” means the parent directory or previous directory. Effectively, the command above is telling the terminal “Hey, take me back to the previous directory.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uMliLAXT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fczjj2bkuq6ucmplyxn8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uMliLAXT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fczjj2bkuq6ucmplyxn8.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
Changed directory from “/Users/alanconstantino/Desktop” to “/Users/alanconstantino.”



&lt;p&gt;Also, if you use this command in the root directory, nothing happens because there isn’t a previous or parent directory to go back to, hence the name root.&lt;/p&gt;

&lt;p&gt;But what if you want to go back more than one directory?&lt;/p&gt;

&lt;p&gt;No problem, the following command is just what you need.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The command above tells the terminal “Hey, I want to go back two directories and make it snappy.” Okay, maybe not so much the snappy part, but it does take you back two directories.&lt;/p&gt;

&lt;p&gt;Essentially, every “../” you add takes you back one directory.&lt;/p&gt;

&lt;p&gt;So the following example will take you back three directories:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now that we know how to traverse the directory tree and list its contents, we should move onto more useful commands.&lt;/p&gt;

&lt;p&gt;Before that though, we should probably clear our terminal screen because by now it may be a little tough to read.&lt;/p&gt;

&lt;h4&gt;
  
  
  clear
&lt;/h4&gt;

&lt;p&gt;By typing in the following command into the terminal, you are able to clear what’s on screen.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--meFKmZpi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/opklk70yr7dhdvv2vkma.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--meFKmZpi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/opklk70yr7dhdvv2vkma.gif" width="840" height="378"&gt;&lt;/a&gt;&lt;/p&gt;
Clearing the terminal.



&lt;p&gt;Now that our screen has been cleared, we can move onto more useful commands, like the mv (move) command.&lt;/p&gt;

&lt;h4&gt;
  
  
  mv — move
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv [source] [destination]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The mv (move) command simply moves a file or directory to another place.&lt;/p&gt;

&lt;p&gt;From the skeleton command above, the “source” is what you want to move while the “destination” is where you want the file to end up.&lt;/p&gt;

&lt;p&gt;For example, if I have something like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;one
├── myfile.txt
└── two
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where “one” and “two” are folders, and I want to move, “myfile.txt” to folder “two” I would simply do the following assuming I was already in the “one” folder location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv myfile.txt two
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gc5ZRmVC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/y9tuqgizssw10xjl4cc8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gc5ZRmVC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/y9tuqgizssw10xjl4cc8.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We moved “myfile.txt” to the folder “two.”



&lt;p&gt;Of course, you could be anywhere in the directory tree to execute this command — and pretty much any command for that matter — but you just have to make sure you enter the full location path of the file you want to move and its destination.&lt;/p&gt;

&lt;p&gt;For example, in the following screenshot, I’m in my root directory but I’m still able to move a file from my Desktop to the “two” folder from the previous example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T7-zs9qt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/u0xue11o3bijrheugs70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T7-zs9qt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/u0xue11o3bijrheugs70.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We moved “anotherfile.txt” to the “two” folder while in the root directory.



&lt;p&gt;Now, what if we wanted to move a file or folder from wherever it is to our current location in the directory tree.&lt;/p&gt;

&lt;p&gt;Well, remember earlier how I talked about the “.” being our current directory, we would have to use “.”&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv /somelocation/myfile.txt .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example above moves “myfile.txt” to wherever we currently are in the directory tree.&lt;/p&gt;

&lt;p&gt;Another command that’s similar to mv (move) is cp (copy).&lt;/p&gt;

&lt;h4&gt;
  
  
  cp — copy
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp [source] [destination]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The copy command is just like the move command except instead of moving a file or folder, it makes a copy of it leaving the original file unharmed.&lt;/p&gt;

&lt;p&gt;To copy a file you would do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp myfile.txt /one
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UuFbd96I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2zbxaw6azikhv1is3czq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UuFbd96I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2zbxaw6azikhv1is3czq.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We copied “myfile.txt” to the “one” folder.



&lt;p&gt;Now to copy a directory you have to add the “-r” option like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp -r one two
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---fAN5JUl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zax3tnv8zthmsrwphepo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---fAN5JUl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zax3tnv8zthmsrwphepo.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We copy the contents of the “one” directory into the “two” directory.



&lt;p&gt;All the “-r” option means is that it tells the terminal to copy the files recursively which is a fancy way of saying everything.&lt;/p&gt;

&lt;p&gt;So by using the “-r” option, we tell the terminal “Please copy all the contents, including folders and files to our destination.”&lt;/p&gt;

&lt;p&gt;It’s also important to keep in mind that most, if not all, commands can have options and there are different options for every command. You can also have more than one option.&lt;/p&gt;

&lt;p&gt;Now, what if we wanted to open a file or folder from our terminal?&lt;/p&gt;

&lt;p&gt;We would need to utilize the open command.&lt;/p&gt;

&lt;h4&gt;
  
  
  open
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;open [file/folder]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command lets us open a file with its associated program.&lt;/p&gt;

&lt;p&gt;For example, if we have a “.txt” file and we do the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;open myfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IGRIuxoC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3nrmqo0iarbihls573zi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IGRIuxoC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3nrmqo0iarbihls573zi.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We open a file named “myfile.txt.”



&lt;p&gt;this opens “myfile.txt” with your default text editor like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e8WQG_fH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/j41q9hewr2l7q5uwq0hw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e8WQG_fH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/j41q9hewr2l7q5uwq0hw.png" width="697" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s another example.&lt;/p&gt;

&lt;p&gt;If you do the following command, it will open the finder window in the root directory.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m5nj73lr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ist8vc7nhzc34png7bhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m5nj73lr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ist8vc7nhzc34png7bhv.png" width="880" height="434"&gt;&lt;/a&gt;&lt;/p&gt;
We opened a new finder window at the root directory.



&lt;p&gt;The finder window will look something like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---4Bxju9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/w9mahk90r7fri39qag74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---4Bxju9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/w9mahk90r7fri39qag74.png" width="880" height="547"&gt;&lt;/a&gt;&lt;/p&gt;
A finder window showing the contents of the root directory.



&lt;p&gt;It opens the finder window because that’s the program that is associated with the file or in this case the folder you’re trying to open.&lt;/p&gt;

&lt;p&gt;So if we did the following command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;it would open a new finder window from our current location because remember, the “.” means our current directory.&lt;/p&gt;

&lt;p&gt;Now, let’s move onto actually making a directory from the terminal.&lt;/p&gt;

&lt;h4&gt;
  
  
  mkdir — make directory
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir [directory name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make a directory, you simply type the command above and give it a name like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rA27o-Qq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/m61x4lro4mn3qivphju1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rA27o-Qq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/m61x4lro4mn3qivphju1.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We made a directory named “mydirectory.”



&lt;p&gt;We can also create multiple directories like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y1LonX3Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/nnfdxiwuz3xg54gnc33j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y1LonX3Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/nnfdxiwuz3xg54gnc33j.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We created two directories, one named “newdirectory” and another named “anotherdirectory.”



&lt;p&gt;What if we wanted to make a file instead of a directory?&lt;/p&gt;

&lt;p&gt;We would use the touch command.&lt;/p&gt;

&lt;h4&gt;
  
  
  touch
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch [file name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command simply creates an empty file.&lt;/p&gt;

&lt;p&gt;For example, if we do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch myfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a file named “myfile.txt” in our current directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s6dXSchX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ugvxf8ov5xq9aire1yee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s6dXSchX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ugvxf8ov5xq9aire1yee.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We create a file named “myfile.txt.”



&lt;p&gt;And similar to mkdir, you can create multiple files in one command like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GTvzJ40q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/s0s7n2ui7ieovvrg9hof.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GTvzJ40q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/s0s7n2ui7ieovvrg9hof.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We create “myfile.txt” in the current directory and “anotherone.txt” in the previous directory.



&lt;p&gt;In the screenshot above, we create two files, “myfile.txt” and “anotherone.txt.”&lt;/p&gt;

&lt;p&gt;The “myfile.txt” file is created in the current directory while the “anotherone.txt” file is created in the previous directory.&lt;/p&gt;

&lt;p&gt;Let’s move on to deleting a directory.&lt;/p&gt;

&lt;h4&gt;
  
  
  rmdir — remove directory
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rmdir [directory name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rmdir command is self-explanatory, it just deletes a directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VTHtZ900--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rthj1wn4qd4xdapuqp6s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VTHtZ900--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rthj1wn4qd4xdapuqp6s.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We are deleting an empty directory named “emptydir.”



&lt;p&gt;However, it’s important to note that when using this command, you can only remove an empty directory.&lt;/p&gt;

&lt;p&gt;If your directory is not empty and you try to use the rmdir command, you’ll get something like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--McXOAOLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7umjm9u2dke0mpursxw0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--McXOAOLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7umjm9u2dke0mpursxw0.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We failed at removing the directory “folder” because it’s not empty.



&lt;p&gt;Now how do we remove the contents of a directory you may be asking?&lt;/p&gt;

&lt;p&gt;We would have to use the rm (remove) command.&lt;/p&gt;

&lt;h4&gt;
  
  
  rm — remove
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm [file name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command is probably the most powerful and yet the most dangerous one on this list which is why I saved it for last.&lt;/p&gt;

&lt;p&gt;Once you use this command and delete something, it’s gone forever.&lt;/p&gt;

&lt;p&gt;It doesn’t get put into your Trash for you to empty out later. No! Once you type in this command and hit enter, poof… it’s gone… forever…&lt;/p&gt;

&lt;p&gt;This also applies to rmdir, once you remove a directory, it’s gone forever.&lt;/p&gt;

&lt;p&gt;But unlike rmdir, the rm command has the ability to remove both a directory as well as a file.&lt;/p&gt;

&lt;p&gt;With this in mind, let’s see it in action.&lt;/p&gt;

&lt;p&gt;To remove a file, simply do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm myfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2daTsLmi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/bq1akpceyzo6cehnfyfy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2daTsLmi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/bq1akpceyzo6cehnfyfy.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We removed a file named “myfile.txt.”



&lt;p&gt;And just like some of the previous commands, we can delete multiple things at once by using the following format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm [file1] [file2] [etc]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w5q6Q0CJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/eohg55tmn0hmblj91f17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w5q6Q0CJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/eohg55tmn0hmblj91f17.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We delete “afile.txt” and “anotherone.txt”



&lt;p&gt;In the example above, we delete “afile.txt” from the current directory and subsequently delete “anotherone.txt” from the previous or parent directory.&lt;/p&gt;

&lt;p&gt;If we wanted to delete only certain files that end in specific extensions (i.e. .txt, .png, .exe, etc) we would use the asterisk or “*” symbol. This symbol is often referred to as a wildcard.&lt;/p&gt;

&lt;p&gt;For example, if we were in a directory and we only wanted to delete .txt files, we would do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm *.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dveNQE8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/h92qndzzv5wrmu6q27x9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dveNQE8I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/h92qndzzv5wrmu6q27x9.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We delete various .txt files.



&lt;p&gt;As you can see, we deleted all the files that end with the “.txt” extension. If we had other files such as .png, .gif, etc, those files would be unscathed by the rm command.&lt;/p&gt;

&lt;p&gt;So by using the “*” symbol we effectively tell the terminal to disregard the name of the file and only look at the extension of the file.&lt;/p&gt;

&lt;p&gt;Now let’s get into the danger zone.&lt;/p&gt;

&lt;p&gt;Earlier I said that most if not all commands have something called options. These options are added right after the command like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[command] [options] [other paramters]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, the rm command has two options that I’m going to show you which are dangerous if used without precaution and quite lethal in combination.&lt;/p&gt;

&lt;h4&gt;
  
  
  rm -r
&lt;/h4&gt;

&lt;p&gt;The first is the “-r” option. As you may recall, I said that the “-r” option means do it recursively, which is just another way of saying all or targeting everything.&lt;/p&gt;

&lt;p&gt;If you do the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -r [directory]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it will delete everything inside of a directory including the folder itself.&lt;/p&gt;

&lt;p&gt;So if I have the following directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;newfolder
├── folder1
│      └── text1.txt
├── folder2
│      └── text2.txt
└── folder3
         └── text3.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then I input the following command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;It will delete everything within the “newfolder” directory as well as the folder itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y4wefnPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/upiwkpsxq8fnlzg0jozy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y4wefnPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/upiwkpsxq8fnlzg0jozy.png" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
We delete all of the contents of the “newfolder” directory including the folder itself.



&lt;p&gt;As a side note, the ‘tree’ command isn’t available by default on Mac, you have to download and install it seperately.&lt;/p&gt;

&lt;p&gt;Now we move onto the other option, “-f.”&lt;/p&gt;

&lt;h4&gt;
  
  
  rm -f
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -f [file/directory]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sometimes, when you use the rm command, you may get a prompt. This prompt may just be something like “Are you sure you want to delete the following file or directory?”&lt;/p&gt;

&lt;p&gt;By using this option, you avoid having the prompt show up in the first place.&lt;/p&gt;

&lt;p&gt;Essentially, this just tells the terminal, “Delete the following file/directory and don’t give me a prompt.”&lt;/p&gt;

&lt;p&gt;Now we move onto the most lethal combination, “-rf.”&lt;/p&gt;

&lt;h4&gt;
  
  
  rm -rf
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf [directory]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you combine both the “r” and the “f” options, you’re telling the terminal “Delete all of the contents of the directory and don’t show me a prompt, capeesh.”&lt;/p&gt;

&lt;p&gt;As you can probably guess, this is quite dangerous.&lt;/p&gt;

&lt;p&gt;No need to fret though, as long as you’re cautious and don’t use this command on let’s say, you’re root directory, you should — for the most part — be fine.&lt;/p&gt;

&lt;p&gt;So now that we know what the “r” and “f” options do, let’s run through an example.&lt;/p&gt;

&lt;p&gt;Here I have a directory which looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;anotherfolder
└── myfolder
        ├── folder1
        │      └── file1.txt
        ├── folder2
        │      └── file2.txt
        ├── folder3
        │      └── file3.txt
        └── folder4
                 └── file4.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if I run the following command (assuming I’m already at the “anotherfolder” location):&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;It should delete all the contents inside the “myfolder” directory including the folder itself and I shouldn’t see any prompts.&lt;/p&gt;

&lt;p&gt;All right, let’s give it a shot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QLDb7XTQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rq0jiv4dh61mcybb2mzj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QLDb7XTQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rq0jiv4dh61mcybb2mzj.png" width="880" height="515"&gt;&lt;/a&gt;&lt;/p&gt;
We remove all the contents of “myfolder” including the folder itself.



&lt;p&gt;Sure enough, it worked.&lt;/p&gt;

&lt;p&gt;Now let’s recap what we learned.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;p&gt;It’s useful to think of directories as a hierarchical tree with the topmost directory being the root directory.&lt;/p&gt;

&lt;p&gt;The “.” means current directory while “..” means previous or parent directory.&lt;/p&gt;

&lt;p&gt;We also took a look at the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pwd — prints the current working directory
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;ls — lists all the contents of the current directory
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;cd — changes directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd [directory name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;clear — clears the terminal screen
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;mv — moves files or folders from one place to another
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv [source] [destination]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;cp — copies files or folders from one place to another
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp [source] [destination]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;open — opens the file or folder with the associated program
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;open [file/directory]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;mkdir — makes a new empty directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir [directory name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;touch — creates a new empty file with the name of your choice
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch [file name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;rmdir — removes an empty directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rmdir [empty directory]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;rm — removes a file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm [file name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;rm -rf — removes the folder and its contents without showing any prompts
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf [directory name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is only scratching the surface of the terminal.&lt;/p&gt;

&lt;p&gt;There are many more useful commands but these are just the basics to get you up and running.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
