<?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: Christina Blakely</title>
    <description>The latest articles on DEV Community by Christina Blakely (@ceblakely).</description>
    <link>https://dev.to/ceblakely</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%2F328606%2F5ac16ad6-1d06-426c-85be-64fe9c4cfdb1.jpeg</url>
      <title>DEV Community: Christina Blakely</title>
      <link>https://dev.to/ceblakely</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ceblakely"/>
    <language>en</language>
    <item>
      <title>Web-Security for Developers: Cross-Site Scripting (XSS)</title>
      <dc:creator>Christina Blakely</dc:creator>
      <pubDate>Sun, 02 Jan 2022 02:59:46 +0000</pubDate>
      <link>https://dev.to/ceblakely/web-security-for-developers-cross-site-scripting-xss-1hh9</link>
      <guid>https://dev.to/ceblakely/web-security-for-developers-cross-site-scripting-xss-1hh9</guid>
      <description>&lt;p&gt;While web designers and developers tend to be focused on the interface and functionality of a website, it is equally important to be aware of the potential a website has for security incidents that can adversely impact users. Cross-site scripting (XSS) is one of the most common attacks used against users, so let's talk about what we need to do to protect our websites and users from these attacks.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is XSS?
&lt;/h4&gt;

&lt;p&gt;XSS is when a vulnerability in a website allows an attacker to inject malicious code that is used against the user. This can typically look like a web request that contains content that is not validated prior to being presented to the user. XSS attacks usually come from JavaScript code, but it can sometimes present as HTML, Flash, or any other code the web browser can execute. There are three types of XSS attacks:&lt;/p&gt;

&lt;h5&gt;
  
  
  Stored XSS Attack, Type-1 XSS
&lt;/h5&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%2Fwww.imperva.com%2Flearn%2Fwp-content%2Fuploads%2Fsites%2F13%2F2016%2F03%2Freflected-cross-site-scripting-xss-attacks.png.webp" 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%2Fwww.imperva.com%2Flearn%2Fwp-content%2Fuploads%2Fsites%2F13%2F2016%2F03%2Freflected-cross-site-scripting-xss-attacks.png.webp" alt="Stored XSS Attack Diagram"&gt;&lt;/a&gt;&lt;br&gt;
This is when an attacker discovers a vulnerability that allows them to inject malicious code directly to the server, which is where it will stay and impact future users until it is removed. In this attack, a user will become a victim of the attack in response to placing a legitimate request. This type of attack has far greater consequences than the reflected XSS attack because it is more likely to affect each person that visits the compromised website. Websites that are more susceptible to stored XSS attacks are websites that allow users to share content, such as forums, blogs, social networks, or similar platforms. &lt;/p&gt;

&lt;h5&gt;
  
  
  Reflected XSS Attack, Type-2 XSS
&lt;/h5&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%2Fmiro.medium.com%2Fmax%2F748%2F1%2Ao_asKsD_JqunhqggHoxodw.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%2Fmiro.medium.com%2Fmax%2F748%2F1%2Ao_asKsD_JqunhqggHoxodw.png" alt="Reflected XSS Attack Diagram"&gt;&lt;/a&gt;&lt;br&gt;
This is when the malicious code is presented to the user, typically through a link the user clicks on, and the malicious code is injected into the website and used against the user that inadvertently initiated the attack. The importance of not clicking on strange links that have been emailed to you has been stressed to most people over the years, but many people are willing to trust a link that is present on a website they believe has integrity. &lt;/p&gt;

&lt;h5&gt;
  
  
  DOM-Based XSS, Type-0 XSS
&lt;/h5&gt;

&lt;p&gt;This is a lesser known attack compared to the stored and reflected XSS attacks, but it should still be acknowledged. This attack consists of modifying the website's DOM in the browser and changing the content. This can be problematic because it can spread misinformation and damage a company's reputation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Consequences of XSS
&lt;/h4&gt;

&lt;p&gt;The consequences of a successful XSS attack can be enough to cause severe business damage and ruin reputations forever. These attacks can compromise sensitive user data, allowing the attacker to access session information, credentials, or keystrokes. A business can suffer damages for spreading misinformation due to an attacker modifying a website’s content; imagine if an attacker defaced a corporate website or a government website with false information. This attack can also direct users to other malicious websites, leaving users susceptible to malware.&lt;/p&gt;

