<?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>DEV Community: Joseph Trettevik</title>
    <description>The latest articles on DEV Community by Joseph Trettevik (@lofiandcode).</description>
    <link>https://dev.to/lofiandcode</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%2F226065%2Fb83295a1-6cc9-4140-8379-8ad6f4449313.jpeg</url>
      <title>DEV Community: Joseph Trettevik</title>
      <link>https://dev.to/lofiandcode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lofiandcode"/>
    <language>en</language>
    <item>
      <title>Code with Your Friends</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 06 Jul 2020 06:47:34 +0000</pubDate>
      <link>https://dev.to/lofiandcode/code-with-your-friends-4226</link>
      <guid>https://dev.to/lofiandcode/code-with-your-friends-4226</guid>
      <description>&lt;h2&gt;
  
  
  Song of the Week
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/jishle/winters-warmth&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This week is a much shorter and much less technical post. I participated in a mini hackathon yesterday, and I had such a great time I thought I'd share my experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Challenge
&lt;/h2&gt;

&lt;p&gt;We were giving a code challenge, a few hours to work on it, and then we all came together to share our solutions. The challenge was to build some UI cards in React. We had the option to use some starter code or to start from scratch. Here's what I came up with:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/q5g6m"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;It had been along time since I had done a hackathon, so I was reminded how great they are. Here are some of the reason you should participate in one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It can break you out of a coding rut.&lt;/strong&gt; Sometimes when you're spending a lot of time learning to code on your own, you can get bored and lose your motivation. Meet up online with other people and working on a new problem can be like a shot in the arm. It gets you excited about coding again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can learn so much from other people.&lt;/strong&gt; Problems that you may have been struggling with for a while can suddenly become so clear when you get help on them from other coders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You don't have to be an expert.&lt;/strong&gt; Everyone at these events are at different levels, with strengths in different areas. Someone may help you with something your struggling with in CSS, and maybe you help them with a bug in their React files. Everybody wins, learns, and is better for it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You meet great people and can build a community&lt;/strong&gt; of other coders that are also trying to learn and grow their skills. And community is what it's all about!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>react</category>
      <category>codechallenge</category>
    </item>
    <item>
      <title>Git and GitHub: Git Revert</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 29 Jun 2020 03:09:04 +0000</pubDate>
      <link>https://dev.to/lofiandcode/git-and-github-git-revert-1cke</link>
      <guid>https://dev.to/lofiandcode/git-and-github-git-revert-1cke</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/user-862296609/crystal-ship&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Last week we covered how to do a hard reset of your repository. Though they're sometimes necessary, hard resets are a pretty destructive method of rewinding your repository because they alter the commit history.&lt;/p&gt;

&lt;p&gt;Today's post will cover the nondestructive rewind, aka &lt;code&gt;git revert&lt;/code&gt;. &lt;br&gt;
We'll go over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What &lt;code&gt;git revert&lt;/code&gt; does and how it is different from &lt;code&gt;git reset&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;How to revert a single commit.&lt;/li&gt;
&lt;li&gt;How to revert a range of commits.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Git Revert vs Git Reset
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;git revert &amp;lt;commit-hash&amp;gt;&lt;/code&gt; command will reverse the changes made by the commit hash given, and then create a new commit. This is the preferred method for undoing the changes of a specific commit if that commit has already been push to a shared remote repository because it preserves the commit history. &lt;/p&gt;

&lt;p&gt;This is different from a &lt;code&gt;git reset&lt;/code&gt;, because a reset will move the HEAD ref to the commit hash given, and drop all the commits after that one. A &lt;code&gt;git revert&lt;/code&gt; only reverses the commit that was given and keeps all the following commits and the changes that were made in them. This makes &lt;code&gt;git revert&lt;/code&gt; great for removing a bug that was introduced by a single commit without having to redo all the work in the following commits.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Revert a Single Commit
&lt;/h2&gt;

&lt;p&gt;To revert a single commit, enter the following git command in the terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git revert &amp;lt;commit-hash&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also pass &lt;code&gt;git revert&lt;/code&gt; a reference to the commit that is relative the HEAD ref. So, if you entered &lt;code&gt;git revert HEAD~2&lt;/code&gt;, the changes from the third most recent commit would be reversed.&lt;/p&gt;

&lt;p&gt;Let's look at an example. I created a local repository with some files whose names match the commit in which they were created, which looks like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u5HYw02m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bwquj9hfk21alxb1er67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u5HYw02m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bwquj9hfk21alxb1er67.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
All these files just have the text "added content" in them and each was added with their own commit. The &lt;code&gt;git log&lt;/code&gt; looks like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ro8njT1j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nl3q98niv64b1es5ybk1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ro8njT1j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nl3q98niv64b1es5ybk1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Now let's say there was some bug in commit A that we wanted to undo but keep commits B-D. We would enter the following git command:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BvGkVGfh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bnpb60rqmtfaxn4r3bb2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BvGkVGfh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bnpb60rqmtfaxn4r3bb2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
You can see in the &lt;code&gt;git log&lt;/code&gt; that the &lt;code&gt;git revert&lt;/code&gt; command automatically created a commit. Also, I used &lt;code&gt;HEAD~3&lt;/code&gt; to reference commit A. Remember that most recent commit is equal to &lt;code&gt;HEAD&lt;/code&gt;, which can be written as &lt;code&gt;HEAD~0&lt;/code&gt;. So, the fourth most recent commit is &lt;code&gt;HEAD~3&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now if we look at the working directory you'll see that the "commit-A" has been removed, but the rest remain.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EME-tmrF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q2wwiqen9doqmj3zsczr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EME-tmrF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q2wwiqen9doqmj3zsczr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Revert a Range of Commits
&lt;/h2&gt;

&lt;p&gt;To revert a range of commits, simply enter the following git command in the terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git revert -n &amp;lt;commit-hash&amp;gt;^..&amp;lt;commit-hash&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice the &lt;code&gt;^&lt;/code&gt; before the two periods. That caret symbol tells git to include that first commit hash given in the range. And the &lt;code&gt;-n&lt;/code&gt; option tells git to not create a commit, but to instead stage the changes in the Staging Index and the Working Directory. This way you can do one commit manually to maintain a neat commit history.&lt;/p&gt;

&lt;p&gt;In the same example we used above, lets say we want to rewind to commit A and maintain the commit history. You could do that like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2RRwdhyF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/komuf7483lrgn2rqdo1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2RRwdhyF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/komuf7483lrgn2rqdo1y.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
By running &lt;code&gt;git status&lt;/code&gt;, we can see that all files added in the commits B-D have been deleted.&lt;/p&gt;

&lt;p&gt;Now we just need to commit those changes.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6WQ-Ivw3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/muhsx0itw5du2rpg9xe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6WQ-Ivw3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/muhsx0itw5du2rpg9xe7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
In the &lt;code&gt;git log&lt;/code&gt; we see that commits B-D are still in the commit history even though their changes have been reversed. &lt;/p&gt;

&lt;p&gt;If we open the Working Directory, we'll see that it has indeed rewound back to commit A.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Cvb7SWR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nu1o91g80gilowphd9nv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Cvb7SWR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nu1o91g80gilowphd9nv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git revert &amp;lt;commit-hash&amp;gt;&lt;/code&gt; will reverse the changes made by the commit hash given, and then create a new commit.&lt;/li&gt;
&lt;li&gt;Unlike &lt;code&gt;git reset&lt;/code&gt;, &lt;code&gt;git revert &amp;lt;commit-hash&amp;gt;&lt;/code&gt; will not remove the commits after the commit given, thereby preserving the commit history.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git revert&lt;/code&gt; will also accept a commit reference based on HEAD, like &lt;code&gt;git reset HEAD~3&lt;/code&gt;, for example.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git revert -n &amp;lt;commit-hash&amp;gt;^..&amp;lt;commit-hash&amp;gt;&lt;/code&gt; will reverse the changes by the range of commits given(inclusively), and will stash the changes in the Staging Index. The &lt;code&gt;-n&lt;/code&gt; option prevents the auto commits, so you will need to do a manual commit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://seattlerefined.com/travel/5-ways-to-get-off-the-grid-at-mount-st-helens"&gt;Cover Image - Mt St Helens&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/undoing-changes/git-revert#:~:text=The%20git%20revert%20command%20is%20a%20forward%2Dmoving%20undo%20operation,in%20regards%20to%20losing%20work."&gt;Git Revert - atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-revert"&gt;Git Revert - Git Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/1463340/how-to-revert-multiple-git-commits"&gt;How to revert multiple git commits? - stackoverflow.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Git and GitHub: How to Hard Reset Local and Remote Repository</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 22 Jun 2020 05:06:07 +0000</pubDate>
      <link>https://dev.to/lofiandcode/git-and-github-how-to-hard-reset-local-and-remote-repository-4614</link>
      <guid>https://dev.to/lofiandcode/git-and-github-how-to-hard-reset-local-and-remote-repository-4614</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/potsupotsu/just-friends-2&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Before we go over how to do this, let's go over when you should and should not do this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't do a hard reset if you've already pushed the commits in question to a shared remote repository.&lt;/strong&gt; If another developer pulls and starts basing their work on the commits that the reset removes from the commit history, you're going to create huge problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A hard reset can be done if you're the only one using the local and remote repository, or if the reset removes commits that have not yet been pushed to a shared remote.&lt;/strong&gt; In this case, you're the only one affected by the hard reset, so it's relatively safe to do. Just make sure you want drop the commits in question before you do the reset.&lt;/p&gt;

