<?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 Nick Moore on Medium]]></title>
        <description><![CDATA[Stories by Nick Moore on Medium]]></description>
        <link>https://medium.com/@nicholas.moore587?source=rss-376309c30143------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*pd4IjdZkeL9y6dNJN55EIQ.png</url>
            <title>Stories by Nick Moore on Medium</title>
            <link>https://medium.com/@nicholas.moore587?source=rss-376309c30143------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:27:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicholas.moore587/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[Favicon]]></title>
            <link>https://medium.com/@nicholas.moore587/favicon-a49fd34ddefa?source=rss-376309c30143------2</link>
            <guid isPermaLink="false">https://medium.com/p/a49fd34ddefa</guid>
            <category><![CDATA[favicon]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Nick Moore]]></dc:creator>
            <pubDate>Fri, 14 Jun 2019 12:25:00 GMT</pubDate>
            <atom:updated>2019-06-14T12:25:00.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Brief Summary of the Favicon</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZkEUntC_5iKgLiCm" /><figcaption>Photo by <a href="https://unsplash.com/@ninjason?utm_source=medium&amp;utm_medium=referral">Jason Leung</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A favicon, short for<em> favorite icon,</em> is a file containing one or more icons associated with a website. You have probably noticed them a time or two while browsing the web using one of the major web browsers. They often appear in tabs or next to the url at the top of the browser and serve as an aesthetic visual signature.</p><p><strong>History</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NJJFxCBFM2pn6k38" /><figcaption>Photo by <a href="https://unsplash.com/@clarissemeyer?utm_source=medium&amp;utm_medium=referral">Clarisse Meyer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In 1999, Internet Explorer 5 was released and was the first browser to support favicons. The file was stored in the root directory of the website and used to display the icon next to the URL in the address bar if the page was bookmarked. One unintentional (though useful) side affect of this implementation allowed websites to calculate the number of visitors that bookmarked the page by summing the number of favicon requests. Though this feature is no longer active, the favicon quickly caught on and soon became implemented across all modern browsers.</p><p><strong>How to Use</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S-xqVf0lhC40t6OE" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The table below illustrates the different ways to implement the favicon, across a number of browsers. The standard implementation uses a link element with a relattribute in the <a href="https://en.wikipedia.org/wiki/HEAD_tag">&lt;head&gt;</a> section of the document:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7AdOmoUGmySeO8NlBiDtPA.png" /><figcaption>Table sourced from <a href="https://en.wikipedia.org/wiki/Favicon">https://en.wikipedia.org/wiki/Favicon</a></figcaption></figure><p><strong>Limitations &amp; Criticism</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kUQdn6QTf8pelTBc" /><figcaption>Photo by <a href="https://unsplash.com/@jamie452?utm_source=medium&amp;utm_medium=referral">Jamie Street</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Depending on the browser, the favicon can sometimes lead to a slow page load time and 404 errors logged if it is not present. In addition, the use of the icon opens the door to different forms of social engineering. This is a particular concern for browsers that display the icon next to the URL. Malicious actors have been known to use a padlock image to give the impression the site is using secure protocol, like <a href="https://en.wikipedia.org/wiki/Transport_Layer_Security">TLS</a>.</p><p><strong>Personal Experience</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LaNRwz5BJTuqJzwt" /><figcaption>Photo by <a href="https://unsplash.com/@samuelzeller?utm_source=medium&amp;utm_medium=referral">Samuel Zeller</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In my own projects, I have used favicons often. There are many helpful tools online that can convert an image into a viable favicon. These include:</p><ul><li><a href="https://realfavicongenerator.net/">https://realfavicongenerator.net/</a></li><li><a href="https://www.favicon-generator.org/">https://www.favicon-generator.org/</a></li><li><a href="https://favicon.io/">https://favicon.io/</a></li></ul><p>Not only does the favicon add a touch of personalization to your project, they are fun to create too!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a49fd34ddefa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shallow and Deep Copies in JavaScript]]></title>
            <link>https://medium.com/@nicholas.moore587/shallow-and-deep-copies-in-javascript-9aff5aea9d84?source=rss-376309c30143------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aff5aea9d84</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[shallow-copy]]></category>
            <category><![CDATA[deep-copy]]></category>
            <dc:creator><![CDATA[Nick Moore]]></dc:creator>
            <pubDate>Thu, 30 May 2019 17:57:23 GMT</pubDate>
            <atom:updated>2019-05-30T17:57:23.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/323/0*pR3TDS90VoGzdlFF.jpg" /></figure><p>In my time working with JavaScript, I have come to find the language acts like a bit of a yes-man, often allowing you to create and run function after function without sounding the alarm. Don’t be fooled by the lack of red in the console though — just because no objections have been raised doesn’t mean all is as expected under the hood.</p><p>To demonstrate what I mean, let’s run through a quick example:</p><pre>let a = 1</pre><pre>let b = a</pre><pre>console.log(a)<br>console.log(b)<br>a = 2<br>console.log(a)<br>console.log(b)</pre><p>Copy and run the above code into your dev tools console. As probably expected, the return values of the first console.log(a) and console.log(b) were both 1. However, when you changed the value of a to 2, the logged values were 2 and 1, respectively. The reason for this is because the values assigned above are what is known in as “primitives”. In JavaScript, there are six primitive value types: <em>undefined</em>, <em>null</em>, <em>boolean</em>, <em>string</em>, <em>symbol</em>, and <em>number</em>. Primitives are data types that are not an object, have no methods, and cannot be altered. When we assigned a =1, we were linking our variable a to the location the primitive 1resided in memory. Setting b = a also made this connection, linking the variable b to the location primitive 1 resided in memory. Outside of the initial declaration, there is not other relationship linking b to a. This is why when we change the primitive assigned to a from 1 to 2, b is unaffected.</p><p>Let’s run through another example:</p><pre>let a = [1, 2, 3]</pre><pre>let b = a</pre><pre>console.log(a)<br>console.log(b)<br>a.pop()<br>console.log(a)<br>console.log(b)</pre><p>Copy and paste the above code to log the response. Notice anything interesting? When we set b = a and performed an operation on a, b was also affected. The reason for this is because a is assigned to a reference data type. When a variable is assigned to a non-primitive value (an object), it is given a reference to that value. The variable doesn’t actually contain the value, but points to the object’s location in memory. When we call a.pop(), we are not performing this operation on a, but on the value sitting in the location being referenced by a. Since b also references that same location, we see it is also affected by the operation a.pop().</p><p>Ok, let’s dive into the heart of this blog post with another coding example:</p><pre>let a = [1, 2, 3]</pre><pre>let b = a.slice()</pre><pre>console.log(a)<br>console.log(b)<br>a.pop()<br>console.log(a)<br>console.log(b)</pre><p>When the above code is run, we see the results are pretty similar to our primitive data type example. But how can this be, if a and b are assigned to a reference value? The reason for this is we are not actually setting b equal to the reference location of a. Through slice(), we are creating a copy of the object referenced by a, and setting b equal to its reference location. The object referenced by b is a new, separate object than the one being referenced by a.</p><p>Let’s continue on with another example:</p><pre>let a = [[1, 2], [3, 4]]</pre><pre>let b = a.slice()</pre><pre>console.log(a)<br>console.log(b)<br>a[1].pop()<br>console.log(a)<br>console.log(b)</pre><p>When running this code, we don’t get the same results as we did in the previous example. The reason for this is we are making a copy of an array that has elements that are reference values. Copying the array with slice() creates a new object, but the elements of that copy are still pointing to the same reference values. Using slice() in this fashion is what is known as creating a shallow copy, as only the top level object is uniquely created. To create a new, completely unique copy, we need to create what is known as a deep copy, where each of the nested elements are either primitive values or new reference objects.</p><p>There are many ways to create a deep copy. You could manually push each element of each nested object into a new variable’s nested container. Or, you could use recursion to achieve this. A method I found <a href="https://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-deep-clone-an-object-in-javascript">online</a> that is simple (and ingenious) is to stringify and parse the object using JSON. An example of this is below:</p><pre>let a = [[1, 2], [3, 4]]</pre><pre>let b = JSON.parse(JSON.stringify(a))</pre><pre>console.log(a)<br>console.log(b)<br>a[1].pop()<br>console.log(a)<br>console.log(b)</pre><p>If you are anything like me, you’ve probably spent countless hours scratching your head wondering why your data was being manipulated when destructive methods were being called on different variables. Hopefully, after reading this post you understand just what is happening under the hood and feel more confident in your dealings with JavaScript datatypes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*rVTzkH5cTJkJv0O7.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aff5aea9d84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Spaceship Operator]]></title>
            <link>https://medium.com/@nicholas.moore587/the-spaceship-operator-2e8df28419ad?source=rss-376309c30143------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e8df28419ad</guid>
            <category><![CDATA[spaceship]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Nick Moore]]></dc:creator>
            <pubDate>Thu, 02 May 2019 14:07:13 GMT</pubDate>
            <atom:updated>2019-05-02T14:08:49.773Z</atom:updated>
            <content:encoded><![CDATA[<p>In Ruby, there is no single way to accomplish a given task. One of the things I love most about the language is the level of flexibility afforded to the programmer. For those brand new to programming, however, this flexibility can be confusing. You struggle with a problem, do a quick google search to confirm/deny your suspicions — and BAM! You’re hit square in the face with a solution that seems so foreign, you do a double take in the URL to see if you accidentally searched the wrong language.</p><p>This was my experience when I first came across the &lt;=&gt; operator, otherwise known as the “spaceship” operator. What is this syntax, and why does it look so…alien?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*OylXxHh--ollnjFFtJN8Ew.png" /></figure><p>The “spaceship” operator, more formally named the comparable mixin, is used by classes whose objects can be ordered. The operator compares a receiver to an object, and returns different results based on the following evaluations:</p><ul><li>If the receiver is less than the other object, the operator will return -1</li><li>If the receiver is equal to the other object, the operator will return 0</li><li>If the receiver is greater than the other object, the operator will return +1</li><li>If the receiver and object are not comparable, the operator will return nil</li></ul><p>Let’s put this into practice below by dropping into IRB and writing some simple code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*hZrKSUi2Fvi-Ps8pl0KqHw.png" /></figure><p>Seems pretty straightforward…but why is this valuable ? On its face, having the ability to compare two objects doesn’t seem like much of feature. As it turns out, these comparisons don’t just need to happen in a vacuum; you can perform multiple comparisons on a group of elements. This gives us the ability to sort objects in relation to their value. Let’s hop back into IRB and try this out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*YJ349BJGuz1NGMlGh0e6Lw.png" /></figure><p>Wow, this seems neat! We used &lt;=&gt; to sort our list of colors by alphabetical order. But, couldn’t we have simply called #sort on colors to return the same result? The answer to that is, well, yeah. That would have been easier, too.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fo8bK8Qx05v19S%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fo8bK8Qx05v19S%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fo8bK8Qx05v19S%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/164c32c7654fc130b1e3d356467725ba/href">https://medium.com/media/164c32c7654fc130b1e3d356467725ba/href</a></iframe><p>However, you may one day find yourself in a situation where #sort doesn’t do all that you need it to do. Let’s say you have a list of student names. Given a target name, you want to see which students come before and which students come after the target name, when sorted in alphabetical order. One way we could approach this problem is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mof_V9d1ff9t5JmZocOywQ.png" /></figure><p>As you can probably tell, that is an awful lot of work to get from A to B. First, we need to #sort! our list of students to get them into alphabetical order. We then call #partition to split our list into two groups. The first group is names &lt; our target name (“john”). The second group is everything else — but, wait! We didn’t want our list to include the target name! As a result, we now have to call #shift on the second array to finally reach our desired division.</p><p>Perhaps there is a way to provide a cleaner approach using &lt;=&gt;? Let’s take a look below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C94JU8hCDzdJ5gV_x-sGmg.png" /></figure><p>Using the &lt;=&gt; operator and #group_by, we can transform our original array into a hash containing three key-value pairs: a key of -1 with a value of students before our target, a key of 0 with a value of our target, and a key of 1 with a value of students after our target. We’ve obtained the desired result, while doing much less!</p><p>By now, you may have realized the &lt;=&gt; operator is a tool you may not reach for often — in most cases you can substitute Ruby’s #sort method. However, as shown above, there’s a place for it. At the very least, you’re bound to stumble upon it in the wild. When you do, you can approach with confidence knowing that it comes in peace and is here to help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/172/1*_X8b49NUE2u6FOwFHn8viw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e8df28419ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicate and Bang Methods in Ruby]]></title>
            <link>https://medium.com/@nicholas.moore587/predicate-and-bang-methods-in-ruby-96d062750df6?source=rss-376309c30143------2</link>
            <guid isPermaLink="false">https://medium.com/p/96d062750df6</guid>
            <category><![CDATA[bang]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[naming]]></category>
            <category><![CDATA[methods]]></category>
            <category><![CDATA[predicate]]></category>
            <dc:creator><![CDATA[Nick Moore]]></dc:creator>
            <pubDate>Thu, 18 Apr 2019 16:37:18 GMT</pubDate>
            <atom:updated>2019-04-18T16:37:18.673Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3UhKBfLwGJKMTKftFIo9Og.png" /></figure><p>As a Flatiron student, I’ve become accustomed to being overwhelmed. On a daily basis, it’s normal to cycle through feeling confused, curious, confident, and then back to confused again. It seems the moment one concept clicks, two more are introduced to knock me off balance.</p><p>To maintain my sanity, I tell myself a story; a story of building a knowledge skyscraper. You begin with a loose, workable slurry of information and form it into a foundation. Once the foundation has solidified, you quickly begin construction of the first floor…followed by a second floor. Then a third. And on and on until you’re 80 stories high and able to look down on those below struggling to build their own Ruby skyscraper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vlfXUNsq_RUh1dsREMjmiw.jpeg" /></figure><p>As you construct your knowledge building, you’ll often come across things that catch your intrigue, but aren’t critical for the core purpose of the building. If you’re operating under a bootcamp schedule, the best you can do is make a mental note and promise you’ll come back to it when you have more time. But don’t kid yourself; you’ll never have more time. You’ll move on to a new floor, get distracted by new peculiarities, and keep pushing ahead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMTzsf4kD3h1wGjf_i87Eg.jpeg" /></figure><p>Every once in a while, however, you’re given an outlet to revisit those odd, forgotten items. This blog is my outlet. In my first post, I declare my topic of intrigue to be Ruby method naming conventions. Specifically, why do I keep coming across methods that end in either “?” or “!”? Are these pieces of punctuation significant and should I be using them‽</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hq5Xb8Hafe_VArOvvtcWvw.jpeg" /></figure><p>In Ruby, the process of naming methods should follow the <a href="https://github.com/rubocop-hq/ruby-style-guide">Ruby Style Guide</a>. Methods names should be descriptive, written in English, and use lower-case <a href="https://www.w3schools.com/charsets/ref_html_ascii.asp">ASCII</a> characters. The leading character should not start with a number. If the method name consists of more than one word, snake_case<strong> </strong>should be used. If the method name includes a trailing number, do not separate the number from the last word. For example, snake_case_1 should be written as snake_case1. Following these guidelines will be enough to name 90% of Ruby methods. But what about those weird guys (or girls) ending in punctuation? Unsurprisingly, there are guidelines around using these, too.</p><p>Methods ending in “?” are known as <em>predicate methods</em>. These are best defined as a method that returns a value that can be treated as a boolean. While true and false are obvious instances, there are are an infinite number of values that evaluate to a boolean. An example of a predicate method is displayed below below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*onR0xzjg4OT8qTQihysX6A.png" /></figure><p>If we were to run this program, the following would be puts to the terminal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*Fob8bPpOPB4snAJpZgqVcA.png" /></figure><p>As expected, the result of calling #end_with? on string is a boolean value. Properly defining predicate methods with a “?” not only indicates the type of return value, but also follows the Ruby philosophy of readable code. Providing punctuation improves readability and allows the command to be read like English.</p><p>Methods ending in “!” are known as <em>bang methods</em>. Typically, you’ll find that each bang method has a non-bang counterpart. For example, next to the #map method, you’ll find #map!. It’s true Ruby has a number of built in methods that perform the same operation, but this is something entirely different. Bang methods perform the same function as their non-bang counterparts, with one key difference; bang methods modify the object they’re being called on. This is a seemingly small distinction, but one that can have a major impact on your code. For this reason, its best to think of bang methods as <strong>dangerous methods</strong>. The exclamation point at the end is a helpful little reminder to beware!</p><p>To demonstrate, I’ll create a variable named string and call #reverse on it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*16U6529bnbdUAWY1qIMoGQ.png" /></figure><p>If I run the program above, I’ll get the following puts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*O1hPp5oOeVHvWhgXXfLMWw.png" /></figure><p>Pretty straight-forward, right? Now, let’s see what happens when I perform the same operation, but call #reverse!<strong> </strong>instead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5e0VsTQb6uHS9WC1Ll7J4g.png" /></figure><p>If I run this program, the following will be puts<strong> </strong>back<strong>:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*8cj22zqxRJJBJBRhbAhM1g.png" /></figure><p>As you can see in the code above, the string variable has been modified, or mutated, after having the bang operator called on it. This can create major headaches if a mutated result is not your intention. A good rule of thumb regarding bang operators is, if you’re not sure if you should use one — don’t!</p><p>To a novice Ruby user, method naming can appear arbitrary. It can be easy to overlook the naming convention without regarding its intent. However, method names are not random in structure. Like most things in Ruby, there is purpose baked in— one designed to make writing and reading the language easier and accessible to a larger audience. It is up to us as Rubyist to respect these conventions and use them to our advantage when creating content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VCHg-kNqRxXGKA9QZGGbCQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96d062750df6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>