&lt;h4&gt;
  
  
  How do we prevent XSS?
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Input Validation
&lt;/h5&gt;

&lt;p&gt;Input validation allows us to determine if the input the user is providing is appropriate for the request being made. The developer must know what type of data is supposed to come from a specific input field; for example, if a user enters a number in an input field labeled 'First Name', that data should be rejected and not processed because it does not have the String type it was expecting. Using regular expressions or validation functions isn't a bad idea either, but attackers have created various ways to circumvent those types of barriers. &lt;/p&gt;

&lt;h5&gt;
  
  
  Input Sanitation
&lt;/h5&gt;

&lt;p&gt;Input sanitation is more about removing potentially dangerous characters from the user's input. There are a few options you can do based on the needs of the project. You can escape content using HTML entities, which replaces HTML tags with a special string of characters. See &lt;a href="https://www.freeformatter.com" rel="noopener noreferrer"&gt;here&lt;/a&gt; to demo that out. You can also use regular expressions to create a whitelist for allowed content and/or blacklist for disallowed content.&lt;/p&gt;

&lt;h5&gt;
  
  
  Utilize a Content Security Policy (CSP)
&lt;/h5&gt;

&lt;p&gt;A CSP is essentially instructions that are sent to the browser, along with the JavaScript code, to control how it is executed on the client-side. To view how to configure a CSP in your website, &lt;a href="https://content-security-policy.com/" rel="noopener noreferrer"&gt;check this out!&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Build your websites with security in mind in order to prevent XSS attacks that can compromise user data and the integrity of your projects. Drop any questions in the comments below!
&lt;/h4&gt;

</description>
      <category>security</category>
      <category>javascript</category>
    </item>
    <item>
      <title>GitHub Basics Pt. 2: Branches and Pull Requests</title>
      <dc:creator>Christina Blakely</dc:creator>
      <pubDate>Mon, 20 Dec 2021 23:58:25 +0000</pubDate>
      <link>https://dev.to/ceblakely/github-basics-pt-2-branches-and-pull-requests-3dfm</link>
      <guid>https://dev.to/ceblakely/github-basics-pt-2-branches-and-pull-requests-3dfm</guid>
      <description>&lt;h3&gt;
  
  
  This is Part 2 of our GitHub Basics series that will give answers to questions I had while learning about the version control platform GitHub. To read the Part 1 on initializing a repository and pushing to GitHub, see &lt;a href="https://dev.to/ceblakely/starting-with-github-made-easy-3g8"&gt;here!&lt;/a&gt; I'm going to break down the concept of branches, using the branches to manage your repository, and using pull requests to merge changes into your production branch.
&lt;/h3&gt;

&lt;p&gt;Utilizing branches in your project is a safe way to try new things that won’t impact the branch used for production. In most projects you will typically have at least two branches: Main and Master. These can be renamed to whatever suits you, but these are standard branch names. For example, you can create branch Main for development purposes and then create a pull request to merge those changes into the Master branch. It is best practice to not directly edit the Master branch, but to make changes in another branch and merge to the Master branch when the code has been tested and confirmed as stable. &lt;/p&gt;

&lt;h4&gt;
  
  
  This will allow you to have a reliable record of changes that are production-ready, so just in case an issue arises you can roll back to the Master/production branch's previous version. Lets get started. :)
&lt;/h4&gt;

