<?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 Jason Lewis on Medium]]></title>
        <description><![CDATA[Stories by Jason Lewis on Medium]]></description>
        <link>https://medium.com/@jasonedlewis?source=rss-15ab073d9a46------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*p2oAYy87L7sA4rQr0_hauw@2x.jpeg</url>
            <title>Stories by Jason Lewis on Medium</title>
            <link>https://medium.com/@jasonedlewis?source=rss-15ab073d9a46------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:04:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jasonedlewis/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[Accessing Your VM from Your Host Machine via SSH]]></title>
            <link>https://medium.com/@jasonedlewis/accessing-your-vm-from-your-host-machine-via-ssh-b6e355bcd526?source=rss-15ab073d9a46------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6e355bcd526</guid>
            <category><![CDATA[bridge-adapter]]></category>
            <category><![CDATA[virtualbox]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[ssh]]></category>
            <dc:creator><![CDATA[Jason Lewis]]></dc:creator>
            <pubDate>Fri, 10 Apr 2020 14:27:22 GMT</pubDate>
            <atom:updated>2020-04-10T15:17:57.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QcCdPjy4Ap4d7k6X" /><figcaption>Photo by <a href="https://unsplash.com/@alexazabache?utm_source=medium&amp;utm_medium=referral">Alex Azabache</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this blog we will be using Oracle’s V<a href="https://www.virtualbox.org/">irtualbox </a>to build our virtual machine (VM). Our goal is: to have a VM that is indistinguishable from a physical machine or device that your network would recognize and assign a IP address, and be able to access this machine from any other machine within the network via an <a href="https://en.wikipedia.org/wiki/Secure_Shell">SSH </a>connection. There will be no port forwarding nor will we be using VirtualBox’s <a href="https://en.wikipedia.org/wiki/Network_address_translation">NAT</a> to translate IPs or ports. So, lets get started…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*hEZIIOncX7Es071Qplg1cg.png" /><figcaption>We are using Virtual box version 6.1</figcaption></figure><p>SETTING UP YOUR VIRTUAL MACHINE (VM)</p><p>Make sure your Virtual box application — the general application and not any particular vm — has a <em>vboxnetx</em> (where <em>x is the number of the virtual box networks configured, eg your first one will be ‘vboxnet0’ ) </em>set up. This can be found at tools/ hamburger /networks where <em>hamburger </em>is just the<em> hamburger style </em>options that looked like a bulleted list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YwmPuAUawqR3wg7L8EbxWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZQNEsLcq140KiX9w1ziJQw.png" /></figure><p>If there is no network, create one with the ‘create+’ tab. You will find the IP address for that network there and an option to enable the DHCP server. In this post I have left this option unchecked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pi_J5e84oW9J33MlqYrXw.png" /></figure><p>Set up VM with your desired ram, memory, ubuntu image and other configurations. Here I have 3 VM created and will be working with the one labeled <em>ubuntu_03.</em></p><p>With the VM highlighted in the Virtual, goto the settings gear at the top of the application and click on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eugMOVhkOraDQO9bFcqiMw.png" /></figure><p>Then goto <strong><em>Settings</em> </strong>➡ <strong>N<em>etworks</em></strong> then, in the <strong><em>Adapter 1</em></strong> tab set the <em>‘Attached to:’ </em>option from, the default <strong><em>NAT </em></strong>➡ <strong><em>Bridged Adapter </em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5SEf5L-gOXZxJTBepB5I4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0K-D6taO31ugpKW5Sohww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFeCZ2XTBqF5b66l2MNgEw.png" /></figure><p>In the ‘Name’ field make sure you select your network — the network that your host computer is running on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UTcZYsBRRHbbMdb2N67Beg.png" /></figure><p>Now goto the<strong><em> ‘Adapter 2’</em></strong> tab</p><pre><strong>Note:</strong><br> Your VM should be off and NOT in saved mode. If it is running or off, but in ‘saved’ mode you will not be able to choose <strong>‘Adapter 2’</strong> and subsequently access and configure it.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mvaiFUvkrdPqUkhHNq8DfA.png" /></figure><p>Enable the network adapter by checking the <strong><em>‘Enable Network Adapter’ </em></strong>box.Choose <strong><em>‘Host-only Adapter’</em></strong> from the <em>‘Attached to:’ </em>tab. Again Make sure the ‘<em>Name’</em> is set to <strong>your host network.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7PHDuP8bnX1BIOWyF7PlTA.png" /></figure><p>Make sure that VirtualBox network is selected, in this case <em>vboxnet0</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MBuXXzjmyInmTZkpcgJsCw.png" /></figure><p>Within Your VM</p><p>Now that you’re all set up , with your network in the correct configuration, you will need to get IP address of your VM. You can do that with the following command (no <em>‘sudo’</em> prefix needed):</p><pre>run:<em><br>host@username ~ ip addr show</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3BgMG7gGLLSCZD0SDGNnPQ.png" /></figure><p>SSH server install to make sure ssh server is running</p><pre>run:<br><em>host@username ~sudo apt install openssh-server </em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNml7GdKN9zRgA-bT7uUPg.png" /></figure><pre>run:<br><em>host@username ~sudo systemctl status ssh</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDckg8_m-_I9cksHRSYKcw.png" /><figcaption>We can see from the green indicators that the SSH server is loaded, active, and running</figcaption></figure><p><strong>Back to the host terminal</strong></p><p>In host terminal enter:</p><pre><br>host@username <em>~</em>ssh vmusername@vmipaddress</pre><p>For example, my VM has a use name of <em>‘box1’</em>, and an IP address of <em>‘10.0.0.40’ </em>so to access that virtual machine I would enter this:</p><pre><em>host@username ~ </em>ssh box1@10.0.0.40</pre><p>Then enter the password for that virtual machine…..</p><p><strong>*Note*</strong> The first time you attempt to access your VM via SSH, you will see the following message:</p><pre><br>host@theNameOfYourMachine ~ % ssh box3@10.0.0.115</pre><pre><em>The authenticity of host ‘10.0.0.115 (10.0.0.115)’ can’t be established.<br>ECDSA key fingerprint is <br>SHA256:n/X/iDontKNoWSomeCamElCaseWieRDSha256GEnEratedTexT.<br>Are you sure you want to continue connecting (yes/no/[fingerprint])?</em></pre><p>Type ‘yes’ and then enter the password for your VM. This should be the only time you will see this message. All subsequent sessions will begin with you being prompted to enter your (VM )password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6AJ726vbENz34MU-" /><figcaption>Photo by <a href="https://unsplash.com/@judebeck?utm_source=medium&amp;utm_medium=referral">Jude Beck</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Getting out of the guest shell</blockquote><p>To exit the ssh session, simply type <strong>‘exit’</strong> or <strong>‘logout’</strong> in the session shell and get back to your host terminal.</p><p>References:</p><ul><li><a href="https://www.virtualbox.org/">Oracle VirtualBox</a></li><li><a href="https://en.wikipedia.org/wiki/Secure_Shell"></a></li><li><a href="https://en.wikipedia.org/wiki/Network_address_translation">Network address translation - Wikipedia</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6e355bcd526" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React & Rails App Roadmap]]></title>
            <link>https://medium.com/@jasonedlewis/react-rails-app-roadmap-cd812d90f70c?source=rss-15ab073d9a46------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd812d90f70c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Jason Lewis]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 17:05:42 GMT</pubDate>
            <atom:updated>2020-01-23T17:05:42.090Z</atom:updated>
            <content:encoded><![CDATA[<h4>Best Practices for Building Your FullStack App</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JB7zVNpPJkxds8sm" /><figcaption>Photo by <a href="https://unsplash.com/@johnmoeses?utm_source=medium&amp;utm_medium=referral">John Moeses Bauan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When planing a build of a full stack application, the first thought is to plan the most efficient and seamless way your front and back ends are going to work together to offer the best user experience. Depending on your bias, front or backend preference, your first task might be to focus on UX by wire framing your site and and thoroughly vetting your user story, or choosing your back end database, designing your API by making sure your of your data structure and relationships and connected properly. As pertinent and logical as these steps are, fully considering the nuances that go into these design decisions could make the construction of your app as easy or hard as you would like. Here are a few of my best practices, born out of projects that started as long string of broad planning that quickly turned into an unmanageable ball of yarn.</p><h3>Build out your User story</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fSsZYCjeG22k7Iwz" /><figcaption>Photo by <a href="https://unsplash.com/@paul_?utm_source=medium&amp;utm_medium=referral">Paul Hanaoka</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>What a user of your app will experience is probably the motivation for your app. You might be designing an app to relieve a pain point that you have/ are experiencing yourself; and usually these are the best ideas. But as clear of a road map for a project that is idea yields, translating each part directly into code is essential, especially the parts that you may not be primary features. This means that you want to consider not only the main features that your app offers, but also the intuitive or “reflex” secondary and tertiary options that a user may be expecting. This could be something as simple as knowing where the contextual ‘home’ page of your app is, that now the home page necessarily, and how the user is always able to get there from anywhere in your app. Is this a button? Is it a swipe? What would you do if you were trying to get back to the ‘main’ page? What event would you be looking to trigger?</p><h3>Wire framing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F1k2jymzMaE1QOEX" /><figcaption>Photo by <a href="https://unsplash.com/@d_mccullough?utm_source=medium&amp;utm_medium=referral">Daniel McCullough</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Now that you have your user story together, wireframe that experience not only considering the layout of the standard button and fields, but those nuanced features that you have considered from your user story. If an event wont be triggered by and DOM node, just note the action and where/how it might take place. consider all pages and their progression , <strong><em>Forwards &amp; Backwards </em></strong>and remember that <em>‘home’ but not ‘HOME’ </em>action that will allow a user the safe place to go back to while learning how to navigate your site.</p><h3>State Storage</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EHD-9Th6lMuEZVl9" /><figcaption>Photo by <a href="https://unsplash.com/@ruchindra?utm_source=medium&amp;utm_medium=referral">Ruchindra Gunasekara</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Local or Store?</p><p>The next design feature is more about utility and access than were things are placed and navigated. We’re talking about where the changes in the state of your models will be “stored” for further manipulation and access. Once learning the nuances and surmounting that deep learning curve that came with learning React- Redux, it is my goto for my apps but with a React frontend. I like to think about Redux akin to the plumbing in your house. These pipes run underground and behind walls but allow you to put a toilet or sink virtually anywhere in your house (head back to wire framing before putting a toilet in your kitchen). Redux has the same power allowing you to <em>connect </em>any React component; class or functional, or JS file to the <em>Redux Store </em>by simply importing:</p><pre>import {Connect } from ‘react-redux&#39;</pre><p>into the component that will need the data and</p><pre>const mapStateToProps = props =&gt;{</pre><pre>return {<br>// this will bring in all of the users from the users reducer</pre><pre>   users: state.users.all</pre><pre>}</pre><pre>}<br>export default connect({props}, { dispatch function(s) })(name of component);</pre><p>thats it! Redux is a powerful tool that flattens the hierarchical pyramid of parent-child relationships — the only linear way to pass props — and allows not only for props to accessed any where, but these props’ state and be changed any where with these changes being represented globally across your app. If your state needs are not as complex, you may be fine with keeping state stored locally and communicate with your data base from the relevant component(s).</p><blockquote>Backend</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*NEcHQR9IiQDoXovwSsYWvA.png" /></figure><p>Setting up your API and authorization/authentication in your backend are going to follow some pretty standard practices. The main models will stand out clearly and so will most of the relationships between them. Setting up RESTful routes and a few custom ones might also be or become more clear as you get started hashing them out. Getting the data will be pretty straightforward as these pieces have come together. Outside of those main setup goals, here are somethings that have make my experiences a bit easier.</p><h3>Serializers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7JZ2WPvBFaQfBjvQT2WKNw.png" /></figure><p>If you’ve use a <a href="https://api.rubyonrails.org/">Ruby on Rails</a> you have probably heard of<a href="https://github.com/rails-api/active_model_serializers"> serializers</a>. If you haven’t, serializers provide a way to render your API in two unique ways:</p><ol><li>It allows for you to include and/or exclude the attributes you want for a specific models. For example, when you instantiate and instance of a model it usually comes with information like :</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UVN09lNnoWq2RwqfnKR96Q.png" /></figure><p>Usually attributes like<em> created_at </em>and <em>updated_at</em> are not initially that valuable, especially because these values are the same. In addition, as you update and instance or an attribute of that instance, you con see the <em>updated_at </em>in your rails console.</p><p>2. There is no great relief as a programmer, that relies on one or more APIs, than not having to sorting and sifting through complex or stratified object to manipulate. Serializers, if set up properly, allows you fetch from your API in a way that the response will contain all the pertinent information relative to a model and/or its relationships. I have used Fast JSON and other Ruby serializer gems, and they are great but require a quick tutorial. With most of my Rails API builds though, I take the time to set up my serializers by hand. Having a tailor-made JSON http response is where the ROI (return on investment) is seen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mGN1kJ0cM_M-y9kmuwqicA.png" /></figure><h3>Seeding Data</h3><p>You will need to seed data to test the connections of your models, relationships and to see what your API is looking like. If you decided to employ serializers in your code, your API will also show if your data is filtering as expected and if your relationships are rendering right. But don’t over seed. Over seeding may seem innocuous but too much data can be distracting when you’re working on your backend and you have too many instances seeded and their attributes become clouded. Seed enough to verify connections but leave enough room to test your code.</p><h3>Frontend</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*I77gQCtn2vBiqZOwyDNu_A.png" /></figure><p>Building out your front end with React can go a long way depending on how your data needs to disbursed, rendered, and updated. One of the consequences — good or bad — for this can be very complex familiar trees where components can <em>only</em> receive data through parental lineage (parent, grandparents, etc ) and <em>only</em> send data back if <em>allowed</em> via a callback function.</p><h3>Separate Utility, Nodes, &amp; Logic</h3><p>It is natural, and often healthy to fetch data, write the logic to display the desired data, and to render that data to view starting off in your logic file. Once this file starts to get a bit too large you should probably start to plan on ‘<em>separating concerns’, eg </em>moving the components that have different functionality into their own file(s) or folder(s). After separation, simply exporting these files into this file that needs it won’t change your apps functionality. your fetch fetch and other utility files to another folder do so systematically. Let get into how I separate my files when working.</p><blockquote>Logic</blockquote><p>The head quarters for my code; where most of the logic and functionality is called from lives in my<em> ‘App.js’ </em>file. This is where my project usually begins and when enough of the functionality of my app is built out &amp; <em>separation of concerns</em> are in full gear, this is where my logic remains.</p><blockquote>Utility Files</blockquote><p>What do I mean? Lets say your doing a fetch and you have your fetch in your App.js class. Once your fetch has successfully returned the data you want move that function to the utility file, reference it and then test to see that it returns the same data. This is a good way to have your utilities out of the away keeping your App.js or whatever you main file for logic clean and clutter-free so that you can keep your logic … Logical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1oyvi6ayGgKReb1g8p3-mw.png" /></figure><blockquote>Nodes</blockquote><p>Nodes are the html-derived — and in the case of React — the JSX blocks that build the components that are rendered. Although these can be either class or functional components, if they do not need to hold the state of that components actions, it might be best to have that as a functional component. Regardless of your choice, import and refer to it as needed and try to keep as much of it out of your logic based component as possible. Here is a case where is didn’t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KBYr3Z2cxjRoXT4YcNeoHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5ec8ezTJ1i0dILRQYw2Yw.png" /></figure><p>Conclusion:</p><p>As exciting is it is to get going on a project and as clear as you may be on what you want to build and how you want to build it, it never hurts to do a bit of extra planning. This planning is an on going process that is ok to alter and deviate from. I hoped this article has encouraged you to go deeper in your planning, outside of how you app with convey and facilitate that idea, and the architecture of the technologies that you are going to use to make your wonderful idea come to life!!</p><p>How do you plan out your builds? I love to know below!</p><p>REFERENCES:</p><ul><li><a href="https://github.com/rails-api/active_model_serializers">GitHub - rails-api/active_model_serializers: ActiveModel::Serializer implementation and Rails hooks</a></li><li><a href="https://api.rubyonrails.org/">Ruby on Rails API</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd812d90f70c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Axios.all with Rails API]]></title>
            <link>https://medium.com/@jasonedlewis/axios-all-with-rails-api-18991e1913ed?source=rss-15ab073d9a46------2</link>
            <guid isPermaLink="false">https://medium.com/p/18991e1913ed</guid>
            <dc:creator><![CDATA[Jason Lewis]]></dc:creator>
            <pubDate>Thu, 16 Jan 2020 10:28:52 GMT</pubDate>
            <atom:updated>2020-01-16T10:28:52.599Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/axios/axios">Axios</a> is a promise based HTTP client for the browser and <a href="https://nodejs.org/en/">Node.js</a>*. It intercepts requests and responses submitted and returned from http calls, and transforms request and response data automatically to JSON. Axios also cancels err request and has client side support for protecting against <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">XSRF</a> (also known as <strong>one-click attack</strong> or <strong>session riding).</strong></p><p>Axios can be accessed by download via <em>npm</em>, <em>yarn</em> or <em>bower</em>. If you prefer CDN there is a link available to add to your script tag. is After installing Axios:</p><pre>$ npm install axios</pre><p>or:</p><pre>$ yarn add axios</pre><p>or:</p><pre>$ bower install axios</pre><p>or:</p><pre>&lt;script src=&quot;https://unpkg.com/axios/dist/axios.min.js&quot;&gt;&lt;/script&gt;</pre><p>then importing it into the JS file you plan to execute your fetches in:</p><pre>import axios from &quot;axios&quot;;</pre><p>You’re ready to go!</p><blockquote>Let’s Fetch!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C2I86HuabIm647OY" /><figcaption>axios.get() Photo by <a href="https://unsplash.com/@robfuller?utm_source=medium&amp;utm_medium=referral">Rob Fuller</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><em>CommonJS vs Axios API</em></blockquote><p><em>The CommonJS Way</em></p><p>Axios’ http request can be made in two ways; in a <em>CommonJS</em> way or as an <em>Axios API</em>. The CommonJS has a nice shorthand syntax combines the familiarity of calling the methods of a POJO (plain old javaScript Object) and a sprinkle of magic. RESTful API calls are initiated by simply appending <strong><em>Axios</em></strong><em> </em>with the desired<strong> <em>http verb </em></strong><em>— verbs that are inherent methods of the Axios object.</em></p><pre>axios.get(&#39;<a href="http://localhost:3000/">http://localhost:3000/</a>&#39;)</pre><pre>axios.post(&#39;<a href="http://localhost:3000/">http://localhost:3000/</a>signup&#39;, {signupObj})</pre><pre>axios.patch(&#39;<a href="http://localhost:3000/">http://localhost:3000/</a>:id&#39;, {patchObj})</pre><pre>axios.delete(&#39;<a href="http://localhost:3000/">http://localhost:3000/</a>users/:id&#39;)</pre><p><em>Axios API Calls</em></p><p>The Axios API is a function that takes an object in as an argument. This object contains: the method (http verb), url, and data**, action permitting.</p><pre>axios({<br>  method: &#39;POST&#39;,<br>  url: &#39;/user/29&#39;,<br>  data: {<br>    firstName: &#39;John&#39;,<br>    lastName: &#39;Doe&#39;<br>});</pre><p>This syntax should look very familiar to a standard javaScript fetch request, with the notable difference being that the url is in the object as opposed to being passed in as its own argument. The response data can be accessed with a simple:</p><pre>.then(data =&gt; someFunction(data))</pre><p>This works for both CommonJS and Axios API calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HasZufXkJQnLtGPv_WIKRA.png" /></figure><p>Axios has an exhaustive list of method aliases and instance method that allow for creative and efficient use of this http client. In my project — a tutoring app where the administrator manages the relationship between the students instructors and their sessions- running a concurrent request that created a new session between student and instructor as well as decrementing the instructor’s hours every time a student was assigned to her/him.</p><p><em>A little background on my app’s buildout:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IjqlYAefQhExsy_Ro561uA.png" /></figure><p><em>Axios.all()</em>, the concurrent request function, was a perfect situation. The .all() takes in an array as an argument. This array is comprised of multiple http request where the response data is accessed once the last request has returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8lBiKdHsJXBk4n5VRY81bQ.png" /><figcaption>Here I use the axios.all( ) to create session and decrement instructors hours</figcaption></figure><blockquote>But what HAPPENED??</blockquote><p>Because I am using a Rails backend it seemed as though multiple request to the same server was something that Rails could not handle…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*IHxRM7BjZk1q6NACCxb87Q.png" /></figure><p>As we see above, it appears that the first request; to update the instructor’s hours triggered a</p><pre>500 Internal Server Error</pre><p>halting the creation of the session and a successful response to either request.</p><p>After reversing the order of the requests and even initiating Axios.all( ) with a single fetch element in the array as an argument, which worked by the way, I could not get the .all() method to work.</p><blockquote>What to do now…</blockquote><p>Still needing the coordinated request and response from both fetches, I decided to make the <em>patch</em> request to the ‘…/instructors’ end point contingent on the successful response and creation of the session. Once both request returned successful their respective data would be dispatched to the redux store prompting the updating of the react components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PNo43dkmWQ9MUVw5tU1Xdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qz-9P4cCzb0IxCAG53PZqQ.png" /></figure><p>This resulted in an ad hoc version of axios.all( ) that helped me achieve the result I desired. But was there something I am missing with axios.all( ) using a Rails backend?</p><p>I’d love to know your experience using Axios with your full stack apps or API’s</p><h3>References</h3><p>*Axions Github</p><p>** (analogous to the body object in a standard JS POST/PATCH fetch request)</p><ul><li><a href="https://github.com/axios/axios">GitHub - axios/axios: Promise based HTTP client for the browser and node.js</a></li><li><a href="https://nodejs.org/en/">Node.js - Run JavaScript Everywhere</a></li><li><a href="https://en.wikipedia.org/wiki/Cross-site_request_forgery">Cross-site request forgery - Wikipedia</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18991e1913ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How can Bitcoin be Money?]]></title>
            <link>https://medium.com/@jasonedlewis/how-can-bitcoin-be-money-1b48370e7625?source=rss-15ab073d9a46------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b48370e7625</guid>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Jason Lewis]]></dc:creator>
            <pubDate>Thu, 19 Sep 2019 18:54:46 GMT</pubDate>
            <atom:updated>2019-09-19T18:54:46.393Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Six Case for Bitcoin as A Global Currency</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z4ny7ASmdK88ShiU" /><figcaption>Photo by <a href="https://unsplash.com/@wildbook?utm_source=medium&amp;utm_medium=referral">Dmitry Demidko</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>Wait, What is Bitcoin?</strong></blockquote><p>Bitcoin is the world most noteworthy and most popular cryptocurrency. Released in 2009 by the pseudonymous <a href="https://en.bitcoin.it/wiki/Satoshi_Nakamoto">Satotshi Nakamoto</a> — no one is sure of his/ her/ they’er identity, Bitcoin has been at the nexus of technology and currency for the past decade. Seen by some as a seminal means to a global currency, Bitcoin has its equal share of detractors. Opponents of Bitcoin have labeled it from everything from a Ponzi-scheme and the latest version of snake oil, to the digital equivalent to the black market economy that facilitates the most unscrupulous of activities.</p><p>Proponents of Bitcoin view Bitcoin as a liberation of money and accept this freedom of finances, (almost) free of transaction — and absolutely free of boarders — as both the future of money and a means of transaction that could revive fair trade and a resurgence of the parter system as we once knew it, way back when….</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUm63OQz3bjo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUm63OQz3bjo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FUm63OQz3bjo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e7f6843fde663249d070ecbc6e62b44/href">https://medium.com/media/5e7f6843fde663249d070ecbc6e62b44/href</a></iframe><blockquote><strong>Cryptocurrency ?</strong></blockquote><p>A <em>Cryptocurrency</em><strong> </strong>is a digital asset, or currency, whose existence and transactions are secured by cryptography. This powerful security tool makes it possible to make trustless ;no needed to rely on trust, transactions of these digital assets over the internet. You are probably reading this book because of your interest in the cryptocurrency, bitcoin, which is the most popular as of the time of this writing.</p><p>A good starting place to understand cryptocurrencies is by comparing it to something that we are all familiar with, money. <strong><em>Money</em></strong>, in its many distinct forms, possesses unique characteristics that are agreed upon and recognized by the masses that makes it an accepted medium of transfer. It has been common place for hundreds of years now to acquire goods and services with the value backed physical instrument, no matter what form it was in. Just as technology has had its hand on changing, for better or worse, most things in our lives, the way we transact has not eluded technology’s influence.</p><p>The idea of transferring value, via a digital medium, is not a new one. Digital currencies have tried and failed in the past, but have gained monumental traction with the 2009 release of <a href="https://bitcoin.org/en/"><strong><em>Bitcoin</em></strong></a>. Since then a plethora of other cryptocurrencies, or <strong><em>Alt-coins</em></strong>, have come on the scene. These Alt-coins are akin to bitcoin in that they use the <strong><em>blockchain </em></strong>technology as an integral component of their architecture, but are quite different in structure and function .</p><h3><strong>Is Bitcoin currency?</strong></h3><p>Taking a quick look at the headlines it is not easy to tell. If you read the headlines that taut bitcoins incredible growth and the speculation around it, it would appear to be a traded commodity. But flipping the pages to the international business section of that same publication might change your mind.</p><p>Where do cryptocurrencies like bitcoin derive their value? Money’s value was linked directly to gold <strong>(<em>The Gold Standard</em></strong>) until the 1970s. Its current valuation is complicated, but a large part of it is trust. What backing or trust is there for cryptocurrencies, even the most popular, bitcoin?</p><p>This book will go into a brief history of money, bitcoin, and the common and distinct components that give both their value. It will also give us ideas about their value, use cases and how the technology that underly them have the power to drastically change how we do things.</p><blockquote><strong>1. Fungibility</strong></blockquote><p>For something to be fungible it has to be recognizable for its overall value and have not more value, individually, than an item of the same composition. So, for example, all US notes/bills, regardless of their denomination, are fungible; a $20 bill from Bill Gates will not buy you any more groceries than a $20 bill out of a random ATM. Equally, one piece of gold of the same weight and percent purity has equal value of any other piece of gold of the same weight and purity, regardless of where each piece was minded. Without fungibility, you cannot have a viable and stable currency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1IAHa1tiTLyMHo3F" /><figcaption>Photo by <a href="https://unsplash.com/@odla?utm_source=medium&amp;utm_medium=referral">Aldo Schumann</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>2. Divisibility</strong></blockquote><p>Imagine grocery shopping with a brick of gold. Not only would it be back breaking lugging that heavy piece of metal around the store, but how would the cashier make change of it after she rang up your $100 of goods? Even if we used another item of value, lets say a shell, as Joshua Seims points out in <a href="http://metastablecapital.com/what-drives-the-value-of-crypto-currencies/">‘<em>What Drives the Value of Crypto Currencies?</em> ‘ </a>, <strong>” </strong>What if you want to buy something that costs less than one shell? They don’t divide easily.<strong>”</strong></p><p>In America, the USD is only has a five fold range of divisibility; our greatest denomination is the $100 bill and our lowest is $0.01. This may not seem like a small range because most everyday purchases can be handled with a manageable amount of tangible currency, but try buying something in the five-figure range with cash… Pretty inconvenient.</p><p>Bitcoin, on the other hand, because of its significant <a href="https://coinmarketcap.com/currencies/bitcoin/">price </a>and eight fold divisibility, called a <a href="https://en.bitcoin.it/wiki/Satoshi_(unit)">“Satoshi” </a>(0.00000001 BTC) , just a few bitcoin can be used to make substantial purchase</p><p>Being able to have identical, producible, yet non-manipulatable denominations of a greater currency that is appropriate for the purchase of / can withstand high volumes of trade, is characteristic that is paramount in a would-be viable currency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8m9Fahc9gd4tDwr5" /><figcaption>Photo by <a href="https://unsplash.com/@joaosilas?utm_source=medium&amp;utm_medium=referral">João Silas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>3. Record of account</strong></blockquote><p>Having a basic unit to be able to establish market value for goods and services is what a record of value does. For us to agree on how much a tomato or bag of rice should cost, we first have to agree on the value within the proposed unit of value. If I do not believe in the dollar bill and it value as 100 pennies, we will have no basis on which to find and determine value within an ecosystem. The bitcoin community and its rate of adoption is evidence that, along with the markets its used in, of its fidelity as a secure record of account. As long as the community remains stable and the price grows less volatile, I think the the case for Bitcoin as a good record of account remains strong.</p><blockquote><strong>4. Store of value</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ca9t_q7JOrq3E2Me" /><figcaption>Photo by <a href="https://unsplash.com/@munz0?utm_source=medium&amp;utm_medium=referral">Aaron Munoz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>There was a time when every piece of currency in circulation represented an equal part of gold that was stored in the national treasury. The dollar bills that were being passed around through commerce were back by the value that was <em>stored </em>in its gold representative. A gold bar would buy a common or luxury good 200 years ago just as it would, more indirectly, today. Therefore the value store is not just wide adoption and belief about also in the instruments temporal, long term, or generational weigh in value. Vacating the Gold Standard in 1976 under president Nixon, the US dollar and subsequent currencies that are based off of it, were primed for inflation; as an infinite supply of currency can be printed.</p><p>Bitcoin, with its finite supply of 21 million “coins” is by nature <em>deflationary. </em>This allows for a secure store of value, and relative to inflationary assets, appreciation absent of any direct market influences. This fact, amongst others have cause some Bitcoin enthusiasts to refer to it as <em>“Digital Gold”.</em></p><blockquote><strong>5. Durability</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*wRfb_djt4kdfu0dDVUnUbQ.jpeg" /><figcaption>Source: US Federal Reserve</figcaption></figure><p>I have had some US notes that have seen better days. I have even been passed bills that had a ripped corner or were marked up a bit. Although paper is not the first material you think of when you think of a tough material, there are bills, the $100 for instance, that has the durability to stay in circulation for up to 15 years*.</p><p>As stated above, passing pieces of chipped shells around in an economy would not prove prudent. A case for the durability of a currency is not hard to make. Although this is probably the least compelling case on this list as fiat currency is slowly but sure being replaced by digital transactions, I have gotten my fair share of ripped, taped, and partial bills to realize that the issues with fiat durability is not one to be completely ignored. Bitcoin, as a digital asset, obvious evades these issues completely.</p><blockquote><strong>6. Portability</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R6pYxD6v1auUUskr" /><figcaption>Photo by <a href="https://unsplash.com/@davidshares?utm_source=medium&amp;utm_medium=referral">David Shares</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For a value to be transferred physically, the instrument of transfer has to be , not only durable, but manageable. The US dollar weighs approximately one gram, so passing it is effortless, for even a small child. Bottom line is: the negotiations of the transaction should be the focus, being limited by the physical passing of the instrument should not be a barrier for trade. Bitcoin is recognized world wide and can be exchanged into most local currencies without a massive reduction/adjustment in conversion amounts.</p><p>So, is Bitcoin <em>“Money” </em>? Many who take advantage of access to digital transitions and recognize the fiat nature of the USD are still reluctant to fully commit to the idea of fully converting to a digital currency. Those who embrace the ways technology has democratized the way that many things are done, find adopting a digital currency as “the” national, or even global, currency a natural consequence of progress. So, is Bitcoin fit enough to be a currency? Does it have the backing to be the worlds first global currency? We will have to wait to see what the world decides.</p><h3>References</h3><p><a href="http://www.coinmarketcap.com/">www.coinmarketcap.com</a></p><ul><li><a href="http://metastablecapital.com/what-drives-the-value-of-crypto-currencies/">What Drives the Value of Crypto Currencies?</a></li><li><a href="https://bitcoin.org/en/">Bitcoin - Open source P2P money</a></li><li><a href="https://en.bitcoin.it/wiki/Satoshi_(unit)">Satoshi (unit)</a></li></ul><p><a href="https://en.bitcoin.it/wiki/Satoshi_Nakamoto">https://en.bitcoin.it/wiki/Satoshi_Nakamoto</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b48370e7625" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Little Help Traversing the DOM]]></title>
            <link>https://medium.com/swlh/a-little-help-traversing-the-dom-22c6be71218d?source=rss-15ab073d9a46------2</link>
            <guid isPermaLink="false">https://medium.com/p/22c6be71218d</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jason Lewis]]></dc:creator>
            <pubDate>Tue, 27 Aug 2019 20:28:47 GMT</pubDate>
            <atom:updated>2019-08-29T07:39:41.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xj4H0NUTZJrDzOnp" /><figcaption>Photo by <a href="https://unsplash.com/@alicekat?utm_source=medium&amp;utm_medium=referral">Alice Donovan Rouse</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Working with JavaScript in the <em>Document Object Model, or </em>DOM , <em>can</em> be chore. In traversing the branches of this inverted tree, some feel like the acrobatic squirrel in its playful domain, while others are left feeling like the cat waiting for the fireman . Yet , for the chosen few, the DOM’s veiny structure is more like a road map to a bunch of small, but, valuable treasures. When found, these nuggets that can be manipulated to glitter like gold, or just be just enough raw material to get some RESTful CRUD going. Regardless of your exploratory prowess; if you have a good hardhat and a well calibrated compass, this trek is worth the adventure!</p><h3>Let’s Begin the Journey!!!</h3><p>In this post I will not only be your tour guide, I will also provide you with the perfect equipment you need to clear the path, smooth out the terrain, and make the DOM feel like one of the trees in your backyard .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*svf2swUTu2zfxqyM3JmXBg.jpeg" /><figcaption>travelling mac fraggle rock</figcaption></figure><pre><strong>             DOCUMENT.QUERYSELECTOR/ALL(&#39;ELEMENT&#39;)</strong></pre><p>By far the two of the most helpful; and thus most frequently used methods for beginning the exploration of the DOM is to ask , or <em>query, </em>the document by selecting for a specific element or node, granted, you know what element you’re looking for. Once you have the abbreviated tag name of the element(s) can just ask the document to find it /them by :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uFOfSuyZQUSOavrEVD-HMA.png" /></figure><pre><strong>    LET&#39;S SELCT ALL OF THE HEADERS (&#39;h1&#39; ....&#39;h6&#39;) ON THE PAGE</strong></pre><p>As powerful as these methods are, they can be tedious to call, over, and over, and over…… <em>again. </em>This leads the prudent coder to save the queried ‘<em>nugget’ </em>in a variable, for later use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdFcdQlWfJJt-0zQKtEW1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4PD4Jfjo-cZlsYHVliEdbA.png" /></figure><p><strong>S</strong>o if it’s good, useful, and <strong><em>DRY </em></strong>to store retrieved elements in a variable; how much more useful might it be to store our little search engines in their own ‘<em>variables’, </em>or<em> ‘functions’ and use those functions to </em><strong><em>C</em></strong>reate, <strong><em>R</em></strong>ead (or locate), <strong><em>E</em></strong>dit, and or <strong><em>D</em></strong>elete the elements of our choice<em>?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*4i1Y-74HrM1jFvLiXVvhbw.jpeg" /></figure><p>Below I have written a few functions that have helped me be a bit more efficient when exploring the DOM. These are not, by far, functions that will facilitate every DOM action that you might be looking to do. It’s not meant to be. This list is meant to inspire you to explore more efficient ways to traverse the DOM with your own set of techniques and methods.</p><h3>Searching……..</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kEHFtPPQl8FYZKZe" /><figcaption>Photo by <a href="https://unsplash.com/@evgenit?utm_source=medium&amp;utm_medium=referral">Evgeni Tcherkasski</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>Find element by element type:</strong></blockquote><pre><strong><em>const</em></strong> <strong>findEle</strong> =(ele) =&gt;{  </pre><pre><strong>return</strong> document.querySelector(ele); </pre><pre>}<br><strong>ex:</strong> let firstDiv<strong> = findEle(&#39;div&#39;)</strong></pre><blockquote><strong><em>Find all of one element type:</em></strong></blockquote><pre><strong><em>const</em> findAllEle </strong>=(ele) =&gt;{</pre><pre><strong>return</strong> document.querySelectorAll(ele);</pre><pre>}<br><strong>ex:</strong> let theHeaders = <strong>findAllEle(&#39;header&#39;)</strong></pre><h3>Lets Create Some Stuff</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5oto7GXgVvu5bhNU" /><figcaption>Photo by <a href="https://unsplash.com/@alicegrace?utm_source=medium&amp;utm_medium=referral">Alice Achterhof</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><strong>Create New element:</strong></blockquote><pre><strong><em>const</em> newEle</strong> =(ele) =&gt;{<br><strong>return </strong>document.createElement(ele); <br>}</pre><pre><strong>ex: </strong>let newDiv = <strong>newEle(&#39;div&#39;);</strong></pre><pre><strong>ex:</strong><em>  let mainPara = </em><strong><em>newEle(&#39;p&#39;)</em></strong></pre><blockquote><strong><em>Adding Text to Element:</em></strong></blockquote><pre><strong><em>const</em> says</strong> = (who, saidWhat) =&gt; {</pre><pre><strong>return</strong> who.innerText = &quot;saidWhat&quot; ;</pre><pre>}<br><strong>ex: says(mainPara, &#39;</strong>it was the best of times... It was the worst of times&#39;<strong>)</strong></pre><blockquote><strong>Adding the Child to the Parent element:</strong></blockquote><pre><strong>const adoptThisChild </strong>= (parent, child)=&gt;{ <br><strong>return </strong>parent.appendChild(child); <br>}</pre><pre><strong>ex: adoptThisChild(mainPara, newDiv)</strong></pre><p>The functions above have helped expedite my journey in, through and all around the DOM. It was not an exhaustive list; nor was it meant to be. This list is meant to inspire you to explore more efficient ways to traverse the DOM and write some useful functions of your own. In my constant pursuit to be a better programmer, Im always thinking of ways to keep my code DRY. As programmers our goals should be focused on having fun and being creative with our code, not be distracted by the verbose and often nuanced way that JavaScript operates. My hope is that this has inspired you to take one more foot down that path.</p><p>How do you traverse the DOM? What functions , shortcuts do you use? I love for you to share in the comments below!! Happy Coding!!</p><blockquote>Resources:</blockquote><p>The DOM</p><p><a href="https://www.w3schools.com/js/js_htmldom.asp">JavaScript HTML DOM</a></p><p>JavaScript Arrow Functions</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">Arrow function expressions - JavaScript | MDN</a></li><li><a href="https://medium.com/free-code-camp/learn-es6-the-dope-way-part-ii-arrow-functions-and-the-this-keyword-381ac7a32881">Learn ES6 The Dope Way Part II: Arrow functions and the ‘this’ keyword</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22c6be71218d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/a-little-help-traversing-the-dom-22c6be71218d">A Little Help Traversing the DOM</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[Ruby Helper Methods]]></title>
            <link>https://medium.com/@jasonedlewis/ruby-helper-methods-8dab626b39a?source=rss-15ab073d9a46------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dab626b39a</guid>
            <dc:creator><![CDATA[Jason Lewis]]></dc:creator>
            <pubDate>Mon, 05 Aug 2019 17:18:54 GMT</pubDate>
            <atom:updated>2019-08-06T23:28:59.789Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iWJs2JNKCzZ76EW6" /><figcaption>Photo by <a href="https://unsplash.com/@jonnysplsh?utm_source=medium&amp;utm_medium=referral">Jonny Caspari</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When a programmer reaches for a method to employ in their code, the process for finding the ‘right one for the job’ is usually done in just a few steps that might look similar to this:</p><ul><li>what is the source of the data that I’m looking to manipulate?</li><li>which class is this data stored in?</li><li>does the function need to be a C<em>lass </em>or <em>instance</em> method?</li><li>Do I need to iterate over this data? =&gt; <strong><em>Enumerables</em></strong><em> (each/map/select)</em></li><li>Do I need a return value of ‘true’ or ‘false’ =&gt; <strong><em>Booleans</em></strong> (<em>?/ includes?/ empty?/ etc)</em></li></ul><blockquote>And after things are narrowed down from there…..</blockquote><ul><li><em>Will one of the inherent methods suffice? Do I need a couple, or maybe a few?</em></li></ul><p>Reading this list probably took twice the time a programmer may actually need to make their decision and design a plan of attack. This is, in part, due to the fact that the method choice; their mechanism and the classes they operate on, are <em>clearly defined</em>.</p><h3>So, w<strong><em>hat defines a Helper Method ?</em></strong></h3><p>The best definition that I found for a helper method is from <a href="https://teamtreehouse.com/community/what-exactly-is-a-helper-method">Manav’s team treehouse post</a> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Puc8ft7JMMbAazn-lCQNXQ.png" /></figure><p>As concise as Manav’s definition is, it’s high-level, a bit <em>too precise, rarther narrow, </em>and frankly too<em> techy </em>. This is because; as powerful and dehumidifying as <em>helper functions</em> can be, defining or identifying one is a fluid task , one that can only be done within the context of the situation, and what <strong><em>help </em></strong>they are providing.</p><p>Now that I have convinced you of the ambiguity of defining a <strong><em>HelperMethod</em></strong>, I have taken the liberty of making my own list of <strong><em>methods(.class == Helper) </em></strong>, and I’ll be defining them along the way. The convention by which they will be classified is simple; the context in which they have helped me keep my code DRY, light weight, neat, and logical.</p><blockquote>Lets begin:</blockquote><h4><strong>1. Keeping it RAW</strong></h4><p>“Ooo Baby I like it raw!!!”~ Ol’ Dirty Bastard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9Cv0QhB3ZzM7P0Jy" /><figcaption>Photo by <a href="https://unsplash.com/@kate5oh3?utm_source=medium&amp;utm_medium=referral">Katie Smith</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When extracting — or<em> select(ing) </em>— vital information from a data set, it might behoove you to keep it general… or RAW. If you planned on having chicken five days this week, would you buy chicken breast from the butcher — that you could cook five different ways — or a ten-piece from Popeyes? Well if you wanted the same redundant taste, you might opt for Popeyes. However, if you wanted some variety, you might head to the local butcher and get it by the pound.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZfwdBn9y2I6KuiOBlcehRQ.png" /><figcaption>when it comes to naming my methods, “def info” is my raw method.</figcaption></figure><p>In this example, we have an app that aggregates reviews for restaurants from its customers. The deliverables called for a host of information; information to be derived and filtered from Review.class. We want details like: the restaurants under reviewed and the customers who left them. This information could be accessed from the source each and every time it was needed, but that wouldn’t be most efficient. Each method is coded to extract the specific data needed, but instead of multiple trips to the butcher, we just went back to the fridge: the<strong> [def info]</strong> method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6tkgw_TK92KDfgHWrq1-A.png" /></figure><h4>2. Keeping Things D.R.Y</h4><p>“Dehydrate”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YRXLjUUSWeN40YDo" /><figcaption>Photo by <a href="https://unsplash.com/@ripato?utm_source=medium&amp;utm_medium=referral">Ricardo Gomez Angel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Don’t Repeat Yourself</strong></p><p>If you’re <em>HERE</em>, reading an article about <em>Ruby Helper Methods,</em> I’m 99% sure that you’ve <em>at least </em>heard of — and are currently doing your best <em>TO</em>, keep your code — DRY. As our friend Manav so eloquently states above, helper methods can help our code stay nice and parched by writing a set of instructions that, when, nestled in a method block, can complete repetitive task simply by adding your input and calling the method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGI-x91To41LPN6WMqtp3w.png" /><figcaption>Now we can add 14 to any num(ber)!</figcaption></figure><h4>3. Escaping ‘Out of Scope’</h4><p>“Let me out…..please”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jgl_7mWqD1CbPZoA" /><figcaption>Photo by <a href="https://unsplash.com/@chrisrossharris?utm_source=medium&amp;utm_medium=referral">Christopher Harris</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When I started with functional programming (JavaScript, I miss you 😘) , the early stages of my coding journey covered methods or functions, right after the data types and variables. One of the more difficult concepts for me to resolve was: extracting the value that the method/function had processed for me and having it available for use elsewhere in my code. As I’ve matured in the discipline, I have realized that <em>Escaping</em> (the value I’d computed) ‘<em>Out of the Scope’ </em>of the method was not the most profound thing that had <em>escaped </em>me. But that is for another post….. I digress.</p><p>One of the most powerful ways I learned to overcome this challenge is to save the method to a variable or to use the method <em>ITSELF </em>as the <strong>variable.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mmaj4A29Bm8dgzZl43XrQ.png" /><figcaption>“Hashes + Internet “ Eric Kim Flatiron School 7/2019</figcaption></figure><p>In the lines above we can see that the limitation of accessing the returned value of each method is totally avoided by setting said value to a variable. This technique not only preserves the value processed and returned by the method, it also makes it accessible in the global scope of this page of code. The above is a high fidelity chain of processes used to provide a custom experience for the user of this proprietary application, which has data secured in an API.</p><p>Ruby helper methods, like proteins in biological systems, can take the many shapes and perform many functions. We’ve seen them nestled neatly in classes and allowed to accessed (inherited ) elsewhere in the program. We also enjoy the ability to write them ourselves so that they are tailor made for our specific task. The classes, objects, and data types that these methods work on/with may vary, but as long as they are keeping our programming lean, mean, and DRY, we can call them whatever we want!</p><p>QUESTION: How do YOU define Helper Methods? I’d love to know below!</p><p><strong>References:</strong></p><ul><li><a href="https://teamtreehouse.com/community/what-exactly-is-a-helper-method">What exactly is a helper method?</a></li><li><a href="https://stackoverflow.com/questions/3992659/what-do-helper-and-helper-method-do">What do helper and helper_method do?</a></li><li><a href="https://github.com/learn-co-students/dumbo-web-071519/tree/master/02-hashes-and-the-internet">learn-co-students/dumbo-web-071519</a></li></ul><p><a href="https://github.com/learn-co-students/module-1-code-challenge-round-1-dumbo-web-071519-complete-this-challenge-1563974823">https://github.com/learn-co-students/module-1-code-challenge-round-1-dumbo-web-071519-complete-this-challenge-1563974823</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dab626b39a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>