<?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: JavaScript➕Coffee🚀</title>
    <description>The latest articles on DEV Community by JavaScript➕Coffee🚀 (@javascriptcoff1).</description>
    <link>https://dev.to/javascriptcoff1</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%2F447449%2F85c10746-5ded-4c19-bdf5-416844c5b0f0.jpg</url>
      <title>DEV Community: JavaScript➕Coffee🚀</title>
      <link>https://dev.to/javascriptcoff1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/javascriptcoff1"/>
    <language>en</language>
    <item>
      <title>What **is** React?</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Tue, 20 Feb 2024 11:43:48 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-react-9f</link>
      <guid>https://dev.to/javascriptcoff1/what-is-react-9f</guid>
      <description>&lt;p&gt;Ask anyone what React is, and they will probably reply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"React is Facebook's version of Vue"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;That doesn't help you understand it though, does it?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I'm not going to compare React to Vue or Angular or anything like that, we will look at elements and props and things..&lt;/p&gt;

&lt;p&gt;Rather than just being one 'thing', React is more like a set of tools used to build and structure the UI (user interface)&lt;/p&gt;

&lt;h4&gt;
  
  
  A framework or a library...?
&lt;/h4&gt;

&lt;p&gt;Technically, React is a JavaScript library, although most people refer to it as a framework and it is comparable to actual javaScript frameworks due to its ability to create a full stack application. Even though React is strictly a frontend framework, it can be used alongside other technologies, just as Mongo or other backend-y stuff.&lt;/p&gt;

&lt;p&gt;People love React so much because it is so flexible when used with other stacks - it can be made full stack because the React community is &lt;/p&gt;

&lt;h2&gt;
  
  
  HUGE
&lt;/h2&gt;

&lt;p&gt;This means that people have created lots of add ons and an entire &lt;em&gt;ecosystem&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnw5ds12s4fwy4gd5vicm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnw5ds12s4fwy4gd5vicm.png" alt="Man in garden surrounded by plants. Crouching down wearing a hat and overalls" width="500" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;React is a SPA (single page application) that can be used to build full stack apps and do all the clever backend stuff too if used with a backend stack!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  A spa....? I like to relax!
&lt;/h4&gt;

&lt;p&gt;Yes yes, but in tech, a SPA is a single html page that a framework (such as React) essentially takes as a puppet and makes it...do stuff. Remember this puppet idea, we might come back to it later.&lt;/p&gt;

&lt;p&gt;While it is correct that React is, in theory, quite similar to Vue, I've found a few differences on the ground after diving into React this week.&lt;br&gt;
I've used Vue/Nuxt before and really like it - I've also &lt;a href="https://dev.to/javascriptcoff1/what-is-vue-3753"&gt;written What &lt;strong&gt;is&lt;/strong&gt; Vue&lt;/a&gt; if you're browsing through frameworks&lt;/p&gt;
&lt;h5&gt;
  
  
  Framework...another one?!
&lt;/h5&gt;

&lt;p&gt;Yes, another one. People love a framework, especially a JavaScript one.&lt;/p&gt;
&lt;h5&gt;
  
  
  A JavaScript framework, right
&lt;/h5&gt;

&lt;p&gt;Yes, well, a library, but React is essentially a layer on top of your JavaScript code that is made up of &lt;em&gt;elements&lt;/em&gt; and &lt;em&gt;JSX&lt;/em&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  Right
&lt;/h5&gt;

&lt;p&gt;Ok, let's go into that...&lt;/p&gt;

