<?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 Myung Kim on Medium]]></title>
        <description><![CDATA[Stories by Myung Kim on Medium]]></description>
        <link>https://medium.com/@myung.kim287?source=rss-2e0d1c012665------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*nuvz33hKUIBU7zWceH-GeQ.jpeg</url>
            <title>Stories by Myung Kim on Medium</title>
            <link>https://medium.com/@myung.kim287?source=rss-2e0d1c012665------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 20:18:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@myung.kim287/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[Active Storage with Rails API]]></title>
            <link>https://medium.com/swlh/active-storage-with-rails-api-23d6a72ed3f2?source=rss-2e0d1c012665------2</link>
            <guid isPermaLink="false">https://medium.com/p/23d6a72ed3f2</guid>
            <category><![CDATA[active-storage]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[rails-api]]></category>
            <dc:creator><![CDATA[Myung Kim]]></dc:creator>
            <pubDate>Fri, 31 May 2019 10:01:13 GMT</pubDate>
            <atom:updated>2019-06-03T13:45:39.067Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*uZaHu4ZVuc9aJ76-.gif" /></figure><p>Using Active Storage in a pure rails app is pretty straightforward but, when we switch over to a Rails API with a detached front-end (such as a React app), it becomes a bit more tricky. There are a lot of articles and blogs floating around about Active Storage in a pure rails app or exclusively how to utilize Active Storage on a detached front-end.Therefore, this article will try to be a comprehensive, quick start guide to setting up Active Storage in the back-end and sending data from a detached front-end that Active Storage can read.</p><h4>From the Back-End</h4><p>Let’s start with setting up Active Storage in the back-end and connecting the models that should have files attached to them. Start by installing Active Storage via the command line:</p><pre>rails active_storage:install</pre><p>Running this command will create migration files that will generate an active_storage_blobs and an active_storage_attachments tables. For more detail on what these tables are doing, feel free to read Rails’ documentation for Active Storage. Run these migrations and now these tables should be in your schema.</p><p>Now it is time to connect these tables to the models you want the uploaded files to belong to. This is conveniently done through the built-in Active Record methods of has_one_attached or has_many_attached based on whether an instance should have a single or many attached files. These methods take in an argument of a string or symbol which will act as the reference/key to the getting and setting of the instance’s file. Think of it as establishing another column in the model’s table, except it will be storing it in the Active Storage tables rather than the model’s table. So it will ultimately look something like this inside of a hypothetical User model:</p><pre>class User &lt; ApplicationRecord</pre><pre>    has_one_attached :photo<br>end</pre><p>Finally, we can work on the controller part of the process. As mentioned earlier, Active Storage files attached to a model can be thought of as just another attribute of that model. Therefore, as long as you have the key/reference to that file (declared via the has_one_attached method, photo in the case above), you can simply place that in your strong parameters as you would with any other normal attribute. Active Record magic will know to look for the attachment when it encounters this key.</p><h4>From the Front-End</h4><p>The Front-End can be tricky. There are a few specific key points you should know when trying to send a file’s data to the back-end for Active Storage to interpret. First and foremost, let’s assume you have a working form (in React or vanilla JavaScript) that properly submits to the correct back-end controller. This form should have an input of type “file” for a user to have the ability to upload a file from their local machine. This is what the input tag should look like:</p><pre>&lt;Input type=&#39;file&#39; name=&#39;photo&#39;/&gt; </pre><p>It is important to note that, in my example, I defined name as ‘photo’ based off of my previous examples, and what key I am looking for in my strong params. With this, the first important detail to note is that in-order to access the value of the file input field you must use .files[0] instead of .value. Dot value will return a strange ‘fake url path’ that isn’t very useful. We also indicate at index zero because dot files returns a collection of information on the uploaded file; we really want the file data at index zero. This information will become useful as we talk about the most important step of this process: FormData.</p><p>Usually, we would send a form’s data to the back-end via an object of key and value pairs of the inputs (their names as the keys and values as, well, the values), JSON.stringifying this, and sending it as the body in our request. However, it isn’t as simple as this when we are working with files because they are not convertible to strings or formatted for JSON. Therefore, instead of sending it as JSON, we send it as a FormData object. You can read up more on the intricacies in the MDN Web Docs linked in the resources, something to do with encoding the data as &quot;multipart/form-data&quot;.</p><p>If the only thing you are sending within that form is the file, then utilizing FormData can be as simple as new FormData(formObj) where ‘formObj’ is the selected form element. However, if you are sending other information along with the file, such as a username of type string, then you can utilize FormData’s append method like so:</p><pre>const data = new FormData()<br>Object.keys(formObj).forEach((key, value) =&gt; {<br>data.append((key, formObj[key])<br>}</pre><p>This is essentially iterating through a ‘formObj’ with key and value pairs of the inputs; however, it is now time to utilize the dot files I mentioned earlier when trying to store the value for the file input. For example, in a React app, this would be storing the input’s .files[0] into the state on change. Then, sending the state as the ‘formObj’ to be used in the above snippet of code. Additionally, this FormData logic would most likely be placed wherever and right before the request to the back-end.</p><p>Finally, the FormData object should be ready to send to the back-end. But wait, it’s still not working! The last step necessary is to make sure that headers don’t include ‘application/json’, that you are not JSON.stringifying it, or doing anything with JSON because, remember, we are not sending JSON (some ‘multipart/form-data’ stuff). Now, you’re back-end should be able to receive the file data, attach it to the newly created or updated instance, and you should see the file appear wherever you’ve set your storage.</p><p>Phew! That was a lot! Now, there are a few things left to check off. If you are wondering how to display, get or send to the front-end the file that is now in your storage, you can add the following line of code in your Serializer to point to the file location in your back-end:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e3dffca81bcbb81548daee4c2fe646/href">https://medium.com/media/25e3dffca81bcbb81548daee4c2fe646/href</a></iframe><p>One other important issue I will tackle in a future blog is where to store the files. This blog is under the impression that your storage.yml is pointing to your local storage, but it can point to more practical, cloud based storages such as S3 and Azure. All in all, thank you for reading my long winded blog and hoped it helped solve any issues with Active Storage in a headless Rails API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*C-aY1TALiIQHDRCh.gif" /></figure><h4>Resources</h4><p>Rails’ official guide for Active Storage: <a href="https://edgeguides.rubyonrails.org/active_storage_overview.html">https://edgeguides.rubyonrails.org/active_storage_overview.html</a></p><p>More information on FormData: <br><a href="https://developer.mozilla.org/en-US/docs/Web/API/FormData">https://developer.mozilla.org/en-US/docs/Web/API/FormData</a></p><p>Other blogs I’ve found helpful on this matter:<br><a href="https://medium.com/@anurag_722/send-files-to-rest-api-with-rails-5-2-active-storage-as-backend-65128a1170b">https://medium.com/@anurag_722/send-files-to-rest-api-with-rails-5-2-active-storage-as-backend-65128a1170b</a><br><a href="https://tech.xing.com/using-ruby-on-rails-5-2-active-storage-598982e99fb1">https://tech.xing.com/using-ruby-on-rails-5-2-active-storage-598982e99fb1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23d6a72ed3f2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/active-storage-with-rails-api-23d6a72ed3f2">Active Storage with Rails API</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[Declarative vs Imperative]]></title>
            <link>https://medium.com/@myung.kim287/declarative-vs-imperative-251ce99c6c44?source=rss-2e0d1c012665------2</link>
            <guid isPermaLink="false">https://medium.com/p/251ce99c6c44</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[declarative-programming]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Myung Kim]]></dc:creator>
            <pubDate>Tue, 02 Apr 2019 13:54:36 GMT</pubDate>
            <atom:updated>2019-04-02T14:05:50.817Z</atom:updated>
            <content:encoded><![CDATA[<h4>Transition into React from Javascript</h4><p>This article strives to make this distinction of declarative vs imperative specifically for people transitioning from vanilla Javascript into React. Additionally, I am writing this during a similar transition so I apologize for any misinformation. But, I am a person who cannot just idly sit by with “React is a declarative writing style.” Therefore, I will attempt to pull apart what makes React declarative and compare it to its imperative counterpart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*8AFF_Yi2FERZV12i.gif" /></figure><p>First off, from a very high level, declarative programming focuses on the WHAT rather than the HOW. What does this mean? Declarative programming is much more driven by the result and describing this end result rather than the step by step process of getting to the result (often disregarding the process to get there). This is opposed to imperative programming which is much more instructional and cares about the step by step process. As per every “Declarative vs Imperative” article, here is a directions metaphor of getting to Penn Station from Port Authority:</p><p>The imperative programming paradigm: “After exiting Port Authority, head southwest on 8th Ave toward W 41st St, turn left onto W 33rd St and you should arrive on Penn Station.”</p><p>The declarative programming paradigm: “Penn Station is located at 7th &amp; 8th Avenues, between 31st &amp; 33rd Streets New York, NY 10001”</p><p>As you can see, the first example lists out the directions step by step, hence indicative of an imperative approach. The second example merely describes the end location/result with an address, disregarding how the traveler/user might get there. To really illustrate this distinction, let’s jump into a simple coding example through Ruby before we get into React and Javascript. Here are two approaches to implementing a simple, linear search algorithm in Ruby:</p><pre>//Imperative <br>def imperative_search(array, item)<br>  for i in array do<br>    if i == item<br>      return item<br>    end<br>  end<br>  return false<br>end</pre><pre>//Declarative<br>def declarative_search(array, item)<br>  array.find(item)<br>end</pre><p>The first is a prime example of the imperative search as it lays out each step of how the search function works and how it got to the result. This really illustrates the HOW and gives discrete ‘instructions’ to get to the desired result. In contrast, the declarative example focuses on purely the result and describing what this result will look like. If you have been working with Ruby’s enumerator methods such as each, collect, select etc., guess what? You’ve been writing declarative code this whole time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/0*a2dCobDbPP6iqkzn" /><figcaption>Imperative = STEPS</figcaption></figure><h4>Declarative React</h4><p>Finally, we’ll move into the crux of this blog: why React is declarative. If you are like me, the Javascript you’ve written so far has been of an imperative style. For instance, take this example of very imperative code which manipulates the DOM by adding a div and an h1 with my favorite artist “Mitski” to the body:</p><pre>function addArtistNameToBody() {<br>  const bodyTag = document.querySelector(&#39;body&#39;)<br>  const divTag = document.createElement(&#39;div&#39;)<br>  let h1Tag = document.createElement(&#39;h1&#39;)<br>  h1Tag.innerText = &quot;Mitski&quot;<br>  divTag.append(h1Tag)<br>  bodyTag.append(divTag)<br>}</pre><p>This is very imperative as, via step by step instructions, it finds the necessary tags and appends the necessary elements. In contrast, to achieve the same result through react would look something like this:</p><pre>class Artist extends Component {<br>  render() {<br>    return(<br>      &lt;div&gt;<br>        &lt;h1&gt;{this.props.name}&lt;/h1&gt;<br>      &lt;/div&gt;)<br>  }<br>}</pre><p>As you can see, the React way focuses on the result and further describes it in the render block of code. Simply put, “what I want rendered on the page is going to look like this and I don’t care about how you get there.” Referring to the metaphor, “This is my address. This is how my house looks like. I don’t care how you get here but get here!” Therefore, React’s implementation is declarative because you state in code the result, what you ultimately want displayed on the page, and not the instructions or steps to get there.</p><p>Before researching and writing this blog, my apprehension of the declarative programming paradigm mainly came from lack of distinction between declarative and functional programming. Functional programming is a prime example of the declarative approach, but they are not the same thing. I realized I needed to draw the line between declarative vs imperative and functional vs object oriented. Of course, React exhibits a lot of functional programming characteristics (things to do with the virtual DOM and passing functions) which then starts to get really complicated (a good follow up blog). For now, I hope this clarified to why React exhibits a declarative approach as it did for me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*C7CYm13f0qcQs9_1.gif" /></figure><h3>Resources</h3><ul><li><a href="https://tylermcginnis.com/imperative-vs-declarative-programming/">https://tylermcginnis.com/imperative-vs-declarative-programming/</a></li><li><a href="https://codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2">https://codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2</a></li><li><a href="https://medium.com/defmethod-works/declarative-ruby-programming-4b5c62719d6b">https://medium.com/defmethod-works/declarative-ruby-programming-4b5c62719d6b</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=251ce99c6c44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trains, Cars, and Tech]]></title>
            <link>https://medium.com/@myung.kim287/trains-cars-and-tech-b79662625451?source=rss-2e0d1c012665------2</link>
            <guid isPermaLink="false">https://medium.com/p/b79662625451</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[history-of-technology]]></category>
            <category><![CDATA[visual-thinking]]></category>
            <category><![CDATA[art]]></category>
            <dc:creator><![CDATA[Myung Kim]]></dc:creator>
            <pubDate>Sun, 17 Mar 2019 23:23:57 GMT</pubDate>
            <atom:updated>2019-03-17T23:26:03.728Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Evolution (or Depreciation) of our Human Perception</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FO7W62egHugBHg_XlxEOiA.jpeg" /></figure><p>The above painting is called Wanderer above the Sea of Fog by Casper David Friedrich. It is the considered the poster child for the Romanticism movement, which strove to illustrate intense, emotional, aesthetic experiences especially when it comes to witnessing sublimity and beauty in nature. Gaddis John Lewis, in his book <em>The Landscape of History,</em> aptly interprets this piece as “suggesting at once mastery over a landscape and the insignificance of the individual within it.” I cite this art piece not to discuss Romanticism, or to describe our relationship with nature but rather to look into our visual language and perception that allowed these discussions to be possible in the first place. We will revisit this image at the end of this blog and, hopefully, it will, by then, become clear what I mean by “visual language and perception” that has now been drastically changed and replaced through trains, cars and tech.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*aAiw3hBERoLkPwDNgjepZQ.jpeg" /></figure><p>Trains, first introduced in the 19th century, was a revolutionary technical innovation for transportation. However, overlooked is the equally significant impact/revolution it had on our visual language and perception. Before the train, the main mode of transportation was by carriage and horse, which were fast but not nearly as fast. The speed of the train drastically changed our sense of time by collapsing it; going from one location to another took very little time. Our sense of distance was also consequently warped, collapsing the scale of the world. Most importantly, for the purposes of this article, it warped our way of perception, collapsing landscape and space into flat, two dimensional, series of images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*fmULFxRy3fY0fSSKL6ECdQ.gif" /></figure><p>Look at this image above. The landscape outside of the train window becomes a series of flattened images moving at immense speed from one to the next. Perspective, depth, scope, context, presence, meditation all dissolve within the train window, because none is as important and sacred as speed. Bygone are the days of truly witnessing and experiencing landscape like Fredrich’s Wanderer has and acknowledging the sense of space and one’s presence inside of this space. Ultimately, we become disinterested passer-biers, rather than wanderers and active participants, like these travelling companions inside of a railway car below. Overall, before I lose you too much, the train introduced a visual language of images, to perceptually operate by representations rather than things themselves with an emphasis on speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpA07XVrixLibv7MzMc3jw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*OdwDRwRQf0vkx6nObuSuSg.jpeg" /></figure><p>The car incorporates similar elements as the train: speed. However, one stark difference and characteristic of the car is its ubiquity. The train reinterpreted the landscape and nature; the car, due to its ubiquity, terraformed the landscape or more precisely, architecture. Architecture stopped being intended for people but rather people in cars. The beauty in design, form and concept were disregarded for the importance of disseminating information, particularly for people zooming by at 50mph. This ended up taking shape as the image above, text, Text and TEXT. There is no place for subtlety and interpretation, there is only room for speed, convenience, and information.</p><p>So where are we now? The image below succinctly summarizes our current visual language and perception. Does it look familiar? It builds upon all the aforementioned elements and changes brought by the train and the car: speed, ease of consumption, everything is an image, dissemination of information shaped by speed etc. Even visually, there is somewhat of a resemblance to the window of a train or car, scrolling through the landscape. One can even posit that the computer and today’s web applications would not have existed without the precursor of the train and the car. Not because they derive technologically but perceptually. We would not be able to visually comprehend what we see on a daily basis on the web if not for the drastic perceptual changes brought upon by the train and the car.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*sFuGviAVzu08pvlQUoyb5A.gif" /></figure><p>Now begs the ethical question which is what I am most interested in. Is this an evolution or depreciation of our human perception? Should we mourn for the loss of the original Wanderer above the Sea of Fog and that way of seeing? I say yes, and I am driven to reintroduce these lost humanistic elements (in this case our old way of seeing). In a future blog, I might focus on how this might look like, especially in the tech industry with recent examples.</p><p>Also, I feel like I did not come across as clear and eloquently as I would have liked so I highly recommend these resources for further reading.</p><h3>Resources</h3><p><em>The Railway Journey</em> — Wolfgang <a href="https://www.amazon.com/Wolfgang-Schivelbusch/e/B001H6OGAQ/ref=dp_byline_cont_book_1">Schivelbusch</a></p><p><em>Disenchanted Night</em> — Wolfgang Schivelbusch</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b79662625451" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bootstrap Quickstart on Rails]]></title>
            <link>https://medium.com/@myung.kim287/bootstrap-quickstart-on-rails-7f6d5a0b70d1?source=rss-2e0d1c012665------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f6d5a0b70d1</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Myung Kim]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 05:03:30 GMT</pubDate>
            <atom:updated>2019-03-15T20:29:41.180Z</atom:updated>
            <content:encoded><![CDATA[<h4>Bootstrap Installation and Bootstrap Templates</h4><p>If you are new to the whole front-end stack particularly having to do with css and html, try giving Bootstrap a try. This guide will introduce you to Bootstrap and, hopefully, by the end of this be able to style your very own app with minimal amount of time investment.</p><p>First, what is even Bootstrap? Bootstrap is an open-source front-end framework that has many pre-built html and css templates/classes. This framework was originally developed by Twitter as “Twitter Blueprint” and eventually released to the public as an open source project on August 19, 2011. Some benefits for using Bootstrap over regular css/html is that it is browser compatible, faster development, responsive layout, and a good fit for people with little front-end experience or design/UI sensibility.</p><h4>Installation</h4><p>To start using Bootstrap via a Rails app, first add Bootstrap to your Gemfile. I opted for a Sass variant so mine would look like the following:gem &#39;bootstrap-sass&#39; . Thereafter, in your Rails generated assets directory and under its stylesheet folder, there should be an application.css file. Make sure to add the following line of code to this file:</p><pre>@import “bootstrap”;</pre><p>If you are following along with me and also decided to use the sass variant, make sure to rename this stylesheet and add the extension “.scss” so the file name would ultimately be application.css.scss. Voila, it’s as easy as that, you should now be setup to make all kinds of beautiful web pages. Another way to install Bootstrap that is not rails specific is to embed the Bootstrap CDN within the header of each html page (or the single layout page) like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7600791f251962284bb8094920a12ae4/href">https://medium.com/media/7600791f251962284bb8094920a12ae4/href</a></iframe><h4>Let’s Cheat Kind-Of</h4><p>Now that we have Bootstrap setup, we can jump right into making our webpages look beautiful. However, I’m not about to just head into how to make a pretty button, or how to properly align forms, or talk about any one of millions of Bootstrap customization tricks. I’m going to admit that I have no idea what I am doing and, with a project due in a week, going to let other people do the brunt of the work. How? Through Bootstrap templates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VqjVKpTcgutBs44WsZtEcw.png" /><figcaption>Go from this garb</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nauTcG7FHoLxQN7mxLO9CA.gif" /><figcaption>To this!</figcaption></figure><p>There are many sites that offer free Bootstrap templates that can make your app go from an ugly, white, blue links, everything in the left, piece of crap to a decent looking web page (and some of them are actually really quite beautiful). I will list some of these sites in the resource section. Most of these templates will come with an option to download them onto your local machine and store the html with Bootstrap classes, custom css stylesheets, and images. However, there’s no need for I will tell you how to do this purely from online.</p><p>You can do this straight from the inspect or view source code page, where you can copy and paste over the desired elements of the page into your apps own view files. The Bootstrap html classes should do a lot of the legwork but to completely imitate the aesthetic, you will have to carry over the references to custom stylesheet and fonts within the &lt;head&gt;. Here’s the tricky part: those paths should be relative only within the context of where that page is being run/displayed. Therefore, you will most likely have to prepend the url where you are displaying that page on in the browser. That’s that! You will now be able to display your app with whatever Bootstrap template. However, I recommend that you download the templates and have the stylesheets and other references locally, incase the site these are from goes offline for whatever reason. Plus, they’ll usually come with super helpful instructions and readme!</p><p>Now, <strong>this is probably the most important part of this blog</strong>. I believe you can do this with whatever page being displayed on the web (via view source and what not). <strong>However, </strong>I’m pretty sure this can be considered as <strong>plagiarizing and copywriting</strong>, so make sure to do this with permissible, approved, and template examples.</p><h4>Conclusion</h4><p>All in all, this was a guide to get you started on a Bootstrap project the quickest way possible. If you are like me, coming from a backend heavy track and need to create a web app using Rails, take advantage of Bootstrap and templates. However, I still would highly recommend spending time spinning up your own creative and beautiful designs. What’s the point of using someone else’s design and template, where’s the fun in that. I would even go as far as to suggest try spinning up designs with pure css (not the Pure framework), which let’s you really have that freedom and stretch your creative juice (don’t become a “Bootstrap Designer” jk). Definitely, do though, look at these templates for inspiration and ways to implement your very own idea.</p><h3>Resources</h3><ul><li><a href="https://startbootstrap.com/">Free Bootstrap Themes, Templates, Snippets, and Guides</a></li><li><a href="https://colorlib.com/wp/free-bootstrap-4-website-templates/">35 Top Free Bootstrap 4 Website Templates 2019 - Colorlib</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f6d5a0b70d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s Meta?]]></title>
            <link>https://medium.com/@myung.kim287/whats-meta-74d1ea506fc7?source=rss-2e0d1c012665------2</link>
            <guid isPermaLink="false">https://medium.com/p/74d1ea506fc7</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[metaprogramming]]></category>
            <dc:creator><![CDATA[Myung Kim]]></dc:creator>
            <pubDate>Tue, 19 Feb 2019 03:23:35 GMT</pubDate>
            <atom:updated>2019-03-22T14:20:59.433Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to metaprogramming through Ruby</h3><h4>define_method and missing_method in Ruby</h4><p>Metaprogramming is to imbue code with the ability to introspect, reflect and grow as an individual. Intimidated? Don’t fret! That was just a cooler (more pedantic) way of saying metaprogramming allows code to read, analyze, generate and modify itself and other code during runtime. This allows for code that is incredibly dynamic and eloquent, characteristics important to and indicative of the Ruby language. Rather than talking in circles let’s jump straight into practical implementation of metaprogramming through Ruby’s built-in define_method and missing_method.</p><p>First, I would like to introduce the code I will be using to demonstrate these two methods. The snippet below is part of a command line application that asks the user a series of world trivia questions. More specifically, this snippet generates comparison questions that asks the user to choose which country has the greater amount. However, these two methods seem almost identical except for the slight adjustments to the category they belong to, population and total area. Thus, let’s combine these two methods with the define_method that will generate them during runtime.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9457649a16fe8c80a80b92c453845459/href">https://medium.com/media/9457649a16fe8c80a80b92c453845459/href</a></iframe><p>Define_method is a built-in method of the Module class. It allows our program to define and create methods during runtime. The new code below utilizes this method and demonstrates the benefits to metaprogramming. As you can tell, there is no code that explicitly “def population_question” or “def total_area_question” yet the program runs fine when these methods are called and is able to acknowledge their existence. When we call generate_comparison_questions, it creates and defines these two methods by iterating through the types array and passing the elements into the block of code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c792d97097d11f78c396ef667344154b/href">https://medium.com/media/c792d97097d11f78c396ef667344154b/href</a></iframe><p>The most important detail to note is the:</p><p>define_singleton_method(“#{type}_question”) do |prompt, game|</p><p>This is where the magic happens of generating our methods at runtime; we’re making our program do the coding! The “singleton” part is there to signify that we want to create a class method as opposed to an instance method. The method will take in a string as an argument which will become the method’s name. In this case, I use the type interpolated into a string with “_question” appended to it. Whatever goes in between the pipes are the method-to-be-generated’s arguments. Overall, the population and area methods will be generated during runtime and can be called upon without ever explicitly defining them.</p><p>Finally, here comes the crème de la crème, something that is even more dynamic than define_method: Ruby’s method_missing. Method_missing allows methods to not only be generated on runtime but also the moment that method is called! Therefore, we can call Question.population_question without ever having to define it explicitly or tell our program to generate it beforehand. It just works.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d787f1381225b2abba02f6c9b83eb7f/href">https://medium.com/media/3d787f1381225b2abba02f6c9b83eb7f/href</a></iframe><p>Okay, how it really works is that if a method is not defined, the program will immediately look for a method_missing with the first argument as the undefined method’s name and subsequent arguments as the undefined method’s arguments. Then, through some conditionals and regexes like so:if method_name.to_s =~ /(.*)_question/ &amp;&amp; types.include?($1). These undefined functions will operate as if they existed, creating incredibly dynamic, eloquent, self-sufficient code!</p><p>All in all, metaprogramming through methods like define_method and method_missing can make for very eloquent and beautiful code (code that makes code!). However, there are always drawbacks that balance out the pros to a practice. For instance, metaprogramming can make for harder code to debug through, in some cases be less readable, and, most importantly, have unexpected behaviors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74d1ea506fc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>