&lt;p&gt;Command to check branch you are currently on:&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;git branch&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It will show all branches on your local repository and the branch you are currently on will be starred.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LQqVf7gu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ly1ukolbwhipwccbcuxl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LQqVf7gu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ly1ukolbwhipwccbcuxl.png" alt="Git Branch Command" width="485" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Command to create another branch based on the branch you're already on and automatically move over to that branch:&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;git checkout -b testbranch1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Command to create branch while remaining on the current branch:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git branch testbranch1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;When you have modified your code in the testbranch1 and want to add it to your production code on the Master branch, use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add filename.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;git commit -m "Commit message here for context"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;git push origin testbranch1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;You will want to go back to your repository in GitHub and select the Compare &amp;amp; pull request button seen below. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VAifoIr6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v93ciwkbxqsbpia6xuth.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VAifoIr6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v93ciwkbxqsbpia6xuth.png" alt="Creating Pull Request" width="880" height="242"&gt;&lt;/a&gt;&lt;br&gt;
 In my repository, I was working on the Main branch and will be merging the changes into the Master branch.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZIs81Gpz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwizw5cay54nnqcsdwaq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZIs81Gpz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwizw5cay54nnqcsdwaq.png" alt="Confirming Pull Request" width="859" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Doing a pull request can be useful if other people need to review what changes have been made before they are approved. To compare the changes, select the Pull Requests (1) Tab and select the name of your pull request; in my case, we would select the link that says "Collections template added."&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1OfJowWb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3x418fhjslnfg6lacmwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1OfJowWb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3x418fhjslnfg6lacmwt.png" alt="Overview of Pull Requests Tab" width="880" height="420"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7gvXz0EM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5aep0qbhgh6aphrnklma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7gvXz0EM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5aep0qbhgh6aphrnklma.png" alt="Comparison" width="880" height="353"&gt;&lt;/a&gt;&lt;br&gt;
 After you have finished reviewing the changes, you can finish by merging the pull request. &lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---UuwdxFS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvx37bs4v7irk58ljnn4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---UuwdxFS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvx37bs4v7irk58ljnn4.png" alt="Merge Pull Request" width="880" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have finished merging and closing the pull request, GitHub will let you know you can safely remove the development branch if you want.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0RZEFGJn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3q2pe5vav859il35110s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0RZEFGJn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3q2pe5vav859il35110s.png" alt="Delete Branch" width="880" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You don't have to delete the branch, but it is an option. You can also delete a branch through the terminal if you choose to. If you are needing to delete testbranch1, for example, you will need to move to the Main, Master, or another branch. Use these commands to change branches and delete testbranch1:&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;git checkout Main&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;git branch -d testbranch1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;




&lt;p&gt;I hope this helped clarify some points that had me confused when I first joined GitHub. Hit me up in the comments :) &lt;/p&gt;

</description>
      <category>github</category>
      <category>versioncontrol</category>
      <category>beginners</category>
    </item>
    <item>
      <title>GitHub Basics: Init, Commit, &amp; Push</title>
      <dc:creator>Christina Blakely</dc:creator>
      <pubDate>Sat, 26 Jun 2021 21:20:30 +0000</pubDate>
      <link>https://dev.to/ceblakely/starting-with-github-made-easy-3g8</link>
      <guid>https://dev.to/ceblakely/starting-with-github-made-easy-3g8</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7uljzn3xfabpr93lucx6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7uljzn3xfabpr93lucx6.png" alt="GitHub Heat Map"&gt;&lt;/a&gt;&lt;br&gt;
GitHub was a confusing and intimidating platform for me when I first started programming. I wasn’t sure what the point of it was or why I should be using it. After a few years using GitHub, I figured I would write a quick breakdown of the platform that would have been useful for me back then. &lt;/p&gt;

&lt;p&gt;To get started, let’s discuss why GitHub is used. GitHub is a place to host code, collaborate with other developers, and keep track of how the code has changed over time. This is also known as version control and it is important because if there is a problem with the code that has been pushed to production, there is a way to easily roll back changes to the last version of functional code. Also, it is not a good idea to only have versions of your code on your local machine in case your machine becomes compromised. &lt;/p&gt;

&lt;p&gt;I will assume you already have a &lt;a href="https://www.github.com" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; account and Git installed on your system and text editor. Now let’s get you started. &lt;/p&gt;