&lt;p&gt;You write React by writing &lt;em&gt;elements&lt;/em&gt; (that look like this: &lt;code&gt;const element = &amp;lt;h1&amp;gt;Hello React!&amp;lt;/h1&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  Hey, I recognise that, it looks like HTML!
&lt;/h5&gt;

&lt;p&gt;Yes, it does but don't get carried away...&lt;br&gt;
React is written around an element that React developers often call the 'root element'&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div id="root"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Elements cannot be changed, and actually neither can variables or &lt;code&gt;const&lt;/code&gt;s that you create as it would require the whole page to rerender.&lt;/p&gt;
&lt;h3&gt;
  
  
  The puppet master
&lt;/h3&gt;

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

&lt;p&gt;Back to this puppet idea...&lt;br&gt;
So we've got the HTML page sitting there...static....essentially useless and highly non user-friendly.&lt;/p&gt;

&lt;p&gt;Along comes React and BOOM!&lt;/p&gt;
&lt;h4&gt;
  
  
  Ok, if only it was that easy...
&lt;/h4&gt;

&lt;p&gt;React needs to be able to read your html SPA in order to know how it should behave and render. For this, React uses its own dialect of JavaScript, called JSX. JSX sounds (and looks) intimidating to first time users, but like most things, it is a learning curve. It stands for 'JavaScript syntax extension' and that's essentially what it is - just a different way to write JavaScript in a way that React understands so it knows what to do with all the html.&lt;/p&gt;

&lt;p&gt;Earlier, we mentioned that elements and &lt;code&gt;const&lt;/code&gt;s cannot be changed. This is not technically true - this is where the JSX comes in. JSX is the strings on the puppet&lt;/p&gt;
&lt;h2&gt;
  
  
  Dynamic markup
&lt;/h2&gt;

&lt;p&gt;Sounds scary...&lt;br&gt;
It's not, really - it is formatted like html but we can add in JavaScript to make it movey-shakey! In React, if you need to pass new information to a variable, you can do that by using curly braces {}&lt;/p&gt;

&lt;p&gt;Here's a small example from some code I wrote yesterday:&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;button className="square"
 onClick={onSquareClick}&amp;gt;
   {value}
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can see that I have a button, defined with some Tailwind styling, that I have given the props &lt;code&gt;onSquareClick&lt;/code&gt; and &lt;code&gt;Value&lt;/code&gt;. OnSquareClick was defined elsewhere in the code and essentially told my app to wait for a click and then do something, the &lt;code&gt;{value}&lt;/code&gt; prop told it what to display.&lt;/p&gt;

&lt;p&gt;Hold on... this looks a lot like&lt;/p&gt;

&lt;h3&gt;
  
  
  ✨Reusable components✨
&lt;/h3&gt;

&lt;p&gt;Hooray! We love a reusable component!&lt;/p&gt;

&lt;p&gt;I find that reusable components are great for when you're working in a team/with a large code base, and things can get messy and unmanagable very quickly, with so much code all referencing itself in the same place.&lt;/p&gt;

&lt;p&gt;Reusable components stop this because your code will be &lt;em&gt;structured&lt;/em&gt; in defined sections, you can even have things on separate pages if you want to.&lt;br&gt;
I am a big fan of any component-using codebase as it makes things much clearer and cleaner to look at, although other people aren't so in favour of them. Opinions are ok!&lt;/p&gt;

&lt;p&gt;Anyway, React needs you to set the &lt;code&gt;type&lt;/code&gt; as &lt;code&gt;module&lt;/code&gt; if you are going to export it&lt;/p&gt;

&lt;h4&gt;
  
  
  Export it?
&lt;/h4&gt;

&lt;p&gt;Yes, sorry, React requires you to use the keywords &lt;code&gt;import&lt;/code&gt;, &lt;code&gt;export&lt;/code&gt; and &lt;code&gt;module&lt;/code&gt; when you are using and creating your components. Say you've built a lovely navbar or menu on your homepage. Consistency and design say that you should probably use the same thing throughout the pages on your site. What are your options here?&lt;/p&gt;

&lt;p&gt;You could copy and paste to every page and risk &lt;em&gt;typos&lt;/em&gt; and &lt;em&gt;bugs&lt;/em&gt; 🤢 OR you could create a ✨reusable component✨. You're going to want to stick a &lt;code&gt;type = module&lt;/code&gt; on that bad boy first, then make sure you &lt;code&gt;export navbar&lt;/code&gt; somewhere on the page, and that's it!!&lt;/p&gt;

&lt;p&gt;From now on, you can &lt;code&gt;import navbar from ../pageName&lt;/code&gt; at the top of every file and you'll have access to that lovely navbar, everywhere you go!&lt;/p&gt;

&lt;h3&gt;
  
  
  Managing state
&lt;/h3&gt;

&lt;p&gt;This is more of a tricky concept in React, let's break it down.&lt;/p&gt;

&lt;p&gt;The 'State' in React is essentially &lt;em&gt;what each individual part is doing&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So when your user is typing into a box, does your page need to know to make a dragon fly across the screen..? Ok probably not but stay with me.&lt;/p&gt;

&lt;p&gt;State is like a little memory full of eventListeners (remember those)?! It enables you to not only say 'when &lt;em&gt;this&lt;/em&gt; happens, do &lt;em&gt;this&lt;/em&gt;', &lt;code&gt;useState&lt;/code&gt; allows you to say 'if &lt;em&gt;this&lt;/em&gt; happens, do &lt;em&gt;this&lt;/em&gt;, else do &lt;em&gt;this&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Yes, useState is essentially an event listener with a memory.&lt;/p&gt;

&lt;p&gt;Not so tricky...&lt;/p&gt;

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

&lt;p&gt;I'm enjoying looking into React so far, and hope to start building my first demo page out today!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
      <category>learning</category>
    </item>
    <item>
      <title>Is anyone still out there?</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Wed, 12 Jul 2023 19:42:48 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/is-anyone-still-out-there-37k0</link>
      <guid>https://dev.to/javascriptcoff1/is-anyone-still-out-there-37k0</guid>
      <description>&lt;p&gt;Well hi...it's been a while...&lt;/p&gt;

&lt;p&gt;I lost access to my &lt;a class="mentioned-user" href="https://dev.to/javascriptcoff1"&gt;@javascriptcoff1&lt;/a&gt; account around 2 years ago and went off to try and become a vet.&lt;/p&gt;

&lt;p&gt;I'll be honest with you, I haven't made much progress.&lt;/p&gt;

&lt;p&gt;It's incredibly competitive and I've been bombarded at every turn by people telling me I can't physically do it.&lt;/p&gt;

&lt;p&gt;So I'm rethinking.&lt;/p&gt;

&lt;p&gt;I miss my nerdy friends&lt;/p&gt;

&lt;p&gt;How are you? &lt;/p&gt;

</description>
    </item>
    <item>
      <title>What **is** caching?</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Tue, 31 May 2022 12:20:21 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-caching-30ff</link>
      <guid>https://dev.to/javascriptcoff1/what-is-caching-30ff</guid>
      <description>&lt;h2&gt;
  
  
  Money money, cache cache 💵
&lt;/h2&gt;

&lt;p&gt;Invented in 1965 by Maurice Wilkes, a British computer scientist, caching was described as a system whereby data would be pulled from a main, slower memory source in order to speed up subsequent use.&lt;/p&gt;

&lt;p&gt;Let's start with the modern official definition:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Computing component that transparently stores data so that future requests for that data can be served faster&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Makes sense...
&lt;/h3&gt;

&lt;p&gt;Yes, so it seems that the cache is like a little memory system in your browser that remembers stuff you've done before so it can do it faster next time... right?&lt;/p&gt;

&lt;h3&gt;
  
  
  Essentially, yes
&lt;/h3&gt;

&lt;p&gt;Imagine that you needed to do a research paper for school or work and that you were only allowed to use books from a library (like the olden days 📚)&lt;br&gt;
You could go back to the library every time you needed a new piece of information, but the most efficient thing to do would be to take some books home with you and put them on your desk while you work.&lt;br&gt;
Here, your desk is your cache. Instead of going back and forth to the library, you're storing the information you need so you can be more efficient and access it quicker if you need it again.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  As always though, we can dig a little deeper into it. 🎢
&lt;/h3&gt;

&lt;p&gt;Let's continue with the library analogy, because it works here. Just like your desk, the cache is smaller and cannot hold &lt;strong&gt;as much&lt;/strong&gt; information as the whole library.&lt;/p&gt;

&lt;p&gt;The first time you visit any website, say &lt;code&gt;dev.to&lt;/code&gt;, it takes a lot longer than it will do on subsequent visits, because the first time you visit it, your computer has to download &lt;strong&gt;everything&lt;/strong&gt; - the logos, the images, the scripts that make the site run, &lt;strong&gt;everything&lt;/strong&gt;. After that, your computer will only need to download new information that it hasn't seen before.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wait...is that why 'clearing the cache' can often solve things?
&lt;/h3&gt;

&lt;p&gt;Yep! Clearing your browser cache means that you are deleting all of the information previously stored in the browser. Your computer might be a little slower to load larger websites again, as it has to start from scratch, but remember that developers often update the scripts or images in their site and therefore old 'versions' of it will no longer work. This is why clearing your cache can often fix problems. You're forcing your computer to download the whole of the website again, not just download 'new' bits.&lt;/p&gt;

&lt;h4&gt;
  
  
  So only browsers have caches?
&lt;/h4&gt;

&lt;p&gt;Typically, yes - however, modern devices often have caches too. Hardware such as processors, GPUs, hard drives and SSD's can all have caches. This creates a 'memory hierarchy' 😱&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04w4x135t353biwgq5w2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04w4x135t353biwgq5w2.png" alt="memory hierarchy" width="800" height="549"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the top of the hierarchy are memory processors, which are super fast but very small. At the bottom are the SSD's and hard drives, which have huge capacities but are really slow (compared to the top)&lt;/p&gt;

&lt;h3&gt;
  
  
  Dig out the library analogy again! 📚
&lt;/h3&gt;

&lt;p&gt;Let's go from the top of the hierarchy: at your desk, you can access a limited amount of information very quickly; the information in the books stacked in the library must be searched through, but there's so much more there; at the bottom of the hierarchy would be the old books that hardly anyone uses and have been moved to off site storage. This bottom tier has the biggest amount of information in, but would be the slowest to access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ok, got it, but what has this got to do with my memory storage?
&lt;/h3&gt;

&lt;p&gt;I'm glad you asked! &lt;br&gt;
Consider what would happen if your cache (your desk) got full? How would you know what information (books) to get rid of first? You need more room!&lt;/p&gt;

&lt;h3&gt;
  
  
  Don't panic...we have a cache eviction strategy
&lt;/h3&gt;

&lt;p&gt;No really...that is what it's called. We'll shorten it to CES.&lt;/p&gt;

&lt;p&gt;🤓Let's get nerdy.... &lt;/p&gt;

&lt;h2&gt;
  
  
  Common CES'
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Least Recently Used&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a pretty logical (in my opinion!) and easy to implement strategy. It just means that you get rid of old information that you haven't used for a while - starting with the oldest and least used.&lt;br&gt;
The issue with this strategy is that it requires you to keep track of when items in your cache were last accessed, which does slow it down a bit.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Random Replacement&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Grab logic firmly by the scruff of the neck and throw it outside.&lt;/p&gt;

&lt;p&gt;As you probably guessed, this strategy involves removing a &lt;em&gt;random&lt;/em&gt; item when the cache is full 🤷🏼‍♀️&lt;br&gt;
This strategy is the easiest to implement and in practice doesn't end up being too different to Least Recently Used. It's used in small ARM processors to keep operations light and designs simple.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7sk5i0n6e6u7wivcuo5u.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7sk5i0n6e6u7wivcuo5u.jpeg" alt="hands sorting through a stack of records" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
In conclusion, caching is a small but important piece of computer logic from 66 years ago that can be made as complicated as you want....sounds like most of tech to be honest!&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href="https://twitter.com/EmmiePaivarinta"&gt;Emmie&lt;/a&gt; for suggesting the topic!&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>What **is** technical writing?</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Thu, 11 Nov 2021 11:18:18 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-technical-writing-4799</link>
      <guid>https://dev.to/javascriptcoff1/what-is-technical-writing-4799</guid>
      <description>&lt;p&gt;&lt;strong&gt;Writing about technical stuff, right?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Not always.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I hinted at what technical writing &lt;em&gt;actually&lt;/em&gt; is in this tweet.&lt;br&gt;
&lt;iframe class="tweet-embed" id="tweet-1458530582779006979-250" src="https://platform.twitter.com/embed/Tweet.html?id=1458530582779006979"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1458530582779006979-250');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1458530582779006979&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h4&gt;
  
  
  So what &lt;strong&gt;is&lt;/strong&gt; it?
&lt;/h4&gt;

&lt;p&gt;Technical writing is actually a style of writing, rather than a &lt;em&gt;subject&lt;/em&gt; of writing. Technically, you could write a technical piece about some technology using a technical writing style, but you don't &lt;em&gt;have&lt;/em&gt; to...&lt;/p&gt;

&lt;h5&gt;
  
  
  Technical...
&lt;/h5&gt;

&lt;p&gt;Yes, sorry; I got carried away with that word - let me explain.&lt;/p&gt;

&lt;p&gt;You could write for a scientific paper in a technical writing style, or you could write for a mechanics magazine in a technical writing style.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is it actually used for?
&lt;/h3&gt;

&lt;p&gt;Technical writing is a style of writing that you will usually see in things like manuals, technical documentation and educational leaflets. It is often used in STEM fields and is only ever factual. You'd never write opinions in technical writing, unless specific circumstances call for it.&lt;br&gt;
The style is authoritative, well-informed, factual and very formal. I've tried to break it down to the three main things that technical writing should do. There's a fair bit more to it, but to me, these are the most important:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inform&lt;/li&gt;
&lt;li&gt;Direct&lt;/li&gt;
&lt;li&gt;Instruct&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Let's look at what these actually mean
&lt;/h3&gt;

&lt;p&gt;When you're using a new piece of technology, or you've just got your new drone out of the box, or you're figuring out how to use a bunsen burner in the lab, what sort of documentation would you find useful?&lt;br&gt;
Clear, directive instructions with some diagrams or even pictures to go alongside?&lt;br&gt;
Exactly!&lt;br&gt;
Technical writing that is unclear, informal or ambiguous could actually be very dangerous or costly - &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Turn the bunsen burner upside down and hold it at the end while you turn the red dial that's next to the blue dial the other way on the gas cylinder"...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  💥
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Inform
&lt;/h3&gt;

&lt;p&gt;Technical writing must inform the reader; the reader is expecting to either learn something by reading your writing, or learn HOW TO do something (in the case of a manual or documentation), so you must consider this when laying out your writing. Make sure to use white space as well as pictures to distribute your work cleanly on the page. Using white space sparingly for this is very useful - it means that information can be portioned out into 'bite-sized' portions for the reader to absorb more easily than a huge block of text. How would you feel if you opened the manual to your new hardware/software and the docs read like a chapter from a novel?&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhqmsw74fmke4vdnmlhm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhqmsw74fmke4vdnmlhm.jpeg" alt="Small brown dog with nose in book" width="672" height="1048"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Direct
&lt;/h3&gt;

&lt;p&gt;We could look at this one 2 ways - you want to make sure that you are &lt;em&gt;directing&lt;/em&gt; your reader, especially if it is a confusing or dangerous topic that you are writing about. You need to use an authoritative tone and leave your reader in no doubt as to what they must do.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Always wear safety goggles"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Is more effective than&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Consider wearing safety equipment to protect your eyes"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Be direct as well as directive.
&lt;/h4&gt;

&lt;p&gt;Your writing must also &lt;em&gt;be&lt;/em&gt; direct. This means that you don't want to leave any ambiguity in your writing. Leave nothing to chance. Using the example above, you can see in the 'authoritative voice' example, I've specified 'safely goggles', whereas the other line states 'safety equipment'. What does that mean? Gloves are 'safety equipment'....should I use those to wipe my eyes...is that what it means..?&lt;br&gt;
Do you see how being direct in all instances will rule out any ambiguity?&lt;/p&gt;

&lt;h3&gt;
  
  
  Instruct
&lt;/h3&gt;

&lt;p&gt;The writing must instruct the reader. The reader must come away feeling confident that they learned something new or now know how to do something. Do you feel confident writing it? Good, that'll show in your writing. Don't feel confident yet? That's fine, just note your ideas at that time, go back and do some more research.&lt;br&gt;
Leave the 'might', 'probably', 'sometimes' and even the 'often' out of it. You want clear, sharp instructions that are easy to follow. &lt;br&gt;
☕️ You're not writing for people who are sitting down with a cup of tea to enjoy the poetic language, you're writing for people who have got things to do!&lt;/p&gt;

&lt;h3&gt;
  
  
  Research
&lt;/h3&gt;

&lt;p&gt;Ah yes, research...&lt;br&gt;
You might spend just as much time researching for a topic or assignment as you do actually writing it. Essentially, you want to be, or at least be able to write as though you are, an expert on the thing you are writing on. If you are a contractor writing on a topic that isn't in your field of expertise, it's always best to ask for help. It isn't a sign of weakness.&lt;/p&gt;

&lt;p&gt;No one is born an expert.&lt;/p&gt;

</description>
      <category>writing</category>
    </item>
    <item>
      <title>What **is** Django? 🤷🏼‍♀️</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Tue, 10 Aug 2021 16:49:49 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-django-1813</link>
      <guid>https://dev.to/javascriptcoff1/what-is-django-1813</guid>
      <description>&lt;p&gt;So, you know how this goes - someone asked me about a technology that I didn't know much about and...I researched it!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So here we are, all wondering...what is Django (other than a really good and important film)?...what is it for and what does it do? Who uses it?&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Only one way to find out...!
&lt;/h4&gt;

&lt;p&gt;First things first: &lt;em&gt;how do you pronounce it?&lt;/em&gt;&lt;br&gt;
It's a strange spelling, with a silent &lt;code&gt;D&lt;/code&gt;, you pronounce it "Jan"-"go". It's named after a famous jazz guitarist, Django Reinhardt.&lt;/p&gt;

&lt;p&gt;From the Django documentation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The web framework for perfectionists with deadlines.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Sounds interesting but not very descriptive...
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Indeed, let's look deeper&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A high level python framework for web development.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;That's better, we can dig into this now&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Django is a Python framework that is built and maintained by experienced developers - it was first released in 2005 and is a widely used technology in the web development space. It is 'high level' which means that Django already contains a bunch of code necessary for you to create fast and secure web applications rather than having to type it yourself.&lt;/p&gt;

&lt;h4&gt;
  
  
  Sounds like cheating...
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Call it cheating, call it a framework, call it a library if you like - it's saving you precious time and means that you won't &lt;strong&gt;forget stuff&lt;/strong&gt;&lt;/em&gt;. Do you want to manually set up admin and all the fiddly database management by yourself? Do you?&lt;/p&gt;

&lt;p&gt;This is why frameworks were made. They ‘start you off’ quickly, so you can get on with all of the fun parts of your project. Django just happens to be a framework for the Python language.&lt;/p&gt;

&lt;h4&gt;
  
  
  So why do people choose Django over all of the other frameworks out there?
&lt;/h4&gt;

&lt;p&gt;Great question.&lt;br&gt;
Django is built in a way that enables you to build secure and maintainable websites quickly. It includes everything that you might need ‘out of the box’. This means that you shouldn’t need to install a bunch of other things to get your project up and running. This ‘out of the box’ concept is sometimes called the ‘Batteries included’ philosophy.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cool, can I use it? 🤑
&lt;/h4&gt;

&lt;p&gt;Django is entirely free, and it is also Open Source; this means that if you have a suggestion or change to the framework that you think many people would also find useful, you can submit your request or even make the change yourself and make a pull request! Thanks to the philosophy of having everything working together in this framework, everything works seamlessly and follows consistent design principles. This is important because you shouldn’t have to fuss around with any part of the configuration; it is all set up for you. Django includes access to some popular databases and provides you with a secure way to manage accounts and passwords. Again, this functionality is ‘out of the box’ (Batteries included!) Of course, this functionality will have been tested fully and means that you’ll avoid any common security mistakes such as putting session information (cookie data) in a public place or forgetting to hash (scramble up and distort) passwords.&lt;/p&gt;

&lt;h4&gt;
  
  
  Smart &lt;em&gt;and&lt;/em&gt; security-conscious!
&lt;/h4&gt;

&lt;p&gt;Yes, and that’s not all - Django provides built-in protection from vulnerabilities such as SQL injection, cross-site scripting and…&lt;/p&gt;

&lt;h4&gt;
  
  
  What?!
&lt;/h4&gt;

&lt;p&gt;Hmm, yes… ok let’s do a quick breakdown of that:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SQL injection&lt;/em&gt; = someone attempting to gain access to data in the backend by typing in SQL (a backend database language) into a web application to try and trick the application into running the SQL and giving the user data that they shouldn’t have access to.&lt;br&gt;
Example:&lt;br&gt;
&lt;em&gt;HackerPerson&lt;/em&gt; types &lt;code&gt;select * from secretInfo&lt;/code&gt; into a text field on a frontend form.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvds9depspxqsb1a1q4ah.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvds9depspxqsb1a1q4ah.jpeg" alt="person in hoodie on computer in dark room" width="800" height="534"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Note: It’s really great that Django includes this as standard for you to use out of the box, however it is pretty standard for websites to protect against SQL injection - it’s a pretty ancient and well known method of data harvesting…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you want to learn more about web security, &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Server-side/First_steps/Website_security"&gt;this site&lt;/a&gt; is pretty good.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  What if I want to build a huge and successful web application?! I have plans for the next Youtube!
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Funny you should say that...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Youtube is built with Django! This isn’t surprising; actually many of the sites you and I use every day are built with Django - after all it &lt;em&gt;is&lt;/em&gt; fast, flexible, security conscious and many other things.&lt;br&gt;
Back to your point - you are asking if Django is a &lt;em&gt;scalable&lt;/em&gt; framework, i.e. can it adapt and grow with the application you build? &lt;br&gt;
Yes, Django is scalable - in fact it is built using the ‘shared-nothing’ architecture principles. This just means that all the little parts and components that go into the framework are replaceable and changeable.&lt;/p&gt;

&lt;h4&gt;
  
  
  Like Jenga?
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjn7pgupe6a202g5rr1t7.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjn7pgupe6a202g5rr1t7.jpeg" alt="Colourful jenga bricks" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
I guess! Jenga/Django, try and say that fast…!&lt;/p&gt;

&lt;p&gt;Back to the topic at hand - &lt;em&gt;scalability&lt;/em&gt;. Django copes with your site recieving extra traffic (visitors) by being flexible and allowing you to add extra hardware (caching servers, database servers, or application servers) anywhere you need. One of Django’s most successfully scaled users is probably Instagram.&lt;/p&gt;

&lt;h2&gt;
  
  
  DRY
&lt;/h2&gt;

&lt;p&gt;This buzzword/acronym pops up everywhere, and yes Django also uses DRY priciples. DRY just stands for “Don’t Repeat Yourself” and just means that you shouldn’t write duplicate code, or code that does the same thing. Django will help you implement this principle into your application, however it is pretty common and you should be trying to do it anyway.&lt;/p&gt;

&lt;h4&gt;
  
  
  Ok, DRY lecture over…
&lt;/h4&gt;

&lt;p&gt;In reading the Django documentation (which is pretty good by the way), it seems that Django does, in fact, let you use components. This &lt;em&gt;is&lt;/em&gt; something I’m familiar with from Vue (a JavaScript framework) and means that you can create reusable files, almost like code snips that you can call into your application:&lt;/p&gt;

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

&lt;p&gt;I want to create a portfolio with 5 pages. I want a navbar on every page. What should I do? My options are; write the code for a navbar on &lt;em&gt;every&lt;/em&gt; page (this might take a while and will be tedious) &lt;em&gt;or&lt;/em&gt; I could write the code once and copy/paste it… (this comes with a VERY HIGH chance of errors and bugs.&lt;br&gt;
In comes &lt;em&gt;our saviour&lt;/em&gt;, &lt;em&gt;Components&lt;/em&gt;. Components mean that you can write your navbar in a file called &lt;code&gt;navbar.vue&lt;/code&gt;......wait……&lt;code&gt;navbar.py&lt;/code&gt;... and then call it into every other page you need just by typing &lt;code&gt;import navbar&lt;/code&gt; or something similar…&lt;/p&gt;

&lt;h4&gt;
  
  
  Ok, I got carried away with that analogy because I got excited to be writing about something I &lt;em&gt;actually recognised&lt;/em&gt;, but let’s get back to Django.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Are there any cons of using Django?
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;As someone who has not played with Python or Django myself - these opinions are not my own:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It’s not the fastest&lt;/strong&gt;&lt;br&gt;
If your website isn’t properly optimised for speed, you may not get the best results when you are using Django. However, the framework does offer some built-in optimisation test to help you if you think this is a problem you may face.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lack of convention&lt;/strong&gt;&lt;br&gt;
Compared to a framework such as Ruby on Rails, everything in Django has to be explicitly defined which takes time. However, Python is generally a language where you should explicitly define everything anyway, so if you are using Django then we can maybe assume that you wouldn’t find this a problem…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It isn’t great for smaller projects&lt;/strong&gt;&lt;br&gt;
As Django was built to help you build larger CRUD (Create, Read, Update, Delete) applications, it will probably be overkill on your small one page project, so make sure that you are using the appropriate tool for your project and don’t just go with the one that sounds the coolest (Django does sound pretty cool)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confusing for search engines&lt;/strong&gt;&lt;br&gt;
It’s true, searching on google for ‘Django’ may leave you confused as there is a film by that name. I recommend searching for “Django framework” to make sure you get the most relevant results.&lt;br&gt;
&lt;em&gt;Django Unchained is a really great and important film and you should watch it.&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;It is not about tech frameworks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy Django-ing!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What **is** Kubernetes? 🤷🏼‍♀️</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Wed, 19 May 2021 16:21:51 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-kubernetes-ljm</link>
      <guid>https://dev.to/javascriptcoff1/what-is-kubernetes-ljm</guid>
      <description>&lt;p&gt;I was challenged on Twitter to write an article about Kubernetes. Here we go...&lt;/p&gt;

&lt;h3&gt;
  
  
  Glossary:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Bandwidth&lt;/strong&gt;: The capacity. How much data can be transferred. &lt;br&gt;
Can also be a word used to describe free time by techy people "how much bandwidth do you have today?" 🤨&lt;br&gt;
&lt;strong&gt;Load balancer&lt;/strong&gt;: Something that...balances the load... of traffic to a site. Makes sure that data and traffic to the site are distributed evenly.&lt;/p&gt;

&lt;p&gt;🌮&lt;em&gt;You're going to want to read my short &lt;a href="https://dev.to/javascriptcoff1/what-is-docker-3be2"&gt;What *&lt;em&gt;is *&lt;/em&gt; Docker?&lt;/a&gt; article if you don't know what Docker is before we hit the road here. I know there are usually no prerequisites to my articles, but this is an exception!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  There's a theme here...
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Kubernetes&lt;/em&gt; is the Greek word for a helmsman or someone that steers a ship. ⛴&lt;/p&gt;

&lt;h3&gt;
  
  
  Hold that thought.
&lt;/h3&gt;

&lt;h2&gt;
  
  
  The scenario
&lt;/h2&gt;

&lt;p&gt;Imagine you (and Randall, from the Docker article) have a site up and running with a Docker container. It's doing pretty darn well. You are getting a lot of visitors to your site, and business is great.&lt;br&gt;
Sometimes, you get &lt;em&gt;too&lt;/em&gt; many visitors to the site and it crashes...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not good&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your site is starting to crash a lot - too many people are visiting and the server is just getting overstretched. It can't handle it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do we do?!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You set up another container on another server. That way, you've got twice the amount of &lt;em&gt;bandwidth&lt;/em&gt; to play with, and in theory, you should be able to have twice the amount of visitors.&lt;br&gt;
You also set up a &lt;em&gt;load balancer&lt;/em&gt; to make sure that visitors are evenly distributed between your servers to ensure that there are no more problems.&lt;br&gt;
Easy, problem solved, right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrong&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your business is &lt;strong&gt;incredible&lt;/strong&gt;, you go viral and suddenly you have a ridiculous number of visitors to your site. Everything is great!&lt;/p&gt;

&lt;p&gt;Hold on...these servers can't handle it...&lt;br&gt;
You set up another 20+ servers (just to be sure this time), which all need Docker containers and some extra load balancers to help manage the bandwidth distribution.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This process is called Horizontal Scaling&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This all takes a &lt;em&gt;lot&lt;/em&gt; of work, and don't even &lt;strong&gt;think&lt;/strong&gt; about making any update to your website...&lt;br&gt;
This is putting a &lt;strong&gt;lot&lt;/strong&gt; of pressure on you, and you are considering hiring another engineer...💭$$$$$$$$$$$&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;💭 Imagine if you could &lt;em&gt;automate&lt;/em&gt; this server/container duplication process...&lt;/p&gt;

&lt;p&gt;Well, my friends, I have some news for you&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes 🦸‍♀️
&lt;/h3&gt;

&lt;p&gt;Ok, so, let's imagine that you knew about Kubernetes right at the beginning. You start to use it when you have just one or 2 servers running with Docker. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Kubernetes, your Docker image (the server with the container and everything that you need to run your website) is called a pod&lt;/strong&gt;&lt;br&gt;
Kubernetes comprises of the 'master' (its official name) and 'worker nodes'.&lt;br&gt;
The worker nodes do all the heavy lifting in terms of storing, transferring and receiving data around the sites and between the servers.&lt;/p&gt;

&lt;p&gt;So, the premise of Kubernetes is like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You decide how many 'worker nodes' you want (typically the same number of servers that you have)&lt;/li&gt;
&lt;li&gt;You give the 'Kubernetes master' (this is the official name) a list of the number of pods (servers) that you need in the form of a &lt;code&gt;.yaml&lt;/code&gt; file. This is called the manifest.&lt;/li&gt;
&lt;li&gt;The Kubernetes master takes a look at the manifest that you have given it and assigns the pods out to the worker nodes. Pods are assigned to the worker nodes depending on how much work they are already doing. Pretty clever, right?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can control the number of pods through the command line and have direct access to information about your pods and worker nodes, such as their name, IP address and other info. You can also update the &lt;code&gt;.yaml&lt;/code&gt; file through the command line with &lt;code&gt;cubectl edit deployment&lt;/code&gt; and then your &lt;code&gt;.yaml&lt;/code&gt; file name. Imagine it as handing a supervisor in charge of a workforce an updated task list. It is their job to make sure that work is distributed evenly and that no one worker node is over or underworked.&lt;br&gt;
The master node monitors the amount of work that each worker node is doing - if anything looks like it is going to crash or become unstable, it will re-distribute the work. &lt;em&gt;Smart, right?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Yes, but that's not all...!
&lt;/h3&gt;

&lt;p&gt;So these pods that are created, and the images that are inside them, all have their own IP addresses. Great, they are all accessible to the outside world and each version of your site can be reached by the public, and by you, if you want to edit anything.&lt;br&gt;
&lt;em&gt;Wait...how can they be exposed if they are in a pod?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I'm glad you asked that. This is another powerful feature of Kubernetes.&lt;br&gt;
For the outside world to be able to view your site, you need to expose the pods to the network. If you tell it to, Kubernetes will spin up something called a Service which will act as a load balancer to make sure that none of the pods are getting too much traffic (crash zone!)&lt;/p&gt;

&lt;p&gt;The thing that makes it different to a usual load balancer is that Kubernetes will balance the load by pod ID, rather than just balancing across &lt;em&gt;every&lt;/em&gt; server. This means that you can control everything with a lot more precision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Doesn't sound &lt;em&gt;that&lt;/em&gt; special...?&lt;/strong&gt;&lt;br&gt;
💥&lt;br&gt;
It also creates a load balancer in your cloud provider. This means that you update your website in &lt;em&gt;one&lt;/em&gt; place. 🤯&lt;/p&gt;

&lt;p&gt;Save yourself a lot of time. Orchestrate your containers!&lt;/p&gt;

&lt;h3&gt;
  
  
  Save even more time - managed kubernetes options - good to know...
&lt;/h3&gt;

&lt;p&gt;While researching for this article, I found out how tricky and in-depth it is to set up. Luckily, there are managed options that do it all for you - Azure's AKS and Amazon's EKS.&lt;br&gt;
If you need to get started with Kubernetes fast, say you've built the next Amazon using Docker containers and you need to future-proof &lt;br&gt;
fast, then I recommend using them while you look into Kubernetes. It is very CLI-heavy and looks like it would take some time!&lt;/p&gt;

&lt;p&gt;_So that was Kubernetes. So, now we know what it ** is **! ⛴&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjrk27oy0j2zvq0r6xps1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjrk27oy0j2zvq0r6xps1.jpeg" alt="Ship with s" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>kubernetes</category>
      <category>docker</category>
    </item>
    <item>
      <title>What **is** Git? 🤷🏼‍♀️</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Sun, 25 Apr 2021 14:21:23 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-git-4pmh</link>
      <guid>https://dev.to/javascriptcoff1/what-is-git-4pmh</guid>
      <description>&lt;p&gt;Git is an extremely useful tool for developers. It is also quite abstract and tricky to learn.&lt;br&gt;
I learned about git by reading, watching videos, viewing images, and trying out using it.&lt;br&gt;
I've highlighted some of my favourite resources at the bottom of this article.&lt;/p&gt;
&lt;h4&gt;
  
  
  The general idea:
&lt;/h4&gt;

&lt;p&gt;Have you ever worked on something, maybe an essay for school etc, where you were undecided about how you wanted the intro  to be, so you made:&lt;/p&gt;

&lt;p&gt;essayintro1.doc&lt;br&gt;
essayintro2.doc&lt;br&gt;
essayintro3.doc&lt;br&gt;
essayconclude1.doc&lt;/p&gt;

&lt;p&gt;and so on...&lt;/p&gt;

&lt;p&gt;Maybe you tested out parts of the essay in this way and then put all of your final thoughts together in:&lt;/p&gt;

&lt;p&gt;essayMAIN.doc&lt;/p&gt;

&lt;p&gt;This is essentially version control, and although messy, it works for 1 person...&lt;/p&gt;
&lt;h4&gt;
  
  
  The problem:
&lt;/h4&gt;

&lt;p&gt;Now imagine that you had multiple people writing and making edits on this essay...this would get very confusing very quickly and it would be pretty impossible to ever finish the essay (project)&lt;/p&gt;
&lt;h3&gt;
  
  
  Git saves the day
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;"Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A Version Control System is an invisible system that holds copies of your files and records changes so you can switch back to a previous version. It also means that you can work together with two or more people on a document and you won't save over each other's work.&lt;/p&gt;

&lt;p&gt;With large codebases such as those needed for organizations or product-building companies, there are inevitable issues that trying to keep track of changes, proposals or bugs would cause when multiple people are trying to work on it.&lt;br&gt;
Imagine trying to build a house with 40 other people while blindfolded and with no communication. The likelihood is that you would end up crashing into each other, you'd build over other people's work and you'd probably break stuff...&lt;/p&gt;

&lt;p&gt;A version control system such as Git means that you can keep track of changes and do your own work on your own &lt;code&gt;branch&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Branch?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Imagine Git as like a tree&lt;/strong&gt; * ...&lt;/p&gt;

&lt;p&gt;*The metaphor of git as a 'tree' is an abstraction to help some people visualize, but also it can be thought of as different versions of a file.&lt;/p&gt;

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

&lt;p&gt;The main trunk of the tree is called the &lt;code&gt;main&lt;/code&gt; or &lt;code&gt;master&lt;/code&gt; branch, and this should always be the &lt;strong&gt;source of truth&lt;/strong&gt; of the code; the production-ready, correct, and most up-to-date version. You can create a branch from the main branch, which means that you have created a copy of whatever is on the main branch.&lt;br&gt;
Now you can make changes to your &lt;em&gt;own&lt;/em&gt; branch as if you've put tracing paper over the original code. Now you can make the changes you want to that code with no worry about breaking anything. You can test the code like this in a &lt;em&gt;dev environment&lt;/em&gt;. When you are happy with the changes you have made, you can &lt;em&gt;merge&lt;/em&gt; your branch back into the main branch. If you are collaborating on a project rather than working on your own, this is done via a PR, or Pull Request. Merging your branch means that Git puts all of your changes back into the original branch - now your changes are on the main branch! You've put your version into the codebase and now your new changes or updates are possibly in production (live!)&lt;/p&gt;
&lt;h2&gt;
  
  
  The three states
&lt;/h2&gt;

&lt;p&gt;There are actually three 'trees', or states of git, used for creating and retrieving commits (saves):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the working directory&lt;/li&gt;
&lt;li&gt;the index&lt;/li&gt;
&lt;li&gt;something called "HEAD" for creating and retrieving commits.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  The working directory
&lt;/h4&gt;

&lt;p&gt;Files whose content you can change are in your &lt;em&gt;working directory&lt;/em&gt;. These are the files that you are able to put into your code editor and make changes to. The &lt;em&gt;working directory&lt;/em&gt; represents a particular &lt;code&gt;commit&lt;/code&gt; (save) and is the version that &lt;code&gt;HEAD&lt;/code&gt; is pointing at.&lt;/p&gt;
&lt;h4&gt;
  
  
  The index
&lt;/h4&gt;

&lt;p&gt;Also called the staging area, the cache, the staged cache, stages files or directory cache...&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;index&lt;/em&gt; can be seen as an area to store your drafts, or an area that you can see all of your changes and choose which files you want to &lt;code&gt;commit&lt;/code&gt; to your repo. It's a holding area for your changes&lt;/p&gt;
&lt;h4&gt;
  
  
  HEAD
&lt;/h4&gt;

&lt;p&gt;The HEAD is a reference point that shows you &lt;em&gt;where you are&lt;/em&gt; along your commit line. It points to the currently checked out branch and to the last file that you committed (saved) onto that branch. This means that it frequently changes (and can be hard to keep track of...leading to a &lt;code&gt;detached HEAD&lt;/code&gt; state - more on this later 🧟‍♀️)&lt;/p&gt;

&lt;p&gt;The flow of updating the main branch in a git repository would be like this:&lt;/p&gt;

&lt;p&gt;1.Make a new branch from main and switch to the new branch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; Some-new-changes!
// Switched to a new branch &lt;span class="s2"&gt;"Some-new-changes!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Make your changes&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwebdikcyl1plplb8w7gl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwebdikcyl1plplb8w7gl.png" alt="Github desktop showing some changes on a " width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;code&gt;Add&lt;/code&gt; your changed files to the index (your draft area)&lt;/p&gt;

&lt;p&gt;4.&lt;code&gt;Commit&lt;/code&gt; your changed files with a message about what you did&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"commit message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.&lt;code&gt;Push&lt;/code&gt; your changes to your branch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6.Happy with your changes and checked everything? Create a Pull Request detailing what changes you've made.&lt;/p&gt;

&lt;p&gt;7.When your PR is accepted, this means that your changes have been &lt;code&gt;merged&lt;/code&gt; into the main files of the project.&lt;/p&gt;

&lt;p&gt;The HEAD would move through points 1-4 here in turn and follows around what you are doing.&lt;/p&gt;

&lt;h4&gt;
  
  
  😱 Detached HEAD 💀
&lt;/h4&gt;

&lt;p&gt;This sounds like a ⚠️horrific error⚠️ and pretty terrible.&lt;br&gt;
I'm here to tell you it's not.&lt;br&gt;
In fact, it is sometimes necessary to use this state to test out a feature.&lt;br&gt;
Say you suddenly think of a different way that you could have solved something, or a different idea entirely that you could have approached your change or addition...if only you could go back in time to a few commits ago to test your new theory out...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What you need is a time machine&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can't have a time machine, but what you can do is point your HEAD marker to a few commits ago (via the hash of the commit), or whenever you want to start testing your new idea and create a &lt;em&gt;temporary branch&lt;/em&gt; to use. With a detached HEAD, the changes do not belong to any specific branch and so you need to be careful that you don't lose your changes if you want to keep your new work.&lt;br&gt;
The easiest way to get to a detached HEAD state is to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &amp;lt;the commit SHA&lt;span class="o"&gt;(&lt;/span&gt;abcdef123&lt;span class="o"&gt;)&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TL;DR: Detached HEAD state is sometimes used if you want to make experimental changes to an earlier commit. Not a horrific error. Don't panic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recommended resources
&lt;/h3&gt;

&lt;p&gt;I'm not affiliated with these links or resources in any way, but I found them useful in my own learning journey.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=USjZcfj8yxE"&gt;Real-life references Youtube&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.git-tower.com/learn/git/faq/detached-head-when-checkout-commit/"&gt;Detached HEAD explanation and examples&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.atlassian.com/git/tutorials/saving-changes/git-commit"&gt;Command line git messages reminder&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What **is** a script? 🤷🏼‍♀️ How can I use them with Raycast?</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Sat, 10 Apr 2021 13:19:43 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-raycast-3pig</link>
      <guid>https://dev.to/javascriptcoff1/what-is-raycast-3pig</guid>
      <description>&lt;p&gt;💚 &lt;em&gt;Disclaimer: No prior knowledge needed...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Raycast is a productivity tool for MacOS, and as a native app, it &lt;em&gt;fits in&lt;/em&gt; with the Mac styling and performance that you are used to. I'll be using Raycast as an easy way to show. you how to run and access scripts. &lt;/p&gt;

&lt;p&gt;If you use &lt;strong&gt;Spotlight&lt;/strong&gt; (hit &lt;code&gt;cmd&lt;/code&gt; &lt;code&gt;spacebar&lt;/code&gt; and you'll find it), then you will be more familiar with what Raycast is. There are many tools that you can use that are similar, such as Alfred, Automator, Launchbar and others. With all of these tools, you can search your &lt;em&gt;entire&lt;/em&gt; computer for a file, you can search for things in the browser &lt;em&gt;without even opening the browser&lt;/em&gt; and you can add commands (Alfred calls them workflows, Raycast calls them extensions) to speed up the things that you do the most often, such as opening a particular website, starting a new email or emptying the trash (my favourite command 🤓)&lt;/p&gt;

&lt;p&gt;Personally, I find the Raycast UI to be much more natural for Mac and it has a strong community that can help with any questions, and I love how easy it is to install extensions, or &lt;em&gt;scripts&lt;/em&gt;. It also is easier to extend and adapt to your personal workflows.&lt;/p&gt;

&lt;p&gt;Also, right now it's totally free! 🥳&lt;/p&gt;

&lt;h2&gt;
  
  
  Hold up, what is a script?
&lt;/h2&gt;

&lt;p&gt;A script is a code file that allows your computer to automate a set of instructions. This could be something relatively simple, such as opening a webpage in your default browser, or something more complex such as starting up your development environment and opening the browser as well as your IDE. Scripts run in the background - this means that they run without getting in your way, and they generally happen &lt;em&gt;fast&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Writing a script is like writing a recipe for someone else to use - you give them exact ingredients and tell them what to do with those ingredients, and then they might make you a delicious meal!&lt;/p&gt;

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

&lt;p&gt;Mmm...&lt;/p&gt;




&lt;p&gt;Scripts mean that you can instruct your computer to perform a set of instructions without having to ask you for anything.&lt;/p&gt;

&lt;p&gt;Let's start with a script that does something that we all probably do too much but that probably isn't great for our productivity - opening Twitter in your default browser! &lt;/p&gt;

&lt;p&gt;Luckily for us, the &lt;code&gt;bash&lt;/code&gt; scripting language is pretty easy to remember for this script: the command word is &lt;code&gt;open&lt;/code&gt;, so our script is going to be pretty short! Firstly, we need to install &lt;a href="https://raycast.com/" rel="noopener noreferrer"&gt;Raycast&lt;/a&gt; if you haven't already got it, and type &lt;code&gt;Create Script Command&lt;/code&gt; as this will allow us to start coding straight away with all the metadata already set. &lt;/p&gt;

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

&lt;p&gt;For this script, we are going to use &lt;code&gt;Bash&lt;/code&gt;. The reason for this is because it is good for smaller and less complex scripts. Soon enough, you'll be coding with &lt;code&gt;Ruby&lt;/code&gt; and &lt;code&gt;Python&lt;/code&gt; and &lt;code&gt;Swift&lt;/code&gt; and everything else, but for now let's get started with &lt;code&gt;Bash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After you've filled out the form, hit &lt;code&gt;cmd&lt;/code&gt;+&lt;code&gt;enter&lt;/code&gt; and choose where you'd like to save it. I recommend saving it in a folder called 'Code' if you don't have one already. If you're really stuck, just save it on the desktop and you can sort it out later 🥴&lt;/p&gt;

&lt;p&gt;Now close Raycast for now, and go to the new file that you just made. Right-click, and go to Open With...&lt;/p&gt;

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

&lt;h3&gt;
  
  
  I need to install some fancy tool though, right?
&lt;/h3&gt;

&lt;p&gt;Nope!&lt;/p&gt;

&lt;p&gt;I'm using the built-in TextEdit Mac app, although you'll have a much better time if you have Visual Studio Code...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtehrcvxlzp32s1ubq9w.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%2Fgtehrcvxlzp32s1ubq9w.png" alt="TextEdit window showing the code which is generated with the Create Script Command function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok, so we have our template, and we changed &lt;code&gt;fullOutput&lt;/code&gt; to &lt;code&gt;silent&lt;/code&gt; in the &lt;code&gt;@raycast.mode&lt;/code&gt;(because we don't need to see any output or data for this script). &lt;/p&gt;

&lt;p&gt;Would you believe me if I said we were nearly done?!&lt;/p&gt;

&lt;p&gt;Next, we are going to write the &lt;em&gt;actual&lt;/em&gt; script... hold onto your hats... 🧢&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;open https://twitter.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yep, it's really &lt;em&gt;that&lt;/em&gt; easy! Congrats on writing your first script! Now, let's save it before we load it into Raycast. If, like me, you are using TextEdit for this, you'll need to change it to a 'plain text' file, under the &lt;code&gt;format&lt;/code&gt; header, so that we can do what we want with it.&lt;/p&gt;

&lt;p&gt;Next, you need to make a folder. I recommend saving it on on your desktop so you always remember where you put it! ✅ Now go back to your file and save it into your newly created folder. Name it anything you like, but make sure that the file ends in &lt;code&gt;.sh&lt;/code&gt;. If it won't let you save it with the &lt;code&gt;.sh&lt;/code&gt; file extension, go back and make sure that you remembered to make it a plain text file. If you aren't using TextEdit, then search for 'plain text' and the name of the text editor you are using in Google.&lt;/p&gt;

&lt;p&gt;Now we can load it into Raycast!&lt;/p&gt;

&lt;p&gt;🤓 &lt;strong&gt;Side note:&lt;/strong&gt; As developers, we call folders on your computer &lt;code&gt;directories&lt;/code&gt;. If they are on your computer, then they are &lt;code&gt;local directories&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;To load your script into Raycast, firstly open Raycast, then go to About, then Extensions, then click the little '+' to get to 'add script directory', find your folder, and then click open.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ok, done!
&lt;/h2&gt;

&lt;p&gt;Now we want to test our script, right?!&lt;/p&gt;

&lt;p&gt;Go back to the root search of Raycast, and search for the title of your script! We set the &lt;code&gt;@raycast.title&lt;/code&gt; to 'Open Twitter', so search for Open Twitter in Raycast and then hit enter on it...&lt;/p&gt;

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

&lt;p&gt;Magical...🪄&lt;/p&gt;

&lt;p&gt;Now, what happens if you change the URL and save the file, or if you add another &lt;code&gt;open https://...&lt;/code&gt; ?&lt;/p&gt;

&lt;p&gt;Suddenly, you have a way to open ALL of the web pages you need on a daily basis...at once!&lt;/p&gt;

&lt;h2&gt;
  
  
  Only web pages?
&lt;/h2&gt;

&lt;p&gt;You can also open apps using the &lt;code&gt;open&lt;/code&gt; command in bash - as long as you know the &lt;code&gt;path&lt;/code&gt; to where the app is (usually &lt;code&gt;/System/Volumes/Data/Applications/...&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;Here's an example, my 'open-Everything.sh' file. As the name suggests, this script opens everything I need for my workday!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="c"&gt;# Required parameters:&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.schemaVersion 1&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.title Open Work&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.mode inline&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.description Open my workflows&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Optional parameters:&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.icon 💻&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.iconDark&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Credits&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.author Faye Sipiano&lt;/span&gt;
&lt;span class="c"&gt;# @raycast.authorURL https://github.com/FSipiano&lt;/span&gt;

open https://twitter.com
open https://app.frontapp.com/inboxes/teammates
open https://github.com/raycast/script-commands
open https://www.notion.so/raycastapp
open https://calendar.google.com/calendar/u/0/r
open /System/Volumes/Data/Applications/iTerm.app
open /System/Volumes/Data/Applications/Slack.app
open /System/Volumes/Data/Applications/Spotify.app
code
open /System/Volumes/Data/Applications/Aware.app
open https://app.pluralsight.com/library/courses
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So that's how we can speed up our workflows using Raycast and &lt;code&gt;open&lt;/code&gt; in &lt;code&gt;bash&lt;/code&gt; scripts... what if you want to take it further..? What if you wanted to open a specific repo or file to work on? For that, you can add things like &lt;code&gt;~/Developer/raycast-web&lt;/code&gt; to tell it to open something in a &lt;em&gt;specific&lt;/em&gt; place - you have given it the &lt;strong&gt;path&lt;/strong&gt; (route) to get to it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scripting languages are cool and you can do a lot with them, but you don't need to &lt;em&gt;remember&lt;/em&gt; how to write them...Google is your friend...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There're &lt;em&gt;tonnes&lt;/em&gt; of workflows that you can speed up by loading scripts into Raycast. If you want inspiration or want to try out useful scripts written by the community, then head over to &lt;a href="https://github.com/raycast/script-commands#raycast-script-commands" rel="noopener noreferrer"&gt;the community repo&lt;/a&gt; and see what you can find! One of my favourites is the &lt;a href="https://github.com/raycast/script-commands/blob/master/commands/system/quit-all-apps.swift" rel="noopener noreferrer"&gt;Quit Everything&lt;/a&gt; command. I have it mapped to &lt;code&gt;option&lt;/code&gt; &lt;code&gt;q&lt;/code&gt; for extra &lt;em&gt;drama&lt;/em&gt;. Obviously, I can't show you this script as my recorder would shut off, but it does what it says on the tin and it's a nice way of finishing off your workday in style 😎&lt;/p&gt;

&lt;p&gt;I can't show you what it looks like, but it feels like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/cYeTawXmSKVOaHU5XB/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/cYeTawXmSKVOaHU5XB/giphy.gif" alt="https://media.giphy.com/media/cYeTawXmSKVOaHU5XB/giphy.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are lots of scripts that you can write or download that will save you time and increase your productivity; take my usual, non-scripted, development workflow, for example:&lt;/p&gt;

&lt;p&gt;Over 1 minute to get into my dev environment...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F21f2z0ah5fst8qo0dv5t.gif" 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%2F21f2z0ah5fst8qo0dv5t.gif" alt="It takes over 1 minute to navigate to the right file and then use Gridsome to get into my dev environment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is what I turned that into with the help of Raycast and a &lt;code&gt;bash&lt;/code&gt; script:&lt;/p&gt;

&lt;p&gt;8 Seconds!!! I save 63 seconds with this script.... that doesn't sound like A LOT, but trust me... it is A LOT if you are loading up your dev environment multiple times a day!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fysnlfjshkummvcv77pz6.gif" 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%2Fysnlfjshkummvcv77pz6.gif" alt="I open Raycast, type 'dev' and hit enter. Everything loads up straight away and is 8 seconds from start to finish"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's Raycast! I hope that has inspired you to start looking into ways to speed up your workflows - head over to the community repo and see if you can find anything you like! As I mentioned, I &lt;em&gt;personally&lt;/em&gt; recommend the &lt;a href="https://github.com/raycast/script-commands/blob/master/commands/system/quit-all-apps.swift" rel="noopener noreferrer"&gt;Quit All Applications&lt;/a&gt; script and the &lt;a href="https://github.com/raycast/script-commands/blob/master/commands/system/empty-trash.applescript" rel="noopener noreferrer"&gt;Empty Trash&lt;/a&gt; script.&lt;/p&gt;

&lt;p&gt;If you have any questions, recommendations or comments about Raycast or any of the repos or documentation, please reach out to me either through the &lt;a href="https://www.raycast.com/community" rel="noopener noreferrer"&gt;community Slack channel&lt;/a&gt; - it is &lt;em&gt;literally&lt;/em&gt; my job as a Developer Advocate to make sure that you get the best experience, regardless of your skill level 💚&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>bash</category>
      <category>startup</category>
    </item>
    <item>
      <title>What **is** an API?🤷🏼‍♀️ Part II</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Sat, 13 Mar 2021 17:56:25 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-an-api-part-ii-192h</link>
      <guid>https://dev.to/javascriptcoff1/what-is-an-api-part-ii-192h</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclaimer&lt;/em&gt;: I'm not a backend engineer (although I did once write a form in PHP....and then broke it, and I quite like Ruby), so this is written from a frontend-newbie point of view!&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/javascriptcoff1/what-is-an-api-pt-i-2914"&gt;Part I&lt;/a&gt;, we got to grips with what an API &lt;strong&gt;actually is&lt;/strong&gt;.&lt;br&gt;
There's a lot more to learn about APIs, and of course, a whole bunch of &lt;em&gt;jargon&lt;/em&gt; to get through (this &lt;strong&gt;is&lt;/strong&gt; the tech industry after all...)&lt;/p&gt;

&lt;p&gt;So sit back and relax as we tackle a few of the more common &lt;em&gt;jargons&lt;/em&gt;...&lt;/p&gt;
&lt;h3&gt;
  
  
  REST
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Ok, don't relax that much...REST stands for "REpresentational State Transfer" which is kinda complicated, so hold onto your hats&lt;/strong&gt; 🎩&lt;/p&gt;

&lt;p&gt;"Representational State Transfer" essentially means "This API will listen for the endpoints, which you'll have got from the documentation, and then you'll receive the data you asked for!" &lt;strong&gt;Representational&lt;/strong&gt; because the endpoint &lt;em&gt;represents&lt;/em&gt; a piece of data (a resource), &lt;strong&gt;state&lt;/strong&gt; as in &lt;em&gt;object&lt;/em&gt; or &lt;em&gt;data&lt;/em&gt; and &lt;strong&gt;transfer&lt;/strong&gt; as in... &lt;em&gt;transfer&lt;/em&gt;&lt;br&gt;
&lt;em&gt;At least they went with 'REST API' rather than 'RST API'....&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudm3b66w6gfd6yey5xow.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudm3b66w6gfd6yey5xow.jpeg" alt="Black/white image, man confused face" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember we talked about an API essentially being like a bridge in the first blog? Keep thinking about that.&lt;/p&gt;

&lt;p&gt;For a REST API, you send your request over the bridge (the API) and you get back a piece of data...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Like a normal API?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Yes, but also no&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You see, with a REST API, you can specify the data that you want to receive and then it'll only pass you back the bit that you want!&lt;br&gt;
To do this, you need to look through the API documentation and figure out what bit of info is attached to what endpoint&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Me?! I could never understand API documentation! Never!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I know, I know, it does sound scary...&lt;br&gt;
However, many things in tech sound scary but actually &lt;em&gt;aren't&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;I promise that you will understand, but it takes time.&lt;/p&gt;

&lt;p&gt;One thing that genuinely (this is not a sponsored article) helped me to understand the mystical world of APIs is Postman. Postman lets you see what response you are getting from an API, and if it's the right thing that you want. &lt;a href="https://www.postman.com/cs-demo/workspace/2e243885-318c-4b51-bf5c-8bf2241e4acd/folder/8854915-64142a26-a16b-43f9-9303-ff8b13d9d3ee?ctx=documentation"&gt;I recommend downloading it and looking into the docs too&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What does an API response look like?
&lt;/h2&gt;

&lt;p&gt;Ok, prepare yourself... JSON isn't the nicest thing to look at...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"viewer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"pullRequests"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"nodes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"baseRepository"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node-cms"&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Updated to exclude AWS references"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"number"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://github.com/vfwood/node-cms/pull/1"&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"baseRepository"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node-cms"&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Update README.md"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"number"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                        &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://github.com/vfwood/node-cms/pull/2"&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yep, eek... &lt;br&gt;
This JSON is an &lt;em&gt;actual real life&lt;/em&gt; call to my GitHub repo to find out how many pull requests I have open. As you can see, there are multiple layers to the data and it is set out in a weird format - this is called the 'JSON tree'.&lt;/p&gt;

&lt;p&gt;Here is calling the API looks like in Postman: &lt;/p&gt;

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

&lt;p&gt;That particular JSON response above is from GitHub's GraphQL API (a different one to the REST API)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What?! We are talking about REST!!!!!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I know, but I needed to compare it with something rather than just explaining it with &lt;em&gt;words&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;Remember the steps from earlier? This is the query that you'd write in your code to get the API to give you back the title of your PRs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "query": "query { viewer { pullRequests(first: 10 states:OPEN) { nodes {baseRepository {name} title number url} }}}"
}

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

&lt;/div&gt;



&lt;p&gt;See if you can follow the JSON tree and figure out the logic of the query - you can see that it's returning the name of the repo, the title of the PRs, the number of the PR, and the URL of the particular PR. &lt;/p&gt;

&lt;p&gt;Nice, but that is a LOT of sorting through data.&lt;/p&gt;

&lt;p&gt;GitHub also have a REST API, hence we are using them for our examples!&lt;br&gt;
If you wanted to access the same data through the REST API, you'd first need to make sure you are calling the right API. Theoretically, to get the same into from the REST API, you'd call `.request('GET/repos/{owner]/{repo}/pulls', {&lt;/p&gt;

&lt;p&gt;As you can see, we aren't having to wade through the JSON tree so much, we are just telling it what info we want (the repo name, the PR titles, the number and the URL)&lt;/p&gt;

&lt;p&gt;This is the fundamental difference between REST APIs and other types of API.&lt;/p&gt;

&lt;p&gt;As a front end developer, you need to know about the different types of API because you need to know how to cal the endpoints in your code, but remember that fundamentally, APIs are just bridges and the documentation is a set of instructions that will tell you what to do to access the data.\&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cool, are we done?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Not quite...stop resting and listen up, let's talk about....verbs...&lt;/p&gt;

&lt;h1&gt;
  
  
  HTTP methods
&lt;/h1&gt;

&lt;p&gt;You need to know your HTTP methods when calling an API, regardless of whether it is RESTful, Graphql-ful, or anything else-ful!&lt;/p&gt;

&lt;p&gt;It will tell you in the API documentation which one the particular API uses, and personally, I've only seen &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt;, although I think &lt;code&gt;DELETE&lt;/code&gt; is a widely used one too.&lt;br&gt;
If you are calling an API, you need to know which of these methods it uses, as they all do different things.&lt;/p&gt;

&lt;h2&gt;
  
  
  GET
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;GET&lt;/code&gt; is a read-only operation, you are just &lt;em&gt;getting&lt;/em&gt; the data and you can't change or manipulate it. An example of this could be if you were using the Twitter API to &lt;em&gt;get&lt;/em&gt; someone's profile data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
GET /repos/{owner}/{repo}/pulls&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;br&gt;
&lt;em&gt;GitHub REST API url&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  POST
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;POST&lt;/code&gt; is typically used to &lt;em&gt;create&lt;/em&gt; a new resource.&lt;br&gt;
An example of this could be if you were using the Twitter API to &lt;em&gt;post&lt;/em&gt; a tweet. &lt;code&gt;POST&lt;/code&gt; is not idempotent...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Eh?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Yeah...that word...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;'Idempotent' is a horrible word that means that you can keep calling the same request multiple times and nothing will happen. An example of this would be if the API set person1's email address to &lt;a href="mailto:hi@123.com"&gt;hi@123.com&lt;/a&gt; and then did that exact same call again, nothing would happen - there would be no 'side effects' to the call. &lt;code&gt;POST&lt;/code&gt; is &lt;strong&gt;not&lt;/strong&gt; idempotent and so if you called it twice and it updated the email address again, it might do something unwanted like duplicate an ID...or a whole person...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A database nightmare waiting to happen&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;....&lt;strong&gt;Indeed, so watch your &lt;code&gt;POST&lt;/code&gt;s!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  PUT
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;PUT&lt;/code&gt; is used for updating an existing API resource. The main difference between &lt;code&gt;PUT&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt; is that &lt;code&gt;PUT&lt;/code&gt; is idempotent and so you can happily call it as many times as you like and &lt;strong&gt;nothing will change&lt;/strong&gt;! An example of using &lt;code&gt;PUT&lt;/code&gt; would be if you used the Twitter API to update your bio. The Twitter API probably doesn't use &lt;code&gt;POST&lt;/code&gt; on anything that needs updating such as a bio... why do you think that is?&lt;/p&gt;

&lt;h2&gt;
  
  
  DELETE
&lt;/h2&gt;

&lt;p&gt;I'll give you 2 guesses about what this http method does...&lt;/p&gt;

&lt;p&gt;Yep! You were probably right!&lt;br&gt;
An example of this is if you used the Twitter API to &lt;code&gt;DELETE&lt;/code&gt; some posts from your profile.&lt;/p&gt;

&lt;p&gt;Again, it's good to know what the HTTP methods &lt;em&gt;are&lt;/em&gt;, but the API documentation will tell you which one to use. It's good to know what the methods are as you will understand more about the expected behaviour of the API and will be able to identify issues quicker!&lt;/p&gt;




&lt;p&gt;As ever, I'm always learning, and I'd like to thank &lt;a href="https://twitter.com/Mastacheata"&gt;Benedikt&lt;/a&gt; for the below info!&lt;/p&gt;

&lt;p&gt;There's another useful API method to know about, &lt;code&gt;PATCH&lt;/code&gt;!&lt;br&gt;
&lt;code&gt;PATCH&lt;/code&gt; is very similar to &lt;code&gt;PUT&lt;/code&gt; as they're both used to change stuff that's already there. The difference is how they do it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PUT&lt;/code&gt; takes whatever item you want to change and replaces it with whatever you send in the &lt;code&gt;PUT&lt;/code&gt;-Request.&lt;br&gt;
&lt;code&gt;PATCH&lt;/code&gt;, on the other hand, takes the item you want to change and only updates those fields you send in the &lt;code&gt;PATCH&lt;/code&gt;-Request. It's therefore sometimes called a partial update as well.&lt;br&gt;
&lt;code&gt;PATCH&lt;/code&gt; allows you to be more specific than &lt;code&gt;PUT&lt;/code&gt;&lt;br&gt;
Let's take a look at a GitHub issue example:&lt;/p&gt;

&lt;p&gt;The fields you can modify in an issue are the title and text (and a bunch of other things, but let's focus on those 2):&lt;/p&gt;

&lt;p&gt;In order to change the title of your issue using &lt;code&gt;PUT&lt;/code&gt;, you have to send both the changed title as well as the original text of the issue.&lt;br&gt;
With a &lt;code&gt;PATCH&lt;/code&gt; request on the other hand you can just send the title and not send the text at all.&lt;/p&gt;




&lt;p&gt;So that was Part II. As always, any suggestions are welcome, you can DM me on &lt;a href="https://twitter.com/JavaScriptCoff1"&gt;Twitter&lt;/a&gt; or comment here 😊&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What **is** an API? 🤷🏼‍♀️ Pt I</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Mon, 01 Mar 2021 12:42:25 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-an-api-pt-i-2914</link>
      <guid>https://dev.to/javascriptcoff1/what-is-an-api-pt-i-2914</guid>
      <description>&lt;p&gt;&lt;em&gt;An intro&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Another acronym!
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Hooray, I love acronyms!
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What does it mean.....?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;API stands for 'Application Programming Interface'&lt;/p&gt;

&lt;h3&gt;
  
  
  Mysterious...
&lt;/h3&gt;

&lt;p&gt;Yes, indeed.&lt;br&gt;
Tech does love to be mysterious. Almost all applications have APIs and they are essentially contracts telling you what you &lt;strong&gt;can&lt;/strong&gt; do with a system and &lt;strong&gt;how&lt;/strong&gt; to get the data you need.&lt;/p&gt;
&lt;h4&gt;
  
  
  Like a rulebook?
&lt;/h4&gt;

&lt;p&gt;Kinda, but not as specific as that. &lt;/p&gt;

&lt;p&gt;In my &lt;a href="https://github.com/FSipiano/newbieDictionary"&gt;Newbie Dictionary&lt;/a&gt;, API has been defined as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Stands for Application Programming Interface, is a software intermediary that allows two applications to talk to each other, is a contract between you and the software that you want to use, telling you what you can and can't do with it. It's a bridge allowing you to use the software and integrate it with your code, so that it becomes easier to integrate. Example- The google maps API allows you to integrate their maps to your apps through their API."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's a pretty good definition, but what does that &lt;em&gt;actually&lt;/em&gt; mean?&lt;/p&gt;

&lt;p&gt;Let's take the Google Maps example further; say you wanted to have a map of your business location displaying on your site (this is a common use case).&lt;/p&gt;

&lt;p&gt;You'd access your code, specifically your JavaScript, HTML and CSS for the map, and include the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HTML:&lt;/code&gt;&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="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Simple Map&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://polyfill.io/v3/polyfill.min.js?features=default"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/css"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"./style.css"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"./index.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"map"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class="c"&gt;&amp;lt;!-- Async script executes immediately and must be after any DOM elements used in callback. --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script
      &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&amp;amp;callback=initMap&amp;amp;libraries=&amp;amp;v=weekly"&lt;/span&gt;
      &lt;span class="na"&gt;async&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;JavaScript:&lt;/code&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;let&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;initMap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;google&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;maps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;lat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;34.397&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;lng&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;150.644&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;zoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&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;&lt;code&gt;CSS:&lt;/code&gt;&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;#map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Optional: Makes the sample page fill the window. */&lt;/span&gt;
&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&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;&lt;em&gt;You could do this right now (assuming you have set up a billing account for google cloud) and have a little page running locally with a map on it.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cool
&lt;/h3&gt;

&lt;p&gt;In the above example, we have accessed the Google Maps API. &lt;/p&gt;

&lt;h3&gt;
  
  
  But it all happened so fast!
&lt;/h3&gt;

&lt;p&gt;It did. Let's break it down.&lt;/p&gt;

&lt;p&gt;Look back at the &lt;code&gt;HTML&lt;/code&gt; block. In the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag at the bottom (that's where JavaScript lives on that page), we have a little &lt;code&gt;src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&amp;amp;callback=initMap&amp;amp;libraries=&amp;amp;v=weekly"&lt;/code&gt; This &lt;code&gt;src&lt;/code&gt; is called an &lt;strong&gt;endpoint&lt;/strong&gt; and it is pointing at what looks like a normal URL, and in fact it is, but that is actually a request to the Google Maps API. It's saying 'Hey, I need the &lt;code&gt;weekly&lt;/code&gt; maps sent over to me please, look - I am authorised, I have an 'API key!' &lt;/p&gt;

&lt;p&gt;The API key gives you access to the API. In Google's case, you probably get it when you set up a billing account and email. It would look something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;b07fa21a-8863-4953-8aae-22027540a782&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I got this key from a &lt;a href="https://codepen.io/corenominal/pen/rxOmMJ"&gt;random API key generator&lt;/a&gt; on codepen&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You'd enter that into where it says &lt;code&gt;YOUR_API_KEY&lt;/code&gt; in the &lt;code&gt;src&lt;/code&gt; we looked at earlier. Forgetting to do this or copy/pasting it incorrectly is a common mistake and is one of the first things you should check - are all of the characters there or did you chop off one by mistake?&lt;/p&gt;

&lt;h4&gt;
  
  
  So is an API always a map or something that you add to your site?
&lt;/h4&gt;

&lt;p&gt;Unfortunately for you, and for anyone trying to explain of understand APIs, an API can &lt;em&gt;literally be anything&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A Content management system?&lt;/p&gt;

&lt;h4&gt;
  
  
  There's an API for that
&lt;/h4&gt;

&lt;p&gt;A scientific calculator?&lt;/p&gt;

&lt;h4&gt;
  
  
  There's an API for that
&lt;/h4&gt;

&lt;p&gt;Randomly generated dog photos?&lt;/p&gt;

&lt;h4&gt;
  
  
  There's an API for that (&lt;a href="https://dog.ceo/dog-api/"&gt;here&lt;/a&gt;, you know you want to)
&lt;/h4&gt;

&lt;p&gt;You get the picture. Just know that an API is like a bridge that gives you access (and tells you how to access it) to &lt;strong&gt;data&lt;/strong&gt;. It doesn't always &lt;em&gt;transfer&lt;/em&gt; data back to you, but as long as you have a magic key, you have access.&lt;/p&gt;

&lt;h4&gt;
  
  
  If they all work so differently and do different things, how will I ever know how to use them?!
&lt;/h4&gt;

&lt;p&gt;Documentation my friend, documentation. All APIs will have documentation of some kind, and this will contain steps about how to use it.&lt;/p&gt;

&lt;p&gt;If you are still reading down here rather than looking at randomly generated dog images, firstly hello 👋🏻 and secondly, why are you not looking at dog pictures?!&lt;/p&gt;

&lt;p&gt;While you're there, take a look at the documentation, there are multiple endpoints that you could use in your project. It's free, too!&lt;/p&gt;

&lt;p&gt;If you want to look at more examples of APIs that we use in our everyday life, I recommend &lt;a href="https://nordicapis.com/5-examples-of-apis-we-use-in-our-everyday-lives/"&gt;this site&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://openweathermap.org/api"&gt;This weather API&lt;/a&gt; gives you an idea of how different endpoints can give you different things&lt;/p&gt;

&lt;h3&gt;
  
  
  So you've heard of REST, HTTP, GET, POST, AUTHENTICATION and all this other stuff?
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Hold tight, that's a little out of the scope of this article, but I'm collecting resources and knowledge for a Part II and maybe a Part III.
&lt;/h4&gt;

&lt;p&gt;'API' is a big subject, and although I've used them in the past, I've not fully understood what they ** are ** and what the details are.&lt;/p&gt;

&lt;p&gt;We are all codeNewbies here...&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What **is** hoisting? 🤷🏼‍♀️</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Thu, 18 Feb 2021 15:00:29 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-hoisting-2gkl</link>
      <guid>https://dev.to/javascriptcoff1/what-is-hoisting-2gkl</guid>
      <description>&lt;h3&gt;
  
  
  Easy!
&lt;/h3&gt;

&lt;p&gt;Hoisting is a JavaScript thing that means that you can use a variable before you declare it...&lt;/p&gt;

&lt;h3&gt;
  
  
  Hold up, what?
&lt;/h3&gt;

&lt;p&gt;Yeah, you're right, let me dig into this a little bit...&lt;/p&gt;

&lt;p&gt;Firstly, we need to understand the definitions of these 2 words:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;declared&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;defined&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;declaring&lt;/strong&gt; a variable -&lt;br&gt;
&lt;/p&gt;

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


***************
This is **defining** a variable -



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

&lt;/div&gt;

&lt;p&gt;greeting = "Hello, how are you?"&lt;/p&gt;

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


Secondly, let's think about *scope*
_I wrote a little example of what **scope** is on my Twitter_
&lt;iframe class="tweet-embed" id="tweet-1362026187262988289-393" src="https://platform.twitter.com/embed/Tweet.html?id=1362026187262988289"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1362026187262988289-393');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1362026187262988289&amp;amp;theme=dark"
  }





_Let's run with this analogy..._

For your little people to be able to work locally, they need to have been **declared**. Any people in your factory that haven't been declared can be seen by **everyone** in other factories within your code - they are _global._


####Ok, that's scope. Can we talk about hoisting now?

Actually, no. Ok kinda.


_Where you put stuff matters_

Let's think back to our **declared** and **defined** again. There are 2 different ways you can do these things:

_Simultaneusly_:



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

&lt;/div&gt;

&lt;p&gt;var greeting = "Hello world"&lt;/p&gt;

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

In this example, we are **declaring** the variable (greeting) at the same time as **defining** what it is going to say ("Hello World")

###or

_not.....simultaneously..._


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

&lt;/div&gt;

&lt;p&gt;var greeting&lt;/p&gt;

&lt;p&gt;....&lt;/p&gt;

&lt;p&gt;greeting = "Hello World"&lt;/p&gt;

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

In this example, we are **declaring** the variable (greeting) and then later on in the code, we are **defining** what it is ("Hello World")


###Why are there 2 ways of defining and declaring, isn't that kinda confusing? 1 way would be easier...

_My thoughts entirely._
Personally, I prefer the first way, I think it looks nicer and is easier to read
However, it is also nice to make all of your **declarations** at the top and then you can **define** them wherever you like. 

Anyway, moving on...

###Hoisting?

Yes, yes. 
So we have looked at the different ways of declaring and defining, but what JavaScript also lets you do....is this...



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

&lt;/div&gt;

&lt;p&gt;greeting = "Hello World"&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;var greeting&lt;/p&gt;

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


Now, logically, you shouldn't be able to do this, because you are using the variable before you are declaring it with the **var** keyword. It _should_ throw an error, but it doesn't. It will still know what **greeting** is. This is because the JavaScript compiler quickly scans your code and _hoists_ all of your declarations up to the top, as if you had written it like this:



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

&lt;/div&gt;

&lt;p&gt;var greeting&lt;/p&gt;

&lt;p&gt;greeting = "Hello World"&lt;/p&gt;

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



It essentially _knows_ that you might have declared variables in random places (because everyone writes differently!) and wants to pull them all up to the top before it starts properly working on what you have written.

I think that's pretty logical actually. 

**It's like quickly reading a list of names in your head to make sure you know how to pronounce them all _before_ you read them out loud and get stuck!**


So, if you get an 'undefined' error on a variable that you weren't expecting, check the order that you've written everything in, and then blame hoisting (and probably start using let and const*) 🤣

Also, you may have noticed that I have used *var* as my JavaScript keyword throughout the examples. This is on purpose:

* `var` is a bit of a weird one - using it means that you might get some 'undefined' errors. `var` doesn't stand up for itself and is pretty unsure about things.
When you use `let` or `const` instead, they don't let the compiler boss them around - they know their job and they are sticking with it. `let` and `const` aren't affected by hoisting.
If you've **defined** something before you've **declared** it, you'll get a Reference error, and you don't need to worry about hoisting moving things around for you.

Hoisting also works with function declarations:


This is written in a logical order and works as expected. No hoisting involvement.


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

&lt;/div&gt;

&lt;p&gt;function example() {&lt;br&gt;
   var a = 1;&lt;br&gt;
   return a;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;console.log(example())&lt;/p&gt;

&lt;p&gt;//1&lt;/p&gt;

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


************************

This one is written with the `console.log` first, but will still work as expected because of hoisting - the compiler has skim read your code and 'hoisted' (pulled) all of your variable declarations to the top!



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

&lt;/div&gt;

&lt;p&gt;console.log(example())&lt;/p&gt;

&lt;p&gt;function example() {&lt;br&gt;
var a = 1;&lt;br&gt;
return a;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;//1&lt;/p&gt;

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




The lesson here: **stop using var, it will do you no good** 

Understanding hoisting is still essential for when you have to work with older codebases (`let` and `const` haven't always been around to save you from hoisting!)



####Shoutouts:

* Big shoutout to [@pasoevi](https://twitter.com/pasoevi) for helping to proofread!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What **is** recursion? 🤷🏼‍♀️</title>
      <dc:creator>JavaScript➕Coffee🚀</dc:creator>
      <pubDate>Wed, 10 Feb 2021 16:08:02 +0000</pubDate>
      <link>https://dev.to/javascriptcoff1/what-is-recursion-190n</link>
      <guid>https://dev.to/javascriptcoff1/what-is-recursion-190n</guid>
      <description>&lt;p&gt;I was challenged by &lt;a href="https://twitter.com/100days100"&gt;@100days100&lt;/a&gt; to learn and write about recursion.&lt;br&gt;
This is not something that I've looked into or used before..&lt;/p&gt;

&lt;p&gt;This article will answer the question 'what is recursion?' and will hopefully give you a solid way with which to explain it to others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recursion is a principle which occurs in many different languages and formats, but we are going to stick with explanations and examples using JavaScript so we don't go &lt;em&gt;completely&lt;/em&gt; mad.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  So here we gooooooooo 🥳
&lt;/h2&gt;

&lt;p&gt;Recursion (ree-curr-shon) is a Computer Science principle that is found in almost every coding language. It is a type of process or method that is used to break a problem down to solve it in smaller, repetitive ways. It's a method that calls itself.&lt;/p&gt;
&lt;h3&gt;
  
  
  Like a loop?
&lt;/h3&gt;

&lt;p&gt;Yeah, exactly like a for-loop, except a for-loop is a &lt;em&gt;loop&lt;/em&gt;, not a &lt;em&gt;method&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remember that tech likes to be confusing...&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  So....a &lt;em&gt;method&lt;/em&gt; that keeps referring to itself...?
&lt;/h3&gt;

&lt;p&gt;Imagine someone that keeps referring to themselves in the third person. &lt;br&gt;
Example: "Hi, Faye's name is Faye. Faye likes writing and learning about things that Faye doesn't understand yet - essentially Faye likes to teach people while learning."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Yeah, sounds really weird. Give yourself a minute to come up with some funny sentences and then you'll be able to focus again.&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;You got it out of your system?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ok great, let's carry on...&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Why would you ever need to make a method refer to itself?
&lt;/h3&gt;

&lt;p&gt;Great question...&lt;br&gt;
A popular 'task' in a coding quiz or even interview is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a function that returns the factorial of a given integer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Stop right there. What?
&lt;/h3&gt;

&lt;p&gt;Ah yes, this mathematical concept that I also just learned about! So this seems to be the best way to explain recursion&lt;br&gt;
'factorial' is all about multiplying numbers together&lt;br&gt;
So 'factorial 6' - 6! would be 6 * 5 * 4 * 3 * 2 * 1.&lt;/p&gt;

&lt;p&gt;You could work this out pretty easily, but what about factorial 97?&lt;/p&gt;

&lt;p&gt;This is where a recursive function will be useful.&lt;/p&gt;

&lt;p&gt;Your function needs to loop (yes, loop, don't @ me) around all of the numbers, &lt;strong&gt;but&lt;/strong&gt; &lt;em&gt;(and hold on here)&lt;/em&gt; do you see the issue?&lt;/p&gt;

&lt;p&gt;Let's take factorial 6 again - and I want you to imagine that each of the steps is a block of lego. &lt;strong&gt;Also, I'm calling each answer (n). Stay with me for now, we will come back to that later.&lt;/strong&gt;&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;6 * 5 = n(30)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;So here in our first block, we have the original number multiplied by itself-1&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;2nd block - (n) * 4 = n(120)&lt;br&gt;
&lt;em&gt;So this block is &lt;strong&gt;relying&lt;/strong&gt; on the first block because it needs to know what the first blocks' (n) answer was, and then it comes up with its own (n)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;3rd block - (n) * 3 = n(360)&lt;br&gt;
&lt;em&gt;This block is relying on the 2nd block for it's (n) answer, and is also, by extension, relying on the 1st block. This is why we are imagining them as lego - they all fit together and hold each other up)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;4th block - (n) * 2 = n(720)&lt;br&gt;
&lt;em&gt;This fourth block is relying on every other block before it for all of their versions of n, and then it's created another version!&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;5th block - (n) * 1 = n(720)&lt;br&gt;
&lt;em&gt;Our 5th block doesn't really do much, it is just multiplying n by 1, nevertheless, we need it to finish our lego tower.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;6th block - n * 0 = n(0)&lt;br&gt;
&lt;em&gt;Our last block feels like it's undoing all of that nice math that we were just doing, right? Yep, but that's math. Hold tight for the...&lt;/em&gt; &lt;strong&gt;👀base case👀&lt;/strong&gt;😱&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Ok, that's factorial, what's that got to do with recursion?
&lt;/h3&gt;

&lt;p&gt;The point of me explaining that was to show a recursive function, spread out like a scroll. Now imagine if you could squish &lt;strong&gt;all&lt;/strong&gt; of those 6 lego blocks into 1.&lt;/p&gt;

&lt;p&gt;Imagine all of the lego blocks for factorial 50, or even 700! &lt;br&gt;
Imagine it was your task to write that out in code. Sure, achievable with for loops and if/else statements but...&lt;/p&gt;

&lt;p&gt;Think of the clean code you could have if you didn't have for loops and if/else statements everywhere.&lt;/p&gt;
&lt;h5&gt;
  
  
  Elegant 💃🏼
&lt;/h5&gt;

&lt;p&gt;The recursive function that you'd need for the 6! (factorial 6) puzzle would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function factorial(n) {
  if (n &amp;lt; 0) return;
  if (n === 0) return 1;
  return n * factorial(x - 1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above function, if you wanted to find factorial 6, you'd &lt;code&gt;console.log(factorial(6))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's break down exactly what the function would do next.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (n &amp;lt; 0) return;
if (n === 0) return 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, 6 &lt;strong&gt;is&lt;/strong&gt; greater than 0, and it &lt;strong&gt;isn't&lt;/strong&gt; 0, so it would jump over these 2 ifs. We passed the termination condition and base case! Carry on!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return n * factorial(n - 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Woah....
&lt;/h4&gt;

&lt;p&gt;Yep, this is the &lt;em&gt;actual&lt;/em&gt; recursive function.&lt;/p&gt;

&lt;p&gt;Bow down to it. This is what this whole article has been about.&lt;/p&gt;

&lt;p&gt;What this little friend does is to say 'if you have passed the termination and base...' (we did) '...then multiply 6 by 6-1'&lt;/p&gt;

&lt;p&gt;This function will run again and again, forever and ever, until it is stopped by the nets (the termination condition and base case. &lt;/p&gt;

&lt;p&gt;Our 6th lego block (the one that undid all our nice math) will be caught in the base case (because it &lt;strong&gt;does&lt;/strong&gt; === 0) and the previous results will be logged in reverse order (like an unravelling spiral)&lt;/p&gt;

&lt;h4&gt;
  
  
  References!
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://dev.to/dpkreativ/recursion-in-javascript-2ch4"&gt;Recursion In JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=Mv9NEXX1VHc&amp;amp;t=434s"&gt;What on Earth is Recursion? - Computerphile&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As always, &lt;a href="https://twitter.com/oliverjumpertz"&gt;Oliver&lt;/a&gt; and &lt;a href="https://twitter.com/Mastacheata"&gt;Benedikt&lt;/a&gt; on Twitter&lt;/p&gt;

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