&lt;p&gt;Also, just as a quick reminder, &lt;code&gt;git reset --hard &amp;lt;commit-hash&amp;gt;&lt;/code&gt; will move the HEAD pointer back to the commit hash that was given, the Stage Index and the Working Directory will be reset back to the way they were at that commit, and all commits after the commit that was given will be dropped from the commit history. This means that &lt;strong&gt;any uncommitted work in the Staging Index or Work Directory will be lost.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Hard Reset the Local Repository
&lt;/h2&gt;

&lt;p&gt;To simplify the example, I created a repository with a README in it, and for each commit, I added a line that matches the commit message. So, after four commits I ended up with a README that looked like 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%2Fmo3rvl0k90swovu9rnzi.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%2Fmo3rvl0k90swovu9rnzi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To reset your local repository, first you need to know which commit you want to reset to, and what the hash is for that commit. One way to do this is to run &lt;code&gt;git log&lt;/code&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%2F6wghcz23q4px9qhybv2i.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%2F6wghcz23q4px9qhybv2i.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's say that after looking through this commit history you wanted to reset to the "second commit". Then, you would write down or copy the commit hash for that commit and run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git reset --hard &amp;lt;commit-hash&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Based on the example, that command would look like 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%2Fi9a35h95dqo139xd7jgv.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%2Fi9a35h95dqo139xd7jgv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After running the hard reset command, the Working Directory now looks like 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%2Fkplejmwpx14nl21jrmi4.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%2Fkplejmwpx14nl21jrmi4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see from &lt;code&gt;git log&lt;/code&gt; and the Working Directory that we have rolled back to the second commit and dropped the third and fourth commits.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Hard Reset the Remote Repository
&lt;/h2&gt;

&lt;p&gt;Performing a hard reset of the remote repository is quite easy. After you've reset the local repository, simply do a force push with the follow git command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push -f &amp;lt;remote&amp;gt; &amp;lt;branch-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the example we used above, that git command would look like 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%2Ftr8eyx6irw2d2gnuqc1t.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%2Ftr8eyx6irw2d2gnuqc1t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Only do a hard reset if you are the only using the remote repository, or if you haven't yet pushed the commits you're going to drop.&lt;/li&gt;
&lt;li&gt;Find the commit hash of the commit you want to reset to with &lt;code&gt;git log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Perform the local hard reset by running &lt;code&gt;git reset --hard &amp;lt;commit-hash&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To hard reset the remote repository, first hard reset the local and then run &lt;code&gt;git push -f &amp;lt;remote&amp;gt; &amp;lt;branch-name&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.sciencealert.com/if-a-nuclear-bomb-explodes-these-are-the-emergency-supplies-you-should-have" rel="noopener noreferrer"&gt;Cover Image&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/3639115/reverting-to-a-specific-commit-based-on-commit-id-with-git?lq=1" rel="noopener noreferrer"&gt;Reverting to Specifi Commit Based on Commit ID with Git - stackoverflow.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/5816688/resetting-remote-to-a-certain-commit" rel="noopener noreferrer"&gt;Resetting Remote to a Certain Commit - stackoverflow.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/undoing-changes/git-reset" rel="noopener noreferrer"&gt;Git Reset - Atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting" rel="noopener noreferrer"&gt;Resetting, Checking Out, and Reverting - Atlassian.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Git and Github: git log</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 08 Jun 2020 06:21:11 +0000</pubDate>
      <link>https://dev.to/lofiandcode/git-and-github-git-log-4m6f</link>
      <guid>https://dev.to/lofiandcode/git-and-github-git-log-4m6f</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/cloudchord/cloudchord-x-oatmello-gin&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;One of the first things you'll find a need for once you begin creating a commit history is the ability to view that history. This where &lt;code&gt;git log&lt;/code&gt; comes in handy. There numerous options you can use with &lt;code&gt;git log&lt;/code&gt; to display the commit history in different ways, but in post I'll cover some of the more useful options.&lt;/p&gt;

&lt;h2&gt;
  
  
  Display Options
&lt;/h2&gt;

&lt;h4&gt;
  
  
  git log
&lt;/h4&gt;

