<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Peter Meister on Medium]]></title>
        <description><![CDATA[Stories by Peter Meister on Medium]]></description>
        <link>https://medium.com/@prmeister89?source=rss-911d74b7e73------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yKD5a8pMAzherBsbac-iwA.jpeg</url>
            <title>Stories by Peter Meister on Medium</title>
            <link>https://medium.com/@prmeister89?source=rss-911d74b7e73------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:04:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prmeister89/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What I’ve Been Up To]]></title>
            <link>https://medium.com/@prmeister89/what-ive-been-up-to-485f5a2bf44d?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/485f5a2bf44d</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 03:51:37 GMT</pubDate>
            <atom:updated>2019-03-04T03:51:37.197Z</atom:updated>
            <content:encoded><![CDATA[<p>This week has been a busy one. I’ve had interviews, worked on some labs, and have had social events in between. So far, I’m feeling pretty good about all of it.</p><p>More specifically, I’ve been keeping up with my Object Oriented Programming. As much as I would like to get into the specifics of <em>what</em> I’ve been keeping up with, I have to save it for next week.</p><p>I started brushing up on my Ruby and using OOP to create simple classes and methods, however, I recently had an interviewer ask me to do the same thing, but using JavaScript.</p><p>I hope to write a blog discerning the differences between the two and hopefully help identify the key similarities and differences.</p><p>Until then…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=485f5a2bf44d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rediscovering the ‘FizzBuzz’ Problem in Javascript]]></title>
            <link>https://medium.com/@prmeister89/rediscovering-the-fizzbuzz-problem-in-javascript-4e4d0ca9572f?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e4d0ca9572f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[fizzbuzz]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Mon, 25 Feb 2019 02:09:30 GMT</pubDate>
            <atom:updated>2019-02-25T02:09:30.492Z</atom:updated>
            <content:encoded><![CDATA[<p>A Lesson from an Interview Question</p><p>Recently, I had an interview where this question came into play. Normally, I would be able to solve this pretty easily, however, the circumstances of the interview denied me the use of any external assistance and didn’t allow me to test my code.</p><p>That last part was the more difficult part for me. Anyway, I started pseudo-coding and was able to workout a pretty safe framework for how I thought the solution should look. However, not being able to test it kind of got to me so I went back to my notes after the interview and confirmed my answer was super close.</p><p>This article is a simple breakdown of that problem. Whether it’s for my sake or yours, it doesn’t really matter. Putting the knowledge out there in any form or capacity is more important.</p><p><strong>The Problem</strong></p><p><em>Write a function that console logs numbers from 1 to 100. The multiples of 3 should log “Fizz”, for the multiples of 5 log “Buzz”, and for numbers which are multiples of both 3 and 5 log “FizzBuzz”.</em></p><p><strong>The Solution</strong></p><p>The best way to do this is to set up a <strong><em>for()</em></strong><em> </em>loop that starts at 1 and ends at 101. Then, it should check if the number (i) is divisible by 3, 5, and 15. Based on the number, the console will log either “Fizz”, “Buzz”, or “FizzBuzz”. Otherwise just log the number (i).</p><pre>for (var i=1; i &lt; 101; i++){<br>    if (i % 15 == 0) console.log(&quot;FizzBuzz&quot;);<br>    else if (i % 3 == 0) console.log(&quot;Fizz&quot;);<br>    else if (i % 5 == 0) console.log(&quot;Buzz&quot;);<br>    else console.log(i);<br>}</pre><p>My answer to the interview question was close to this. However, not being able to test my code prevented me from being 100% sure about my answer. If anything, this article should serve as an important note to future developers. Make sure you can do this and make sure you understand what is going on in the above-mentioned solution. Understanding is more important than memorization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e4d0ca9572f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I got my Update User Bio function working in React]]></title>
            <link>https://medium.com/@prmeister89/how-i-got-my-update-user-bio-function-working-in-react-e05c55c773dc?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/e05c55c773dc</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Sun, 17 Feb 2019 20:36:04 GMT</pubDate>
            <atom:updated>2019-02-17T20:36:04.067Z</atom:updated>
            <content:encoded><![CDATA[<p>Current Work-in-progress, JokeBook App</p><p>I’ve been working on my JokeBook app for a while, adding features and styling here and there, but I wanted to share how I was able to create an update function that allows a User to edit their Bio.</p><p>Since I am using a modal to open and close on click of ‘edit’, I created functions that opened and closed the modal in App.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*3n_5giQxVgwAkafEoNEwnA.png" /></figure><p>Next, I created a <strong>handleUpdateUserBio</strong> function (still in App.js) that took in an event (in this case, I wanted to pass in the <strong>bio</strong> ONLY) and send it to the backend as a PATCH. When I got a response from the backend, I made sure to keep all the userInfo the same <strong>except</strong> for the bio (lines 130–137). After that, invoke the closeModal() function to exit the modal on the webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*HaR2hIoestLJ-7AWpfwWbw.png" /></figure><p>In App.js, make sure you pass the handleUpdateUserBio function (line 191), and the two open/close Modal functions (lines 196 &amp; 197) down to the appropriate components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*iYYM0pXDZ5cFGYsyC0Z-Cg.png" /></figure><p>For clarification, these functions are being passed as such:</p><p>App.js &gt;&gt; ProfileContainer.js &gt;&gt; UserContainer.js &gt;&gt; UserForm.js</p><p>In UserForm.js, I assigned my open/close functions from App.js (now <em>props</em> in USerForm.js) to the same format that semantic-ui required for Modals (Part 1 picture below) and the <strong>contents</strong> for that Modal in the same required format and as a &lt;Form&gt; (Part 2 picture below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*j04gcudEkZ3p0hH9A-gXWQ.png" /><figcaption>Part 1 of UserForm.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*Eh6Pq0cF_m5U5hEHVITzDA.png" /><figcaption>Part 2 of UserForm.js</figcaption></figure><p>As you can see, onSubmit() of the form (when the “submit” button is clicked), the handleUpdateUserBio() function will pass the newly edited bio as an argument. That new bio will go all the way back to App.js, communicate with that backend, and update that User’s bio. That, in turn, will edit the web page and show us the new bio.</p><p>And that’s that! Just thought I would share my solution to updating a User’s Bio with a PATCH function. Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e05c55c773dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ruby Blocks and Yield]]></title>
            <link>https://medium.com/@prmeister89/ruby-blocks-and-yield-e30e60a52d3d?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/e30e60a52d3d</guid>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Sun, 10 Feb 2019 16:27:01 GMT</pubDate>
            <atom:updated>2019-02-10T16:27:01.906Z</atom:updated>
            <content:encoded><![CDATA[<p>What is a Block?</p><p>A <em>Block</em><strong><em> </em></strong>in Ruby is a chunk of code between braces or between <strong>do..end</strong> that you can associate with <em>method invocations</em>, almost as if they were parameters.</p><p>Let’s look at a simple example:</p><pre><strong>def</strong> invoke_block<br>   <strong>puts</strong> &#39;Beginning of Method&#39;<strong><br>   yield</strong><br>   <strong>puts</strong> &#39;End of Method&#39;<br><strong>end</strong></pre><p>In this case, we would see the following code returned:</p><pre>&gt;Beginning of Method<br>&gt;In the &#39;yield&#39; block<br>&gt;End of Method</pre><p>A <strong>block</strong> is simply a chunk of code, and yield allows you to &quot;inject&quot; that code at some place into a function. So if you want your function to work in a <strong>slightly different way</strong>, you don&#39;t have to write a new function, instead you can reuse the one you already have, but give it a <strong>different block</strong>.</p><p>What is Yielding?</p><p>The yield keyword, when used inside the body of a method, will allow you to call that method with a block of code and pass the torch, or <em>yield</em>, to that block. Think of the yield keyword as saying: &quot;Stop executing the code in this method, and instead execute the code in this block. Then, return to the code in the method.&quot;</p><p>If we were to call our above function with an argument, that argument would be “injected” where theyield keyword is placed.</p><pre><strong>def</strong> invoke_block<br>   <strong>puts</strong> &#39;Beginning of Method&#39;<strong><br>   yield</strong><br>   <strong>puts</strong> &#39;End of Method&#39;<br><strong>end</strong></pre><pre>invoke_block { <strong>puts</strong> &quot;the method yields to the block&quot; }</pre><pre>&gt;&#39;Beginning of Method<br>&gt;&#39;the method yields to the block&#39;<br>&gt;&#39;End of Method&#39;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e30e60a52d3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keeping Up with Ruby on Rails]]></title>
            <link>https://medium.com/@prmeister89/keeping-up-with-ruby-on-rails-4551fe5c7318?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/4551fe5c7318</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Mon, 04 Feb 2019 00:54:52 GMT</pubDate>
            <atom:updated>2019-02-04T00:54:52.677Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I made a blog post that acted as an re-introduction to keeping my Ruby skills sharp. As promised, here is my follow-up to what I’ve been doing.</p><p>I’ve learned a few new things while going through my old online assignments, primarily how different Ruby is compared to other programs (duh). However, I wanted to write down the pros as I get back into all this.</p><p>Ruby on Rails is pretty time efficient (considering). Although it is relatively easy to learn the basics of this framework, it will take some time for you to unlock its true potential. However, some time investment, you’ll definitely see an ROI on how much time you can save overall.</p><p>Ruby has a built-in debugger, but it is <a href="http://guides.rubyonrails.org/debugging_rails_applications.html">not the only tool you can use</a> to debug Rails applications.</p><p>It’s a simple blog so far, but more of my time has gone back into actually coding instead of writing about it.</p><p>If and when I come across a cool new feature that I’d like to write about, I’ll put it up here ASAP.</p><p>Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4551fe5c7318" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Post-Grad Blog Post]]></title>
            <link>https://medium.com/@prmeister89/my-first-post-grad-blog-post-ce6e34094f83?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce6e34094f83</guid>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 21:10:22 GMT</pubDate>
            <atom:updated>2019-01-27T21:10:22.479Z</atom:updated>
            <content:encoded><![CDATA[<p>Getting back into coding after a brief time getting your post-graduated ducks in order can be a challenge in itself. Like any skill, coding is one that (if not practiced) can be dulled and rusted.</p><p>After brushing up on my Ruby, I definitely felt my mental muscles slowly remember themselves. With all the varied coding languages out there, it’s strange how they can all be very similar, yet, implemented in such a different way. Almost annoyingly so.</p><p>Today, I spent the better part of the day flexing those old muscles and trying my hand at some Ruby practice problems. From sorting arrays to navigating hashes, it was all very illuminating and almost nostalgic.</p><p>Further blog posts will be dedicated to going into detail about what I learned for that week, but this one is simply an introduction to the process I plan to adhere to. I’ excited to get back into it all and hope to grow even more in the process. Excelsior! (R.I.P. Stan Lee)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce6e34094f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement React Google Maps]]></title>
            <link>https://medium.com/@prmeister89/how-to-implement-react-google-maps-1c04808e238f?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c04808e238f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[google-maps]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Thu, 18 Oct 2018 18:34:06 GMT</pubDate>
            <atom:updated>2018-10-18T18:34:06.484Z</atom:updated>
            <content:encoded><![CDATA[<p>A Simple Set-Up Guide</p><h4>Step 1: Build a Map Component</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*NgCmAnuOj7Gz5iI5JEOuSw.png" /><figcaption>Either Right-Click and Create File or Create the File from your console →</figcaption></figure><pre>touch src/components/Map.js</pre><p>Next, we need to set-up our <strong>Map Component…</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*TOtQxwR7F6PRqNZd1yFwiw.png" /></figure><p>Now, let’s connect our <strong>Map Component</strong> with our <strong>App.js</strong> file and make sure it renders…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*dXQtQhWcrZjf_BczWPuWqA.png" /><figcaption>Our App.js File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*sWdtTxKE5FjPRhQ_WH7J0w.png" /><figcaption>We can see our App.js File is rendering our Map Component</figcaption></figure><p>Cool! Look’s like everything is set-up!</p><h4>Step 2: Downloading and Structuring our Map Component</h4><p>First, we need to download the ‘google-maps-react’ library to our node modules:</p><pre>npm:</pre><pre>npm install --save react-google-map</pre><pre>yarn:</pre><pre>yarn add react-google-map</pre><p>Next, we need to import specific parts of the ‘react-google-maps’ package into our Map.js file and then pass them some props to render. We want our Map.js file to look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*6AvcMeiqaXj_kGOlksQHXQ.png" /></figure><p>Here’s what we did:</p><p>We needed to pass in two props into ‘GoogleMap’ to get the component to work and those are <strong>‘defaultCenter’</strong> and <strong>‘defaultZoom’</strong>. For defaultCenter, your latitude and longitude need to be in the form of an object. The same applies for your number in defaultZoom.</p><p>Next, we needed to return the <strong>const</strong> we just created. By adding the props of <strong>‘containerElement’</strong> and <strong>‘mapElement’, </strong>we can set the height and width of the <strong>containerElement</strong> to anything we want (in this case, we are using a fixed pixel size of 500px by 500px). For the <strong>mapElement</strong>, we want to fill the container, so the height will be 100%.</p><p>Step 3: Rendering you Map Component</p><p>If we try rendering our Map component as it is, we’ll see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*kpxphHTSzVryFq2wzwxrMA.png" /><figcaption>You need a GoogleAPI Key</figcaption></figure><p>This is because we need to <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">get an API key from Google</a>. Once we have that, we’ll need to go into our <strong>index.html</strong> file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*qIimLXd-AAii0VBFxygwlg.png" /></figure><p>In the header of your index.html file add the following script (I added it after the link tags) along with your private Google API key:</p><pre>&lt;script src=&quot;<a href="https://maps.googleapis.com/maps/api/js?key=AIzaSyA6C5cnXRvJjsYI0SI9nlojhaEtovEUOxk">https://maps.googleapis.com/maps/api/js?key=Y</a>OUR_API_KEY_GOES_HERE&quot;&gt;&lt;/script&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*WCuPEJSQQzLIxUr2nd-xfw.png" /></figure><p>After getting your API key, you should see the magic of…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*zJHZMVeOwcKrAybI9VLd8w.png" /></figure><p>WOOT WOOT!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F6oMKugqovQnjW%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F6oMKugqovQnjW%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F6oMKugqovQnjW%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/558e9ef27cb1d2d28bf12809f8c97155/href">https://medium.com/media/558e9ef27cb1d2d28bf12809f8c97155/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c04808e238f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with React]]></title>
            <link>https://medium.com/@prmeister89/getting-started-with-react-8d67e2adc4df?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d67e2adc4df</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Thu, 04 Oct 2018 19:33:54 GMT</pubDate>
            <atom:updated>2018-10-04T19:33:54.965Z</atom:updated>
            <content:encoded><![CDATA[<p>A Beginners Guide To Setting-Up a Basic React App</p><p>Get excited, because “there must be a better way” isn’t referring to some ethereal future notion of understanding…it’s referring to React.</p><p>If “excited” isn’t the right word, then I’ll let you stick to a <strong><em>react-ion</em></strong> your most comfortable with</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FTHua3iQuHfw4g%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fdont-understand-get-it-THua3iQuHfw4g&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FTHua3iQuHfw4g%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/415e1a9fd7107310ab3812d03b21415f/href">https://medium.com/media/415e1a9fd7107310ab3812d03b21415f/href</a></iframe><h4>Getting Started</h4><p>Let’s start with going into our console.</p><pre>create-react-app blog-example</pre><p>This will install all the appropriate packages and scripts that a basic React app will need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*-LqdFSMI5V0_2KdgN40rWA.png" /></figure><p>Once your console is done downloading everything it needs, go into your new project directory and start your app to make sure it is set-up properly.</p><pre>//blog-example<br>npm start</pre><h4>App.js</h4><p>Now that your app is connected, you can start molding it into what you want. As you can see, your React app comes with a few JavaScript files. For the sake of this example, we will focus on what’s going on in src &gt; App.js:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*57Rm0j3EhMCw13khN6AplQ.png" /></figure><p>As you can see, this React app has some default code rendered in its App.js file. There are a few things going on here that are key setting up and connecting any future files down the road. Let’s point them out and explain what their functions are.</p><h4>Import/Export</h4><p>At the top of the App.js file, we have a few lines of code that start with ‘import’. Remember when we did ‘create-react-app’? During that download, we were getting all the related packages and scripts associated with a React app. These imports are grabbing everything App.js will be using from outside sources (i.e. ‘react’, ‘./WelcomePage’).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*pdNijcEG7Q7B2j-EE_7HrA.png" /></figure><p>At the bottom of the App.js file, we have a default ‘export’ function that simply exports this App.js file as ‘App’. If another file wants access to App.js, it would import App from ‘./App.js’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*z93QC6V-L_kNp35mDVabVg.png" /></figure><h4>App.js — Class Component</h4><p>Below is a simple set-up to our App.js file. What we are doing is creating a class App, setting its ‘state’, an object that determines how that component renders &amp; behaves, to have the name: “Billy”, and telling it to render the &lt;WelcomePage/&gt; Component in a &lt;div&gt;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*J6nXZu2GEBy_v7SRWtWILA.png" /></figure><p>As you can see, we are passing the ‘state’ object to our &lt;WelcomePage /&gt; Component by assigning ‘this.state.name’ to <em>name. </em>Now our &lt;WelcomePage /&gt; Component knows what <em>name</em> is.</p><h4>WelcomePage.js — Functional Component</h4><p>Below is a simple set-up to our WelcomPage.js file. What we are doing is creating a function sayHi that takes in ‘props’ as its argument, returns an &lt;h1&gt; tag that says ‘Hi, {props.name}’, and exports itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*99q0wO9VBZIrCBU3fkWb_Q.png" /></figure><p>Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.</p><h4>The Result</h4><p>Now, when we go to our <a href="http://localhost:3001/api/v1/jokes">http://localhost:300</a>2, we can see the results of our work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*4Tx686WfOEy08AdtGmv7GQ.png" /></figure><h4><strong>Summary</strong></h4><ul><li>We created a simple React app</li><li>Set up our App.js file to <strong>import<em> </em></strong>the<strong><em> </em></strong>Components we need from their locations</li><li>Set-up our ‘state’ object to hold the name of the person we want to say “Hi” to</li><li>Passed our ‘state’ object to our WelcomePage Component</li><li>Retrieved our ‘state’ object information from App.js to WelcomPage.js</li><li>Called that ‘state’ information ‘props’, and told our WelcomePage Component to render the name via ‘props.name’</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F7TtvTUMm9mp20%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F7TtvTUMm9mp20%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F7TtvTUMm9mp20%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="508" frameborder="0" scrolling="no"><a href="https://medium.com/media/96c2204ede62ab3cbf7d757ff428a4ef/href">https://medium.com/media/96c2204ede62ab3cbf7d757ff428a4ef/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d67e2adc4df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[audio.play( )]]></title>
            <link>https://medium.com/@prmeister89/audio-play-5adafaf7e591?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/5adafaf7e591</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Thu, 20 Sep 2018 19:18:37 GMT</pubDate>
            <atom:updated>2018-09-20T19:18:37.441Z</atom:updated>
            <content:encoded><![CDATA[<p>Adding Audio to EventListeners</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F10FwycrnAkpshW%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F10FwycrnAkpshW%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F10FwycrnAkpshW%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/47d484e89ace00de4062240ce31285da/href">https://medium.com/media/47d484e89ace00de4062240ce31285da/href</a></iframe><p>For one of my Flatiron projects, I made an application in Javascript called SoundScribe. It was an app that allowed you to play a simple melody of notes and save that melody for future reference. It was meant for remembering a tune that you didn’t want to commit to memory.</p><p>For that project, I created both the front-end and back-end code. In this blog, I’m going to go through the steps I took to add audio functionality for when the notes on my NoteBar were clicked.</p><h4>Setting-Up the Back-End</h4><p>Just for reference, I created a migration file in my database for Notes, where each note has an <strong>id</strong>(implicitly applied) and <strong>name</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*CGZdGIdmAq-i-GkcOZWefQ.png" /></figure><h4>Next</h4><p>I set-up my Seed data and gave my Notes database table some initial values when my application was loaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*wSLkNcPooGUh7p2km0MKmQ.png" /></figure><h4>Confirm</h4><p>It’s always good to make sure our database is set-up the way we want. If I go to <a href="http://localhost:3000/notes">http://localhost:3000/notes</a>, I want to see my Notes database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/1*TkB9JZ1QW_YSuF7uotmDwg.png" /></figure><p>Awesome! Our back-end Notes database is ready and can now be referenced by our front-end!</p><h4>Setting-Up the Front-End</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*wnYl5ZshtnURy0sBRqOGGg.png" /></figure><p>Navigating to our Front-End folder, we can find some familiar files (index.html, script.js, style.css). However, we need somewhere to put our audio files. I put mine in their own folder, within my Front-End folder. That way I can access them relatively easily in the future.</p><h4>Connecting your audio files to your HTML</h4><p>The next thing we want to do is link up our mp3 files with our HTML. How do we do that? Funny enough, HTML comes with an &lt;audio&gt; tag for such an occasion!</p><p>Well, that makes things pretty convenient. All we have to do is give each Note &lt;audio&gt; tag an <strong>id</strong> and map the &lt;audio src&gt; to the corresponding mp3 file in our folder. Let’s see how that would look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRR7qP3LfjexFFPMBNo1gg.png" /></figure><h4>On Load of our DOM</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*yuidk6uJi97wWBXUrjpbRw.png" /></figure><p>When our page loads, we want to get our Notes from our database. We’ll do this with a fetch() function and call it…fetchNotes()!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*ttg02bhaAj3DVXg-fv8Luw.png" /></figure><p>Our fetchNotes() function will go to our Notes database, return that information in JSON format, and pass that JSON information as ‘notes’. We’ll then do a forEach on ‘notes’ and pass each note to the addToNoteBar() function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*npeBc5HL6U-rDST9P1Y5aA.png" /></figure><p>Now that ‘note’ is passed as the argument in the addToNoteBar() function, we can do a few things. The most important things we need to do is:</p><ul><li>Create an element (&lt;a&gt;)</li><li>Assign a className called ‘note-${note.id} item’</li><li>Give that element the innerText of that note’s name (i.e. C, D, E, etc.)</li><li>Set up that element’s <strong>dataset</strong> information so that it can be specifically accessed from an EventListener() function.</li><li>Add an EventListener that responds to a ‘click’, takes in the ‘event’ information, finds that event’s target, which will have access to the <strong>dataset</strong> information, and assign that to a variable called ‘noteNameClicked’.</li><li>Now that we have the name of the note we clicked (thanks to our dataset), we can find our specific HTML note element &#39;#{noteNameClicked}-Note&#39;. For example, if we ‘clicked’ a C-Note, the event would find the HTML element with the <strong>id</strong> of ‘C-Note’.</li></ul><h4>What’s that sound?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*3T2k_quSC91iwH5R1Z0qFw.png" /></figure><p>The cool thing about JavaScript, is that it comes with a .play() embedded function!</p><p>So all we have to do is audio.play(), and we’ll get the sound of the mp3 file we attached to to our EventListener!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*Tui75tfHt3pma7nsD2rwrQ.png" /></figure><p>Now, anytime we ‘click’ on a note, we’ll hear it play the mp3 file!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FCTX0ivSQbI78A%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FCTX0ivSQbI78A%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaXJhd2xveDNlMnVkanFrbGdqam9vdWM4MTFsZ2RiZXh1MDgwODZiMSZlcD12MV9naWZzX2dpZklkJmN0PWc%2FCTX0ivSQbI78A%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="322" frameborder="0" scrolling="no"><a href="https://medium.com/media/581f70fe9edde58bfad8b64c7b63fb77/href">https://medium.com/media/581f70fe9edde58bfad8b64c7b63fb77/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5adafaf7e591" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating your DOM with CSS Selectors]]></title>
            <link>https://medium.com/@prmeister89/navigating-your-dom-with-css-selectors-f431a99537ba?source=rss-911d74b7e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/f431a99537ba</guid>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Peter Meister]]></dc:creator>
            <pubDate>Thu, 23 Aug 2018 20:28:28 GMT</pubDate>
            <atom:updated>2018-08-23T20:28:28.845Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*nvs-Fo69HaeG2WZm.gif" /></figure><p>HTML and CSS usually go hand-in-hand. As we all know, the HTML is the ‘skeleton’ of the website and the CSS is how you want to style your website and make it look nice.We’re going to look at the basics behind styling HTML content with CSS Selectors.</p><p>CSS Selectors are used to find HTML elements and apply stylistic changes to those elements based on how specific you want that styling to be. There are 3 basic Selectors that can do this by calling on an element’s name, id, and class.</p><h4>Basic CSS Selectors:</h4><ol><li>Type (element)</li><li>ID</li><li>Class</li></ol><h4>Type/Element Selectors</h4><p>The element selector is used to find HTML elements that match with the element you wish to style. For example, if we wanted to find and select all &lt;p&gt; elements on a page and make the text red and have it centered, we would does this:</p><pre>HTML DOCUMENT</pre><pre>&lt;p&gt; <br>This is a paragraph.  There are many like it and I want to style them ALL in a specific manner.<br>&lt;/p&gt;</pre><p>To apply our CSS changes to every &lt;p&gt;, we would type:</p><pre>HTML DOCUMENT</pre><pre>&lt;style&gt;<br>p {<br>    color: red;<br>    text-align: center;<br>}<br>&lt;/style&gt;</pre><pre>&lt;p&gt; <br>This is a paragraph.  There are many like it and I want to style them ALL in a specific manner.<br>&lt;/p&gt;</pre><p>Now, all of our &lt;p&gt; tags will be centered and have red text. Cool!</p><h4>ID Selectors</h4><p>The ID Selector finds and selects all elements with an ID attribute value matching the name the selector is calling upon. This is typically used to find specific elements, as each ID of an element should be unique. For example, if we wanted to find and select an element with the id= “p1”, we would first assign ID’s to what specific element we’d like to style:</p><pre>HTML DOCUMENT</pre><pre>&lt;p id=&quot;p1&quot;&gt; <br>This is a paragraph.  There are many like it, but I only want to style THIS SPECIFIC paragraph.<br>&lt;/p&gt;</pre><pre>&lt;p id=&quot;p2&quot;&gt;<br>This is another paragraph. I don&#39;t want to style this one, but I&#39;ll give it an ID just in case I want to style it in the future.<br>&lt;/p&gt;</pre><p>To apply our CSS changes to &lt;p&gt; with the ID of “p1”, we would use a hashtag # to say “the thing I’m trying to find/access is going to be an ID Name,” just so nothing is confused during your request.</p><pre>HTML DOCUMENT</pre><pre>&lt;style&gt;<br>#p1 {<br>    color: red;<br>    text-align: center;<br>}<br>&lt;/style&gt;</pre><pre>&lt;p id=&quot;p1&quot;&gt; <br>This is a paragraph.  There are many like it, but I only want to style THIS SPECIFIC paragraph.<br>&lt;/p&gt;</pre><pre>&lt;p id=&quot;p2&quot;&gt;<br>This is another paragraph. I don&#39;t want to style this one, but I&#39;ll give it an ID just in case I want to style it in the future.<br>&lt;/p&gt;</pre><p>Now, only the &lt;p&gt; with the ID of “p1” will have red text and be centered.</p><h4>Class Selectors</h4><p>The class selector finds and selects all elements with a class attribute value that matches the name the selector is calling upon. Usually, you would want to break up your HTML Document into different sections (or divisions &lt;div&gt;) so that you can organize the page. It’s also useful for calling upon specific elements <em>within </em>that section (&lt;div&gt;). For example, let’s say we have a section in our HTML for an Introduction.</p><pre>HTML DOCUMENT</pre><pre>&lt;div class=&quot;intro&quot;&gt;</pre><pre>&lt;p id=&quot;p1&quot;&gt; <br>Welcome to my blog! Here&#39;s a quick introduction paragraph about myself, what I&#39;m writing about, and a link to my blog if you want to check out my work.<br>&lt;/p&gt;</pre><pre>&lt;a href=&quot;<a href="http://www.wikipedia.org/">http://www.myblog.org</a>&quot;&gt;My Blog&lt;/a&gt;<br><br>&lt;/div&gt;</pre><p>As you can see, we’ve sectioned off the Introduction into its own division (&lt;div&gt;) and gave that &lt;div&gt; a class attribute of “intro”. Similar to how we used the hastag # for calling upon an element ID, we use a period before the class name to say, “the thing I’m trying to find/access is going to be a Class Name”, just so you don’t confuse this with an ID Name. If we wanted to make all of the text <strong>bold</strong> in that class, we would use a Class Selector to affect the &lt;div&gt; called “intro”:</p><pre>HTML DOCUMENT</pre><pre>&lt;style&gt;<br>.intro {<br>    font-weight: bold;<br>}<br>&lt;/style&gt;</pre><pre>&lt;div class=&quot;intro&quot;&gt;</pre><pre>&lt;p id=&quot;p1&quot;&gt; <br>Welcome to my blog! Here&#39;s a quick introduction paragraph about myself, what I&#39;m writing about, and a link to my blog if you want to check out my work.<br>&lt;/p&gt;</pre><pre>&lt;a href=&quot;<a href="http://www.wikipedia.org/">http://www.myblog.org</a>&quot;&gt;My Blog&lt;/a&gt;<br><br>&lt;/div&gt;</pre><p>Now, everything in the “intro” class will have <strong>bold</strong> text. We could even go the extra step by saying “we only want to make “p1” bold by putting that <em>before</em><strong><em> </em></strong>the .intro, like this:</p><pre>&lt;style&gt;<br>p1.intro {<br>    font-weight: bold;<br>}<br>&lt;/style&gt;</pre><p>Now, “p1” will be <strong>bold</strong> and the link to ‘My Blog’ will stay unchanged. Cool!</p><p>Those are the 3 basic types of CSS Selectors that actually go a long way to styling your HTML Document the way you want. By assigning an ID to a specific element(s), you can make specific changes exactly where you need them. By assigning a class to a section (&lt;div&gt;), you can make changes to a section of your document. By combining the two, you can add specificity by making a specific paragraph of a specific section the style you want.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f431a99537ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>