<?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 Aaron Na on Medium]]></title>
        <description><![CDATA[Stories by Aaron Na on Medium]]></description>
        <link>https://medium.com/@syn228?source=rss-53185d8dafd2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*owVOGlaP3UpI-oJZF6j86Q.jpeg</url>
            <title>Stories by Aaron Na on Medium</title>
            <link>https://medium.com/@syn228?source=rss-53185d8dafd2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 14:45:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@syn228/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[Basics of CSS Responsive Design: Featuring Simple Breakpoints and Media Queries]]></title>
            <link>https://medium.com/@syn228/basics-of-css-responsive-design-featuring-simple-breakpoints-and-media-queries-a454577a2be2?source=rss-53185d8dafd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a454577a2be2</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[media-queries]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Aaron Na]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 00:40:20 GMT</pubDate>
            <atom:updated>2019-01-07T00:40:20.171Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*--EspSYCVrEyo2Q0.png" /><figcaption>Source: <a href="https://www.interaction-design.org/literature/article/responsive-design-let-the-device-do-the-work">https://www.interaction-design.org/literature/article/responsive-design-let-the-device-do-the-work</a></figcaption></figure><p>When creating a website for users to view, you want to make sure that the page looks great and intuitive regardless of the users’ devices.</p><p>Your website may look astonishing on the computer but does it look just as good on a mobile device?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*O9RtiuGUYmXa4CE3x3mrIg.gif" /><figcaption>Standard Website with Animation</figcaption></figure><p>Looks nice and clean, with simple keyframe animations. But how would it look on a smaller device such as a smartphone?</p><p>If you have a website that you want to inspect on a different size resolution, you can use the Google Chrome developer tools and toggle the device toolbar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Uvh-L0CJagjiz747hRXYgg.gif" /><figcaption>Google Chrome Dev Tools Device Toolbar</figcaption></figure><p>Neat feature from Chrome but as you can see, the end result of the website at smaller resolution is quite poor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*LrCErqJHKiyj8PfFFo2c2Q.png" /><figcaption>Same Website on an iPhone X Viewport</figcaption></figure><p>The website may look fine on a bigger screen, but it should also accommodate for smaller screens like smartphones or tablets.</p><p>To help combat this problem, I will be going over the basics of breakpoints and media queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*ARzMmyh2plEm0rDECjQNmg.png" /><figcaption><a href="https://material-ui.com/layout/breakpoints/">https://material-ui.com/layout/breakpoints/</a></figcaption></figure><p>Breakpoints are often broken down into several sections of different screen resolution. These points can be designed specifically for phones, tablets, computers, or large-sized screens in general.</p><p>For example, the appropriate screen resolution for phones can range from 400 ~ 600 px, tablets from 900 ~ 1200 px, and computers and other screens at 1200px or higher.</p><p>Defining the correct breakpoints for your website depends on whether or not the website followed the Mobile-First Approach or the Desktop-First Approach. Both of them have their pros and cons but require a lot more in-depth explanation. If you want to read more about the two types of approaches, this <a href="https://www.brainleaf.com/blog/brainleaf-news/mobile-first-vs-desktop-first-how-to-choose-a-responsive-strategy/">article</a> differentiates the two approaches well.</p><p>Once you’ve identified the desired breakpoints for your website, we can then go ahead and use media queries to make the website more responsive.</p><p>Simply put, <a href="https://www.w3schools.com/css/css_rwd_mediaqueries.asp">media queries</a> are CSS techniques that help specify conditions for which you want changes to occur. Let’s take a look at some of the CSS for the website shown above:</p><pre>.header {<br>  height: 85vh;<br>  background-image: linear-gradient(to right bottom, #2998ff,    <br>  #5643fa);<br>  background-size: cover;<br>  background-position: top;<br>  position: relative;<br>}</pre><p>This is the CSS for the header element that encompasses the entire website above. If we wanted to add a condition for some of this header’s element to change, we can add a media query to do so with the @media syntax in the same style.css file:</p><pre>@media (max-width: 900px){<br>  .header {<br>    background-image: linear-gradient(to right bottom, red, orange);<br>  }<br>}</pre><p>In this example, we are specifying that if the maximum width of the screen 900px or less, we want to access the header element and change the background-image linear-gradient colors to red, orange. The transition would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bSIqlyoZM_hmCkPYgwl5kQ.gif" /><figcaption>Reaching 900px Breakpoint</figcaption></figure><p>As soon as the resolution width hits 900px, the background linear-gradient turns into orange/red color scheme, indicating that the media query is taking effect.</p><p>Note that in the media query, we <em>only</em> specified the changes we wanted, instead of rewriting the entire .header style.</p><p>Using this logic, we can apply different changes to the website.</p><p>First, here are some of the original CSS code we will change:</p><pre>.heading-primary-main {<br>  display: block;<br>  font-size: 60px;<br>  font-weight: 400;<br>  letter-spacing: 35px;<br>  animation: leftEntrance 1s ease-out;<br>}</pre><pre>.heading-primary-sub {<br>  display: block;<br>  font-size: 20px;<br>  font-weight: 700;<br>  letter-spacing: 17.5px;<br>  animation: rightEntrance 1s ease-out;<br>}</pre><pre>.header {<br>  height: 85vh;<br>  background-image: linear-gradient(to right bottom, #2998ff, <br>  #5643fa);<br>  background-size: cover;<br>  background-position: top;<br>  position: relative;<br>}</pre><pre>.btn{<br>  text-transform: uppercase;<br>  text-decoration: none;<br>  padding: 15px 40px;<br>  display: inline-block;<br>  border-radius: 80px;<br>  transition: all .2s;<br>  position: relative;<br>}</pre><p>We will make changes to the above code to better fit the smaller resolution screens. For this particular example, we will use a 600px breakpoint:</p><pre>@media (max-width: 600px){<br>  .heading-primary-main {<br>    font-size: 40px;<br>    font-weight: 200;<br>    letter-spacing: 30px;<br>  }</pre><pre>  .heading-primary-sub {<br>    font-size: 15px;<br>    font-weight: 500;<br>    letter-spacing: 15px;<br>  }</pre><pre>  .header {<br>    height: 65vh;<br>  }</pre><pre>  .btn {<br>    padding: 10px 30px;<br>    border-radius: 60px;<br>  }<br>}</pre><p>The changes above are mainly decrease in font-size or height to accommodate the screen resolution change.</p><p>With the above media query, the website will change as it reaches the 600px breakpoint:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*x7x8WL8-dtYQHON6urFGFA.gif" /><figcaption>Reaching 600px breakpoint</figcaption></figure><p>You can very clearly see the changes apply once the screen resolution reaches 600px.</p><p>This is of course a very basic example of responsive design; the possibilities are endless.</p><p>Regardless of the approach you take, whether it’s Mobile-First or Desktop-First, you should always keep responsive design in mind when creating your website.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a454577a2be2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using React with different syntax, featuring JSX, Hyperscript, and Hyperscript-helpers.]]></title>
            <link>https://medium.com/@syn228/using-react-with-different-syntax-featuring-jsx-hyperscript-and-hyperscript-helpers-4baaee96043d?source=rss-53185d8dafd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4baaee96043d</guid>
            <category><![CDATA[hyperscript]]></category>
            <category><![CDATA[jsx]]></category>
            <category><![CDATA[hyperscript-helpers]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Aaron Na]]></dc:creator>
            <pubDate>Sun, 01 Jul 2018 19:02:06 GMT</pubDate>
            <atom:updated>2018-07-01T19:02:06.394Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*ubhW4nx424p1RLFZ.png" /><figcaption>Source: <a href="https://hub.packtpub.com/wp-content/uploads/2018/03/react-jsx.png">https://hub.packtpub.com/wp-content/uploads/2018/03/react-jsx.png</a></figcaption></figure><p>This blog will focus on the topic of syntax in React, namely JSX, Hyperscript. Then I will build upon these two methods by introducing Hyperscript-helpers.</p><h3><strong>JSX (Javascript XML)</strong></h3><p><a href="https://reactjs.org/docs/introducing-jsx.html">JSX </a>is an extension of Javascript commonly used in React to provide a syntactic sugar for what would be a rather convoluted syntax with React.</p><p>Despite its potential benefits, there are mixed feelings about JSX, as it essentially combines HTML and Javascript together. As I am not here to convince anyone to use JSX or not, I will simply go over how code in React differs when using JSX and when not.</p><p><em>When using JSX in React, the code is converted to Javascript via compilers, such as </em><a href="https://babeljs.io/repl/#?presets=react&amp;code_lz=GYVwdgxgLglg9mABACwKYBt1wBQEpEDeAUIogE6pQhlIA8AJjAG4B8AEhlogO5xnr0AhLQD0jVgG4iAXyJA"><em>Babel</em></a><em>.</em></p><p>Let’s take a look at how code looks when JSX is used for React:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3045470afaf5b823f037549e9d468bf/href">https://medium.com/media/f3045470afaf5b823f037549e9d468bf/href</a></iframe><p>This code will render “This summer is really hot!” Fairly straight forward, especially since everything inside of the ‘return’ looks a lot like HTML.</p><p>Here is the non-JSX method with the same results:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f800c559b2d2d8102e2a792ffee7906/href">https://medium.com/media/9f800c559b2d2d8102e2a792ffee7906/href</a></iframe><p>Let’s break this down a little bit.</p><p>React.createElement takes in 3 arguments: (<em>type</em>, <em>props</em>, <em>children</em>)</p><p>It will create a type of HTML tag (div), take in any props for the <em>element </em>then any children associated with the element (this.props.weather).</p><p>You may be wondering why we don’t simply have ‘{weather: ‘hot!’}’ as a second parameter in the createElement inside the render/return and go through the trouble of writing ${this.props.weather} as a children parameter.</p><p>Generally speaking, you do <strong>not </strong>want to pass the props directly to the element type itself (div). Instead, the props should go down to the <strong>component/class</strong> where you can more explicitly control which props are utilized where.</p><p>This is why at the bottom of the snippet, you see the ReactDOM.render which takes care of passing down the props to the Weather <em>Class </em>and not the div.</p><h3>Hyperscript</h3><p>For those of you who hate using JSX due to the HTML nature of it, let’s look at an alternative to JSX: <a href="https://github.com/mlmorg/react-hyperscript/blob/master/README.md">Hyperscript</a>.</p><p>Here is an example usage:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd2f35a6f7d25b6e3392756efe5fc504/href">https://medium.com/media/cd2f35a6f7d25b6e3392756efe5fc504/href</a></iframe><p>You’ll notice that the way we create HTML tags such as div or h1 is already very different.</p><p>With the above example, you would essentially have a parent div element, with both h1 and h2 enclosed inside as children.</p><p>Also note that you can assign ID or Class to the HTML tags by using # or . respectively, following the conventions of CSS.</p><p>As far as the “h” that’s being used to create elements, here are the parameters:</p><p>h(componentOrTag, properties, children)</p><ul><li>componentOrTag - Can be a React component OR tag string with optional css class names/id.</li><li>properties - An object containing the properties you&#39;d like to set on the element.</li><li>children - An array of h() children or a string. This will create child elements or a text node, respectively.</li></ul><p>Thus, Hyperscript offers a more Javascript-like approach to running React without having to deal with the HTML components.</p><h3>Hyperscript-Helpers</h3><p><a href="https://github.com/ohanhi/hyperscript-helpers">Hyperscript-helpers</a> are npm extensions that help reduce some of the code syntax in React.</p><p>Hyperscript-helpers can be used for Hyperscript <strong>and</strong> JSX.</p><p>Take a look:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b3de5553874bc7feddc8ebffd02be83/href">https://medium.com/media/5b3de5553874bc7feddc8ebffd02be83/href</a></iframe><p>Using Hyperscript-helpers, you can define which of the elements/tags you would like to use and set them on the require(‘hyperscript-helpers’). As you can see in this example, because we’re using &lt;ul&gt; and &lt;li&gt; tags, we required these at the top.</p><p>Having done so, you can now utilize hyperscript-helpers as seen at the bottom of the code, simply using ul(<em>arguments</em>) or li(<em>arguments</em>) instead of writing them separately inside as parameters.</p><p>If you’re interested in trying it out, all you have to do is:</p><pre>npm install hyperscript-helpers</pre><p>Then require the necessary assets on the top of the code, and you’re good to go.</p><p>In conclusion, there seems to be a mixed crowd between using JSX and using Hyperscript. At the end of the day, <strong>the best syntax is the one that you are most comfortable with</strong>, as long as you can solve your problems in an efficient, logical way using either of the tools at your disposal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4baaee96043d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Usage and Cases of Array#sort() in Javascript]]></title>
            <link>https://medium.com/@syn228/the-usage-and-cases-of-array-sort-in-javascript-c4510218e3a5?source=rss-53185d8dafd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4510218e3a5</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Aaron Na]]></dc:creator>
            <pubDate>Sun, 10 Jun 2018 21:04:05 GMT</pubDate>
            <atom:updated>2018-06-10T21:04:05.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hBR3LrWIBpaKIOd18B70ug.jpeg" /><figcaption>Source: <a href="http://knowledge.wharton.upenn.edu/wp-content/uploads/2017/02/Algorithm.jpg">http://knowledge.wharton.upenn.edu/wp-content/uploads/2017/02/Algorithm.jpg</a></figcaption></figure><p>I have been writing vanilla Javascript for a week and have used many operators and methods, one of which was <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort"><strong>Array#sort()</strong>.</a></p><p>For those who are unfamiliar with the method, the sort method reorganizes the array based on conditions.</p><p>For an array of simple numbers, it looks like this:</p><pre><em>// myArray = [1,5,7,2,8,9,4]</em><br>myArray.sort();<br>console.log(myArray)<br><em>// expected output: Array [1,2,4,5,7,8,9]</em></pre><p>Sort can also work on strings:</p><pre><em>// myArray = [&#39;Aaron&#39;, &#39;Zebra&#39;, &#39;Bill&#39;, &#39;Jon&#39;, &#39;Frank&#39;]</em><br>myArray.sort();<br>console.log(myArray) <br><em>// expected output: Array [&#39;Aaron&#39;, &#39;Bill&#39;, &#39;Frank&#39;, &#39;Jon&#39;, &#39;Zebra&#39;]</em></pre><p>Essentially what’s happening under the hood is that the sort function goes through each value inside the array, compares the first value “a” with the second value “b.”</p><p>If the difference between a and b is a negative number or 0, it does not change the sorting and moves onto the next set. If the difference between a and b is a positive number, the sort function inverts the position of the two and moves on.</p><p>It repeats this iteration until the difference between a and b of the entire set is a negative number or 0, confirming that it has been sorted in an ascending order.</p><p>The strings are no exception to this rule; they have their own intrinsic values that the sort function goes through case by case, set by set. It is because of this rule that this happens when you compare a string that starts with lower case and one that starts with an upper case:</p><pre><em>// myArray = [&#39;aaron&#39;, &#39;Zebra&#39;, &#39;bill&#39;, &#39;Jon&#39;, &#39;Frank&#39;]</em><br>myArray.sort();<br>console.log(myArray) <br><em>// expected output: Array [&#39;Frank&#39;, &#39;Jon&#39;, &#39;Zebra&#39;, &#39;aaron&#39;, &#39;bill&#39;]</em></pre><p>This is because the value of lower case letters are actually higher than that of upper case letters. Thus, the rules of finding the difference between a and b then sorting based on the computational output still applies.</p><p>This makes sense but what’s <strong>actually </strong>happening? What kind of algorithm does the sort function consist of?</p><p>I pursued this rabbit hole and found some interesting information (but not necessarily a single answer for all sort functions).</p><p>Upon further digging, I found out that the sort function actually employs different commands based on the browser you’re using, the amount of data you wish to sort, and the values inside the array. This is done to find the most optimal way of sorting the dataset you wish to sort, which impacts the sorting performance of the algorithms.</p><h3>Quicksort</h3><p>Google Chrome and Safari use variations of <a href="https://en.wikipedia.org/wiki/Quicksort"><strong>quicksort</strong></a> for numeric arrays(arrays of primitive type). This variation of quick sort is the C++ standard library function known as <a href="http://en.cppreference.com/w/cpp/algorithm/qsort"><strong>std::qsort</strong></a> also known as <a href="https://en.wikipedia.org/wiki/Introsort"><strong>introsort</strong></a><strong>.</strong></p><p>Visually, this is what quicksort looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*1OXQp3jbpyUJHYMX5rrJOQ.gif" /><figcaption>Source: <a href="https://en.wikipedia.org/wiki/Quicksort#/media/File:Sorting_quicksort_anim.gif">https://en.wikipedia.org/wiki/Quicksort#/media/File:Sorting_quicksort_anim.gif</a></figcaption></figure><p>Quicksort is a divide and conquer algorithm that defines elements inside the array then recursively sort through the sub-arrays. The steps it takes are:</p><ol><li>Pick an element called <strong>pivot</strong> from the array.</li><li>Reorder the array so that elements with values less than the pivot come before the pivot and any elements greater than the pivot come after. This is called the <strong>partition </strong>operation.</li><li>Recursively apply the first two steps to the sub-array of elements with smaller values and separately to the sub-arrays of elements with greater value.</li></ol><p>The pivot selection and partition operation can be done in several different ways in which the choice of specific implementation schemes greatly affects the algorithm’s performance.</p><h3>Merge Sort</h3><p>When the arrays are non-numeric, the values inside the array are <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify"><strong>stringified</strong></a><strong> </strong>then is sorted through <a href="https://en.wikipedia.org/wiki/Merge_sort"><strong>merge sort</strong></a>(Mozilla/Firefox also resorts to merge sort by default).<strong> </strong>Here is a slow(but self-explanatory!) representation of merge sort:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*opwN0BhtH4zvPF697fPlow.gif" /><figcaption>Source: <a href="https://en.wikipedia.org/wiki/Merge_sort#/media/File:Merge-sort-example-300px.gif">https://en.wikipedia.org/wiki/Merge_sort#/media/File:Merge-sort-example-300px.gif</a></figcaption></figure><p>For actual algorithmic visualization with graphical dots, it can be represented this way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*KuRhJc8FTVXDC3qYOet2lQ.gif" /><figcaption>Source: <a href="https://en.wikipedia.org/wiki/Merge_sort#/media/File:Merge_sort_animation2.gif">https://en.wikipedia.org/wiki/Merge_sort#/media/File:Merge_sort_animation2.gif</a></figcaption></figure><p>Here are the steps merge sort takes:</p><ol><li>Divide the unsorted list into <em>n</em> sublists, each containing 1 element.</li><li>Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This last remaining sublist will be the sorted list.</li></ol><p>The merge sort is an efficient, general-purpose sorting algorithm that accomplishes its job well when it comes to comparison.</p><h3>Selection Sort</h3><p>For any other types of arrays, <a href="https://en.wikipedia.org/wiki/Selection_sort"><strong>selection sort</strong></a><strong> </strong>is used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*SV4ejb55ZqkEmFxBhqKV3g.gif" /><figcaption>Source: <a href="https://en.wikipedia.org/wiki/Selection_sort#/media/File:Selection_sort_animation.gif">https://en.wikipedia.org/wiki/Selection_sort#/media/File:Selection_sort_animation.gif</a></figcaption></figure><p>As written in the Wikipedia page, selection sort divides the input list into two parts: the sublist of items already sorted(which starts out empty), and the sublist of items remaining to be sorted that occupy the rest of the list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, swapping it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.</p><p>This explanation can be visualized with this snippet:</p><pre>Sorted sublist == ( )<br>Unsorted sublist == (11, 25, 12, 22, 64)<br>Least element in unsorted list == 11<br><br>Sorted sublist ==  (11)<br>Unsorted sublist == (25, 12, 22, 64)<br>Least element in unsorted list == 12<br><br>Sorted sublist == (11, 12)<br>Unsorted sublist == (25, 22, 64)<br>Least element in unsorted list == 22<br><br>Sorted sublist == (11, 12, 22)<br>Unsorted sublist == (25, 64)<br>Least element in unsorted list == 25<br><br>Sorted sublist == (11, 12, 22, 25)<br>Unsorted sublist == (64)<br>Least element in unsorted list == 64<br><br>Sorted sublist == (11, 12, 22, 25, 64)<br>Unsorted sublist == ( )</pre><pre><em>Source: </em><a href="https://en.wikipedia.org/wiki/Selection_sort"><em>https://en.wikipedia.org/wiki/Selection_sort</em></a></pre><p>As you may have guessed, this has <a href="https://en.wikipedia.org/wiki/Time_complexity"><strong>O(n²)time complexity</strong></a>, meaning that it is a fairly inefficient method of sorting compared to its sorting brothers such as merge sort, quick sort, etc.</p><p>Ultimately, different sort methods are used based on the browser you are using and the type/amount of values you are sorting. As the amount of data you want to sort becomes greater, the performance levels of each sort methods become important as to not have the elementary algorithm take too long to perform its functions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4510218e3a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying HTML with HAML]]></title>
            <link>https://medium.com/@syn228/simplifying-html-with-haml-cbe520db685a?source=rss-53185d8dafd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbe520db685a</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[gem]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Aaron Na]]></dc:creator>
            <pubDate>Sun, 20 May 2018 17:05:53 GMT</pubDate>
            <atom:updated>2018-05-20T17:05:53.211Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*EvvHMA3ZR2oDaFsUMkepTw.jpeg" /><figcaption>Source: <a href="http://bankwalebabu.com/maths/simplification">http://bankwalebabu.com/maths/simplification</a></figcaption></figure><p>Having recently been introduced to Sinatra and Rails, I inevitably had to work with a lot of HTML, specifically inside the .erb(<strong>E</strong>mbedded <strong>R</strong>u<strong>B</strong>y) files.</p><p>While I had a fair amount of exposure to HTML prior to learning Ruby, it still seemed a bit foreign and a lot more clunky in terms of structure (and that’s without working with much of CSS).</p><p>Thus, I began to look for ways to facilitate the coding process of HTML as well as how the language looks in a file. That’s when I found HAML.</p><h3>HAML: What is it?</h3><p><a href="https://en.wikipedia.org/wiki/Haml">HAML</a> stands for <strong>H</strong>TML <strong>A</strong>bstraction <strong>M</strong>arkup <strong>L</strong>anguage.</p><p>Introduced by <a href="https://en.wikipedia.org/wiki/Hampton_Catlin">Hampton Catlin</a> with the intent of making HTML more readable and executable, HAML is a <a href="https://rubygems.org/gems/haml/versions/5.0.4">gem</a> that replaces and facilitates most of the robust styling in HTML. Though it is mostly used for Rails, it can also be used for vanilla Ruby.</p><h3>Setting it up</h3><p>To start using HAML, simply:</p><pre>gem install haml</pre><p>Make sure to require the gem in your Gemfile and make sure to run ‘bundle.’</p><p>For more information about specific HAML commands, type in your terminal:</p><pre>haml --help</pre><h3>Usage</h3><p>Here are some examples of HTML and how the same outputs can be rendered in its counterpart, HAML.</p><pre>&lt;ul&gt;<br>   &lt;li&gt; Peanut &lt;/li&gt;<br>   &lt;li&gt; Butter &lt;/li&gt;<br>   &lt;li&gt; Jelly &lt;/li&gt;<br>&lt;/ul&gt;</pre><p>Here is a simple, unordered list of items in the HTML syntax. The same line of code can be written as such in HAML:</p><pre>%ul<br>  %li Peanut<br>  %li Butter<br>  %li Jelly</pre><p>Simple, easy to read, and most importantly, no need for closing tags!</p><p>One thing to note here is that the indentation is <strong>crucial. </strong>If the ‘li’ tag following the ‘ul’ tag is not properly indented, HAML will <strong>not </strong>recognize the syntax and return an error.</p><p>HAML can also be employed for easy interpolation.</p><p>In HTML, you can interpolate the ruby code within the .erb file by:</p><pre><strong><em># array = [1, 2, 3, 4, 5]</em></strong></pre><pre>&lt;% array.each do |value| %&gt;<br>  &lt;% if value &gt; 2%&gt;<br>  &lt;p&gt;&lt;%= value %&gt;&lt;/p&gt;<br>  &lt;% end %&gt;<br>&lt;% end %&gt;</pre><pre><em>=&gt; [3, 4, 5]</em></pre><p>This returns the output of values 3, 4 and 5, as displayed by the ‘&lt;%=’ tag while the contents inside the ‘&lt;%’ tag are invisible to the user to hide/perform the iteration.</p><p>Here is the same expression in HAML:</p><pre><strong><em># array = [1, 2, 3, 4, 5]</em></strong></pre><pre>  - array.each do |value|<br>  - if value &gt; 2 <br>%p= value</pre><pre><em>=&gt; [3, 4, 5]</em></pre><p>The ‘ — ’ is the equivalent of the ‘&lt;%’ tag while the ‘=’ is the equivalent of the ‘&lt;%=’ tag.</p><p>Again, no need for the closing tags for any of these elements and no need for ‘end’ for the ‘each’ method.</p><p>Another nice aspect of the HAML is its simplicity when it comes to CSS class and id selectors as well as the ‘&lt;div&gt;’ implication:</p><pre>&lt;div class=&#39;code&#39; id=&#39;love&#39;&gt;I love programming!&lt;/div&gt;</pre><p>Here is a typical &lt;div&gt; tag assigned to the class of ‘code’ and the id of ‘love’. As you may know, in CSS, the class selector is classified by ‘ . ’ and the id selector by ‘#’. This is representative in HAML as well:</p><pre>.code #id I love programming!</pre><p>Due to the common nature of &lt;div&gt; in HTML, if you don’t assign any tags to the class and id selectors, it automatically assumes &lt;div&gt; for the tag. Also notice that the classification of class and id can be done with the CSS selector equivalent of ‘ . ’ and ‘#’.</p><p>Putting it all together, you can use the id and class attribution and interpolation together; the following HTML code:</p><pre>&lt;div class=&#39;product&#39; id=&#39;item#&lt;%= @item.id %&gt;&#39;&gt;<br>  &lt;%= @item.name %&gt;<br>&lt;/div&gt;</pre><p>can look like this:</p><pre>.product{:id =&gt; &quot;item#{@item.id}&quot;} = @item.body</pre><p>Since the value of the id selector needed to be interpolated, it can be enclosed inside the braces({}) and interpolated with the familiar quotation(“ ”) interpolation.</p><p>We’ve seen enough examples, so let’s break it down.</p><p><strong>Pros of HAML:</strong></p><ul><li>Easier to read, cleaner, and conforms to the DRY(<strong>D</strong>on’t <strong>R</strong>epeat <strong>Y</strong>ourself) principle.</li><li>Different but familiar/intuitive, with specific syntax that still adheres to the coding structure such as ‘.’ for class and ‘#’ for id in CSS.</li><li>Flexibility in your project; you can have both HAML <em>and .</em>erb files in the same project in case you want to retain your progress in .erb or your project needs to be in .erb format</li></ul><p><strong>Cons of HAML:</strong></p><ul><li>Wrong indentation could mean a lot of unnecessary time spent looking for spacing errors.</li><li>You would need to learn more syntax instead of working with ones that you already know</li></ul><h3>Last Few Notes</h3><p><em>Want to apply the HAML for all your current .erb files?</em></p><p>You can use the <a href="https://rubygems.org/gems/html2haml/versions/2.0.0">html2haml gem</a> for that!</p><p><em>Want to try converting to HAML but most of your project is already in .erb?</em></p><p>No problem, as both .erb and HAML can coexist in one project folder!</p><p>While it is true that you must learn a few specific syntax for HAML, it may be worth your while as the readability as well as the capabilities of HAML are excellent.</p><p>You can read more about the HAML gem in the <a href="http://haml.info/docs/yardoc/">documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbe520db685a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Facilitating Your Coding Experience With Useful Hotkeys (Beginner Edition)]]></title>
            <link>https://medium.com/@syn228/facilitating-your-coding-experience-with-useful-hotkeys-cd087863fee0?source=rss-53185d8dafd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd087863fee0</guid>
            <category><![CDATA[atom-text-editor]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[shortcuts]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[keyboard-shortcuts]]></category>
            <dc:creator><![CDATA[Aaron Na]]></dc:creator>
            <pubDate>Sun, 06 May 2018 21:08:45 GMT</pubDate>
            <atom:updated>2018-05-18T12:59:28.369Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*0HHEQCoMIfVmR4BsqXH6Kg.gif" /><figcaption>Source: <a href="https://giphy.com/gifs/toXKzaJP3WIgM">https://giphy.com/gifs/toXKzaJP3WIgM</a></figcaption></figure><p>If you’re like me, you like to find short-cuts and hotkeys that improve your efficiency on the computer.</p><p>More specifically, I have been writing a lot of code in the past few weeks and have been looking for small ways to speed up my process on Atom.</p><p>This blog will cover few interfaces and several useful hotkeys on your mac that minimizes your usage of the mouse and help continuously code on your keyboard.</p><p><em>Note: There are many, many more hotkeys than the ones that will be covered here. I am going through some of the specific ones that I personally found helpful while coding.</em></p><h3>Few Useful Interfaces</h3><ol><li><em>Terminal in your text-editor:</em></li></ol><p>I will not be covering packages, as there are plethoras of blogs and articles about them. However, I will recommend one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j8wchwWpyusTR50Ce6ksgQ.png" /><figcaption>Atom Text-editor with built-in terminal</figcaption></figure><p>While it is possible to have your own terminal open while you test codes on your text editor, I found it extremely convenient to have the terminal right on the text editor itself so that I don’t have to command+tab through them.</p><p>To get this package, simply search for “terminal” in your packages search and look for an integrated terminal. I am personally using “Platformio-ide-Terminal” but there are many other options out there. Once installed, there should be a “+” symbol on the bottom left of your text-editor which can pull up the terminal.</p><p>2. <em>Soft Wrap:</em></p><p>Every once in a while, you come across a line of code that is just way too long:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*qdOd7xnRvGVrSzui3BDWgw.gif" /><figcaption>You can only have so much beer…</figcaption></figure><p>This is not only hard to read, but it is also tedious to scroll through all the text. To ensure that you can see all the data without scrolling furiously to the right, you can enable Soft Wrap!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*091KbekzcBl25k2De_HV1A.gif" /></figure><p>This feature will allow the text to not exceed the line-length of your current view and drop down to the next line (you can also customize the length limit in the same editor window).</p><p>Now that we’ve covered the two tools that really helped me out while coding, let’s get to the real highlight of this blog!</p><h3>Several Useful Hotkeys</h3><ol><li><em>‘⌘ + ctrl+ ↑↓’</em></li></ol><p>Ever put a code few lines above or below where you meant to? Is your binding.pry outside of the loop? You can use this command to move them without cutting and pasting the line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*XfJ63_AsNQb0CXbmnB6nCQ.gif" /><figcaption>Hopefully everyone knows the order of operations :)</figcaption></figure><p>2. ‘<em>⌘ + ⇧ + D’</em></p><p>If you’ve ever wanted to duplicate a line of code, you can use this command instead of copying/pasting them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*kJf5C5Vl3W6GfFD664ZvYg.gif" /><figcaption>If only we could duplicate our actual lottery winnings… (or win in the first place)</figcaption></figure><p>3. ‘C<em>trl + ⇥(tab)’ and other variations</em></p><p>Inevitably, there are times when you must open more than one tab of text editor. Though we can easily switch between tabs using the mouse, I personally like to stay on my keyboard as long as possible for min-maxing my efficiency.</p><p>We’ll start with ‘Ctrl + ⇥’ which switches the tab back to the most recent tab you were on:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*jg4k7AwQQ6GQ6Eo_Tb5MlQ.gif" /></figure><p>We can also freely cycle through the tabs by their tab #, using the hotkeys ‘⌘+ # of the tab’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*JSKp06dCLfya1xIk35o88g.gif" /><figcaption>Note: ⌘ + 9 will go to the last tab, regardless of the number of tabs open</figcaption></figure><p>4. ‘<em>⌘ + D’, ‘⌘ + U’, and ‘⌘ + Click’</em></p><p>These commands will help you work with multiple elements corresponding to the same name/selection. ‘⌘ + D’ allows the user to find the next element matching the highlighted one and modify them together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-HsOHawKB8X2dnD1VHy06Q.gif" /><figcaption>Quick note that “defi + return/tab” will automatically fill the initialize method upto one argument</figcaption></figure><p>One common issue I ran into with this hotkey is that I sometimes selected an additional element that I did not want to select. Thankfully, there is ‘⌘ + U’ which unselects the most recently selected element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*SjsIdDhAkUPFGkkSoM_-zg.gif" /><figcaption>@name != owner</figcaption></figure><p>If the above example is not an issue and you’re fine selecting <em>all </em>the elements of the corresponding name, you can use ‘⌘ + Ctrl + G’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Ts5RHwycyI3pwfTiNTx_xw.gif" /></figure><p>Lastly, you can use ⌘ + click(I know, this goes against my entire being using a mouse for this next example but it is actually helpful) to manually select the areas you want to modify together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*7GC2_7sX5J0UScZIn5lTew.gif" /><figcaption>This example is gonna be outdated in a few years…</figcaption></figure><p>5. <em>‘⌘ + K + ↑↓←→’</em></p><p>If you use Atom, you’ve probably seen <em>‘⌘ + K + →’ </em>already, as it is displayed on an empty tab when you open one. I would like to reinforce their recommendation, as this command really helps to reference more than one tab at a time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*0JQ0Zfc7ph5L1nO5b5S1cw.gif" /></figure><p>This becomes extremely helpful to reference where the information is coming from and what to expect from a particular method if it is heavily dependent on the input from another file.</p><p><em>6. ‘Ctrl + G’</em></p><p>This command allows you to type in the line that you wish to navigate to and Atom will instantly move to the selected line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*YtDnb57RaPYHbFzrZkGoAA.gif" /><figcaption>Even if you’re lonely, we can find you!</figcaption></figure><p>Definitely saves time trying to look for the specified line for any errors.</p><p><em>7. ‘⌘ + R’</em></p><p>This one is similar to the one above, but is used for finding methods:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*cfDNq2bbMk-4yuCXrALr8Q.gif" /><figcaption>We need to make sure our dogs can bark.</figcaption></figure><p>I found this hotkey to be particularly useful when I received errors for a specific method while working on projects with a ton of methods.</p><p><em>8. ‘⌘ + F’ &amp; Replace All</em></p><p>This functionality is simple; it finds the word that you type into the search bar opened with ‘⌘ + F’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*yevqORN3yOcvbM0dzBoLkw.gif" /><figcaption>Notice that the search-word is not case-sensitive.</figcaption></figure><p>Within this command, you can also take advantage of the “Replace All” function. While the ‘⌘ + Ctrl + G’ hotkey serves a similar purpose, it can really slow down Atom if there is a large selection of the element you have chosen. The replace_all option is an alternative to systematically replace all the elements with a new text:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*CQw8R0k59ErP74HQwxE_6g.gif" /><figcaption>Gotta show some love for the wine-lovers too (**You can execute “Replace All” with ‘⌘ + ⏎’)</figcaption></figure><p>I hope that through this blog, you stay more on the keyboard and less on the mouse to save those microseconds of your life while coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd087863fee0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>