<?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 James MacDonald on Medium]]></title>
        <description><![CDATA[Stories by James MacDonald on Medium]]></description>
        <link>https://medium.com/@jamesdavidmacdonald?source=rss-c87f3d4f9d71------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A3FfTs1UD1fN2g0zipb1jg.jpeg</url>
            <title>Stories by James MacDonald on Medium</title>
            <link>https://medium.com/@jamesdavidmacdonald?source=rss-c87f3d4f9d71------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 19:23:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jamesdavidmacdonald/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[To my Cohort, my Companions, and to the Future]]></title>
            <link>https://medium.com/@jamesdavidmacdonald/to-my-cohort-my-companions-and-to-the-future-1e31453f502c?source=rss-c87f3d4f9d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e31453f502c</guid>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[change]]></category>
            <category><![CDATA[reflections]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[James MacDonald]]></dc:creator>
            <pubDate>Mon, 24 Sep 2018 04:37:59 GMT</pubDate>
            <atom:updated>2018-09-24T04:37:59.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*upoJtrK075RgVJiV" /><figcaption>“body of water in front of mountain ranges” by <a href="https://unsplash.com/@mckenzietoyne?utm_source=medium&amp;utm_medium=referral">mckenzie toyne</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There are times when I catch a look at myself and immediately make note of my flaws. “I could be in better shape, I should really dress better, I’m really not eating all that healthy”. The same applies to where I am currently in life. “I should have already found a career, I could be starting a family now, so many people I know are much more accomplished than I am”. It is easy to look back on the decisions I’ve made up until now and see how much more I could have done, how much better a position I could be in if I had been more assertive, had more drive, chosen to put more time into actions that would advance me instead of choosing to indulge in the pleasures of the moment. Television, video games and social media absorbing hour on hour, page after page refreshing to see if there’s anything interesting and if there isn’t, then peruse the next site. Rinse and repeat, telling myself that I would get around to what I wanted to get to later, with “later” slipping further and further away from me until I realized that I had fallen into habits generating the opposite result from what I wanted in the first place. There were times where I couldn’t help but see myself as a failure for having squandered my potential that my family and others in my life had laid out for me, that I had made myself into a person that would not accomplish anything not due to outside factors but due to my own weaknesses.</p><h3>And yet…</h3><p>I currently find myself crossing a new threshold after having chosen to accept the risks, and taken the burdens necessary to make a significant change in the direction I was headed. Outside of that, a fire has begun to burn inside of me, and urge to do more than simply do what is merely required to continue forward, but to seek out the best version of myself possible and carve it out in reality. The temptations of the past do not have the same appeal as they did before, replaced with a pull towards actions that will create tangible results, and develop long term-happiness. Looking out at the world, the way it was, the way it is currently, the way it is becoming, I have taken more and more to the enrichment of not only the physical, but emotional and spiritual nature of the self to become a more complete person. In this time of change there have been several lessons I have taken to heart, treated as mantras that I use to remind myself of the person I want to be, and to act as kindling to the fire acting as my driving force:</p><h3>Love your body as it is, but give it the respect it deserves:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DIr6Oo-ciSW1dACGzYyKwA.jpeg" /></figure><p>Your body is most powerful tool you possess, and it will be your workhorse until the end of your days. For all the work it has done, and all it will do for you, treat it as you would treat a loved one; work to make it the best it can be but give it your unconditional love and acceptance. It is never too late, nobody is too far gone, the beauty of the human body allows every one of us to unlock more potential than we realize. True love means we must struggle against the weights of our feelings of inadequacy, our temptations to indulge in actions that will degrade ourselves, and our doubts and frustrations when we stumble. There is no more precious resource that the flesh we are made of, and the world is a harsh place; we must temper ourselves, consolidate our resolve and our passion, and become a rampart that will weather the storm that is this existence.</p><h3>Surround yourself with those that support you, but will also challenge you:</h3><p>As stated in Proverbs 27:17 “Iron sharpeneth iron; So a man sharpeneth the countenance of his friend.”. The support of a companion that will lift you up when you have your moments of weakness is vital, but it is equally vital to have those close to you able to test your resolve and mettle. Only by engaging in the halls of debate or competing against others can you truly determine if you have developed a sharp wit, a silver tongue or a persistent outlook. Seek out strong and healthy rivalries that will want to see you built up as much as they seek it themselves.</p><h3>Remember where you’ve come from:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0H_f491rLmtVXceE" /><figcaption>“man wearing black top photo” by <a href="https://unsplash.com/@jessedo81?utm_source=medium&amp;utm_medium=referral">jesse orrico</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Nobody is truly here by accident. Every person is here because for thousands upon thousands of years, our ancestors fought to survive and pass on to the next generation. They endured famine, disease, struggled against human and animal, had to overcome nature itself, all in the hopes that they would be able to pass their lineage on a little longer. Many branches in the tree of life have ended, but not yours. You contain the fruits of their struggle and their stories continue with you writing the next page. Learn some of their story and let their memories push you forward, as they would want you to succeed in their name. To quote Gustav Mahler: “ <em>Tradition is not to preserve the ashes, but to pass on the flame.”</em></p><h3>No knowledge is wasted, no lesson invaluable:</h3><p>There exists pressure to only spend time learning what we are told is important, to prioritize what will be used in everyday life or the pursuit of a career and nothing more. Ironic that when access to knowledge is at its most accessible does it seem to reach fewer and fewer ears. Take advantage of what we are given, and seek out a tidbit of information you did not have before. A historical event you did not know, a study you were not aware of, a lesson you were not taught in your education, never stop thinking, learning, experiencing and growing.</p><h3>In Parting…</h3><p>My journey is just beginning, I bear only fresh scars of struggle and am but a follower of the greats that came before me. This step is but one of many that will be taken, harder than some but easier than most. I hope to encourage those who walk the same path as I do, to be worthy of those who have opened the pathway for me, and to open a path for those yet to come.</p><p><em>In loving memory of Terri. I know you are watching over me, and your work, your love, your history will be carried forward. Never forgotten, always loved.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e31453f502c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating A Scroll-to-Fixed Header Bar]]></title>
            <link>https://medium.com/@jamesdavidmacdonald/creating-a-scroll-to-fixed-header-bar-56f808a91dd2?source=rss-c87f3d4f9d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/56f808a91dd2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[James MacDonald]]></dc:creator>
            <pubDate>Fri, 14 Sep 2018 01:28:30 GMT</pubDate>
            <atom:updated>2018-09-14T01:28:30.413Z</atom:updated>
            <content:encoded><![CDATA[<p>When designing your web page, you may come across a situation where you want to have a portion of your content stay with the user as they scroll down your page. Now what if in addition to that, you don’t want your header to interfere with your hero image or other element on the top of your page. Fear not fellow developers, for here is an elegant solution that can be implemented with ease: A scroll-to-fixed header bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUvMkoYPhMjXz6jftgnFGw.png" /><figcaption>State 1: the search bar above is positioned using position: absolute</figcaption></figure><p>In essence what we are doing is transitioning between two states, the first one takes place when the user is scrolled to the top of the page, where our header bar is not visible, and our search bar (pictured above) is below our page title. The second state (below) we make our header bar visible and change our search bar from position: absolute to position: fixed. We then use some CSS transitions to make our change look more natural.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SWNQdfLU6Gr6QVxxESa8AQ.png" /><figcaption>State 2: The header bar is visible and the search bar scrolls with the page.</figcaption></figure><p>Lets take a look at the example I’ve created, first the HTML :</p><pre>&lt;body&gt;</pre><pre>&lt;div class=&quot;wrap&quot; id=&quot;wrap&quot;&gt;</pre><pre>     &lt;header class=&quot;headerBar&quot;&gt;</pre><pre>          &lt;button&gt;Up Top&lt;/button&gt;</pre><pre>          &lt;button&gt;Mid-Town&lt;/button&gt;</pre><pre>          &lt;button&gt;Down Low&lt;/button&gt;</pre><pre>     &lt;/header&gt;</pre><pre>     &lt;h1&gt;Scroll-to-Fixed Elements&lt;/h1&gt;</pre><pre>     &lt;div class=&quot;searchBar&quot;&gt;</pre><pre>          &lt;input type=&quot;text&quot; placeholder=&quot;&quot;&gt;</pre><pre>     &lt;/div&gt;</pre><pre>&lt;/body&gt;</pre><p>Our three main elements are the wrapper, the header and the search bar. As stated before, in our first state our header bar is disabled and the search bar is absolutely positioned. Let’s take a look at the SCSS:</p><pre>.headerBar{</pre><pre><em>position</em>: fixed;</pre><pre><em>top</em>: 0;</pre><pre><em>left</em>: 0;</pre><pre><em>width</em>: 100%;</pre><pre><em>height</em>: 60px;</pre><pre><em>opacity</em>: 0;</pre><pre>.fixSearch &amp;{</pre><pre><em>     background-color</em>: blue;</pre><pre><em>     opacity</em>: 1;</pre><pre>}</pre><pre>.searchBar{</pre><pre><em>position</em>: absolute;</pre><pre><em>top</em>: 300px;</pre><pre><em>left</em>: 20px;</pre><pre><em>right</em>: 20px;</pre><pre>.fixSearch &amp; {</pre><pre><em>     position</em>: fixed;</pre><pre><em>     top</em>: 10px;</pre><pre>}</pre><pre>}</pre><p>Both the header bar and search bar classes have rules apply when one their parent element has a class of fixSearch . This is where our wrapper and a little bit of JavaScript comes in. We want to change between the two states right when the search bar would normally scroll off the page. In the SCSS above we set the set the search bar to be set 300px from the top of its parent element so that will be the trigger point for our event listener:</p><pre>$(&quot;#wrap&quot;).on(&quot;scroll&quot;, <em>function</em> (<em>e</em>) {</pre><pre>if (this.scrollTop &gt; 300) {</pre><pre>     $(&quot;#wrap&quot;).addClass(&quot;fixSearch&quot;);</pre><pre>} else {</pre><pre>     $(&quot;#wrap&quot;).removeClass(&quot;fixSearch&quot;);</pre><pre>}</pre><pre>});</pre><p>Using this basic setup we can adjust the content to suit whatever needs the design requires. We can add/remove navigation buttons from our header to allow ease of navigation for infinite scrolling, display different content as we scroll past it, or ensure consistent access to a search bar or other widget. This solution works on all browsers, although position: fixed does have varying support across devices, more info can be found below:</p><p><a href="http://bradfrost.com/blog/post/fixed-position/">Fixed Positioning in Mobile Browsers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56f808a91dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Putting down some Roots: Understanding Binary Tree Data Structures.]]></title>
            <link>https://medium.com/@jamesdavidmacdonald/putting-down-some-roots-understanding-binary-tree-data-structures-5380b1f72152?source=rss-c87f3d4f9d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/5380b1f72152</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[James MacDonald]]></dc:creator>
            <pubDate>Mon, 06 Aug 2018 04:44:58 GMT</pubDate>
            <atom:updated>2018-08-06T04:50:56.382Z</atom:updated>
            <content:encoded><![CDATA[<h3>Putting Down Some Roots: Understanding Binary Tree Data Structures.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-WN6iByiHsh_jRlzu0D58A.png" /></figure><p>For a lot of people who are beginning their journey into programming, the concept of data structures and their uses does not get a lot of coverage, in part due to the small size and scope of the projects that can be completed in the small time frame. This does, however lead to a lack of foresight down the line because as projects get larger and larger, understanding how a properly implemented data structure can make your end program run much more efficiently. Today we will look at just one method of collection, the Binary Heap.</p><h3>What the Heck is a Binary Heap?</h3><p>A Binary Heap is an implementation of the Heap data structure, a way of creating a priority queue. The best way to visualize a heap would be to imagine you are sitting at a desk, and your job is to file a pile of papers in front of you. You start with the first paper in the pile, then the second, then the third. However during your filing, your boss comes in and says that a big client just called and needs his file done as soon as possible. Naturally, even though the client’s file was added last to your pile, it jumps ahead of all the others and becomes the first one you work on. A heap functions in a similar way, organizing data so that certain elements are given <strong>priority </strong>over others.</p><p>To look at it from the perspective of code, imagine an Array acting as you filing the papers. when you file the paper, you are essentially running the shift() method, removing the first Array element, and new elements are added at the end of the Array. However when an element with a higher priority is added to your array, you want to make sure it is properly arranged so that it will be dealt with sooner than those with lower priority but after those with higher priority.</p><h4>Well why wouldn’t I just use the Sort() method then?</h4><p>That may work for smaller data sets, but imagine for a second your Array had six <strong>million</strong> elements. You add an item that needs to be at position 100, but adding the item to your Array automatically places it at the end of the queue to start, then begins sorting, touching every item in the array at least once. That’s at minimum 6,000,000 touches to insert your one item. By comparison a Binary Tree will only touch a small number of your Array items, likely around 20–40 of them, saving you time you can allocate to other things. How does it do this? Lets take a look at the structure and find out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*aecl0Ux0VabWKQn3xrDi3g.jpeg" /><figcaption>A sample binary max heap</figcaption></figure><p>Now why is this referred to as a Binary Heap? Well, when we look at each number in the tree, hereafter referred to as nodes, they can only have up to two decedents, or children. It is also worthy of note that the largest node, in this case 20, is at the top of the heap, and that every parent node is larger than its children, if it has any. This is known as a Max Heap, where we are always sorting for the larger number. There are variations for the smallest number but we will stick with a max heap for this article.</p><p>Now this may seem like a lot to take in, but when we break down this tree into manageable parts it becomes much clearer how this data structure works.</p><h4>Lets start Growing a Tree!</h4><p>Lets begin with an empty tree and add a single element, the number 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*-STPNFFFY78USjjirKiQZg.jpeg" /></figure><p>Here our tree has only one node, and is therefore the largest, but what happens when we add another number? Lets add the number 5 and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*fr0RfU0IvAtSLbFtyk7OCQ.jpeg" /></figure><p>When we add a new number to the tree, the first place it goes is the very end of our tree. How does it know what side to go on? By default, <strong>any new node will go to the leftmost branch on its level.</strong> However we are not done, as our tree needs to be sorted for the largest node. 5 is larger than 1 the two numbers will trade places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*z6X2i8jtuYu75yWKixS4Fg.jpeg" /></figure><p>Now the tree is sorted and we can add another element. This time we will add the number 3. For those Math experts out there, you&#39;ll already know that 3 is larger than 1 but smaller than 5, so it wont be swapping places with its parent. the number 1 is already taking the left branch so the 3 stays right where it is first placed and no sorting needs to take place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*frq_5yMRvGTDWKXRH6KCRw.jpeg" /></figure><p>Now lets add another number, lets go big or go home here comes the number 14! But wait, our parent can only have up to two children. what do we do now? whenever a row, or level is full, we start a new level using the children of the current index. Let’s ask Beyoncé where we start our new level:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*sXQq0CJYsA7tpa_ZJAfi8g.gif" /></figure><p>Correct! Again whenever possible we use the leftmost node we can, so 14 will start off as the left child of our node 1. Once again we will begin to sort our tree switching 14 and 1, but 14 is also larger than 5 so after switching with 1, 14 and 5 will switch places and 14 will take its place on the throne.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*2YeLyLHwQlOV_EP2BsILfw.jpeg" /><figcaption>Unsorted tree</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*Gto2miBiRNr_qz2qSuk3sw.jpeg" /><figcaption>Sorted tree</figcaption></figure><h4>Traversing a Full Tree.</h4><p>Hopefully by now you can see the process and how we can continuously expand this tree should we keep adding items. We add a new item to the lowest, leftmost open node possible, then compare our new number to its parent. If the new number is larger than its parent the numbers change places, then the process continues until the parent node is larger than the new number, or the new number becomes the topmost node, also known as the root node. As the tree grows larger its becomes apparent how fewer steps are needed to sort to find the largest number. Here is a 5 level tree with 29 nodes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*Ka45XZyxABZdGjXXcNLe2w.jpeg" /></figure><p>Going back to he example from earlier of using a Sort() method, adding a new number would mean we would have to compare our new number to all 29 of the other numbers, but lets see what the most possible steps our tree would have to make. we will add a number larger than the current root, so we will add 95 to the tree. Looking at every parent 95 will have to be compared to there are only 4 comparisons needed in order to sort our tree, a far cry from 29.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*wjipGPHrouCyWOTAWJt5Zg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*Tj8oD-Pk7z2aOU_Dy3X8_A.jpeg" /></figure><h4>Snapping off Some Branches.</h4><p>To finish off, lets take a look at how we remove items from our tree, after all we will need to remove the item from our queue once were done with it. To begin the removal process, we swap our root node with the last node in our tree. Using the full tree we just added to, that number will be 68. We then remove the number 95, his job is done. Now we have 68 as the root node, but it is not the largest number in our tree so we need to sort.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*fsvZlda4mlmxqK6pmQpZPw.jpeg" /></figure><p>We begin comparing 68, the current root node to its two children. Both are larger than 68 but the right branch of our tree is the only one with an open node, as we cannot start a new level until the current one is full. We swap 86 with 68, then continue down our tree, in this case always taking the right branch as there are no open nodes on any left branches. Our 68 ends on the 4th level, with 62 as its child and 86 as the root node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*ZixQYUqTb_Vzz_0Gz3OM7w.jpeg" /></figure><p>This concludes some of the essentials to understanding Binary Tree data structures. In the future we may look at how we would go about coding one of the structures, but for now hopefully you have grasped the concept of how these trees function and can be used to better optimize your sorting. Best of luck to all of you out there, to quote Patrick McKenzie, “Every great developer you know got there by solving problems they were unqualified to solve until they actually did it.”</p><p><em>Thank you to the Binary Tree Visualizer for generating the images used in this article. Give them a look at: </em><a href="http://btv.melezinek.cz/"><em>btv.melezinek.cz</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5380b1f72152" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>