&lt;p&gt;The basic option, is no options. If you enter &lt;code&gt;git log&lt;/code&gt; with any options it will print out the commit history for the current repository. The numbers and letter you see on the left are the first 7 digits of the 40 characters commit ID. Next to that is the message associated with that commit, and on the right you can see the author and relative date. You can tell from the relative dates that the commits are listed in reverse chronological order. So the most recent commit is printed first and the commits get older and you move down.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log
067a4ee correct linting errors (Joseph Trettevik, 2 days ago)
b48fdd7 create ScrollContainer component (Joseph Trettevik, 2 days ago)
366b9c1 Merge pull request #85 from FoodIsLifeBGP/client-and-donor-validations (Edgar Martinez, 4 days ago)
d845da0 newline for linting (bastion6429, 4 days ago)
f76b0ce made changes to reflect pre-alpha requirements (bastion6429, 4 days ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  git log --stat
&lt;/h4&gt;

&lt;p&gt;If you'd like to see an overview of what was modified in each commit you can us the &lt;code&gt;--stat&lt;/code&gt; option. This will list the files that were modified, how many lines of code were deleted or added in those files, and summary of that information for each commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log --stat
067a4ee correct linting errors (Joseph Trettevik, 2 days ago)

 src/elements/ScrollContainer/ScrollContainer.tsx | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
b48fdd7 create ScrollContainer component (Joseph Trettevik, 2 days ago)

 src/elements/ScrollContainer/ScrollContainer.tsx | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
366b9c1 Merge pull request #85 from FoodIsLifeBGP/client-and-donor-validations (Edgar Martinez, 4 days ago)
d845da0 newline for linting (bastion6429, 4 days ago)

 src/util/constraints/donorRegistration.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  git log --graph
&lt;/h4&gt;

&lt;p&gt;If you'd like to see a graphical representation of the commit history you can use the &lt;code&gt;--graph&lt;/code&gt; option. This use simple graphics to display the branches and merges in the commit history in a visual way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log --graph
* 067a4ee correct linting errors (Joseph Trettevik, 2 days ago)
* b48fdd7 create ScrollContainer component (Joseph Trettevik, 2 days ago)
*   366b9c1 Merge pull request #85 from FoodIsLifeBGP/client-and-donor-validations (Edgar Martinez, 4 days ago)
|\  
| * d845da0 newline for linting (bastion6429, 4 days ago)
| * f76b0ce made changes to reflect pre-alpha requirements (bastion6429, 4 days ago)
| * 783ffb5 made business license field not mandatory (bastion6429, 4 days ago)
| * 39c7f08 added image in donor registration and donation (bastion6429, 6 days ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  git log --all
&lt;/h4&gt;

&lt;p&gt;To see all commits in the history, even the ones that are not associated with the current branch, you can use the &lt;code&gt;--all&lt;/code&gt; option. In the example below we see that the third commit listed is new compared to that last example. This commit is on a branch off the the master that is no associated with this current branch, but it shows up because we used the &lt;code&gt;--all&lt;/code&gt; option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log --all
067a4ee correct linting errors (Joseph Trettevik, 2 days ago)
b48fdd7 create ScrollContainer component (Joseph Trettevik, 2 days ago)
3e68f7c refactored register to also return formErrors (bastion6429, 3 days ago)
366b9c1 Merge pull request #85 from FoodIsLifeBGP/client-and-donor-validations (Edgar Martinez, 4 days ago)
d845da0 newline for linting (bastion6429, 4 days ago)
f76b0ce made changes to reflect pre-alpha requirements (bastion6429, 4 days ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Limiting and Search Options
&lt;/h2&gt;

&lt;h4&gt;
  
  
  git log --before
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;--before&lt;/code&gt; option will allow you to what to print all the commits that were created before a given date. You can specify a specific date or a relative date like I did in the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log --before='3 days ago'
366b9c1 Merge pull request #85 from FoodIsLifeBGP/client-and-donor-validations (Edgar Martinez, 4 days ago)
d845da0 newline for linting (bastion6429, 4 days ago)
f76b0ce made changes to reflect pre-alpha requirements (bastion6429, 4 days ago)
783ffb5 made business license field not mandatory (bastion6429, 4 days ago)
39c7f08 added image in donor registration and donation (bastion6429, 6 days ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  git log --after
&lt;/h4&gt;

&lt;p&gt;You can allows limit the log output to commits that were created after a certain date with the &lt;code&gt;--after&lt;/code&gt; option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log --after='3 days ago'
067a4ee correct linting errors (Joseph Trettevik, 2 days ago)
b48fdd7 create ScrollContainer component (Joseph Trettevik, 2 days ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  git log --before --after
&lt;/h4&gt;

&lt;p&gt;One of the coolest things about git log is that you can use multiple options to get exactly the output that you want. This allows use to print out the commits that created in a certain range by use both the &lt;code&gt;--before&lt;/code&gt; and the &lt;code&gt;--after&lt;/code&gt; option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log --before='5 days ago' --after='8 days ago'
39c7f08 added image in donor registration and donation (bastion6429, 6 days ago)
803f9f1 added donation validation constraint (bastion6429, 7 days ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  git log --author='name'
&lt;/h4&gt;

&lt;p&gt;Another useful search option is the &lt;code&gt;--author&lt;/code&gt; option. This allows you to print out only the commits that were created by a given author.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log --author='Joseph Trettevik'
067a4ee correct linting errors (Joseph Trettevik, 2 days ago)
b48fdd7 create ScrollContainer component (Joseph Trettevik, 2 days ago)
e066704 rename scroll component to EndOfScrollWrapper (Joseph Trettevik, 2 weeks ago)
ae18eaf add ScrollContainer to index (Joseph Trettevik, 2 weeks ago)
9bfb1b6 create scroll container component (Joseph Trettevik, 2 weeks ago)
b3a6295 add ScrollContainer to index (Joseph Trettevik, 2 weeks ago)
a1d7bc0 create scroll container component (Joseph Trettevik, 2 weeks ago)
d3f1ab0 make typechecking corrections (Joseph Trettevik, 4 weeks ago)
883382d optimize Checkbox component (Joseph Trettevik, 4 weeks ago)
bf74c33 make lint and typechecking corrections (Joseph Trettevik, 4 weeks ago)
1269f2f create functional Checkbox component (Joseph Trettevik, 4 weeks ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  git log -S 
&lt;/h4&gt;

&lt;p&gt;Finally, the &lt;code&gt;-S&lt;/code&gt; option lets you search all commits that contain changes the occurrences of that given string. This is great for the situations where you want to see every commit that changes an certain block of code. In the example between I given the name of a component and all the commits that modify that component are printed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ♥ git log -S 'FormTextInput'
a2ec4fa add contributionGuide for hackathon and following development (duskcloudxu, 6 weeks ago)
bea4470 Revamp Login Screen UI and form interaction (#40) (Ernest Bruno, 6 weeks ago)
bb988f4 Decouple Donations from DonationOrClaim (rahulrajaram, 6 weeks ago)
f7cad70 Client registration screen, absolute imports fixed, made register bidirectional (Abe Dolinger, 5 months ago)
877430c Added use-global-hook state management (Abe Dolinger, 5 months ago)
566cd53 Donations screen loads existing donations, create new donation posts to backend (Abe Dolinger, 7 months ago)
e6d506b Registration, login, approval, dashboard (Abe Dolinger, 7 months ago)
3e7eb9a Added Terms, Header, Icon, Back, Menu (Abe Dolinger, 7 months ago)
c0095b7 Registration UI (Abe Dolinger, 7 months ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git log&lt;/code&gt; - will print out the commit history for the current repository in reverse order (most recent commit at the top of list).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log --stat&lt;/code&gt; - will list the files that were modified, how many lines of code were deleted or added in those files, and summary of that information for each commit.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log --graph&lt;/code&gt; - will use simple graphics to display the branches and merges in the commit history in a visual way.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log --all&lt;/code&gt; - will print all commits in the history, even the ones that are not associated with the current branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log --before='date'&lt;/code&gt; - will print all the commits that were created before a given date.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log --after='date'&lt;/code&gt; -  will print all the commits that were created after a given date.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log --author='name'&lt;/code&gt; - will only print the commits that were created by a given author.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git log -S &amp;lt;string&amp;gt;&lt;/code&gt; - will print all commits that contain changes to the occurrences of that given string.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History"&gt;Viewing the Commit History - Git Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-log"&gt;Git Log - Git Docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Git and GitHub: Merge</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 01 Jun 2020 02:52:51 +0000</pubDate>
      <link>https://dev.to/lofiandcode/git-and-github-merge-3g78</link>
      <guid>https://dev.to/lofiandcode/git-and-github-merge-3g78</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/toouglyboi/uptown-express&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Last week I briefly covered &lt;code&gt;git merge&lt;/code&gt; as part of a general overview of common git commands. This week I wanted to go into more depth on merge since it can be a little tricky. Hopefully I can help you avoid some of the confusion I've experienced in the past.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Topics Covered:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preparing for the Merge&lt;/li&gt;
&lt;li&gt;Fast-Forward&lt;/li&gt;
&lt;li&gt;3-way Merge&lt;/li&gt;
&lt;li&gt;Merge Conflicts&lt;/li&gt;
&lt;li&gt;Deleting Branches&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Preparing for the Merge
&lt;/h2&gt;

&lt;p&gt;Before you execute a merge it's important to take a few steps to prepare. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: Make sure your on the branch you want to merge into. If you're not sure which branch you're on, run &lt;code&gt;git status&lt;/code&gt;. If you're on the wrong branch, run &lt;code&gt;git checkout &amp;lt;branch-name&amp;gt;&lt;/code&gt; to switch to the correct branch.&lt;/li&gt;
&lt;li&gt;Step 2: Make sure the branches you're merging are up-to-date with the latest remote commits. To do this, run &lt;code&gt;git pull&lt;/code&gt; once you're on the branch you want to update. This is especially important if you're merging into a branch that you share with other developers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fast-Forward
&lt;/h2&gt;

&lt;p&gt;There are two types of merges that Git will execute depending on the situation. The simplest is called “fast-forward.” A fast-forward is when Git just moves the tip of the receiving branch to point to the same commit as the tip of the merging branch. This happens when the tip of the branch you're merging into is a direct ancestor of the branch you're merging in. Let’s look at an example!&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%2Fwyiaknrscdsfpyoeoijr.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%2Fwyiaknrscdsfpyoeoijr.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Diagram 1: Commit history before the fast-forward.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s say we’re working with a simply git history like the one in the diagram above. In this example you have a master branch, and a feature branch that branched off at commit #3. We can see that even thought we’ve made two commits on our feature branch, no new commits have been made to the master branch. This means that the tip of the master branch is a direct ancestor of our feature branch. So, when we run &lt;code&gt;git merge feature&lt;/code&gt;, the commit history will look like 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%2F3pqhu093t8wlm29lqxi0.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%2F3pqhu093t8wlm29lqxi0.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Diagram 2: Commit history after the fast-forward.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Notice that the tip of the master branch now points to the same commit as the feature branch. The fast-forward just moved the tip of the master branch up the linear commit history to point to the most recent commit.&lt;/p&gt;
&lt;h2&gt;
  
  
  3-way Merge
&lt;/h2&gt;

&lt;p&gt;Often the commit history is not simple enough for Git to do a fast-forward. This is especially true when you are work on the same code base with multiple developers. &lt;/p&gt;

&lt;p&gt;This is where the 3-way merge comes into play. Git performs a 3-way merge when the tip of the branch you’re merging into is not a direct ancestor of the branch you’re merging in. A 3-way merge is when Git creates a new snapshot of the code using the commits that the two branch tips point to and the common ancestor commit, and then creates a merge commit with the result. Again let’s look at an example to better understand what’s happening. &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%2Fevboym6g6zr37umc4qyo.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%2Fevboym6g6zr37umc4qyo.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Diagram 3: Commit history before the 3-way merge.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this example, the feature branch also branches off at commit #3, but this time the master branch tip is not pointing to a commit that is a direct ancestor of the feature branch. This can happen if you or someone else merged a commit into master after your feature branch was created. &lt;/p&gt;

&lt;p&gt;To merge these branches we should have already switched to the master branch in the prepare step, so we can just run &lt;code&gt;git merge feature&lt;/code&gt;. Notice that is the same Git command, but this time a 3-way merge will result. Git will automatically perform a fast-forward or a 3-way merge depending on the state of the commit history. &lt;/p&gt;

&lt;p&gt;After the 3-way merge the commit history will look like 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%2Fer3a70gwxnou0yimla6s.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%2Fer3a70gwxnou0yimla6s.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Diagram 4: Commit history after the 3-way merge.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Take note of the fact that unlike a fast-forward, the master and feature branch tips do not point to the same commit after a 3-way merge. Master is now pointing to a merge commit that is a combination of the two branch tips and the common ancestor.&lt;/p&gt;

&lt;p&gt;One last thing that should be said if it wasn’t clear. Merges don’t always have to go from a feature branch into the master branch. You can merge any branch into another other branch. So you could merge master into your feature branch, or feature_1 branch into feature_2. branch. &lt;/p&gt;
&lt;h2&gt;
  
  
  Merge Conflicts
&lt;/h2&gt;

&lt;p&gt;Usually Git will automatically merge the files from both branches together. However, if the same part of a file has been changed in different ways on the two branches being merged, Git won't be able to merge them. In this case, Git will label the trouble spot as a conflict and will wait for you to resolve it. To see which files have conflicts you can run &lt;code&gt;git status&lt;/code&gt;. Then open those files in VS Code or whichever text editor you prefer. In the files you will see 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;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;HEAD:app.js
if (a &amp;lt; 0) {
  b = 5;
}
==============
if (a &amp;lt; 0) {
  c = 5;
}
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;feature:app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above I created a hypothetical conflict that may have come up in the 3-way merge example we looked at before. The less than signs (&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt;) mean that everything between them and the equal signs (&lt;code&gt;=========&lt;/code&gt;) is the code from the current branch (aka the branch you're merging into). On the bottom, the greater than signs (&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;) mean that the code between them and the equal signs (&lt;code&gt;========&lt;/code&gt;) is from the branch that you're merging in. &lt;/p&gt;

&lt;p&gt;Once you decide which version to keep, or create a mix of the two, save the file. Once all the conflicts are resolved and saved, run &lt;code&gt;git add &amp;lt;file-name&amp;gt;&lt;/code&gt; on each file with a conflict. Or you can run &lt;code&gt;git add .&lt;/code&gt;, which will &lt;code&gt;git add&lt;/code&gt; all the modified files at once. Then just run &lt;code&gt;git commit -m &amp;lt;type a message here&amp;gt;&lt;/code&gt; with your commit message and your merge is done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deleting Branches
&lt;/h2&gt;

&lt;p&gt;Now that your feature branch is merged into master you can delete it since it's changes have been incorporated into master. To delete a branch run &lt;code&gt;git branch -d &amp;lt;branch-name&amp;gt;&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;So in the case of our examples, after the merge we would run &lt;code&gt;git branch -d feature&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prepare for the Merge&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Make sure you're on the branch you want to merge into by running &lt;code&gt;git status&lt;/code&gt; and running &lt;code&gt;git checkout &amp;lt;branch-name&amp;gt;&lt;/code&gt; if you need to switch to the correct branch.&lt;/li&gt;
&lt;li&gt;Make sure the branches you're merging are up-to-date with the latest remote commits. To do this, run &lt;code&gt;git pull&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Two Types of Merges&lt;/strong&gt; can result from &lt;code&gt;git merge &amp;lt;branch-name&amp;gt;&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fast-Forward:&lt;/strong&gt; When Git just moves the tip of the receiving branch forward to point to the tip of the merging branch. This happens when the the tip of receiving branch is a direct ancestor of the merging branch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3-way Merge:&lt;/strong&gt;  When the tip of the receiving branch is not a direct ancestor of the merging branch Git creates a new snapshot of the code using the commits that the two branch tips point to, and the common ancestor commit, and then creates a merge commit with the result.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Merge Conflicts&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;If the same part of a file has been changed in different ways on the two branches being merged, Git won't be able to merge them and will label them as a conflict.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/code&gt;: Everything between these less than signs and the equal signs (&lt;code&gt;=========&lt;/code&gt;) is the code from the current branch (aka the branch you're merging into)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;=========&lt;/code&gt;: Separates the code from the receiving and the merging branches that is in conflict.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;: Everything between these greater than signs and the equal signs (&lt;code&gt;========&lt;/code&gt;) is the code from the branch that you're merging in.&lt;/li&gt;
&lt;li&gt;Once the conflicts are resolved in a text editor, run &lt;code&gt;git add .&lt;/code&gt; and &lt;code&gt;git commit -m &amp;lt;type a message here&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Delete Branch&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;To delete a branch run &lt;code&gt;git branch -d &amp;lt;branch-name&amp;gt;&lt;/code&gt;. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging" rel="noopener noreferrer"&gt;Basic Branching and Merging - Git Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-merge" rel="noopener noreferrer"&gt;Git Merge - Git Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/using-branches/git-merge" rel="noopener noreferrer"&gt;Git Merge - Atlassian Git Tutorial&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/syncing/git-pull" rel="noopener noreferrer"&gt;Git Pull - Atlassian Git Tutorial&lt;/a&gt;&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-branch" rel="noopener noreferrer"&gt;Git Branch - Git Docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Git and GitHub: The Basics</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 25 May 2020 06:23:14 +0000</pubDate>
      <link>https://dev.to/lofiandcode/git-and-github-the-basics-5chg</link>
      <guid>https://dev.to/lofiandcode/git-and-github-the-basics-5chg</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/jazzinuf/milky-bowl-of-shooting-stars&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Since I've started contributing to open source projects in the last few months, I've learned that I could benefit from a deeper understanding of Git, and GitHub flow. So, this week I'm starting a series of posts about the things I'm learning on my quest to become a Git and GitHub pro.&lt;/p&gt;

&lt;p&gt;Today I'm covering the basics of creating a git repository, branches, commits, push, pull, and merge. &lt;/p&gt;

&lt;p&gt;Before we begin, if you don't have Git installed on your computer you can click the link to find information about &lt;a href="https://www.atlassian.com/git/tutorials/install-git"&gt;Git Installation&lt;/a&gt;. And if you haven't already, you can create an account at &lt;a href="https://github.com/"&gt;GitHub.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Git Repository
&lt;/h2&gt;

&lt;p&gt;There are a two different situations in which you would want to create a git repository. Let's go over how to do this in the command line for each situation. &lt;br&gt;
&lt;strong&gt;Existing Local Directory:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd path/to/directory
git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First you change directories to the one you want to create a git repository for and then you enter &lt;code&gt;git init&lt;/code&gt;. This creates the git repository for the directory that you are in.&lt;br&gt;
&lt;strong&gt;Cloning an Existing Repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd path/to/directory
git clone &amp;lt;url/to/remote/repository&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cloning is used when you want to copy an existing repository to a directory on your local machine. Again you want to switch to the directory where you want to copy the repository. Then you enter &lt;code&gt;git clone&lt;/code&gt; followed by the URL of the remote repository you want to clone. &lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a Remote
&lt;/h2&gt;

&lt;p&gt;In the case of &lt;code&gt;git clone&lt;/code&gt;, your directory is automatically connected to to remote that you copied it from. But what about &lt;code&gt;git init&lt;/code&gt;? In that case you need to manually add a remote.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin &amp;lt;url/to/remote/repository&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command &lt;code&gt;git remote add&lt;/code&gt; accepts two arguments, whatever you want to name the remote, and the URL to the remote repository. Origin is a typically used for the name but you could choose anything. The remote is an online copy of your repository, hence the URL. IF you don't know how to create repository on GitHub and find the associated URL, click this &lt;a href="https://help.github.com/en/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Branch
&lt;/h2&gt;

&lt;p&gt;It's generally considered bad form to work directly off you master branch, so the first thing you want to do is create a feature branch.&lt;br&gt;
&lt;strong&gt;Option 1:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch [branch-name]
git checkout [branch-name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 2:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b [branch-name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Option 1 tells Git to create a branch called &lt;em&gt;branch-name&lt;/em&gt;, then &lt;code&gt;git checkout&lt;/code&gt; tells Git to switch to the branch called &lt;em&gt;branch-name&lt;/em&gt;. Option 2 does both of those things in one command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Committing Changes
&lt;/h2&gt;

&lt;p&gt;So you have your repository initialized, you're connected to a remote repository, and you're on a new branch. Now you're ready to make changes and commit those changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
git commit -m "commit message"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before you can commit your changes you need to tell Git what you want to be in the commit. The command &lt;code&gt;git add .&lt;/code&gt; stages all the files that have been changed since your last commit and tells Git they should be added to the next commit. The &lt;code&gt;git commit&lt;/code&gt; command takes a snapshot of the code as it stands at that moment. It's important to add a descriptive commit message so other developers can get an idea of what was updated in that commit, which you do with the &lt;code&gt;-m&lt;/code&gt; option.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pushing Changes to Remote
&lt;/h2&gt;

&lt;p&gt;To sync the remote with the local repository we use the &lt;code&gt;git push&lt;/code&gt; command.&lt;br&gt;
&lt;strong&gt;If it's your first push:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push -u [remote-name] [branch-name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Any other push:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push [remote-name] [branch-name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;git push&lt;/code&gt; accepts two arguments, the name of the remote you want to push to, and the branch you want to push. The first time you push to your remote repository, you should use the &lt;code&gt;-u&lt;/code&gt; option with tells git to add upstream tracking references. The &lt;code&gt;git push&lt;/code&gt; command will add the local commits to the remote copy of the branch. &lt;/p&gt;

&lt;h2&gt;
  
  
  Pulling Changes from Remote
&lt;/h2&gt;

&lt;p&gt;What if our working with someone else on the same repository and you need to update your local copy with changes that someone else added to the remote copy. You can do this with &lt;code&gt;git pull&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull [remote-name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will update your local directory with all of the new commits that are on the remote repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Merging
&lt;/h2&gt;

&lt;p&gt;Once you have some new feature or change made on your branch, it's time to merge those changes into master.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout master
git merge [feature-branch-name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First you want to switch to the branch you want to merge your feature branch into, in this case 'master'. Then you pass the &lt;code&gt;git merge&lt;/code&gt; the name of the branch you want to merge into the current branch. &lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;And that's it! Well not quite. That's the tip of the iceberg, but it's what you need to know to get started. In the weeks to come I'll be going into more depth on these topics and as well as more advanced Git commands. But for now, let's review:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git init&lt;/code&gt;: Creates the git repository for the directory that you're in.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git clone &amp;lt;url/to/remote/repository&amp;gt;&lt;/code&gt;: Copies a remote git repository to the current directory on your local machine.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git remote add [remote-name] &amp;lt;url/to/remote/repository&amp;gt;&lt;/code&gt;: Connects the git repository of the directory your currently into the remote at the URL given. It also assigns this remote repository the name given([remote-name]).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch [branch-name]&lt;/code&gt;: Creates a new branch with the name given.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout [branch-name]&lt;/code&gt;: Switches to the branch that matches the name given.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git checkout -b [branch-name]&lt;/code&gt;: Create a new branch with the name given and switches to that branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add .&lt;/code&gt;: Prepares all changed files on this branch to be added to the next commit.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git commit -m "commit message"&lt;/code&gt;: Creates a commit and adds a descriptive message to that commit. A commit is a snapshot of the code as it currently stands.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push -u [remote-name] [branch-name]&lt;/code&gt;: Adds new local commits to the remote repository. The &lt;code&gt;-u&lt;/code&gt; option adds remote tracking on your first push, though it can be omitted on all pushes after that.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git pull [remote-name]&lt;/code&gt;: Updates your local directory with all of the new commits that are on the remote repository.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git merge [branch-name]&lt;/code&gt;: Merges the commits from the branch listed into the branch that you are currently on.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.cloudsavvyit.com/2464/how-to-use-git-with-multiple-remote-repositories/"&gt;Cover Image&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/setting-up-a-repository"&gt;Setting Up a Repository - atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone"&gt;Git Clone - atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-clone"&gt;Git Clone - git docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://help.github.com/en/github/using-git/adding-a-remote"&gt;Adding a Remote - GitHub.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.github.com/training-kit/downloads/github-git-cheat-sheet.pdf"&gt;Git Cheatsheet - GitHub.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/saving-changes"&gt;Saving Changes - atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/saving-changes/git-commit"&gt;Git Commit - atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/syncing/git-push"&gt;Git Push - atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/syncing/git-pull"&gt;Git Pull - atlassian.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.atlassian.com/git/tutorials/using-branches/git-merge"&gt;Git Merge - atlassian.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>beginners</category>
    </item>
    <item>
      <title>HTML5 Form Validation Using Input Types</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 18 May 2020 04:30:40 +0000</pubDate>
      <link>https://dev.to/lofiandcode/html5-form-validation-using-input-types-2e48</link>
      <guid>https://dev.to/lofiandcode/html5-form-validation-using-input-types-2e48</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/cloudchord/sunlit&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Last week I wrote a post about how to use input tag attributes to implement form validation without JavaScript. This week I wanted to cover go over how you can use input tag types to implement form validation, again without JavaScript.&lt;/p&gt;

&lt;p&gt;The great thing about using input tag types for form validation is that while some will generate an alert to tell the user they made a bad entry, many others will simply not allow the user to make an invalid entry in the first place. &lt;/p&gt;

&lt;p&gt;Now there are quite a few input tag types, but I chose to show you the 6 types that I thought would be the most useful in restricting form inputs. And just like last week, at the end of this post I embedded a CodePen so you experiment with examples of all the types covered.&lt;/p&gt;
&lt;h2&gt;
  
  
  Date
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;date&lt;/code&gt; input type creates a field in which the user can only enter a date in the format "mm/dd/yyyy". This is an example of one of the input types that doesn't allow the user to enter an invalid input, rather than creating an alert on submit. If the browser supports it, this field will have a date picker to assist when entering a date. Also, the &lt;code&gt;date&lt;/code&gt; input type is not supported by Safari or Internet Explorer 11(or earlier). Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'form'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'date-example'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Date:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'date'&lt;/span&gt; 
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'date-example'&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Time
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;time&lt;/code&gt; input type creates a field in which the user can only enter a time in the format "00:00 AM/PM". Be aware that this input type is not supported by Safari or Internet Explorer 12(or earlier). Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'form'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'time-example'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Time:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'time'&lt;/span&gt; 
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'time-example'&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Email
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;email&lt;/code&gt; input type creates a field which will create an alert if the user does not enter an email address. Another cool feature of this field is that some smartphones will recognize it and add a ".com" to the keyboard. Here's an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'form'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'email-example'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Email:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'email'&lt;/span&gt; 
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'email-example'&lt;/span&gt; 
    &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;'example@example.com'&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  URL
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;url&lt;/code&gt; input type creates a field which will create an alert if the user does not enter a url. Like this email type, some smartphones will also recognize it and add a ".com" to the keyboard. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'form'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'url-example'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;URL:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'url'&lt;/span&gt; 
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'url-example'&lt;/span&gt; 
  &lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Number
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;number&lt;/code&gt; input type creates a field in which the user can only enter a number. In addition to preventing the user from entering letters or symbols with this input type, you can also use the 'min', 'max', and 'step' attributes we covered last week to further restrict the user's entries. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'form'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'number-example'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Number:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'number'&lt;/span&gt; 
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'number-example'&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Range
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;range&lt;/code&gt; input type creates a field in which the user can only operate a slide bar. The default range of the slide bar is 0 to 100, but you can use the &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; attributes to set a custom range. You can also set how the slide bar increments between the min and max with the &lt;code&gt;step&lt;/code&gt; attribute. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'form'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'range-example'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Range (0-30):&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'range'&lt;/span&gt; 
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'range-example'&lt;/span&gt;
    &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt;
    &lt;span class="na"&gt;max=&lt;/span&gt;&lt;span class="s"&gt;"30"&lt;/span&gt;
    &lt;span class="na"&gt;step=&lt;/span&gt;&lt;span class="s"&gt;"5"&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Interactive Example
&lt;/h2&gt;

&lt;p&gt;As you try entering invalid values in each field, be aware that only the email and url input fields will create an alert if you enter an invalid entry. The other field will simply prevent you from making an invalid entry.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/MWazwMe?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;date&lt;/code&gt; input type creates a field in which the user can only enter a date in the format "mm/dd/yyyy".&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;time&lt;/code&gt; input type creates a field in which the user can only enter a time in the format "00:00 AM/PM".&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;email&lt;/code&gt; input type creates a field which will create an alert if the user does not enter an email address.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;url&lt;/code&gt; input type creates a field which will create an alert if the user does not enter a url.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;number&lt;/code&gt; input type creates a field in which the user can only enter a number.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;range&lt;/code&gt; input type creates a field in which the user can only operate a slide bar. The default range of the slide bar is 0 to 100, but you can use the &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; attributes to set a new range.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to read more about these and all the other input types in HTML5, click the w3shools link under references.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://www.theresiliencyinstitute.net/we-need-your-input/"&gt;Cover Image&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/html/html_form_input_types.asp"&gt;HTML Input Types - w3schools.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/MWazwMe"&gt;Input Type Examples - codepen.io/lofiandcode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>beginners</category>
    </item>
    <item>
      <title>HTML5 Form Validation</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 11 May 2020 04:00:33 +0000</pubDate>
      <link>https://dev.to/lofiandcode/html5-form-validation-1f4c</link>
      <guid>https://dev.to/lofiandcode/html5-form-validation-1f4c</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/mishabeatsyou/misha-evil-needle-dreams&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;br&gt;
This week I've been learning about all the different input tag types and attributes in HTML5, and I discovered that HTML5 has some built in form validation. That means you can produce warning messages to notify the user of an invalid entry, all without any JavaScript. &lt;/p&gt;

&lt;p&gt;Let's go over four the input tag attributes that I felt were some of the most useful when implementing form validation. Then at the end, you can see how all these attributes work in the embedded CodePen.&lt;/p&gt;
&lt;h2&gt;
  
  
  Required
&lt;/h2&gt;

&lt;p&gt;The most basic and widely applicable form validation attribute is &lt;code&gt;required&lt;/code&gt;. By simply adding this attribute to the input tag, HTML5 will generate an alert message if the user tries to submit that form without entering a value in that field. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'name-field'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Name:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'text'&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'name-field'&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Min and Max
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; attribute allow you to define a range of valid entries to the following input tag types: number, range, date, datetime-local, month, time and week. This can be very useful if you want the user to enter a rating from 1-10, or to choose a day after a certain date. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'rate-field'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Rating(1-10):&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'number'&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'rate-field'&lt;/span&gt; &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;'1'&lt;/span&gt; &lt;span class="na"&gt;max=&lt;/span&gt;&lt;span class="s"&gt;'10'&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;step&lt;/code&gt; attribute sets an amount by which the value in the field can increase or decrease. So for example, if the input tag is a number type and &lt;code&gt;step&lt;/code&gt; equals 5, then the number entered much be divisible by 5. The &lt;code&gt;step&lt;/code&gt; attribute works with all of the following input tag types: number, range, date, datetime-local, month, time and week. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'donation-field'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Would you like to donate to charity?&lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
    Enter a dollar amount in multiples of $5:
  &lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'number'&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'donation-field'&lt;/span&gt; &lt;span class="na"&gt;step=&lt;/span&gt;&lt;span class="s"&gt;'5'&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Pattern
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;pattern&lt;/code&gt; attribute allows you to use a regular expressions to validate the input. This makes &lt;code&gt;pattern&lt;/code&gt; extremely powerful and allows you to customize the input requirements to that input's specific needs. This could be useful if the input was for 3 letter airport codes or license plate numbers. The &lt;code&gt;pattern&lt;/code&gt; attribute can be used with the following input tag types: text, date, search, url, tel, email, and password. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;'airport-field'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Airport Code:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;'text'&lt;/span&gt; 
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'airport-field'&lt;/span&gt; 
    &lt;span class="na"&gt;pattern=&lt;/span&gt;&lt;span class="s"&gt;[A-Z]{3}&lt;/span&gt; 
    &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;'Enter the 3 capitolized letter code.'&lt;/span&gt; 
    &lt;span class="na"&gt;required&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Interactive Example
&lt;/h2&gt;

&lt;p&gt;To give you a chance to see all these in action I created a simple Airport survey that a hypothetical passenger might fill out. As you try entering invalid values in each field, be aware the HTML5 will always produce an alert on the first field in the form that has an invalid entry. So if you want to see the alerts for an input farther down, you need to enter valid entries in the input fields above.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/dyYeaaP?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;required&lt;/code&gt; attribute will require the user to entry a value in the field before the form can be submitted.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;min&lt;/code&gt; attribute sets a minimum value that is valid for the input field.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;max&lt;/code&gt; attribute sets a maximum value that is valid for the input field.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;step&lt;/code&gt; attribute sets an amount by which the value in the field can increase or decrease.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;pattern&lt;/code&gt; attribute allows you to use a regular expressions to validate the input.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.cerner.com/ae/en/blog/alert-fatigue-the-cause-and-effect"&gt;Cover Image&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/html/html_form_attributes.asp"&gt;HTML Input Attributes - w3schools.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/dyYeaaP"&gt;Airport Survey Form - codepen/lofiandcode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>beginners</category>
    </item>
    <item>
      <title>React Native Elements: Disabling the Checkbox Component</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 04 May 2020 01:43:47 +0000</pubDate>
      <link>https://dev.to/lofiandcode/react-native-elements-disabling-the-checkbox-component-3j8l</link>
      <guid>https://dev.to/lofiandcode/react-native-elements-disabling-the-checkbox-component-3j8l</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/benbadaboom/ben-bada-boom-blossom&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;While working on a React Native app this week I ran into a problem. How do I make a checkbox component that accepted four specific properties? Those properties were &lt;code&gt;checked&lt;/code&gt;, &lt;code&gt;onChange&lt;/code&gt;, &lt;code&gt;disable&lt;/code&gt;, and &lt;code&gt;size&lt;/code&gt; or &lt;code&gt;style&lt;/code&gt;. The first place I looked was React Native's core components and was surprised to discover that they didn't have a checkbox component. I could have used the button component, but that would have involved a lot of customizing and I thought, "Surely someone else has made a checkbox component, so why reinvent the wheel?"&lt;/p&gt;

&lt;p&gt;Then I found the Native Base checkbox component that works on both iSO and Android. I got excited only to learn from the documentation that it didn't have a &lt;code&gt;disable&lt;/code&gt; or &lt;code&gt;style&lt;/code&gt; property, again adding to the amount of customization needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Native Elements CheckBox
&lt;/h2&gt;

&lt;p&gt;Finally, I found the CheckBox component from React Native Elements! It had everything; &lt;code&gt;checked&lt;/code&gt;, &lt;code&gt;onPress&lt;/code&gt;, &lt;code&gt;size&lt;/code&gt;, &lt;code&gt;containerStyle&lt;/code&gt;, &lt;code&gt;checkedIcon&lt;/code&gt;, &lt;code&gt;uncheckedIcon&lt;/code&gt;...the list went on. I was particularly excited by those last two properties because I was eventually going to have to add a custom checkbox icon. But wait, no &lt;code&gt;disabled&lt;/code&gt; property? Really? Yeah, not ideal, but it was the best I could find. So it was time to customize.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Your Environment
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Online Development Environment
&lt;/h4&gt;

&lt;p&gt;To play around with this code in an online development environment, go to &lt;a href="https://expo.io/tools#snack"&gt;Expo Snack.&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Local Development Environment
&lt;/h4&gt;

&lt;p&gt;If you already have your local environment set up to run React Native apps, then you can just install React Native Elements and skip the rest. Otherwise, follow the installation directions below.&lt;/p&gt;

&lt;p&gt;To run locally, this is what you'll need to have installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node and npm 

&lt;ul&gt;
&lt;li&gt;Click to learn &lt;a href="https://www.freecodecamp.org/news/how-to-install-node-js-and-npm-on-windows/"&gt;how to install Node and npm.&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;React JS

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;npm install react&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;React Native

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;npm install react-native&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;React Native Elements

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;npm install react-native-elements&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Adding Disable Functionality
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Fragment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TouchableOpacity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;TouchableWithoutFeedback&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;CheckBox&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native-elements&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Checkbox&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;handleOnPress&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="c1"&gt;// Returns an enabled or disabled Checkbox depending on the value of this.props.disabled&lt;/span&gt;
  &lt;span class="nx"&gt;isDisabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CheckBox&lt;/span&gt; 
          &lt;span class="na"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;TouchableWithoutFeedback&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm a Checkbox&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;iconRight&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CheckBox&lt;/span&gt; 
        &lt;span class="na"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;TouchableOpacity&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; 
        &lt;span class="na"&gt;onPress&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleOnPress&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm a Checkbox&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;iconRight&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Fragment&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isDisabled&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Fragment&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Checkbox&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the React Native Elements CheckBox component didn't have a &lt;code&gt;disabled&lt;/code&gt; property, I added one in my custom component by writing a class component function called &lt;code&gt;isDisabled&lt;/code&gt;. The function returns either an enabled or a disabled version of the CheckBox component based on the value of &lt;code&gt;this.props.disabled&lt;/code&gt;. So when the function is called within the &lt;code&gt;render()&lt;/code&gt; function, only the desired version of the &lt;code&gt;&amp;lt;CheckBox /&amp;gt;&lt;/code&gt; is rendered.&lt;/p&gt;

&lt;p&gt;If you'd like to see how this code works you can click these two clicks to my Expo Snack account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://snack.expo.io/@lofiandcode/checkbox-example---disabled-=-false"&gt;Checkbox Example: disabled = false&lt;/a&gt;&lt;br&gt;
&lt;a href="https://snack.expo.io/@lofiandcode/checkbox-example---disabled-=-true"&gt;Checkbox Example: disabled = true&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;If you're new to React or React Native, remember this trick. I've found that executing a function in &lt;code&gt;render()&lt;/code&gt; is a really powerful way to implement all kinds of behaviors. Maybe, like the example above, you want to conditionally render certain components. Or maybe you want to loop through an array of components and display all or some of the components in that array. There are lots of possibilities.&lt;/p&gt;

&lt;p&gt;And finally, like many of you I'm always looking for the best ways of tackling these problems. So if you know of a better way to implement this checkbox example, please leave comment and share you're approach. &lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://atendesigngroup.com/blog/radios-checkboxes-and-drupal%E2%80%99s-admin-interface"&gt;Cover Image&lt;/a&gt;&lt;br&gt;
&lt;a href="https://reactnative.dev/docs/button"&gt;React Native - Button&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.nativebase.io/Components.html#checkbox-headref"&gt;Native Base - CheckBox&lt;/a&gt;&lt;br&gt;
&lt;a href="https://react-native-elements.github.io/react-native-elements/docs/checkbox.html"&gt;React Native Elements - CheckBox&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/how-to-install-node-js-and-npm-on-windows/"&gt;freeCodeCamp.org - how to install Node and npm.&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/56869192/how-to-disable-react-native-elements-checkbox-touchable-opacity"&gt;stackoverflow - How to disable react-native-element's checkbox touchable opacity?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Vanilla CSS - Icon Animation</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 27 Apr 2020 04:13:14 +0000</pubDate>
      <link>https://dev.to/lofiandcode/vanilla-css-icon-animation-501e</link>
      <guid>https://dev.to/lofiandcode/vanilla-css-icon-animation-501e</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/alexcavoli-2/together&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;br&gt;
In my last post I covered how to create animations with vanilla CSS, and this week I wanted to build on that by showing you how use animations in a practical way. When building a web page it's very common to add clickable icons on the page that link to other sites, like a related social media account. Giving that icon an animation improves the user experience by indicating that the icon is clickable.&lt;/p&gt;
&lt;h2&gt;
  
  
  Pseudo-class &lt;code&gt;:hover&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A quick and easy way to make an icon interactive is to increase its size when the mouse hovers over it. We can do that with the &lt;code&gt;:hover&lt;/code&gt; pseudo-class. This pseudo-class allows us to change the styling of the icon based on the state it's in. So in this case, we are changing the styling whenever the mouse hovers over the icon.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/JjYNLPq?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;If you click on the CSS tab in the codepen above, you can see that following code towards the bottom.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#linkedin&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This selector identifies the element with id="linkedin" and indicates that the following styling should be applied when the mouse hovers over that element. The styling being applied is the &lt;code&gt;transform&lt;/code&gt; property with a value of &lt;code&gt;scale(1.1)&lt;/code&gt;. This causes the element to increase in size by a factor of 1.1. You can decrease the size of the element if you enter a number below 1 into the scale function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Color Transition
&lt;/h2&gt;

&lt;p&gt;Increasing the size of the icon is cool, but what if we wanted to change the color of the icon as well. For this we'll need to create an animation in CSS similar to the ones we created last week.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/oNjWqzg?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;To create this affect, the following code was added to the CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#linkedin&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linkedin-icon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500ms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;linkedin-icon&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0077B5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;animation-name&lt;/code&gt; property links the animation in the &lt;code&gt;@keyframes&lt;/code&gt; block below to the &lt;code&gt;#linkedin:hover&lt;/code&gt; block, so when the mouse hovers over the icon it will trigger the animation. Notice that &lt;code&gt;@keyframes&lt;/code&gt; block only has a 100% style block. Normally there is a 0% style block which specifies starting the properties. Without it, the element will start at it's default properties and then transition to the properties in the 100% over the &lt;code&gt;animation-duration&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Animation Fill Mode
&lt;/h2&gt;

&lt;p&gt;You may have noticed that the icon did not stay blue after the animation was complete. That's because the default behavior is for the element to return to the styling before the animation was applied. If the you want the icon to retain the properties it had at the end of the animation, you need to specify that with the &lt;code&gt;animation-fill-mode&lt;/code&gt; property.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/GRpmQXJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The final change to the CSS can be seen below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#linkedin&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linkedin-icon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500ms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-fill-mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;forwards&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;linkedin-icon&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0077B5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;code&gt;#linkedin:hover&lt;/code&gt; block &lt;code&gt;animation-fill-mode&lt;/code&gt; is set to forwards. This tells the web browser that you want the styling at the end of the animation to continue to be applied to the element even after the animation is complete.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;And that's it. Now you have some simple tools to make links or buttons on your web pages more interaction. Let's quickly review the tools we used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pseudo-class &lt;code&gt;:hover&lt;/code&gt; - When added immediately after the CSS selector it will apply the styling in the block when the mouse hovers over the element.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;transform: scale(1.1);&lt;/code&gt; - Increases the size of the element by a factor of 1.1. Entering a number less than 1 will decrease the element's size.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;animation-name: animation_name;&lt;/code&gt; - Tells the web browser which @keyframes it should apply during the element's animation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@keyframes animation_name {0%{/*css styling*/} 100%{/*css styling*/}}&lt;/code&gt; - Describes the states that the element should transition through to create the animation (0% = starting state and 100% = ending state). The "animation_name" should match the one used for the &lt;code&gt;animation-name&lt;/code&gt; of the appropriate element.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;animation-duration: /*time in seconds*/;&lt;/code&gt; - Tells the web browser how long it should take to complete the animation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;animation-fill-mode: forwards;&lt;/code&gt; - Tells the web browser to continue applying the styling that was applied at the end of the animation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you'd like to learn more about this topic, click the links under References.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.freevector.com/social-media-icons"&gt;Icons Cover Image - freevector.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/"&gt;FreeCodeCamp.org - Responsive Web Design/Applied Visual Design&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/css/css_pseudo_classes.asp"&gt;CSS Pseudo-classes - w3schools.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/css/css_link.asp"&gt;CSS Styling Links - w3schools.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp"&gt;CSS @keyframes Rules - w3schools.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/cssref/css3_pr_animation-fill-mode.asp"&gt;CSS animation-fill-mode Property - w3schools.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/JjYNLPq"&gt;Scale Icon on Hover CodePen&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/oNjWqzg"&gt;Icon Animation without Animation Fill Mode CodePen&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/GRpmQXJ"&gt;Complete Icon Animation CodePen&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Vanilla CSS - Animation Timing Functions</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Sun, 19 Apr 2020 01:44:11 +0000</pubDate>
      <link>https://dev.to/lofiandcode/vanilla-css-animation-timing-functions-4j2c</link>
      <guid>https://dev.to/lofiandcode/vanilla-css-animation-timing-functions-4j2c</guid>
      <description>&lt;h3&gt;
  
  
  Song of the Week
&lt;/h3&gt;

&lt;p&gt;&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/brock1112/in-my-love&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I've been working on improving my vanilla CSS skills, and I'm learning some pretty cool stuff. So, this week I thought I'd share what I've learned about basic animation and animation timing functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Declaring an Animation
&lt;/h2&gt;

&lt;p&gt;Before you can add a timing function to your animation, you need to know the syntax for adding an animation to an element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/*Name of the animation to assign to the element*/&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cool_animation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/*How long you want the animation to take to complete its action*/&lt;/span&gt;
  &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;cool_animation&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/*Characteristics/location of the element at the start of animation*/&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c"&gt;/*You can add multiple percentage point blocks here. The element will transition through each.*/&lt;/span&gt;
  &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/*Characteristics/location of the element at the end of animation*/&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add an animation to an element you simply declare an animation name and duration inside the selector block for that element. You can also declare these inside the class selector block and the animation will be added to all elements in that class.&lt;/p&gt;

&lt;p&gt;You also need specific instructions on what animation is supposed do to over that animation-duration. This is done by creating a @keyframes block with the same name as the one declared in the selector block. In the @keyframes block you can specify positions, colors, size or anything else that the element should have at an exact movement in the animation. Start of the animation is represented by a 0% block and the end is represented by a 100% block. If you only set a 0% and a 100% block, the element with transition between the two over the animation-duration. However, you can also add other percentage blocks between 0% and 100%, the element will transition through each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timing Functions
&lt;/h2&gt;

&lt;p&gt;To fine tune the variation of the element's speed as it moves through the animation, you can add a property called animation-timing-function. This is declared in the selector block and would look like this,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/*Name of the animation to assign to the element*/&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cool_animation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/*How long you want the animation to take to complete its action*/&lt;/span&gt;
  &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/*Defines the speed at which the element transitions through different parts of the animation.
  Basic values include linear, ease, ease-in, ease-out.*/&lt;/span&gt;
  &lt;span class="nl"&gt;animation-timing-function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are four basic timing function values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;linear: even speed over the whole animation.&lt;/li&gt;
&lt;li&gt;ease: slow in the beginning, fast in the middle, and slow at the end.&lt;/li&gt;
&lt;li&gt;ease-in: starts slow and then speeds up as it moves to the end.&lt;/li&gt;
&lt;li&gt;ease-out: starts fast and then slows down as it moves to the end.
If you don't set any timing function, the default is ease.
&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/MWaeEvg?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Above we can see examples of all four basic timing functions. The red, green, blue, and purple balls are set to linear, ease, ease-in, and ease-out, respectively. &lt;/p&gt;

&lt;p&gt;Notice that,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All the balls start and stop their animations at exactly the same time but how they get there in between is different.&lt;/li&gt;
&lt;li&gt;This is the difference between the animation-duration and animation-timing-function properties.&lt;/li&gt;
&lt;li&gt;In the .ball selector block, a property called animation-iteration-count is set to 'infinite'. This causes the animation to execute continuously. If it was set to say 3, for example, the animation when execute 3 times and then stop.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cubic-Bezier
&lt;/h2&gt;

&lt;p&gt;Maybe you're thinking, "Sure those timing functions are great, but none of them are giving me exactly the behavior I want." Not to worry! Vanilla CSS has got you covered with the cubic-bezier function.&lt;/p&gt;

&lt;p&gt;Cubic-bezier allows you to create a custom timing function by passing in 2 points on an x-y axis with the following syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/*Other properties*/&lt;/span&gt;

  &lt;span class="c"&gt;/*The points (x1, y1) and (x2, y2) can be any decimal point value, usually between 0 and 1, but they can also be values about 1.*/&lt;/span&gt;
  &lt;span class="nl"&gt;animation-timing-function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cubic-bezier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are the basic points to understand:&lt;/p&gt;

&lt;p&gt;cubic-bezier(x1, y1, x2, y2)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The default starting and end points are (0, 0) and (1, 1), respectively.&lt;/li&gt;
&lt;li&gt;The points you pass in can be any decimal point values, usually between 0 and 1, but they can also be values above 1.&lt;/li&gt;
&lt;li&gt;The same amount of time is allocated to go from (0, 0) to (x1, y1), (x1, y1) to (x2, y2), and finally (x2, y2) to (1, 1).&lt;/li&gt;
&lt;li&gt;Since speed = distance/time, as the points get farther apart the speed of the animation increases at that stage, and as the points get closer together the speed of the animation decrease at that stage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As an example, if point (x1, y1) is close to (0, 0) and point (x2, y2) is close to (1, 1), the cubic-bezier function will create a timing that makes the element's animation start slow, go really fast in the middle, and then go slow at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bouncing Balls Animation
&lt;/h2&gt;

&lt;p&gt;Let's say we wanted to create a natural motion like that of a bouncing ball. We can accomplish that with the cubic-bezier function and the animation-direction property.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/jObraqb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;If you click on the CSS tab on the CodePen above you'll see that I passed (0.5, 0.05) and (1, 0.5) into the cubic-bezier funcion. This creates a motion that closely approximates how a ball accelerates as it falls to the grown. To get the bounce back up effect, I set the animation-direction to "alternate." This causes the animation to alternate between going forwards and backwards through the animation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bouncing Balls with Varied Speeds Animation
&lt;/h2&gt;

&lt;p&gt;It's great that we have a natural bouncing ball animation now, but wouldn't it look cooler if the balls were bouncing at different rates?&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/lofiandcode/embed/yLYJNPL?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Remember when we talked about how the animation-duration and animation-timing-function properties were different? In the basic timing function example, we saw that all four balls had the same animation-duration but different animation-timing-function values. This caused them to motive out of sync. Well now we have three balls with the same animation-timing-function values, but each with a slightly different animation-duration. This causes them to move out of sync because they have different amounts of time to complete that same animation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;animation-name: keyframe_name;

&lt;ul&gt;
&lt;li&gt;Tells the element which @keyframes it should follow during animation.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;@keyframes keyframe_name {0%{/&lt;em&gt;Some properties&lt;/em&gt;/} 100%{/&lt;em&gt;Some properties&lt;/em&gt;/}}

&lt;ul&gt;
&lt;li&gt;Describes the states that the element should transition through to create the animation (0% = starting state and 100% = ending state). The "keyframe_name" should match the one used for the animation-name of the appropriate element.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;animation-duration: /&lt;em&gt;time in seconds&lt;/em&gt;/; 

&lt;ul&gt;
&lt;li&gt;Tells the element how long it should take to complete the animation.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;animation-iteration-count: /&lt;em&gt;integer&lt;/em&gt;/;

&lt;ul&gt;
&lt;li&gt;tells the element how many times to complete the animation. Setting this to "infinite" will cause the animation to run continuously.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;animation-timing-function: /&lt;em&gt;specify timing function&lt;/em&gt;/;
*defines any variation in the speed of the animation.

&lt;ul&gt;
&lt;li&gt;Possible values:&lt;/li&gt;
&lt;li&gt;linear: even speed over the whole animation.&lt;/li&gt;
&lt;li&gt;ease: slow in the beginning, fast in the middle, and slow at the end.&lt;/li&gt;
&lt;li&gt;ease-in: starts slow and then speeds up as it moves to the end.&lt;/li&gt;
&lt;li&gt;ease-out: starts fast and then slows down as it moves to the end.
&lt;/li&gt;
&lt;li&gt;cubic-bezier(x1, y1, x2, y2) - sets custom timing function based the two points passed in.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Setting different animation-durations or animation-timing-functions for two elements with the same @keyframes block will make them perform the same animation at different rates.&lt;/li&gt;
&lt;li&gt;animation-direction: alternate;

&lt;ul&gt;
&lt;li&gt;Causes the element to perform the animation in reverse after it has performed it in the forward direction.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of what is covered in this post I learned on freeCodeCamp.org. Definitely check it out. It's an amazing free resource if you want to learn frontend development, or if like me, you want to expand on what you already know. &lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://tweepsy.com/media/contentmanager/content/pictures/default/ball-pit-ready-for-cleaning.jpg"&gt;Cover Image&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/"&gt;FreeCodeCamp.org - Responsive Web Design/Applied Visual Design&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/MWaeEvg"&gt;Animation Timing Functions CodePen&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/jObraqb"&gt;Bouncing Balls CodePen&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codepen.io/lofiandcode/pen/yLYJNPL"&gt;Bouncing Balls with Varied Speed CodePen&lt;/a&gt;&lt;br&gt;
&lt;a href="https://codeburst.io/tutorial-make-a-bouncing-ball-entirely-with-css-1e7e3c853a50"&gt;Making a Bouncing Ball Entirely with CSS&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Big O Notation: O(N!)</title>
      <dc:creator>Joseph Trettevik</dc:creator>
      <pubDate>Mon, 13 Apr 2020 02:14:45 +0000</pubDate>
      <link>https://dev.to/lofiandcode/big-o-part-6-n-58e3</link>
      <guid>https://dev.to/lofiandcode/big-o-part-6-n-58e3</guid>
      <description>&lt;h3&gt;
  
  
  Song of The Week
&lt;/h3&gt;

&lt;p&gt;Haha, this isn't really the song of the week, but I couldn't have a Top Gun themed post and NOT embed Danger Zone by the great Kenny Loggins! I put the real song of the week at the bottom.&lt;br&gt;
&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/kennyloggins/danger-zone&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Danger Zone!
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/De5Lfx0LI1SjS/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/De5Lfx0LI1SjS/giphy.gif" alt="Gif of the Archer version of the motorcycle scene from Top Gun"&gt;&lt;/a&gt;&lt;br&gt;
Okay technically we were in the Danger Zone with O(2&lt;sup&gt;N&lt;/sup&gt;), O(n&lt;sup&gt;2&lt;/sup&gt;), and even O(N log N) to certain extent. But O(N!) is really bad. You should definitely avoid writing code that has a time complexity of O(N!).&lt;/p&gt;

&lt;p&gt;Now you may be thinking, "How bad can it be?" It's pretty bad. Let's take a look at why. &lt;/p&gt;

&lt;p&gt;Suppose you passed an array of length 5 to a function with a time complexity of O(2&lt;sup&gt;N&lt;/sup&gt;). In that case, the number of iterations of the code would be:&lt;/p&gt;

&lt;p&gt;2 * 2 * 2 * 2 * 2 = 32 &lt;/p&gt;

&lt;p&gt;Now suppose you passed that same array to a function with a time complexity of O(N!). The number of iterations would then be:&lt;/p&gt;

&lt;p&gt;1 * 2 * 3 * 4 * 5 = 120&lt;/p&gt;

&lt;p&gt;In this example, the O(N!) function performed almost 4 times as many iterations as the O(2&lt;sup&gt;N&lt;/sup&gt;). However, it gets worst as N increases. Watch what happens to the number of iterations required for both functions as N increases.&lt;/p&gt;

&lt;p&gt;O(2&lt;sup&gt;N&lt;/sup&gt;) :&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;N&lt;/th&gt;
&lt;th&gt;Number of Iterations&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;2 * 2 * 2 * 2 * 2 * 2 = 64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;2 * 2 * 2 * 2 * 2 * 2 * 2 = 128&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 512&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;O(N!) :&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;N&lt;/th&gt;
&lt;th&gt;Number of Iterations&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;1 * 2 * 3 * 4 * 5 * 6 = 720&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;1 * 2 * 3 * 4 * 5 * 6 * 7 = 5,040&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 = 40,320&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 = 362,880&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;After only increasing N to 9, the O(N!) function now performs 709 times as many iterations as the O(2&lt;sup&gt;N&lt;/sup&gt;) function! That's crazy, right?! Imagine if N equaled 100, or 1000?&lt;/p&gt;

&lt;p&gt;The reason the factoral is increasing at such a faster rate is because while the total is multipled by 2 each time in 2&lt;sup&gt;N&lt;/sup&gt;, the total is multiplied by a number that continues to increase each time in the case of N!.&lt;/p&gt;
&lt;h2&gt;
  
  
  Basic Example
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/82x3ZQtqp9M88/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/82x3ZQtqp9M88/giphy.gif" alt="Gif of the Archer version of classroom scene from Top Gun"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nFacRuntimeFunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;nFacRuntimeFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example function doesn't do any thing other than execute N! times, but that makes it ideal for helping us understand what to look for. If n = 3, then the for loop will make 3 recursive calls and pass in n = 2. Then those calls will make 2 recusive calls, which will both make 1 recusive call.&lt;/p&gt;

&lt;p&gt;So,&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv84i747il2r6qnhsa6el.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%2Fv84i747il2r6qnhsa6el.jpg" alt="Diagram showing all the nodes in the tree"&gt;&lt;/a&gt;&lt;br&gt;
If N = 4, then the function would create that same tree 4 times and complete 24 iterations of the code. Easy, right? We got this!&lt;/p&gt;

&lt;p&gt;If you'd like to see a non-trivial example of an algorithm with a time complexity of O(N!), checkout the brute force solution to the Traveling Salesman Problem. There's a link to this solution under references below.&lt;/p&gt;
&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/iByd2dFdFwKn6/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/iByd2dFdFwKn6/giphy.gif" alt="Gif of the Archer version of Goose and Maverick High Five scene from Top Gun"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stay off the highway to the Danger Zone.&lt;/li&gt;
&lt;li&gt;Watch for algorithms that make recursive calls from inside a loop that increases it's number of iterations as N increases.&lt;/li&gt;
&lt;li&gt;Checkout the brute force solution to the Traveling Salesman Problem, as well as the best solution. It's pretty interesting.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Real Song of The Week
&lt;/h3&gt;

&lt;p&gt;Sorry, I know the intro to this week's song is a little emo, but it's so good! Hope you like it! :)&lt;br&gt;
&lt;iframe width="100%" height="166" src="https://w.soundcloud.com/player/?url=https://soundcloud.com/ineotic/oui-lele-hopeless&amp;amp;auto_play=false&amp;amp;color=%23000000&amp;amp;hide_related=false&amp;amp;show_comments=true&amp;amp;show_user=true&amp;amp;show_reposts=false&amp;amp;show_teaser=true"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;Images and Gifs:&lt;br&gt;
&lt;a href="https://static.wixstatic.com/media/72b89f_e84ca9f39d834f3088918ecd136d93e0~mv2.jpg/v1/fill/w_742,h_412,al_c,lg_1,q_85/72b89f_e84ca9f39d834f3088918ecd136d93e0~mv2.jpg" rel="noopener noreferrer"&gt;Cover Image&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.giphy.com/media/De5Lfx0LI1SjS/giphy.gif" rel="noopener noreferrer"&gt;Archer - Top Gun motorcycle scene gif&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.giphy.com/media/82x3ZQtqp9M88/giphy.gif" rel="noopener noreferrer"&gt;Archer - Top Gun classroom scene gif&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.giphy.com/media/iByd2dFdFwKn6/giphy.gif" rel="noopener noreferrer"&gt;Archer - Top Gun High Five gif&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Technical:&lt;br&gt;
&lt;a href="https://www.mathsisfun.com/numbers/factorial.html" rel="noopener noreferrer"&gt;How to Calculate N!&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/3953244/example-of-on" rel="noopener noreferrer"&gt;Basic Example of O(N!) function - Stackoverflow&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www2.cs.sfu.ca/CourseCentral/125/tjd/tsp_example.html" rel="noopener noreferrer"&gt;Traveling Salesman Problem - Brute Force Solution&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.quora.com/What-is-the-optimal-and-best-algorithm-for-solving-the-traveling-salesman-problem" rel="noopener noreferrer"&gt;Traveling Salesman Problem - Best Solution&lt;/a&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>bigo</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