&lt;p&gt;Go to GitHub and create your new repository.&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%2Fi.ibb.co%2FGTv37Yz%2FScreen-Shot-2021-06-26-at-2-14-28-PM.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%2Fi.ibb.co%2FGTv37Yz%2FScreen-Shot-2021-06-26-at-2-14-28-PM.png" alt="Create new repository on GitHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create your project's folder in your text editor, add a file, and add some code.&lt;br&gt;&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%2Fi.ibb.co%2FL0GSsrS%2Fdev-1.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%2Fi.ibb.co%2FL0GSsrS%2Fdev-1.png" alt="text here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the terminal in your text editor or open the terminal/cmd application and change directories into your project folder. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You will now want to run the &lt;code&gt;git init&lt;/code&gt; command. This command is how you create, or initialize, a new project repository on your local machine. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you run the command above in the terminal and then run the &lt;code&gt;ls -la&lt;/code&gt; command, you will see a folder named &lt;strong&gt;.git&lt;/strong&gt; listed in the project structure. This folder is used to store project data that is used to keep track of changes occurring in each file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you have initialized the repository, you will want to add a file from your text editor to your local repository. For example, I have a file named index.html that needs to be added to my local repository. In the terminal, I am going to run &lt;code&gt;git add index.html&lt;/code&gt;. This command moves the index.html file from the working environment into the staging environment. The staging environment is for files that are ready to be added to the repository. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you run the command &lt;code&gt;git status&lt;/code&gt;, you will be able to see that index.html has been added to the staging environment, but has yet to be committed. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To commit a file, use the &lt;code&gt;git commit -m "commit message here"&lt;/code&gt; command. When a file change has been committed, it updates the &lt;strong&gt;.git&lt;/strong&gt; folder that will save the current state of that file. To verify that this has been done, run the &lt;code&gt;git log&lt;/code&gt; command to view information on commit history.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the &lt;code&gt;git branch&lt;/code&gt; command to see what branch you are on. Git defaults to the master branch, but you are able to change the name if you want to. If you would like to change the name of this branch, you can run &lt;code&gt;git branch -M “newBranchNameHere”&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The steps above created the local repository, but the last few steps involve creating the &lt;strong&gt;remote repository&lt;/strong&gt; to push code onto GitHub's platform.&lt;/p&gt;

&lt;p&gt;Grab the url listed on the setup page. &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%2Fi.ibb.co%2F4JFQqVz%2FScreen-Shot-2021-06-26-at-2-50-21-PM.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%2Fi.ibb.co%2F4JFQqVz%2FScreen-Shot-2021-06-26-at-2-50-21-PM.png" alt="text here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The command &lt;code&gt;git remote add origin https://github.com/ceblakely/practice1.git&lt;/code&gt; connects your local repository to the GitHub repository where your commits will be published. The term &lt;code&gt;origin&lt;/code&gt; is the universally accepted term for the remote repository, but you could change the name if you wanted to. Lastly, run the &lt;code&gt;git push -u origin master&lt;/code&gt; command to push index.html from the local repository to the remote repository on the master branch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You will have now successfully added a file to your GitHub repository! Below are a few extra tips:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If you wanted to add all files in your project to the staging area, instead of one at a time, run the command &lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Note the difference between staging, committing, and pushing. &lt;/p&gt;

&lt;p&gt;Staging&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;places a completed file in another area to show that it is ready to be committed. This allows you to work on multiple files, stage each one as you finish them, and then commit them at the same time. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Committing&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;adds staged changes to the local repository. This must happen before they can be pushed to the remote repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pushing&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;transfers the commits to the remote repository on GitHub.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Branches are used to save different states of the code. You can have production-ready code on the master branch, create another branch named &lt;code&gt;main&lt;/code&gt; and try out new features on that branch without affecting the deployed code. If you wanted to create a different branch to experiment, use the command &lt;code&gt;git branch branchNameHere&lt;/code&gt;.&lt;/p&gt;



&lt;p&gt;I know the GitHub documentation can be a bit overwhelming, so I hope this helps someone getting started with GitHub! 💫&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>github</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Sets in Python 🐍</title>
      <dc:creator>Christina Blakely</dc:creator>
      <pubDate>Thu, 27 Aug 2020 05:54:32 +0000</pubDate>
      <link>https://dev.to/ceblakely/sets-in-python-25ad</link>
      <guid>https://dev.to/ceblakely/sets-in-python-25ad</guid>
      <description>&lt;h2&gt;
  
  
  What are sets and why should you care about them?
