<?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 Tyler J Funk on Medium]]></title>
        <description><![CDATA[Stories by Tyler J Funk on Medium]]></description>
        <link>https://medium.com/@tyler-j-funk?source=rss-254732f0f328------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uECs5WwwZOXS1LXcS8rTcw.jpeg</url>
            <title>Stories by Tyler J Funk on Medium</title>
            <link>https://medium.com/@tyler-j-funk?source=rss-254732f0f328------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:52:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tyler-j-funk/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[The Simplest Way to Use HTML and With Styling In G-Mail]]></title>
            <link>https://tyler-j-funk.medium.com/the-simplest-way-to-use-html-and-with-styling-in-g-mail-f11a13c990b5?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/f11a13c990b5</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[email-marketing]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Thu, 11 Feb 2021 13:31:41 GMT</pubDate>
            <atom:updated>2021-02-11T13:31:41.519Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEjhV8miCOOcKTpDSUW8YQ.png" /></figure><p>Not too long ago I created a web app called <a href="https://nalarama.web.app/">Nalarama!</a>, which was designed to be a controlled form where my friends and family could submit guesses on the different breeds of our mixed breed puppy as a contest with points and the whole nine yards. Then once the results from her DNA test came back I wanted to be able to send the results in a professional manner, but was unsure of how to send emails with a templated look instead of just text and attachments, a signature, etc.</p><p>So I have spent the last few days trying to figure it out, and I am creating this short post to share what I’ve learned so far! Let me tell you what, I did a lot of trial and error with this, but finally found a way to do what I wanted to do, for the most part.</p><h4>Limitations</h4><p>First and foremost, there are a lot of limitations. For example, if you are used to writing CSS on external stylesheets, that won’t work here. In fact, you can do embedded &lt;style&gt; tags to do CSS in there, which works, but can’t be trusted. G-Mail and other big name web mail clients strip out embedded CSS, and only allow certain CSS characteristics in general.</p><p>So whats the best option for styling? Inline is the most reliable when you want something to work. Period.</p><p>Oh, and if you love using Google Fonts and using &lt;link&gt; tags and imports to get your favorite cool fonts into your HTML, you may be disappointed to know this is something that is incompatible with your HTML template. However, I believe there are other non-conventional ways to use them I am just unaware of how!</p><p>According to a lot of the fine folks on the internet who have fought this battle before, the e-mail playing field is extremely far behind when it comes to styling. There are only so many things we can do in G-Mail for example, <a href="https://developers.google.com/gmail/design/reference/supported_css">here’s</a> the documentation which shows a list of the different acceptable CSS properties.</p><p>If you are someone who is super familiar with making tables in HTML, this is good news for you! Because it is definitely going to be the only way to create a grid.</p><p>So that takes away CSS grid, but what about Flexbox? I have found that display: flex; has been tricky, because it works, since display is able to be changed, but then things like flex-direction: column; aren’t recognized. So I haven’t been using it. Instead, to do things like centering my tables and other elements, I use margin-left: auto; margin-right: auto;.</p><p>To be completely honest, if you have never done this before, there will be a bunch of trial and error, and there’s no way around that. So let’s jump into how to integrate the HTML into your e-mail, so you can start testing it.</p><h4>Integrate HTML Into E-Mail</h4><p>There is a site called Litmus which tests your e-mail across a bunch of different e-mail clients to see how universal it is. I however. mostly just want to demonstrate this concept via G-Mail.</p><p>In order to see what it looks like as a received e-mail, I have been sending the entire thing to myself. Literally, I make myself the recipient and then open it like I just got fresh mail!</p><p>Now, I want to put this out there. Other sources online claim you can serve up your HTML in the browser, and then use command + A to copy all, then copy and paste it into the e-mail body. Does this work? Yes…. Kinda.</p><p>It works, but not all of the attributes work properly, try it for yourself, don’t take my word for it!</p><p>Here is how I have learned to test my e-mails:</p><p>Hit “Compose” to bring up a new e-mail window</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*DbNlW2cPRT7Cjzv7SxlRMQ.png" /></figure><p>Put yourself as a recipient, add a subject, and then right click inside the empty body</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*lJI6e2c1I9H7Lk1XPnvLlg.png" /></figure><p>Click “Inspect” and the dev tools should open with a particular &lt;div&gt; already highlighted (I use Chrome because it supposedly has the best developer tools!). Right click on the highlighted &lt;div&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*bpKKIAJgUGmAb3GPQ5c5YA.png" /></figure><p>If there is anything inside of this &lt;div&gt;, go ahead and delete it, because this is where our HTML document will be pasted. It will look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*0MbrpM6NLguzbhQyFH4H7g.png" /></figure><p>As mentioned above, paste your HTML code inside this &lt;div&gt; and as soon as you click out of that box, you will see the results pop up in your new e-mail window. Here’s what my Nalarama e-mail looks like when I do it for myself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*JFFSQFl4wPTZmlQmzrvoKA.png" /></figure><p>And the result on my phone when I send it to myself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*GTuwMVfoTimaYIr917Z3Fg.png" /></figure><h4>Conclusion</h4><p>If you are curious about the HTML behind this e-mail, I have linked to the GitHub repo <a href="https://github.com/tfunk2/nalarama-email/blob/main/nalarama-results-template.html">here</a>.</p><p>I hope this post was beneficial to someone out there looking for information about HTML in e-mails like I was. Thanks for reading if you made it this far, and as always, happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f11a13c990b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Added An ASCII Banner to My Terminal]]></title>
            <link>https://tyler-j-funk.medium.com/how-i-added-an-ascii-banner-to-my-terminal-34b0a34b898e?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/34b0a34b898e</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[ascii-art]]></category>
            <category><![CDATA[customization]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[command-line-interface]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Fri, 05 Feb 2021 14:19:02 GMT</pubDate>
            <atom:updated>2021-02-05T14:19:02.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*sV3E53A6POMOiPMzmZscPQ.png" /></figure><p>This past week or so I switched up my mac’s terminal from bash to zsh, and I have been enjoying personalizing my terminal just how I like it. I installed a framework called <a href="https://ohmyz.sh/">oh-my-zsh</a> and I really like how easy it is to customize, I highly recommend it.</p><p>However, one of my buddies showed me his terminal when I was first starting at Flatiron School, and I was fascinated by some artwork he had at the top of his new terminal window. It was ASCII art, and I had no clue how he did it!</p><p>At the time I was practically brand new to software engineering, and was way too focused on other things to actually learn how to do it. Since I have been customizing my terminal, it made me remember that I wanted to make my command line interface as cool as his.</p><p>I am pleased to say that I have figured it out, and I wanted to write this short post for anyone out there who is curious on how to do it for themselves.</p><p>First, I’ll show my personal terminal off!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*bYsq301X3JIn1Ew_79NG8g.png" /></figure><p>Maybe you don’t think it’s cool but I did! Now, let’s get into the steps I took to get my terminal to look like this on startup:</p><h4>What do you want your ASCII banner to be?</h4><p>Mine is made with my initials but maybe you want yours to be an image, or a different font. Either way, it is up to you, but if you want your banner to include words/letters, I recommend this <a href="https://www.patorjk.com/software/taag/#p=display&amp;f=Graffiti&amp;t=Type%20Something%20">website</a> which I used to find the font I used, but ultimately customized.</p><p>If you want your banner to be an image, there are ASCII art generators out there, but I don’t have any personal recommendations in particular for that. I do however believe there are some good ones out there!</p><p>I will go ahead and demonstrate changing my own banner, to show from start to finish how to accomplish this!</p><p>Now that I have figured out what I want my new banner to be, I copied and pasted it into a Google Doc, that way I can copy and paste each line individually. You’ll see why shortly.</p><p>Here’s the new fonts I’ll use:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n_cfARhyey4yZgCzL2TffQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hS3zWd2XC8i4sEOsmxwhlg.png" /></figure><p>And then here is what they currently look like together in the Google Doc I have created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5jxEC7_xqezJRO9kzX6w3w.png" /></figure><p>Don’t mind the line spacing here, what you have set up in your terminal is the line spacing that will be used. I am only using this so I can copy each line one at a time.</p><h4>Editing The Shell’s Resource File</h4><p>In my case, as mentioned above, I use zsh now, but if you have bash, I know you can do this also. Instead of opening the~/.zshrc file, you would open your ~/.bashrc. These files hold information about what should happen when starting up a new terminal, including our banner.</p><p>I use VSCode so for me I use the command code ~/.zshrc to open up this file, and this is what it might look like inside before adding a banner:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8ffc19010776c6e269f2f087e52f2d8/href">https://medium.com/media/a8ffc19010776c6e269f2f087e52f2d8/href</a></iframe><p>Whoa! That’s a lot! No worries, we are only going to be adding to this, not changing everything.</p><p>We will be using a shell command called echo. I chose to insert my commands below the ZSH_THEME_RANDOM_CANDIDATES on line 18, but feel free to place it somewhere else in the file, I’m not sure that it matters, but if it does, this is what worked for me.</p><p>I will now copy and paste each line of my ASCII art into double quotes that follow an echo command. Here is what the first one looks like:</p><pre>echo &quot; _____ _____ _____ _____ _____ &quot;</pre><p>Until you have it all filled out like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c08194b1d862bc0767cd091a61b8d3e1/href">https://medium.com/media/c08194b1d862bc0767cd091a61b8d3e1/href</a></iframe><p>You go back to the terminal, and…nothing. What did we do wrong? We need to make our system aware we want to use the updated source file with a command:</p><pre>source ~/.zshrc</pre><p>This will update the file officially, and we should now be seeing the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*FiRd9V3PCzMDAGZdUx5APQ.png" /></figure><p>Keep in mind if you want to add space above or below, you just need to add another echo followed by a space inside double quotes, like so: echo “ ”</p><p>I added space underneath the word “TERMINAL”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*ZBGzuooTS9bNQwmjCbN9Tw.png" /></figure><p>That’s better! Awesome, mission accomplished! It is that simple.</p><h4>Something to Keep In Mind</h4><p>Some characters will have to be “escaped” with a backslash — a tricky one is the backslash character. If you want to put more than one backslash character in a row, you will have to add 3 backslashes per backslash desired.</p><p>Take for example, my banner from earlier, it has a ton of backslashes in it, so here is what it looks like in echo commands:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2f0089df49b37cd308d02fe4873899a/href">https://medium.com/media/b2f0089df49b37cd308d02fe4873899a/href</a></iframe><p>So many backslashes, line 5 doesn’t fit in this GitHub Gist! Yikes! Yet, because so many of them are there just to “escape” the backslashes we want to show, it actually comes out like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*bYsq301X3JIn1Ew_79NG8g.png" /></figure><p>I had to add extra backslashes to get it to look like this, so if your ASCII art doesn’t look right when you use the source command, you may have some characters that aren’t being escaped properly.</p><h4>Conclusion</h4><p>As much as I know this isn’t a super beneficial thing to know, I was having a hard time figuring it out in the beginning, but now I feel confident I can make any kind of ASCII banner possible!</p><p>Hopefully you found this post at least somewhat interesting, despite it’s educational value!</p><p>Thanks for reading, and happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34b0a34b898e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Few Command Line Tricks I Didn’t Know I Needed]]></title>
            <link>https://tyler-j-funk.medium.com/a-few-command-line-tricks-i-didnt-know-i-needed-82af0d922391?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/82af0d922391</guid>
            <category><![CDATA[tricks]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Mon, 01 Feb 2021 06:57:57 GMT</pubDate>
            <atom:updated>2021-02-01T15:49:44.642Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Command Line Trick I Didn’t Know I Needed — Reverse Searching</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ug6ZgMaxfA8pUI1V4MPiQg.png" /></figure><p>This week I want to write about a trick I have been using in my terminal lately, reverse searching. I just learned about this, and I have been kicking myself for not learning about it sooner. Hopefully it will come in handy for you as much as it has for me if you haven’t seen this already!</p><p>First off, I was using bash as my shell for a long time, and just switched to zsh (and installed <a href="https://ohmyz.sh/">Oh My Zsh</a>, it’s awesome!), let me tell you, I was living under a rock. I love it!</p><p>This reverse searching tip is the most useful command line tip I’ve been given lately, and will work for both bash or zsh as far as I understand!</p><p>Let’s say you have some crazy long Rails command that you used to create your models, migrations, controllers, etc. And you used rails g resource plus a bunch of other stuff:</p><p>ex. rails g resource color_form name email:text color_one:text color_two:text color_three:text color_four:text color_five:text percent_one:integer percent_two:integer percent_three:integer percent_four:integer percent_five:integer final_img</p><p>That’s a long command! But wait, maybe we screwed something up and now we want to do this over — but I used that command days ago! Oh no!</p><p>Reverse search to the rescue! On Mac (and I believe also on PC), ctrl + R will put us into this mode:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*TRwKS26JHzOnx3klLT868A.png" /></figure><p>As soon as I begin typing, it starts showing me the most recent command which matches my search query. Let’s say I recently navigated all the way into a file which was 6 directories deep from my home directory. Instead of cding into each directory, or typing the long relative path out again, I can use reverse search!</p><p>If I was looking for this command:</p><pre>cd Development/Code/side-projects/sub-directory/sub-sub-directory/sub-sub-sub-directory<strong>/</strong></pre><p>I might start by searching for a word in the last part of the path, in this case sub-sub-sub-directory. Depending on how many commands I have used since this one, I should probably be able to find it by the time I type the word sub:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*DQAL8yocjyYMZu24g8Inrw.png" /></figure><p>There it is! That simple. The beauty is, it doesn’t matter how far back I did this command, if I search it correctly, I’ll always find it.</p><p>Now if I want to run this command immediately, I can just hit enter. If I wanted to exit the search, I can use either ctrl + C or ctrl + G, whatever works best for you.</p><p>However, if I want to finagle it a bit, I can hit escape and I can now do what I want with that command.</p><p>More to come on this article, stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82af0d922391" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Hooks Controlled Input Example]]></title>
            <link>https://tyler-j-funk.medium.com/react-hooks-controlled-input-example-700150c7edf2?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/700150c7edf2</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[forms]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Mon, 25 Jan 2021 05:10:15 GMT</pubDate>
            <atom:updated>2021-01-25T11:11:01.035Z</atom:updated>
            <content:encoded><![CDATA[<h3>Intro to Controlled Inputs With React Hooks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DL31nrogrVDUdwz5_9Izg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@thevictorbarrios?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Victor Barrios</a> on <a href="https://unsplash.com/s/photos/input?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I recently built an app for my family and friends called <a href="https://nalarama.web.app/">Nalarama</a>, and I was reminded of how useful controlled forms are. In my app, I ask users to make multiple guesses on my puppy’s mix of breeds, which requires multiple inputs. With controlled form inputs, the value typed into the input is easily accessible, and I was able to effortlessly use those values in HTTP POST requests, and also in JSX elements wherever I deemed necessary.</p><p>This post will be a glimpse into controlled inputs, and will demonstrate what that looks like when using React Hooks.</p><p>First and foremost, when I was learning about controlled inputs, it was hammered into my brain that a controlled form has — “inputs which get their value from state” — and then we had to repeat that sentence like 10 times in a row.</p><p>The reason I think my teachers saw this necessary was because this is the principal concept behind controlled forms. As the input is being typed into, we will have a function which updates a state variable. The input will get it’s value from the updated state variable which is constantly changing with every keystroke. It is a very responsive, and “controllable” input, which comes in handy from time to time.</p><p>Let’s look at an example which attempts to demonstrate this as simply as possible:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebd014be48aeaf295f12c2ccac8db8c0/href">https://medium.com/media/ebd014be48aeaf295f12c2ccac8db8c0/href</a></iframe><p>This is a component I’ve appropriately named ControlledInput which holds my “form”. Let’s briefly discuss what goes on inside of this component.</p><p>The important thing happening here is lines 8 through 13, the input. This is a text input, and as you can see, it gets it’s value from our state variable, someValue. In the onChange prop, we use setSomeValue as a callback function to set someValue to whatever has been typed every time it changes. We access that value through the event object: event.target.value.</p><p>Let’s see what this looks like in real time:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fweeklysandyinsect&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fweeklysandyinsect&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FWeeklySandyInsect-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="952" height="664" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fac65837ba43d93478829c2ad187a0f/href">https://medium.com/media/1fac65837ba43d93478829c2ad187a0f/href</a></iframe><p>Here I have the React dev tools pulled up so you can see that every time a letter is typed, the state changes. This allows me to use that state to create an &lt;h2&gt; element with someValue inside it (inside the green box).</p><p>To clean up the onChange prop, we can extract the function inside out to a handler, like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55b2ad13057984a216edea3da9144280/href">https://medium.com/media/55b2ad13057984a216edea3da9144280/href</a></iframe><p>This gives us the same result, but having a handler looks better and cleans up the input props.</p><h4>Conclusion</h4><p>This has been a very quick intro to controlled forms using React Hooks, I hope it was beneficial to you to read it! Controlled inputs are a great way to have a variable which can access the value being typed into it quickly, and effortlessly.</p><p>As always, happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=700150c7edf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner Steps to Build A Rails API Quickly and Efficiently on Mac]]></title>
            <link>https://tyler-j-funk.medium.com/beginner-steps-to-build-a-rails-api-quickly-and-efficiently-on-mac-6b3cd44c3d79?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b3cd44c3d79</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[rails-api]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 05:46:42 GMT</pubDate>
            <atom:updated>2021-01-18T10:16:51.459Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VF4ToxOYu4wqx01b8M3FQ.png" /></figure><p>This week I found myself diving back into Ruby on Rails. Mostly because I recently came up with an idea for an app I want to build which requires a back end. My dog recently had her DNA sent in to a doggy DNA testing site, and I want to build a simple form page my family and friends can visit, guess up to 5 different breeds, and submit their answers to the database so I can ultimately tally up each persons score and send out a results email.</p><p>I quickly started realizing I hadn’t worked with Ruby in awhile, and it was good to shake the cob webs off! I figured now was as good of time as any to write this simple guide of how to get a Ruby on Rails API up and running. For me, the purpose of doing this efficiently is so I can quickly move on to the front end fun.</p><p>For this demonstration I will build out the back end for my doggy breed guessing app, which I will appropriately name ‘Name That Pooch!’. In order to get that going, we need to know what types of values we expect for each column in our table. By that I mean we may have a column or key called email and we expect it to have a value of a string.</p><p><strong>Now, from the beginning!</strong></p><h3>App Creation and Setup</h3><p>Open a terminal and navigate to the folder you wish to create this project in. Since we want to build an API, we can use a special flag which helps Rails know what we want and what we don’t need right away,--api. This flag helps us shave a little extra time in creation as well! Here’s the command:</p><pre>rails new name_that_pooch --api --database=postgresql</pre><p>Why the --database=postgresql? This tells Rails to initiate our app with a Postgres database instead of the default SQLite3. I found Postgres is required to deploy to a hosting service I frequent called Heroku.</p><p>After running this command we should see the app building and end with this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*XHalIHDZ0Xkop212LfUXdg.png" /></figure><p>We can now open up our new back end with code name_that_pooch/, let’s take a look at the file tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*EvdGOybuvRtx6lcctvHL-g.png" /></figure><p>Now is usually when I create a new repository on Github and connect it to my new project, that way I can make an initial commit which marks the very beginning. Once I’ve pushed up my first commit, I am good to move on!</p><p>The next step I like to do right away is activate the CORS (cross-origin resource sharing) I don’t know a ton about this, but I do know this is how I am able to access my API from anywhere. You can otherwise state to only share resources with specific sites, however, in this case, I don’t really care!</p><p>Start by going to the Gemfile, find gem ‘rack-cors’, then uncomment it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*DP0vGPGzY5hgEh1LTabuuQ.png" /></figure><p>Next, navigate to config/initializers/cors.rb and uncomment line 8 through 16 like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*IV8NgI9aZNn_UBo9JzRgDQ.png" /></figure><p>Now that we have some new gems, we should probably install them with a bundler, using bundle install. We should see this result when complete:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*uEmS0-0Z2v79LD_Cg3jblg.png" /></figure><h3>Models, Controllers, Migration</h3><p>Now it’s time to “generate” our model, migration file, controller, and set up routes. Let’s call our form a “guess card”, so that will be the model name in this next command, then I’ll break down the rest of what happened:</p><pre>rails g resource guess_card name:text email:text breed_one:text breed_two:text breed_three:text breed_four:text breed_five:text</pre><p>Breakdown of this command:</p><p>rails g resource — this part tells rails to generate what follows, in this case I chose resource because it sets up all of the necessary files at once.<br>guess_card — name of the model, convention needs this to be singular.<br>name:text — Every pair like this that follows establishes a column in the table, on the right side of the colon, we designate what type of value we are looking for, might be an integer, or string.</p><p>I read somewhere that Postgres is finicky with strings, so I have been using text in place of string. Another note about this, if I were to omit the :text on each pair, the default type would in fact be string. Wanted to throw that out there!</p><p>We should see this result after running the command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*ULEcfHD5mI1n-4a6AzvWOw.png" /></figure><p>We now have a new controller, migration file, and model. Since we have a migration file, we should check it out before we migrate this table into our database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*ftNTKk7FeEo0-mQBADEMAw.png" /></figure><p>Looks good to me, let’s run that migrate command, rails db:migrate, should work great, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*IpWMG1iZbFy0CQJOewVC4A.png" /></figure><p>What happened? Let’s take a look at the top of these error messages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*uHXpXklWYe5--NQWcHViUg.png" /></figure><p>Key words here: database “name_that_pooch_development” does not exist</p><p>How can that be? We have a Postgres database right? Not yet! We are set up for it, but we never actually created it. Start with command rails db:create to get this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*u_84ZnyYPCYjm-G3E_ey1g.png" /></figure><p>That’s better! Let’s try to run rails db:migrate again now that we have an existing database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*0Y8jkhp4wJkpW9qDwRXpXQ.png" /></figure><p>With this command complete, we can now head to db/migrate/schema.rb and see the changes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*YCYKD-6O_q2nsuGxY8ESfg.png" /></figure><p>Add Actions</p><p>We have a way for the the guess cards to be recorded, now how do we get actual instances in our database? We need to put the actions we want in our controller so Rails knows what we can and can’t do when it comes to HTTP requests.</p><p>There are 7 RESTful routes — index, new, create, show, edit, update, and destroy. <a href="https://medium.com/adventures-in-code/snow-white-the-7-restful-routes-afcf87bbe5bd">This article</a> by Melissa Gonzalez is great for going into deeper detail.</p><p>For the purpose of this app, all I really want is to be able to create new guess_cards in the database, and then be able to retrieve all the guess_cards in an array from the API I serve up. To do that, we only need 2 actions — index (shows all guess_cards), and create (allows a new POST to be made to the database).</p><p>Let’s take a look at that after navigating to controllers/guess_cards.rb:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*GfQkX9scGEFH2mIW6Ni1bg.png" /></figure><p>index is pretty self explanatory, we are rendering every GuessCard in JSON. But what is happening in create? We are saying create a new instance of GuessCard, then if it successfully saves, render the GuessCard we just created. Otherwise, render the error messages associated with what happened.</p><p>I like to test my actions in Postman, it’s easy to check index or show, but create can’t be checked without having a form built into your front end with a POST request. So that’s where Postman comes in, they provide a way for me to do query params without pre-coding any forms. I’ll spin up the dev server with the command rails s in the terminal, and we can begin testing it in Postman.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TuA8HQYIWoaCtSlgBNj-Qg.png" /></figure><p>While Postman is set to GET, if we go to the correct localhost port (3000 here) and add the /guess_cards ending, we get an empty array back. That makes sense, because we haven’t made any guess_cards yet! We could add seeds in the editor, but I like to add them in Postman to test the create action at the same time.</p><p>To do that, I’ll change GET to POST, and then a query param for every column in the table, along with a made up value, like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xHE_z3OlGYupYP8ph91lQ.png" /></figure><p>After hitting send, we get this result in the body:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKjvWBNJkLV6i3Xm6CKQxw.png" /></figure><p>We are seeing the first guess_card! I will go ahead and add another one, then go to localhost:3000 in the browser to see what we’ve got! Check it out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lDnz4i_X6tenbb6_7IJYCQ.png" /></figure><h3>Conclusion</h3><p>Finally, we have a working API which can accept new guess_cards, and also makes a list of all guess_cards available in an array. Our goal has been met, and I am ready to start using this API right away! Not so bad right? Rails makes it easy!</p><p>Thanks for reading and following along, and as always, happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b3cd44c3d79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving VSCode Workflow on Mac For Beginners: Part 2]]></title>
            <link>https://tyler-j-funk.medium.com/improving-vscode-workflow-on-mac-for-beginners-part-2-40567d75d2ca?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/40567d75d2ca</guid>
            <category><![CDATA[workflow]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 12:55:05 GMT</pubDate>
            <atom:updated>2021-01-10T12:55:05.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwbIDP4AwgbFCZlHV0avLA.png" /></figure><p>I wrote an article a couple weeks ago about some of the commands and shortcuts that can help improve workflow for those of us using VSCode as our editor. Since then, I have found some more tricks, and figured a ‘Part 2’ was in order! Be sure to check my first post as well as this one, you can find it <a href="https://tyler-j-funk.medium.com/improving-vscode-workflow-on-mac-for-beginners-2af5ef7e98f4">here</a>.</p><p>I said it in the other post, and it is relevant in this one, some of the tips I’ll be discussing may be available in other editors, but I personally am not 100% sure so I don’t want to put any misinformation out there. If I discover they work with other editors, I will come back edit/add info to each tip about which ones they work with.</p><p>Nonetheless, this post will add some new Mac shortcuts and will also focus on a new topic which has a ton of value when trying to save keystrokes and time, a plugin called Emmet.</p><p>Let’s get right to it!</p><h3>Keyboard Shortcuts</h3><h4>Toggle Sidebar</h4><p>Toggling the sidebar is something I always clicked to minimize, with the shortcut ⌘ + B, I won’t have to click anymore.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fdefinitedimwittedhydra&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fdefinitedimwittedhydra&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FDefiniteDimwittedHydra-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1020" height="718" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e6e60a00cb1cd88700169eeb50c9e2f/href">https://medium.com/media/3e6e60a00cb1cd88700169eeb50c9e2f/href</a></iframe><p>I just discovered this one and I have already used it a ton, the less I can use my mouse/touchpad to click things the better. Little time savers like this don’t seem like much individually, but if we had a way to add it up over , I think we would be surprised how much time something like toggling a sidebar can save us in the long run.</p><h4>Toggle Bottom Panel / Terminal</h4><p>So I actually mentioned how to toggle the terminal in the last post, except I used the command control + `. This time, I wanted to show a different command which does the same thing, and could be potentially easier for you depending on which you like more; ⌘ + J.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fflickeringassuredaxisdeer&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fflickeringassuredaxisdeer&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FFlickeringAssuredAxisdeer-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1020" height="718" frameborder="0" scrolling="no"><a href="https://medium.com/media/edad1386dcab54b4b9364f5cee246420/href">https://medium.com/media/edad1386dcab54b4b9364f5cee246420/href</a></iframe><p>Nothing actually new this time, just a different option I found that I might like more. Decide for yourself which works best for you!</p><h4>Format Document</h4><p>I have an extension called Prettier with my VSCode editor, but even if you don’t, this command should still work to format the document you currently have active: shift + ⌥ + F</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fdentalillegalhairstreakbutterfly&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fdentalillegalhairstreakbutterfly&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FDentalIllegalHairstreakbutterfly-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1020" height="718" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6df1fcbf01882a4aa65a245899c0436/href">https://medium.com/media/b6df1fcbf01882a4aa65a245899c0436/href</a></iframe><p>This shortcut comes in handy for me especially when I’m unsure of the formatting for JS frameworks I’m learning. I’m human, like you (I hope), and make formatting mistakes in plain HTML too, so being able to use this shortcut and then know everything will be acceptable to look at is awesome for me.</p><h3>Emmet Plugin Magic</h3><p>Emmet comes built into VSCode, and let me tell you, I was sleeping on using this. There is a whole lot you can do with this, and this <a href="https://docs.emmet.io/cheat-sheet/">cheat sheet</a> for everything you can do with it is probably the best source to learn about it, but I want to share a couple of ways I have been using it that have been saving me so much time and so many keystrokes.</p><h4>HTML</h4><p>Let’s say you are in an HTML document, and you want to create a &lt;div&gt; with a class of ‘container’, and then inside that you want to create an &lt;h1&gt; with an id of ‘title’ followed by a &lt;ul&gt; with 5 &lt;li&gt;’s inside of it. Sounds like a decent amount of typing, right?</p><p>Would you be surprised to know you could type div.container&gt;h1#title+ul&gt;li*5 and hit tab or enter to achieve that result? I definitely was. Still don’t believe me? Check it out for yourself:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fsinfulflakydutchshepherddog&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fsinfulflakydutchshepherddog&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FSinfulFlakyDutchshepherddog-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1020" height="718" frameborder="0" scrolling="no"><a href="https://medium.com/media/fba4ff8520c3d6c69701748b1402a8b2/href">https://medium.com/media/fba4ff8520c3d6c69701748b1402a8b2/href</a></iframe><p>In this case that’s 30 characters typed vs. 138. Massive improvement! The cheat sheet I mentioned above shows all the different syntax and shortcuts possible, and the time saving possibilities are endless. This is only one way to use it with HTML!</p><h4>CSS</h4><p>For this example, let’s say we want to style our new &lt;div&gt; which has a class of container. We want it to have display: flex;, align-items: center;,padding: 20px;, and background-color: red;.</p><p>Once again, would it surprise you to know that I could achieve each of these properties with the following abbreviations? d:f, ai:c, p:20, and bc:red</p><p>Pretty wild right? Watch it in action!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Funrealisticcloudygypsymoth&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Funrealisticcloudygypsymoth&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FUnrealisticCloudyGypsymoth-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1020" height="718" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cab1f1232aa01869f458fe5dfcd979d/href">https://medium.com/media/6cab1f1232aa01869f458fe5dfcd979d/href</a></iframe><p>Similar to using Emmet with HTML, with CSS, you can save a ton of keystrokes by learning the abbreviations. Honestly, a lot of the abbreviations are easily guessed, and d:f for display: flex; is a perfect example of that!</p><h3>Conclusion</h3><p>I want to continue learning ways to improve my workflow in the text editor I’m using, which for now is VSCode. Especially because of how many keystrokes these shortcuts and tips have already saved me in such a short period of time.</p><p>Someone might even take it as far as to say that these tips and tricks are saving your hands from carpal tunnel!</p><p>I hope this article has provided you with some value. As always, I hope you enjoyed reading and wish you happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40567d75d2ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sorting an Array By 1 Variable Then By Another]]></title>
            <link>https://tyler-j-funk.medium.com/sorting-an-array-by-1-variable-then-by-another-711ebddcda85?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/711ebddcda85</guid>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 06:22:02 GMT</pubDate>
            <atom:updated>2021-01-04T14:13:41.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*4D9EN3SYCAiOQ8Bg62O5sw.jpeg" /></figure><p>I was inspired to write about sorting an array by two different variables because of an issue I ran into while creating a project I was working on for Flatiron School before I graduated. I wanted to create a “Top Ten Leaderboard” which sorted the leaders by one variable first, then sorted them again by a different variable.</p><p>In this case I wanted to sort by the amount of time the user took to complete the game, and then sort by the amount of “misses” they made throughout their game session.</p><p>Let’s discuss what that might look like. For example, each game session might be an object that looked like this:</p><pre>{<br>  user: &quot;tyler&quot;,<br>  totalTime: 63,<br>  totalMisses: 1<br>}</pre><p>In order for there to be a “Top Ten” there would have to be 10 games played for us to rank. Here is the array we will be trying to sort:</p><pre>let allGames = [<br>  {<br>    user: &quot;tyler&quot;,<br>    totalTime: 63,<br>    totalMisses: 1<br>  },  <br>  {<br>    user: &quot;kaitlyn&quot;,<br>    totalTime: 34,<br>    totalMisses: 2<br>  },<br>  {<br>    user: &quot;ethan&quot;,<br>    totalTime: 47,<br>    totalMisses: 4<br>  },<br>  {<br>    user: &quot;ryan&quot;,<br>    totalTime: 36,<br>    totalMisses: 4<br>  },<br>  {<br>    user: &quot;kate&quot;,<br>    totalTime: 23,<br>    totalMisses: 2<br>  },<br>  {<br>    user: &quot;maddie&quot;,<br>    totalTime: 64,<br>    totalMisses: 5<br>  },<br>  {<br>    user: &quot;mike&quot;,<br>    totalTime: 65,<br>    totalMisses: 0<br>  },<br>  {<br>    user: &quot;james&quot;,<br>    totalTime: 45,<br>    totalMisses: 1<br>  },  <br>  {<br>    user: &quot;chris&quot;,<br>    totalTime: 50,<br>    totalMisses: 3<br>  },<br>  {<br>    user: &quot;steve&quot;,<br>    totalTime: 28,<br>    totalMisses: 4<br>  }<br>]</pre><p>Finally, here is the result that I would like to achieve via a sorting algorithm, I want the algorithm to sort the games by totalMisses first, then by totalTime:</p><pre>[<br>  {<br>    user: &quot;mike&quot;,<br>    totalTime: 65,<br>    totalMisses: 0<br>  },<br>  {<br>    user: &quot;james&quot;,<br>    totalTime: 45,<br>    totalMisses: 1<br>  },<br>  {<br>    user: &quot;tyler&quot;,<br>    totalTime: 63,<br>    totalMisses: 1<br>  },<br>  {<br>    user: &quot;kate&quot;,<br>    totalTime: 23,<br>    totalMisses: 2<br>  },<br>  {<br>    user: &quot;kaitlyn&quot;,<br>    totalTime: 34,<br>    totalMisses: 2<br>  },<br>  {<br>    user: &quot;chris&quot;,<br>    totalTime: 50,<br>    totalMisses: 3<br>  },<br>  {<br>    user: &quot;steve&quot;,<br>    totalTime: 28,<br>    totalMisses: 4<br>  },<br>  {<br>    user: &quot;ryan&quot;,<br>    totalTime: 36,<br>    totalMisses: 4<br>  },<br>  {<br>    user: &quot;ethan&quot;,<br>    totalTime: 47,<br>    totalMisses: 4<br>  },<br>  {<br>    user: &quot;maddie&quot;,<br>    totalTime: 64,<br>    totalMisses: 5<br>  }<br>]</pre><p>With this list, we have sorted by accuracy, then by speed! However, I quickly realized achieving this result by creating a sorting algorithm wasn’t as simple as it sounded!</p><p>Figuring out how to sort by totalTime wasn’t so bad, JavaScript has a sort method which comes in handy:</p><pre>const sortByMisses = (gamesArray) =&gt; {<br>    return gamesArray.sort((a, b) =&gt; {<br>        return a.totalMisses - b.totalMisses;<br>    })<br>}</pre><pre>let sortedArray = sortByMisses(allGames)</pre><pre>console.log(sortedArray) // array sorted by misses</pre><p>However, if I were to now sort this list by totalTime, it would reorder the entire list of games. So how do we rearrange the games by totalTime without undoing the sort we just got from sortByMisses?</p><p>Well, we could make each quantity of misses it’s own array, for example, if there were 3 different games that all had 2 totalMisses, those 3 games would be in their own sub-array. Following this, we can sort each of the sub-arrays by totalTime, then flatten the outer array back to it’s original format to get our final result.</p><p>Let’s make the function that creates our array of sub-arrays now:</p><pre>const createSubArrays = (sortedGames) =&gt; {<br>        let distinctValues = []<br>        <br>        sortedGames.forEach(game =&gt; {<br>          if( !(distinctValues.includes(game.totalMisses)) ){<br>            distinctValues = [...distinctValues, game.totalMisses]<br>          }<br>        }) <br>        <br>        let groupedGames = distinctValues.map(value =&gt; {<br>          return sortedGames.filter(game =&gt; {<br>            return value === game.totalMisses<br>          })<br>        })<br>        <br>        return groupedGames;<br>}</pre><pre>let matrix = createSubArrays(sortedArray);</pre><p>What happened here? In a nutshell, this adds every different quantity of totalMisses to the distinctValues array. Then it takes each value and returns a filtered array of all the games which has that value equal to totalMisses. If we call console.log(createSubArrays(sortedArray)), it leaves us with a result in this format:</p><pre>[<br>  [{…}],<br>  [{…}, {…}],<br>  [{…}, {…}],<br>  [{…}],<br>  [{…}, {…}, {…}],<br>  [{…}]<br>]</pre><p>The last step now is to sort each of these sub-arrays individually before flattening the outer array. Let’s take a look at that now:</p><pre>const sortEachSubArray = (groupedGames) =&gt; {<br>    let finalArray = groupedGames.map(subArray =&gt; {<br>      return subArray.sort((a, b) =&gt; {<br>        return a.totalTime - b.totalTime<br>      })<br>    })</pre><pre>    return finalArray<br>}</pre><pre>let topTen = sortEachSubArray(matrix).flat()</pre><pre>console.log(topTen) // our desired result from earlier!</pre><p>Let’s talk about this for a bit; each sub-array argument passed into the groupedGames parameter gets sorted by totalTime and mapped to a new array called finalArray. Then, I took the result of calling sortEachSubArray and flattened it back into the original array format in the topTen variable.</p><p>Just like that, we have a list of 10 objects which have been sorted by 2 different variables, placing a higher priority on the totalMisses, but then also sorting by totalTime. It took a little bit more work than originally expected, but with a few helper methods, we were able to make it happen!</p><h3>Conclusion</h3><p>I realize this post is essentially about solving an algorithm challenge, but this one in particular really helped me break down the barriers and think outside of the box. I feel like this particular challenge is good for junior devs like myself to understand, so I felt this would be a good solution to share and fully break down.</p><p>Thanks for reading and as always, happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=711ebddcda85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving VSCode Workflow on Mac for Beginners]]></title>
            <link>https://medium.com/swlh/improving-vscode-workflow-on-mac-for-beginners-2af5ef7e98f4?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/2af5ef7e98f4</guid>
            <category><![CDATA[code-editor]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[shortcuts]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 14:03:31 GMT</pubDate>
            <atom:updated>2021-01-10T12:00:26.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0uQ9eNJS92rheymKb3swA.png" /></figure><p>This week I’ve been learning a few new shortcuts on VSCode, and I am wishing I knew about these sooner! I want to share some of the shortcuts and tricks I’ve found useful as a beginner, and demonstrate how to use them to improve your workflow!</p><p>These tips are intended to save time and keystrokes, and also make navigating the code editor easier. As they say — work smarter, not harder — and don’t ask me who “they” are!</p><p>To be honest, VSCode is the only editor I’ve ever used, but it’s possible this article could relate to other editors such as Atom, or Sublime Text, however, I am not sure! Maybe I will write another article about ways to improve workflow for other editors in the future.</p><p>Anyways, out with the goods — here are a few useful workflow improvements I’ve made recently:</p><h3>Basic Editing</h3><h4>HTML Magic</h4><p>To kick things off with a “bang”, I thought I would share the fastest way to create a boilerplate HTML file. This one is pretty commonly known, but figured it couldn’t hurt to throw it in.</p><p>If I use a ! symbol, otherwise known as a “bang”, and then hit enter, we’ll see a boat load of HTML pre-built and ready to go, saving a ton of opening keystrokes. Check it out:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Famplemeatyincatern&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Famplemeatyincatern&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FAmpleMeatyIncatern-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="552" frameborder="0" scrolling="no"><a href="https://medium.com/media/1aea0f242d1a3e9b8bb0f70712102b69/href">https://medium.com/media/1aea0f242d1a3e9b8bb0f70712102b69/href</a></iframe><p>And you’re off to a hot start with your new HTML file!</p><h4>Expand and Shrink Selection</h4><p>Let’s say you want to highlight a specific section, but don’t want to use your mouse to click and drag across all the characters. I used to do that, and if I didn’t accurately drop the cursor in the correct place… I would do it over again (shame!).</p><p>Never again will I use the mouse with these commands for selection:</p><p><em>Expand one character at a time:</em> shift + →<br><em>Shrink one character at a time:</em> shift + ←<br><em>Expand one word at a time: </em>shift + ⌥ (option) + →<br><em>Shrink one word at a time:</em> shift + ⌥ (option) + ←<br><em>Expand to end of the line: </em>shift<em> + </em>⌘ (command) + →<br><em>Expand to beginning of the line: </em>shift<em> + </em>⌘ (command) + ←<br><em>Select entire line: </em>⌘ (command) + L</p><p>Here’s the above commands in their listed order, demonstrated by highlighting the &lt;title&gt; on line 6 in different ways:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fglossywillingamericangoldfinch&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fglossywillingamericangoldfinch&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FGlossyWillingAmericangoldfinch-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="554" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d676fb7052621868d801ef2f1fde51d/href">https://medium.com/media/3d676fb7052621868d801ef2f1fde51d/href</a></iframe><p>I think it’s important to note that if you shrink past the initial cursor position, you actually start expanding toward the beginning of the line.</p><p>Also, if you remove the shift key from each of the above commands, instead of selecting/highlighting, you will just move the cursor to a new spot, which is also very useful for traversing the editor.</p><h3>Navigation</h3><h4>Quick Terminal</h4><p>For me, being able to pull up a terminal that is already navigated to the project’s root folder is super helpful. Whether I want to open up a development server in the browser, or make Git commits, having a terminal available as fast as possible is a great tool.</p><p>After pressing control + ` (backtick), a terminal will pop up instantly ready for me to begin making commands from the root folder:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fnarrowdearbillygoat&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fnarrowdearbillygoat&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FNarrowDearBillygoat-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="552" frameborder="0" scrolling="no"><a href="https://medium.com/media/81fc6a8883f9904974a9239c1504b3d7/href">https://medium.com/media/81fc6a8883f9904974a9239c1504b3d7/href</a></iframe><p>In roughly 8 seconds, I opened a terminal directly at the “shortcuts-practice” folder, and initialized my project as a Git repository. Pretty nifty!</p><p>I also want to mention if you hit control + ` again, it will close the in-editor terminal.</p><h4>Jump Between VSCode Windows</h4><p>If you’re a full stack developer, it’s very likely you will have a front end and back end in separate folders, and therefore, in different editor windows.</p><p>Sometimes you may even have more windows open. After using the shortcut ⌘ (command) + ` (backtick), we should be able to toggle between multiple VSCode windows specifically, like so:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Funderstatedgrossbarnacle&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Funderstatedgrossbarnacle&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FUnderstatedGrossBarnacle-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1270" height="712" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe3977affe54cbca5e4a3834e71c8609/href">https://medium.com/media/fe3977affe54cbca5e4a3834e71c8609/href</a></iframe><p>This one is very helpful if one of your windows is behind another one and is unclickable. I used to minimize the front window just to get to the one behind, but this shortcut prevents me from using the mouse at all, super convenient!</p><h4>Jump Between Editor Tabs</h4><p>Let’s be honest, sometimes the amount of files we have open inside one editor can get ridiculous. But inside of scrolling through all the open tabs or searching through the file tree for an already opened file, there is a shortcut to save the day!</p><p>Tab right: shift + ⌘ (command) + ] (closing square bracket)<br>Tab left: shift + ⌘ (command) + [ (opening square bracket)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fneedybiodegradablekakapo&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fneedybiodegradablekakapo&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FNeedyBiodegradableKakapo-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="554" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f3b5cace04916bfeec3587a5bef041f/href">https://medium.com/media/1f3b5cace04916bfeec3587a5bef041f/href</a></iframe><p>This one saves me a ton of time if I have a lot of tabs open, I used to sit there and scroll through them with my mouse, no more!</p><h3>Multi-Cursor</h3><h4>Select Next Match</h4><p>Maybe you have a certain type of HTML elements (&lt;li&gt;’s for example) you want to add a class to all at once, but you only want to affect a few in a row, leaving others untouched.</p><p>You can use this trick to select the next match only, using as many times as necessary to place multiple cursors.</p><p>With the code you want to match highlighted, ⌘ (command) + D will add a cursor at the next match:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fjadedfamiliarcleanerwrasse&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fjadedfamiliarcleanerwrasse&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FJadedFamiliarCleanerwrasse-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="554" frameborder="0" scrolling="no"><a href="https://medium.com/media/e50ff71415ffa525563be26ddace01ac/href">https://medium.com/media/e50ff71415ffa525563be26ddace01ac/href</a></iframe><p>The example GIF doesn’t make it perfectly clear, but if there were more &lt;li&gt;’s below the &lt;ul&gt; somewhere, I would have been able to stop short, only adding a class to the 4 spots that I had made cursors for.</p><h4>Select All Matches</h4><p>Instead of just selecting one at a time, we can select every single match on the page, if you’re sure there won’t be any unwanted matches, this can be very useful.</p><p>However, if you have a variable called mainColor, and later use dot notation which also uses the word “color” (ex. someObject.color), you will select both of these instances with the word “Color” <strong>OR</strong> “color” selected.</p><p>This can cause unintended consequences so be careful with this command! By highlighting what we want to select, followed by shift + ⌘ (command) + L</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fnaiveunrulybudgie&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fnaiveunrulybudgie&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FNaiveUnrulyBudgie-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="554" frameborder="0" scrolling="no"><a href="https://medium.com/media/834917d5514eb10f6870654fc5a2ab09/href">https://medium.com/media/834917d5514eb10f6870654fc5a2ab09/href</a></iframe><p>Breaking down what happened in the GIF above:</p><ul><li>Copied and pasted list of NFL teams</li><li>Used a special command (bonus!) which created a copy of the current line below it — shift + ⌥ (option) + ↓ to create 32 pairs of double quotes followed by a comma</li><li>Expanded my selection to cover the quotes and comma</li><li>Did the command to select all matches (shift + ⌘ (command) + L)</li><li>Used ⌘ (command) + V to paste all the teams at once, one per line since I copied them that way</li></ul><h4>Place Cursor Above and Below</h4><p>Here is yet another way to place a new cursor. With this shortcut you can place a cursor either directly above or directly below the original cursor.</p><p>In this case, I plan to place 32 total cursors in order to wrap all 32 NFL team names in double quotes and add a comma at the end to complete the array.</p><p><em>Place cursor above:</em> ⌥ (option) + ⌘ (command) + ↑ <br><em>Place cursor below:</em> ⌥ (option) + ⌘ (command) + ↓</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fcompleteunfortunatefinwhale&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fcompleteunfortunatefinwhale&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FCompleteUnfortunateFinwhale-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="554" frameborder="0" scrolling="no"><a href="https://medium.com/media/d374ee62ecf1acb94d0abea08d05730f/href">https://medium.com/media/d374ee62ecf1acb94d0abea08d05730f/href</a></iframe><p>Breaking down what happened in the GIF above:</p><ul><li>Copied and pasted list of NFL teams</li><li>Started cursor at top left, and added a cursor below repeatedly until there was one for each team</li><li>Expanded my selection to the end of the line to highlight all 32 lines</li><li>Hit “ to wrap the strings in double quotes, then moved cursor to the right to add a comma to make it a list</li><li>Removed the hanging comma for undiagnosed OCD reasons</li></ul><h4>Place New Cursor Wherever</h4><p>There is one more way to create new cursors, and possibly the most dynamic way.</p><p>By using ⌥ (option) + click we can place cursors anywhere. Check it out:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Feachancientfoxterrier&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Feachancientfoxterrier&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FEachAncientFoxterrier-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="946" height="554" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bd191bbe17fc5ef35497bb7a7f7dbff/href">https://medium.com/media/8bd191bbe17fc5ef35497bb7a7f7dbff/href</a></iframe><p>Useful for if you want to have perfect control over where the cursors go! In this case I used it to only affect 3 of the 4 &lt;li&gt;’s.</p><h3>Conclusion</h3><p>There are a lot of shortcuts I didn’t mention here, but hopefully there are enough here to provide a solid foundation of how to improve workflow in VSCode.</p><p>Some reduce keystrokes, while others save time, but they all help us work smarter than harder!</p><p>I hope this was beneficial to at least one person out there. Thanks for reading if you made it this far, and as always, Happy Hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2af5ef7e98f4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/improving-vscode-workflow-on-mac-for-beginners-2af5ef7e98f4">Improving VSCode Workflow on Mac for Beginners</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Styling With Vue.js For Beginners]]></title>
            <link>https://tyler-j-funk.medium.com/dynamic-styling-with-vue-js-for-beginners-f5c3e33031e6?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5c3e33031e6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Mon, 21 Dec 2020 06:19:01 GMT</pubDate>
            <atom:updated>2020-12-21T11:05:37.890Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9rbGyXSf99rdYmplptyaw.png" /></figure><p>Hello everyone! This week I have been doing a little more working with Vue to expand my front end horizons, and have been interested in learning about conditional rendering and dynamic styling. This article will be focusing on dynamic styling, which simply put, means to make the styling for each element able to change based on the state of certain variables or conditions.</p><p>This is what makes Vue and other front end frameworks so amazing for developers! The ability to detect user input, and then instantly update the necessary elements to reflect that input are super valuable dev tools.</p><p>For this article, I will build out a very simple app with Vue that shows a way to change the styling of specific elements upon certain user input happening. Jumping right into it, I’ll be starting with three basic files, a JS file, HTML file, and CSS file all in one project folder. Here is what I’ll be starting with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cb063a4af193c887fa62dabe6e14de7/href">https://medium.com/media/6cb063a4af193c887fa62dabe6e14de7/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1727016e256c4e0b89926f87f7860fd7/href">https://medium.com/media/1727016e256c4e0b89926f87f7860fd7/href</a></iframe><p>For now, we’ll leave the styles.css file empty. First, let’s talk about what we are trying to make here. In order to demonstrate dynamic styling, I think a good project would be to create a top navigation bar with multiple tabs. When one tab has been selected via click, that tab will display different styling than the others to show the user which page they are currently on.</p><p>We’ll put a fake title to our app (“Tabulous” for humor) in the top left corner, and 3 tabs in the top right corner of our window, which will be “Home”, “Contact Us”, and “About”.</p><p>Awesome! Now that we have a plan together, and our boilerplate code is ready to rock, let’s get to work on our nav bar with dynamic styling on the tabs.</p><h3>Initial Creation and Styling</h3><p>I’ll make the nav bar container a &lt;section&gt; and add an &lt;h1&gt; title and a &lt;ul&gt; with 3 &lt;li&gt;’s in it for each of the tabs. Here is what that looks like:</p><p>(For brevity, when showing the state of index.html, I’ll just be showing the &lt;body&gt; from here out.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e923477d3ceb73bc14c6788cd63c167/href">https://medium.com/media/9e923477d3ceb73bc14c6788cd63c167/href</a></iframe><p>Which is giving us this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*WKKRJ8qtDunnL-CTMPwGlw.png" /><figcaption>Not quite a nav bar yet!</figcaption></figure><p>After adding some styling, we can achieve this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*jMxkZ9Q56dwBJh5YadUVDA.png" /><figcaption>That’s a little better!</figcaption></figure><p>Here’s the CSS that made it possible:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd47a35b420273ba5295f9336f9842df/href">https://medium.com/media/dd47a35b420273ba5295f9336f9842df/href</a></iframe><h3>Make It Dynamic</h3><p>Now that we have a styled nav bar with tabs ready to go, we can get started on making the styling dynamic. What is the desired effect? When one tab is “active” we want to see that tab have different style than the other two. Let’s change the background color to something darker, and also change the color and weight of the font to really set it apart from the non-active tabs.</p><p>Going back to the app.js file, I’ll need to accomplish a couple things:</p><ol><li>Add a variable in data for each tab to keep track of whether it is currently active or not</li><li>Add a method which will set all tabs to false before switching whichever tab was selected to true</li></ol><p>Let’s take a look at what that looks like and then discuss a bit:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb4e3eacdc65d72c988a076ff085d681/href">https://medium.com/media/bb4e3eacdc65d72c988a076ff085d681/href</a></iframe><p>I set isHomeActive to true in because it made sense to me that the home page should be active from the beginning. Now that we have amethod to select a tab (selectTab), we need to go back to the index.html file and connect that ability to a click listener for each tab.</p><p>I’m also going to change the regular class property using the v-bind directive, so I can use a ternary statement to change the classes based on the variables in data.</p><p>Like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db136a22a007e0d4ab14c1ac4d0450d4/href">https://medium.com/media/db136a22a007e0d4ab14c1ac4d0450d4/href</a></iframe><p>You can also use the shorthand for the the &lt;li&gt; Vue properties using @ in place of v-on:, and just a : in place of v-bind:. Which looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/489badde1185e9ffefd431c1efc0a288/href">https://medium.com/media/489badde1185e9ffefd431c1efc0a288/href</a></iframe><p>Great! we can now toggle the tabs by clicking on them and called the selectTab method, which then allows us to toggle the classes based on which tab is active. But nothing happens!</p><p>Of course not because we need to add some CSS for the active class! Here is what I added for the active tab:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ad62128a58f1f3b795a678674fa5ee7/href">https://medium.com/media/4ad62128a58f1f3b795a678674fa5ee7/href</a></iframe><p>Which gives us our desired effect, check it out!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fspottedalertamericanshorthair&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fspottedalertamericanshorthair&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FSpottedAlertAmericanshorthair-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="784" height="528" frameborder="0" scrolling="no"><a href="https://medium.com/media/abd1d245fa5d28574718bd3787a5cabd/href">https://medium.com/media/abd1d245fa5d28574718bd3787a5cabd/href</a></iframe><h3>Conclusion</h3><p>Dynamic styling is an awesome way to make your Vue app more interactive and informative about what your user is doing, and what changed when certain events happen, such as a click.</p><p>I hope you learned something from this post and thanks for reading; as always, happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5c3e33031e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Time Working With Vue.js]]></title>
            <link>https://tyler-j-funk.medium.com/my-first-time-working-with-vue-js-f05a5712db80?source=rss-254732f0f328------2</link>
            <guid isPermaLink="false">https://medium.com/p/f05a5712db80</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Tyler J Funk]]></dc:creator>
            <pubDate>Mon, 14 Dec 2020 05:55:59 GMT</pubDate>
            <atom:updated>2020-12-14T05:55:59.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H1w69opDf17drLoibjjSDQ.png" /></figure><p>I recently started taking a Udemy course for Vue.js and have learned enough to play around with it a bit. I figured I would share my initial thoughts, and what I’ve learned in just a couple days.</p><p>In order to demonstrate what I’ve learned, I’ll be building a very simple app from scratch, then I’ll incorporate Vue.js and talk about each step along the way. This post is meant to be an introduction to Vue.js for anyone out there interested in learning but just wants to check it out before they invest more time and energy. Although, so far I think Vue is awesome, and doesn’t require much learning to get started poking around.</p><p>From the first couple of days of learning it, I have found that Vue.js is definitely easy to integrate. Vue can be used to create a whole app, or it can be implemented in just a part of an app. For this post, I’ll be showing how easy Vue can be to integrate into any vanilla JS, HTML, CSS app.</p><h3>Opening Steps</h3><p>I started by opening a terminal, and navigating to the folder I wanted to create the project in. Once I was there, I went ahead and created a project folder:</p><pre>mkdir first-vue-app</pre><p>After that, I entered that directory with cd first-vue-app and created 3 different files, a JS file, HTML file, and CSS file:</p><pre>touch app.js<br>touch index.html<br>touch styles.css</pre><p>Now I am ready to open this app in an editor, and get started!</p><h3>In The Editor — Boilerplate Steps</h3><p>As of right now, all 3 files are empty, and I think a good place to start is by typing ! then hitting enter into the index.html file and getting our HTML going, so far here’s our boilerplate code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d42e80a2838c0b79e78d54caa79221a0/href">https://medium.com/media/d42e80a2838c0b79e78d54caa79221a0/href</a></iframe><p>Now I will change the &lt;title&gt; and get some connections established here by adding a &lt;link&gt; tag for the styles.css, and add a &lt;script&gt; tag for our app.js file. I will also go ahead and install Vue here with a &lt;script&gt; tag that I copied and pasted from the Vue docs under the installation section. Here is what I am going to start with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4683eadf544fd59335b16a6cdf80355/href">https://medium.com/media/a4683eadf544fd59335b16a6cdf80355/href</a></iframe><p>So what have I done so far? Mostly just set up stuff, and connect our files together, just basic web dev stuff; you might have also noticed I added an id to the &lt;body&gt;, this is how we are going to tell Vue which element to mount to (more on that in a bit).</p><p>Now that I have installed Vue with the &lt;script&gt; tag on line 8, we can move on to the app.js file, and start doing actual Vue things!</p><h3>Getting Started With Vue</h3><p>Once in the empty app.js file, I am going to create a const and I will be setting it to the Vue app itself like so:</p><pre>const app = Vue.createApp({</pre><pre>});</pre><p>We have a Vue skeleton, but we won’t see anything happen until after a few more steps. The first of which being that we need to mount this “app” to our &lt;body&gt; element. Why? Because this is how Vue works, it mounts to an HTML element and controls the element and everything inside of it.</p><p>I believe I’ve heard it a few times that Vue is “declarative”, because you lay out what you want as the end result, and let Vue worry about the steps that get you there. That will make more sense in a bit.</p><p>Let’s mount our app:</p><pre>const app = Vue.createApp({</pre><pre>});</pre><pre>app.mount(&#39;#app-body&#39;);</pre><p>Notice how I used the id we inserted earlier? Now we will be able to control every single element inside of the &lt;body&gt; with Vue.</p><p>So what am I trying to accomplish with this app? I just want to demonstrate some basics by showing how to connect variables and functions from the app.js file to the HTML file. I’ll make a simple profile page!</p><p>The way we store variables in the Vue object is by adding a key:value pair, which HAS to have a key called data. The value set to data has to be a function which returns an object. That object will hold all of our variables which can be set to any data type.</p><p>Let’s take a look at that in action:</p><pre>const app = Vue.createApp({<br>  data: function() {<br>    return {<br>      name: &quot;Tyler Funk&quot;,<br>      age: 28,<br>      hometown: &quot;Kansas City, MO&quot;,<br>      hobbies: [&quot;Golf&quot;, &quot;Coding&quot;, &quot;Video Games&quot;],<br>      avatarImage: &quot;https://www.w3schools.com/howto/img_avatar.png&quot;<br>    }<br>  }<br>});</pre><pre>app.mount(&#39;#app-body&#39;);</pre><p>So theoretically we have access to a variable called name, age, hometown, hobbies, and avatarImage. But how do we connect them to our HTML? First, let’s go back to our HTML. I need to add some elements, since we need to lay out what we want the end result to be. Then, I can demonstrate how to use the Vue syntax in the HTML file.</p><p>Since I have some info to display, I should probably make some text elements to have somewhere to attach the info. I’ll start there by adding an &lt;h2&gt; for each string or number, and I’ll add an &lt;img&gt; element for the avatarImage, I’ll put them all in a &lt;section&gt; container:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2eb212e1a2248ae29417eb419bd9e4d7/href">https://medium.com/media/2eb212e1a2248ae29417eb419bd9e4d7/href</a></iframe><p>Now that I have laid out the elements I want to display the information in, I need to use a special double curly brace syntax so Vue knows to use the information stored in app.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40c9650b9d9e34ad477c2b936b70142b/href">https://medium.com/media/40c9650b9d9e34ad477c2b936b70142b/href</a></iframe><p>Okay so the double curly braces makes sense, but what is going on with the attribute on the &lt;img&gt; on line 13? Well, you can’t use the variables inside of an HTML attribute without using the special “directive” called v-bind. If v-bind is followed by a colon, and then by an HTML attribute, it is now possible to access variables in the Vue object.</p><p>Let’s take a look at where this has gotten me so far:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*zsF8F0cuu3_vZP-0QfpEjQ.png" /></figure><p>We can clean that up with some quick CSS:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/728cb5d81f0bd4a88df71c9cf7282548/href">https://medium.com/media/728cb5d81f0bd4a88df71c9cf7282548/href</a></iframe><p>Which gives us a slightly better looking profile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*afSFvHVBqYPuUKJQBMfdmg.png" /></figure><p>Now we have used most of our information, but what about the array of hobbies? I’ll create a function that randomizes which hobby gets shown every time the user refreshes the page. To do that, we need to create a key:value pair with a key of methods, and the value will be an object full of whatever functions we want to create. I’ll first show the set up with an empty function, or “method” named getRandomHobby:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce4dd84e68cf7acdc1eda40b846c5cac/href">https://medium.com/media/ce4dd84e68cf7acdc1eda40b846c5cac/href</a></iframe><p>Inside of the methods key, you don’t use the function keyword when creating functions, and in order to add another one I would just have to put a comma following the closing curly brace and then define a new “method”.</p><p>Now that I have a function defined, I can implement the logic required to grab a random element from the hobbies array:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/953dbb87c709f5903c4b8542241cb60f/href">https://medium.com/media/953dbb87c709f5903c4b8542241cb60f/href</a></iframe><p>And now I can create a new &lt;h2&gt; element which will call the new function/method and will display a random hobby every time the page is loaded (line 17 below):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f62e8366626c4bac0121f6d22ff6146/href">https://medium.com/media/0f62e8366626c4bac0121f6d22ff6146/href</a></iframe><p>Here is the effect I was going for:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fidleinconsequentialbarasingha&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fidleinconsequentialbarasingha&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FIdleInconsequentialBarasingha-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="860" height="734" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c830d6840f5794e41040be1a97acbea/href">https://medium.com/media/2c830d6840f5794e41040be1a97acbea/href</a></iframe><h3>Conclusion</h3><p>I have barely scratched the surface with Vue, there is so so much more to learn, but I am already seeing the practicalities of it. I love that you can inject it into any vanilla JS app, and to be honest, it’s not very much code at all, there is barely 60 lines of code across all 3 files. All that interactivity with such little code, and the fact that you only need one &lt;script&gt; tag to install it makes it one of the easiest front end frameworks to start working with right away.</p><p>I am a React guy, but Vue is growing on me, and I definitely think it has it’s place in the front end world. I am looking forward to learning, and sharing more about Vue with you.</p><p>Thanks for reading if you made it this far, and as always, happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f05a5712db80" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>