&lt;/h2&gt;

&lt;p&gt;Python sets are collections of data that remove duplicates. This is mainly done for the purposes of identifying membership, as well as comparing and contrasting the differences between sets. Utilizing the built-in set data type is more efficient than looping over and manipulating lists, arrays, or dictionaries. &lt;/p&gt;

&lt;p&gt;Sets are mutable, meaning that we can add and remove elements from it. The elements within the set are immutable, hashable objects. This is why sets are so efficient; the set elements are converted to its hash value, which allows for less expensive comparison between elements. Using the frozenset() built-in function creates an immutable version of a set object. I won’t be covering it in this post, but you can read more on it &lt;a href="https://www.programiz.com/python-programming/methods/built-in/frozenset"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s see how to get started with sets and how to use them.
&lt;/h2&gt;

&lt;p&gt;You can create a set with either curly braces or using the set() function on a list, but remember that a pair of empty curly braces creates a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set_a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="n"&gt;red&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="n"&gt;pink&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="n"&gt;yellow&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="n"&gt;set_a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="n"&gt;red&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="n"&gt;pink&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="n"&gt;yellow&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  There are several methods that can be used on sets.
&lt;/h3&gt;

&lt;p&gt;Let's practice with these two sets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set_a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'red'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'pink’, ‘yellow'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'orange'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;set_b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;'blue’, ‘green’, ‘yellow'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'orange'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.remove()&lt;/strong&gt; removes a specified element from a set. If you attempt to remove an element that is not a member of a set, it raises a KeyError.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'yellow'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# set_a = {'pink', 'orange', 'red'}
&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'purple'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# KeyError: 'purple'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.discard()&lt;/strong&gt; removes a specified element from a set, similar to the &lt;strong&gt;.remove()&lt;/strong&gt; method. The difference with this method is that if it tries to discard an element that is not present in the set, it does not return an error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'red'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# {'yellow', 'pink', 'orange'}
&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'purple'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# {'yellow', 'pink', 'red', 'orange'}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.add()&lt;/strong&gt; adds a new element to the set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'purple'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# {‘red’, ‘orange’, ‘purple’, ‘yellow’, ‘pink’}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.pop()&lt;/strong&gt; removes a random element from the set. It takes no arguments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c1"&gt;# red
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.union()&lt;/strong&gt; returns all the elements in all the sets being used. It does not update the main set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;union&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_b&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;# {'red', 'pink', 'orange', 'yellow', 'blue’, ‘green’, ‘yellow'}
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# {'red', 'yellow', 'pink'}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.copy()&lt;/strong&gt; allows you to make a copy of a set. There are two ways to do this, depending on if you want to update changes from original set to the copy or keep the original set in-tact.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;new_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;set_a&lt;/span&gt;
&lt;span class="c1"&gt;# If you do it this way, changes made to set_a will show up in new_set
&lt;/span&gt;&lt;span class="n"&gt;new_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;# new_set will remain however set_a was when it was copied.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.clear()&lt;/strong&gt; is pretty self-explanatory. This method removes all elements from a set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# set()
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.intersection()&lt;/strong&gt; will return the common elements from the sets in use. The shorthand for this method is &lt;code&gt;&amp;amp;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;intersection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_b&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;set_b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# {'yellow', 'orange'}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.symmetric_difference()&lt;/strong&gt; will return the elements present in either of the sets but not in both. It is known as the union of the sets without the intersection. The shorthand for this method is &lt;code&gt;^&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;symmetric_difference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_b&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;set_b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# {'pink', 'blue’, ‘green', 'red'}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.isdisjoint()&lt;/strong&gt; returns True if two sets are disjoint sets. Two sets are disjoint when there are no shared elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isdisjoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_b&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;# False
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.issubset()&lt;/strong&gt; returns True if all elements of one set are present in another set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set_c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;set_d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;issubset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_d&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;# True
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;issubset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="c1"&gt;# False
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Sets are not that complex at all, but it can make your code cleaner and your life easier. Feel free to comment or reach out. ✨&lt;/p&gt;

</description>
      <category>python</category>
    </item>
  </channel>
</rss>
