<?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 Janice Darikho on Medium]]></title>
        <description><![CDATA[Stories by Janice Darikho on Medium]]></description>
        <link>https://medium.com/@janicedarikho?source=rss-706a46ee0ea3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*x19UcVZVMDrq-nJaJDL9Tw.jpeg</url>
            <title>Stories by Janice Darikho on Medium</title>
            <link>https://medium.com/@janicedarikho?source=rss-706a46ee0ea3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:47:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@janicedarikho/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[hario: Fitness Resource Website (React + Rails API)]]></title>
            <link>https://medium.com/@janicedarikho/hario-fitness-resource-website-react-rails-api-af82785f0c9b?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/af82785f0c9b</guid>
            <category><![CDATA[rails-api]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Sat, 25 May 2019 06:49:34 GMT</pubDate>
            <atom:updated>2019-06-10T16:22:49.990Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_GGdEhdPeCSpi1klWptcA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/buWcS7G1_28?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Meghan Holmes</a> on <a href="https://unsplash.com/search/photos/fitness?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Last portfolio project. It’s been a long, fruitful ride. In this post, I will outline the steps needed to design, build, and deploy <a href="http://hario.netlify.com/">hario</a>. This project feels like the epitome of “if you want to learn how to build it, you have to build it”. I bumped into more obstacles than ever, but ultimately got through them.</p><p>If you have more suggestions for fitness tools, comment below and I’ll build them!</p><h3>1. Discovery</h3><p>This time, I decided to do something different — rather than building a typical web-app, I made a sort of hybrid. Some parts of it seems to be static (e.g. home and about page), but some parts of it has the functionality of a web-app (e.g. fitness tool forms).</p><p>This project will be a basic one, built with the following structures:</p><ul><li><strong>Stateless components</strong>: Header, Home, Tools, Services, About</li><li><strong>Container components</strong>: ToolContainer, ToolsContainer</li><li><strong>Routes</strong>: Home, About, Tools, Services, Results, Community</li></ul><p>To make it more interesting, I will make it such that the data are served by the Rails API back-end. That means that in the React JSX code, there are no manually typed data — instead of typing Harrison Oldridge into the render method, I used {this.props.trainer.name} instead (this.props instead of this.state because I used redux and mapStateToProps). The trainer info would have been seeded onto the Rails database, and is accessible via the API GET request. The same applies for services, logs, and tools — with the exception of logs not having any seed data. logs is for the user’s input.</p><p>This means that there will be quite a few API calls. However, the maximum calls that exists on a page is 2, which is comparatively lesser compared to some websites out there.</p><h3>2. Strategy</h3><p>I have never built any React projects on Rails before. Fortunately, there are <a href="https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/">several</a> <a href="https://blog.heroku.com/a-rock-solid-modern-web-stack">comprehensive</a> <a href="https://medium.com/@bruno_boehm/reactjs-ruby-on-rails-api-heroku-app-2645c93f0814">resources</a> for React front-end + Rails API apps that I could use as guides. Some of them even guide you through setting up ActiveAdmin for user authentication — but I will keep it simple and not implement this feature for now.</p><p>A strategy that I used was to implement the form logic (e.g. macronutrient calculation) in the Rails model rather than to implement it in the reducer. Rails will be calculating the form results, and the reducer will just be in charge of fetching data from Rails.</p><h3>3. Design</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rvw07cL5xD-b2UP3r8y_7A.png" /><figcaption>Part of the original mockup, which can be found <a href="https://sketch.cloud/s/pL4WJ/a/eJlaQP">here</a></figcaption></figure><p>I worked out a basic mockup for the website then improvised as I go along. While the live version looks different than the mockup, I think the live version looks simpler and more minimalistic. I used Sketch to design the mockup, which made the whole process really efficient and quick.</p><h3>4. Architecture</h3><p>After setting up the Rails API backbone using rails new hario --api --database=postgresql, we are now free to set up our ActiveRecord relationships and MVC structures. Setting it up with PostgresQL will allow us to easily deploy our app to Heroku later on. So far, everything was pretty straightforward. The most fun I’ve had was rendering each object as JSON and making it available for later API requests.</p><p>Now that the back-end is ready, we’ll now start building our React front-end. This is achievable by running cd app &amp;&amp; create-react-app client, which creates a client folder in hario/app. Following this, we can see our front-end in the browser by running cd client &amp;&amp; npm start.</p><p>Since we will be running our front-end on localhost:3000 and our back-end on localhost:3001, we foresee our React app attempting to load resources from the back-end. This would be performing <a href="https://medium.com/@baphemot/understanding-cors-18ad6b478e2b"><strong>Cross-Origin Resource Sharing (CORS)</strong></a>, and by default, browsers prevents these types of requests from scripts for security reasons. There are several workarounds for this — the one that I chose was probably the simplest.</p><p>For development purposes, I simply installed and enabled a <a href="https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en">Chrome Extension</a> that allows us to request from other sources using AJAX. During production, we will use Netlify for the front-end and Heroku for the back-end, and they seem to have taken care of CORS without the need for the browser extension. I will need to look up on this — any insights are welcome.</p><p>For the first iteration of the project, I decided not to use Redux first. I decided to use no middleware to get everything working first — then refactor, or convert, using Redux.</p><h3>5. Development</h3><p>I thought I would have to watch <a href="https://instruction.learn.co/student/video_lectures#/445">Learn</a> videos to get everything working, as I found the videos really helpful during the Rails+JS project section.</p><p>There were so many learning points during development, some of them being:</p><ul><li>how to send GET request using fetch()</li><li>how to send POST request using fetch()</li><li>how to convert React methods to using Redux middleware and make stateful components stateless</li><li>how to use mapStateToProps</li><li>how to use rootReducer</li><li>how to fix JS bugs using debugger and console.log()</li><li>how to dynamically and conditionally <a href="https://medium.com/@Carmichaelize/dynamic-tag-names-in-react-and-jsx-17e366a684e9">render components</a></li></ul><h3>6. Deployment</h3><p>Deployment was quite painful. My attempts at deployment generally are. There were two parts to deployment: front-end and back-end. There are different ways to deploy a React + Rails API app, and this will be only one of them.</p><p>First, I deployed the Rails back-end to Heroku. Prior to deploying, I created a Procfile, that specifies the commands that are executed by the app on startup. Mine looks like this:</p><pre>web: bundle exec rails s<br>release: bin/rake db:migrate</pre><p>I’ve installed the <a href="https://devcenter.heroku.com/articles/heroku-cli#download-and-install">Heroku CLI</a> and completed the login step previously, so this step should be as easy as:</p><pre>heroku create<br>git push -u origin master<br>git push heroku master<br>heroku run rake db:seed</pre><p>I needed the db:seed command as I need the seeded data to be served to the front-end.</p><p>One persistent challenge that I faced was the You must use Bundler 2 or greater with this lockfile error message from Heroku during the git push heroku master step. After reading through <a href="https://github.com/bundler/bundler/issues/6784">this thread</a>, the solution that worked for me was to update my ruby version to 2.6.1, and to install a specific bundle version (1.17.3) to be used in bundle. This somehow solved the error message, and the deployment was finally successful. I made sure that the /api/trainers works.</p><p>After the back-end is deployed, we can now focus on deploying the front-end. For this project, I’ve chosen to use Netlify as it has been something I’ve wanted to learn. It was surprisingly simple! I setup my public/_redirects app based on <a href="http://snsavage.com - How to Deploy a React App with API Request Proxying">this instruction</a> and also <a href="https://medium.freecodecamp.org/how-to-deploy-a-react-application-to-netlify-363b8a98a985">this post</a>, and both of them were very helpful. After the final deployment to Netlify, I checked the link using my mobile device and discovered that I was only getting a white screen, whereas on Chrome it was showing the app perfectly, with the API information shown correctly. I then used my desktop and checked it again using Opera, and discovered that it wasn’t working, either. Looking at the console, I saw that it was throwing <a href="https://stackoverflow.com/questions/53514758/redux-typeerror-cannot-read-property-apply-of-undefined">this error</a> and after looking through some solutions, I decided to delete the Redux DevTools code in index.js, which got everything working.</p><p>A note is to remember running npm run build before trying to deploy to Netlify, and to remember pushing to the git repository before deploying to Heroku, which I think is good practice.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af82785f0c9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RebelBase: Adding JS Functionality to a Rails Application]]></title>
            <link>https://medium.com/@janicedarikho/rebelbase-adding-js-functionality-to-a-rails-application-5990f20e41ca?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/5990f20e41ca</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ajax]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Wed, 13 Mar 2019 07:23:57 GMT</pubDate>
            <atom:updated>2019-03-13T07:27:37.018Z</atom:updated>
            <content:encoded><![CDATA[<p>Learning JavaScript after spending so much time on Ruby is such a ride! I love spending time solving JS challenges on <a href="https://www.codewars.com/dashboard">Codewars</a>, but mini logic challenges are somehow different from implementing JS on a web app. This is my first time working with both Ruby and JS on a project, so I learned a lot!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67yx2NlYj7zMyT-WILujIA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/Kw_zQBAChws?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ashim D’Silva</a> on <a href="https://unsplash.com/search/photos/tabletop-build?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>1. Discovery</h3><p>Initially, after reading the portfolio assessment requirements, I decided that I’m going to make these changes to my Rails app:</p><ul><li>Render user’s clubs on Memberships index using JS</li><li>Allow user to click through the upcoming books list and read books list by clicking on ‘Next’ on the Book show page with AJAX</li><li>Render Discussion’s list of Comments with AJAX</li><li>Submit a Comment to a Discussion with AJAX</li><li>Construct Discussion as JS Model Object</li><li>Render the username of the user who posted the Comment with AJAX</li><li>Render Comment creation time with AJAX</li></ul><p>As you can tell, a lot of AJAX is going to happen! Essentially, AJAX is a technique used to create asynchronous web-apps. Asynchronous means that while we send a method call to the server, our web page is not blocked / frozen while loading the results. We can even interact with other elements on the page while waiting for the call to finish retrieving our results! But for our small virtual book club app, the time needed to retrieve the results is very short, so we won’t need to do that.</p><h3>2. Strategy</h3><p>A strategy that I employed here is to firstly serialize all my models using <a href="https://github.com/rails-api/active_model_serializers">Active Model Serializer</a>. AMS is a gem that easily lets me convert my data into JSON. I didn’t need to serialize all the models, as I was planning to implement AJAX for only the following models: Memberships, Books, Discussions, and Comments; but I did it anyways, just in case. After serializing, I edited my controllers to allow me to access the views as .json, in addition to .html. This was fun. I use the <a href="https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc">JSONView</a> Chrome Extension to view my JSON data in a neat format, and to expand or collapse any data I need). AMS also allows me to specify any associations between my models, which gives me neatly nested JSON structures, like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*aInec0XiiE55nB6-HwtWPA.png" /><figcaption>JSON for a book’s data (viewed using JSONViewer)</figcaption></figure><p>I used the same associations as the ones I used for my schema. I realised that later on, I needed to modify this slightly — more on that later! After confirming that the data and associations were rendering perfectly, I went on to coding the JS. This is where the hard part begins.</p><h3>3. Design</h3><p>I didn’t focus much on visual design here, as this project mainly serves as a coding challenge for me. I did fix some CSS weirdness, but that was it.</p><h3>4. Architecture</h3><p>Rails’ architecture allowed me to separate my JS file according to the views and models that I’m focusing on. To implement AJAX on the discussion#index page, I only need to code my JS in discussion.js (which I changed from discussion.coffee— CoffeeScript is something that I’ll learn in the future, along with many other things).</p><p>In terms of the views structure, I separated Discussions views from those of Book‘s. What this means is that previously, you can look at a book’s discussions from the individual book’sbook#show page, but I realised that this also means that the AJAX calls for discussion#index will need to be placed in books.js (as the Discussions are rendered via the Books controller). I then decided to move the Discussions views to its own rightful folder, which feels cleaner and more easily manageable.</p><h3>5. Development</h3><p>Longest part of the process. I had to watch many <a href="http://instruction.learn.co/">Learn</a> videos to do this. I signed up for Rails+JS study groups, but they were conducted during my work hours and unfortunately I couldn’t attend them, so I resorted to the recordings instead. I find Brad’s <a href="https://instruction.learn.co/student/video_lectures#/383">study session recording</a> really helpful! He even posted the code in his GitHub repository.</p><p>One of the bugs that I realised early on was that my AJAX calls were firing multiple times. I found out that this was because I have specified the following in my application.js:</p><pre><em>//= require jquery<br>//= require rails-ujs<br>//= require jquery-ujs<br>//= require_tree .<br>//= require popper<br>//= require bootstrap<br>//= require typed</em></pre><p>Do you see it? I had called on multiple jQuery files, which resulted in each AJAX request being fired twice. I deleted the jquery-ujs line, and everything was restored beautifully (no more double vision!).</p><p>Another bug happened when I had to click on a link twice before I see the results being appended onto my view. This was because I had accidentally nested a click function within another click function, which was a mess. This has been corrected.</p><p>One of my biggest learning points for this project was in learning to use $.ajax() and $.getJSON(). I used both for different parts of the project, just to practice more with both styles. Personally, I prefer the latter, as it is a shorthand for $.ajax()— it has already specified the parameter for the output, which is in JSON, and it automatically transforms my JSON output into an Object. Yum. I find $.getJSON() to be more configurable as well, as I can easily specify, configure, and see which URL I’m retrieving my request from.</p><p>I also learned to manipulate the serialised JSON data into giving me specific key-value pairs. In the discussion_serializer.rb file, for example, I added a custom method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/177a9237b59c795bb80f8ff4f1f3b8b4/href">https://medium.com/media/177a9237b59c795bb80f8ff4f1f3b8b4/href</a></iframe><p>To render each comment’s username, I had to be able to access the comment’s user_id from my Discussion JS Object. What I realised was that my Discussion JS Object didn’t have access to the nested comment’s user_id, discussion_id, as AMS only went one-level nest-deep:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*a3WukDQwqoKrrAus1pSCRg.png" /><figcaption>List of comments (viewed from discussions.json)</figcaption></figure><p>However, I was able to see the user_id when I navigate straight to the Comments:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*thxmHZ3Pj0VkQFal-d0VXg.png" /><figcaption>Comments JSON (viewed from comments.json)</figcaption></figure><p>So I needed to make my discussion_serializer.rb serve me my JSON as I like it, which was what the custom method comments_with_user is doing. I was able to construct a new key-value pair for my Discussions Object, retrieve the information I needed, and access it via discussions.json:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*t9XxYPWxVcDIDp2pPTnjlw.png" /><figcaption>Discussions.json featuring comments_with_user</figcaption></figure><p>After I have my comments_with_user data, I didn’t need AMS to give me my original comments (without user) list, and so I commented the line has_many :comments (line 9) from discussion_serializer.rb.</p><h3>6. Deployment</h3><p>I checked out a new git branch to develop the JS features, and submitted my own pull and merge requests. For the live deployment, I will continue to use Heroku for the time being, but I look forward to learning more about server and hosting, especially with AWS EC2, which I’ve been hearing a lot about!</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5990f20e41ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[rebelbase: Virtual Book Club Rails Application]]></title>
            <link>https://medium.com/@janicedarikho/rebelbase-virtual-book-club-rails-application-69ac3a47c72e?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/69ac3a47c72e</guid>
            <category><![CDATA[books]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Sat, 03 Nov 2018 05:23:40 GMT</pubDate>
            <atom:updated>2019-05-25T03:39:00.662Z</atom:updated>
            <content:encoded><![CDATA[<h3>RebelBase: Virtual Book Club Rails Application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpgKXl2SJr8SHwDPl9rFhA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/_ar2ENzmqb0?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sylvia Yang</a> on <a href="https://unsplash.com/search/photos/library?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>It’s portfolio project time! Whew, this one took quite awhile to build. As usual, I’ll share my approach to building <a href="https://rebel-base.herokuapp.com/"><strong>rebelbase</strong></a><strong> </strong>from scratch — from designing the user flow up to deployment. I enjoyed every moment of the process–especially during the final refactoring steps–and I learned so much more from building this project.</p><p>Go see it, play with it, and send a suggestion my way!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.useloom.com%2Fembed%2Fc72e159dcec341d68f31bef549b580d4&amp;url=https%3A%2F%2Fwww.useloom.com%2Fshare%2Fc72e159dcec341d68f31bef549b580d4&amp;image=https%3A%2F%2Fcdn.useloom.com%2Fsessions%2Fthumbnails%2Fc72e159dcec341d68f31bef549b580d4-00001.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=useloom" width="1280" height="800" frameborder="0" scrolling="no"><a href="https://medium.com/media/d41371a9eb4065f82f4b27dd397e2816/href">https://medium.com/media/d41371a9eb4065f82f4b27dd397e2816/href</a></iframe><h3>1. Discovery</h3><p>I love books. Maybe a little too much. During the ideation phase, I was coincidentally looking for an online book club with a few requirements:</p><ul><li>It allows members to suggest the next reads easily</li><li>It allows members to browse all existing clubs</li><li>It allows members to follow / unfollow any club</li><li>Its UI/UX is intuitive and easy on the eyes</li></ul><p>I had not seen any strong contender to date, which is the main reason why I decided to build <a href="https://rebel-base.herokuapp.com/"><strong>rebelbase</strong></a>, but if you know any, do let me know! I’d love to check it out.</p><h3>2. Strategy</h3><p>Rails is amazing. To build a Rails app from scratch, all it literally takes is rails new rebelbase, and this single-line command creates the entire Rails directory structure required for our project. Coupled with the rails generate resource command, this sets up our models, controllers, migrations, and adds the resources :model to our config/routes.rb file.</p><p>An important strategy I’d like to keep in mind for future Rails project is to gather all the potential gems that would be used in the course of the project. This would give me a clearer foresight, and would allow me to configure the gems with my project early in the development stage, rather than after having written lengthy codes, which might increase the likelihood of errors.</p><h3>3. Design</h3><p>After my previous project (<a href="https://flatiron-hall.herokuapp.com/">Flatiron Hall</a>), I learned the value in focusing on the user flow diagram when designing. This is essential as this project is larger in scope than Flatiron Hall, and I did not want to waste time in determining where the user is at any point in time, and where to redirect the user to after a method is run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sjzobvDqH5TRPuy0ZI6HsA.png" /><figcaption>Draft of the user flow diagram</figcaption></figure><h3>4. Architecture</h3><p>Defining the relationships between model is no easy task, either. But after this project, I have a better idea about has_many :through, as well as about setting up references in the database.</p><p>One thing I wish I had done is to set up my Rails app with a PostgreSQL database from the start, rather than after development and before deployment to Heroku. I’d also check my Ruby version and make sure that it fulfils Heroku’s minimum acceptable version.</p><h3>5. Development</h3><p>The longest stage. But also the most enjoyable. I learned to use many gems, such as:</p><ul><li><a href="https://github.com/plataformatec/simple_form">devise</a> (for secure user authentication)</li><li><a href="https://github.com/omniauth/omniauth">omniauth</a> (for OAuth)</li><li><a href="https://github.com/mkdynamic/omniauth-facebook">omniauth-facebook</a> (for Facebook OAuth)</li><li><a href="https://github.com/plataformatec/simple_form">simple_form</a> (for styling form fields)</li><li><a href="https://github.com/stefanpenner/country_select">country_select</a> (for listing countries to indicate user’s location)</li><li><a href="https://github.com/norman/friendly_id">friendly_id</a> (for params[:slug] in the URL search bar)</li><li><a href="https://github.com/cmer/socialization">socialization</a> (for allowing users to follow / unfollow clubs)</li><li><a href="https://github.com/visoft/google_books/">google_books</a> (for searching books and instantiating Book objects)</li><li><a href="https://github.com/carrierwaveuploader/carrierwave">carrierwave</a> (for uploading user profile pictures)</li><li><a href="https://github.com/minimagick/minimagick">mini_magick</a> (works together with carrierwave)</li><li><a href="https://github.com/jouissances/libri-cli-app">libri</a> (for displaying random book-related quotes on user profile pages)</li></ul><h3>6. Deployment (or Publishing)</h3><p>Deployment to Heroku was relatively smooth-sailing, but I couldn’t have done it without Stack Overflow. Some errors I faced include:</p><ul><li>Incompatible Ruby version</li><li>Missing gem that was listed as a dependency by other gems led to LoadError</li><li>Forgetting to run heroku run rake db:drop db:create db:migrate after pushing to GitHub master</li><li>Incorrect migration sequence that had a table column referencing other table, while this ‘other table’ was still not created.</li><li>Forgetting to update heroku config used in Facebook OAuth led to parameter_id error.</li></ul><p>Other than that, it was a successful learning project!</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69ac3a47c72e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flatiron Hall: Sinatra Application for Web Development Inspiration]]></title>
            <link>https://medium.com/@janicedarikho/flatiron-hall-sinatra-application-for-web-development-inspiration-811b7b8f34d?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/811b7b8f34d</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[sinatra]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 07:44:01 GMT</pubDate>
            <atom:updated>2018-07-31T08:04:06.890Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5CsDCzcnJwSHmZqMkz7Vbg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/324nknuhxDg?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Graeme Worsfold</a> on <a href="https://unsplash.com/search/photos/hallway?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>On this second portfolio project post, I’ll share my process-based approach on writing Flatiron Hall from scratch, putting the CRUD functions together, designing and adding user-friendly features, and finally, deployment to Heroku. Needless to say — I faced many roadblocks during the development phase, but nothing insurmountable, and I will share them later on. Most importantly, first things first: Go visit my baby <a href="https://flatiron-hall.herokuapp.com/">here</a>! <strong>It needs a lot of love</strong>.</p><p>Project time is always going to be my favourite part of being in Flatiron. It allows me to be creative, expressive, and to be scrappy—<em>don’t know how to do it?</em> Read the docs. Read other people’s answers to the same problem. Revisit the code, talk to it (yes), and iterate. I learned so much more from building a project than from passing lab specs, and I’m thankful for that.</p><h3>1. Discovery</h3><p>Flatiron Hall was originally Dakota’s idea. During one of my 1:1 sessions with Dakota, we were discussing about potential ideas, and he mentioned that he’s always wanted to do a web-app that puts everyone’s projects in one place. I then enthusiastically volunteered to build it, as I didn’t have any strong pull towards any particular idea at that moment. (I had wanted to make something similar to <a href="https://80000hours.org/problem-profiles/">80,000 Hours’ Problem Profiles</a>, but I decided that the idea hasn’t had much concreteness yet, so I’m letting it incubate for a while more—I may revisit it for my upcoming Rails project.) Even so, I knew that I wanted to create something that other people would use, and would enjoy using, and Flatiron Hall’s idea seems extremely exciting!</p><h3>2. Strategy</h3><p>To build a Sinatra app from scratch, the Corneal app generator is available on the open-source. This gem will take care of the skeletal MVC structures (with all the scaffold directory), and everything you need to load your basic development environment, including `shotgun`. <em>This gem was made by a fellow Flatiron Student!</em></p><p>Using the knowledge I learned from <a href="http://learn.co/">Learn.co</a>’s previous labs (especially Fwitter), programming Flatiron Hall and making it fully functional isn’t at all the challenging part. The challenge would be the designing of the front-end, streamlining the user on-boarding and flow throughout the app, as well as ensuring that all user interactions with the app is meaningful and purposeful—we want to minimise user frustration as much as possible.</p><h3>3. Design</h3><p>Naturally, along that line of thought, I chose to first engage in the design aspect of the project. I didn’t focus on making any prototype—rather, I first built a design system that will guide my overall thinking process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HzOpf5lFh4D_im3ty5GJxw.png" /><figcaption>Flatiron Hall Design System (Iteration 1)</figcaption></figure><p>For this project, the design system only serves as a visualisation guide, as I only got to the wire-framing stage and didn’t proceed with the prototyping. After considering the time/effort/efficiency of prototyping vs. developing, I jumped straight into the front-end development right away, as I already had mental pictures of how the frames will interact.</p><p>In hindsight, this made the creation process quite efficient, especially because this was such a simple project with only a few views, and it was easy to visualise the user flow without having a prototype to refer to. It saved me some time that would’ve been spent prototyping. Nonetheless, I could’ve spent time building out the user flow diagram, just so that it’d make life easier when determining which path to redirect the user, or considering which flash message to show, and at which point of the user journey. I previously used <a href="http://draw.io/">Draw.io</a> to map out the user journey, however I feel more affinity towards <a href="http://milanote.com/">Milanote</a> due to it being lightweight and minimalistic, and I believe that it can also be suitable for the task.</p><p>I also noticed that I made a few changes in design decisions along the development, which gave me an inkling of how developers can provide their input and perspective for designers, and vice versa, to improve the overall UX of the product. This developer-designer feedback loop is an aspect in which I will try to deepen my understanding, and this project has been a great stepping stone for me. I’m looking forward to exercising more code-switching between the two disciplines with future projects.</p><h3>4. Architecture</h3><p>Back to code. After installing Corneal with gem install corneal, you can cd to the appropriate directory, create your app using corneal new &lt;app-name&gt;, and watch the magic happens! I discovered this gem a little too late, so I created the scaffold and configured everything manually—however, due to VSCode’s capabilities and its integrated terminal, setting up wasn’t a very time-consuming process.</p><p>Afterwards, make sure to redefine the scaffold structure according to your needs. I ended up with the following:</p><pre>├── config.ru<br>├── Gemfile<br>├── Gemfile.lock<br>├── Rakefile<br>├── README.md<br>├── app<br>│   ├── controllers <br>│   │   ├── application_controller.rb<br>│   │   ├── projects_controller.rb<br>│   │   └── users_controller.rb<br>│   ├── models<br>│   │   ├── project.rb<br>│   │   └── user.rb<br>│   └── views<br>│       ├── projects<br>│       │   ├── create.erb<br>│       │   ├── edit.erb<br>│       │   ├── projects.erb<br>│       │   └── show.erb<br>│       ├── users<br>│       │   ├── create.erb<br>│       │   ├── login.erb<br>│       │   └── show.erb<br>│       ├── about.erb<br>│       ├── error.erb<br>│       ├── index.erb<br>│       └── layout.erb<br>├── config<br>│   └── environment.rb<br>├── db<br>│   └── migrate<br>├── lib<br>│   └── .gitkeep<br>└── public<br>    ├── css<br>    │   └── style.css<br>    ├── fonts<br>    ├── icons<br>    └── js<br>        ├── jquery.js<br>        └── main.js</pre><p>I also defined the relationship between the User and Project model. In this case, it’s straightforward enough without the has_many :through association, but I also illustrated the relation via <a href="http://milanote.com/">Milanote</a> as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*P2egmdefoLhbOsNdAcKqwg.png" /><figcaption>Created via app.milanote.com</figcaption></figure><p>Now, our environment is all set up and it’s ready for some action!</p><h3>5. Development</h3><p>Again, this stage took the longest—no surprises there. But again, this has proved to be a successful project, and I learned a few more things:</p><h4>Back-end:</h4><ul><li>Do not use type as an ActiveRecord column names, as type is one of the <a href="https://edgeguides.rubyonrails.org/active_record_basics.html#overriding-the-naming-conventions">reserved keywords for AR</a>. I used type originally to indicate which type of project the user has submitted — and ran into errors. I have changed the column name to category instead. Dakota warned me of this earlier—but I forgot about it, and had to learn it the hard way.</li><li>Try to use params[:slug] as early as possible. I originally used params[:id] to set up relations between the project views and controllers, and changed nearer to the completion of the app. Needless to say, at this point, there are already a few interactions set up based on params[:id] and I missed making a few changes, which broke the edit and delete function of the application. Alternatively, I could have done a mass-replacement of the .id as well, but I believe it’s better to just use .slug earlier.</li><li>Do not use two similar paths in the controller, i.e. get &#39;/projects/:id&#39; and get &#39;/projects/:slug&#39;. Only one of them will work, and I believe that depends on which comes first in the controller. So if there is a request to http://localhost:9393/projects/&lt;project-name&gt;, it will give you the Sinatra “don’t know this ditty” page, as there are no projects with params[:id] = &lt;project-name&gt;.</li><li>Used and formatted created_at for viewing date of submission of projects, as well as added a few more columns along the way. It’s probably not realistic to have migrated all the columns I wanted right at the start of the project—I realised there were other columns which I wanted to add, such as the blog_url and timestamps.</li></ul><h4>Front-end:</h4><ul><li>Using if-else in the .erb files to display certain message, depending on conditions (e.g. logged_in?, user == current_user).</li><li>Implementing sinatra-flash messages to interact with users. Did the user successfully edit their project? Did they successfully log out? The gem also allows full reign over the styling of the alerts, which I find really neat—different colours can be used to indicate the nature of different alerts.</li><li>Better understanding of yield. I previously only vaguely understand this concept—thinking that yield is meant to be written in the different views, when it is only meant for the layout view.</li><li>HTML class names are case-sensitive. I had problems with the filter feature due to this. The way the filter works is by attaching a value to each filter link (say, I click CLI, then the value attached to that link is cli, and so on). Then a JS script tells it to hide all projects, and only show all the project that has the HTML class cli. Pretty simple in concept (learned about this in <a href="http://superhi.com/">SuperHi</a>). I dynamically implemented the HTML class names to every project just by adding &lt;%= project.category %&gt; to the project div— such that it becomes &lt;div class=”project &lt;%= project.category.downcase %&gt;”&gt;. The .downcase was to ensure that the HTML class name is now cli instead of CLI. I had that inkling the first time around and everything works perfectly. But during deployment, I deleted the .downcase and everything fell apart. Please don’t ask why I deleted it.</li><li>Customise radio button look. I had the help of <a href="https://medium.com/u/2687a6e67fd0">Sam Keddy</a>’s public <a href="https://codepen.io/samkeddy/pen/PbROLK">Codepen creation</a> to achieve this. It’s in the create and edit project view of the application.</li><li>Keeping aspect ratio of iframe contents using CSS padding. I still don’t quite remember which percentage means which aspect ratio—but we have the Internet for that.</li></ul><h3>6. Deployment (or Publishing)</h3><p>Deployment was made incredibly painless due to the help of Heroku doing all the heavy-lifting and Dakota’s step-wise walkthrough. Postgres configuration was surprisingly easy. An issue I faced, however, was the Gemfile specification for the pg gem—the version has to be specified, such that it looks like so: gem &#39;pg&#39;, ‘~&gt; 0.20’. Simply adding gem &#39;pg&#39; will not work, and the release will break. Otherwise, all is good.</p><p>Once again, check out the project here: <a href="https://flatiron-hall.herokuapp.com/">https://flatiron-hall.herokuapp.com/</a>.</p><p>All in all, this project wouldn’t have happened without <a href="https://medium.com/u/1d2840d405f6">Dakota Lee Martinez</a>’s help and guidance, and I would like to mention a special thanks to <a href="https://medium.com/u/6ae3d61ea1df">Razelle McCarrick</a> for her support and feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=811b7b8f34d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Libri: CLI Scraper RubyGem for Bibliophiles]]></title>
            <link>https://medium.com/@janicedarikho/libri-cli-scraper-rubygem-for-bibliophiles-ad1a936e3c95?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad1a936e3c95</guid>
            <category><![CDATA[scraping]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rubygems]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Sat, 30 Jun 2018 07:25:28 GMT</pubDate>
            <atom:updated>2018-06-30T08:01:46.105Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*unOpP83dlvhHy5MlQjg1Uw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/6ywyo2qtaZ8?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Eugenio Mazzone</a> on <a href="https://unsplash.com/search/photos/books?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I’ll share my process-based approach on how I created Libri and published it on <a href="http://rubygems.org/">RubyGems.org</a>, alongside some technical roadblocks that I faced during the development phase. This project specifically focuses on scraping, which is a term used to describe the act of retrieving HTML-and-CSS-based data from a website page. Here is a walkthrough video of how Libri works:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F277752446%3Fapp_id%3D122963&amp;dntp=1&amp;url=https%3A%2F%2Fvimeo.com%2F277752446&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F710603592_960.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1152" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c0eac8d644bacc3ec9d48091bf5ec6c/href">https://medium.com/media/4c0eac8d644bacc3ec9d48091bf5ec6c/href</a></iframe><h3>1. Discovery</h3><p>After sifting through several scraping ideas—including scraping <a href="https://noti.st/events">Noti.st</a>, or <a href="https://80000hours.org/problem-profiles/">80,000 Hours’ Problem Profiles</a>, or <a href="https://learn.adafruit.com/category/raspberry-pi">Adafruit’s Raspberry Pi projects</a>—I settled on going back to a theme that can be simple, meaningful, and usable by many: Books. In searching for which website to scrape from, I had several options: the <a href="http://themanbookerprize.com/international">Man Booker</a> website, <a href="https://www.goodreads.com/award">Goodreads’ Awards</a> section, as well as <a href="https://www.penguinrandomhouse.com/books/award-winners">Penguin’s Award Winners</a> list.</p><p>I chose <a href="https://www.barnesandnoble.com/b/books/awards/_/N-29Z8q8Z1d6q?showMoreIds=10008">Barnes &amp; Noble’s</a> awards webpage to scrape as it seems to be the most comprehensive and it’s also quite up-to-date.</p><h3>2. Strategy</h3><p>To build a gem using Bundler, I started by running bundle gem libri in the terminal at the Libri working directory. This will create file structures (called <a href="https://bundler.io/v1.16/guides/creating_gem.html">scaffold directory</a>) for our gem, so we can start coding right away.</p><p>I made sure that my computer has also installed the following dependencies:</p><ul><li><strong>Rake</strong>, used to build a local copy of our gem, which we’ll use to push and publish to RubyGems.org</li><li><strong>OpenURI</strong>, used to open a URL as if it is an HTML file</li><li><strong>Nokogiri</strong>, used to parse HTML and XML values from a webpage</li><li><strong>Pry</strong>, used as a local sandbox and a debugging tool</li><li><strong>Colorize</strong>, used to style text in the terminal using different colours</li></ul><h3>3. Architecture</h3><p>Now, for Libri, I wanted to make 3 things work on my terminal:</p><ol><li>Display the various awards</li><li>Display the books belonging to a chosen award</li><li>Display the information of a chosen book</li></ol><p>To do this, I structured my lib folder in this manner, separating the CLI, scraper, awards, books, and book classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*YmKk_1m67ONVidLpO7Xv0g.png" /><figcaption>Simplified directory structure for Libri</figcaption></figure><p>Each class is responsible for different parts of the gem:</p><ul><li>The CLI class is responsible for the terminal interface that interacts with the user</li><li>The scraper class scrapes text-based contents off the webpage</li><li>The awards class creates new instances of Awards object from hash values returned by the Scraper.scrape_barnes_noble method</li><li>The books class creates new instances of Books object from hash values returned by the Scraper.scrape_award(award) method</li><li>The book class creates new instances of Books object from hash values returned by the Scraper.scrape_book(book) method</li></ul><h3>4. Development</h3><p>This stage took the longest to complete, but all in all, it was a success, and I have several notes to make:</p><ul><li>I learned to use a multi-line string via HEREDOC, which in itself has various methods to achieve the same thing (e.g. %{...}, %Q{...}, &lt;&lt;-EOS...EOS)</li><li>Initially, whenever an exit command was called, the Please try again. message would also be displayed. This was fixed by using a single-level if/else...end conditional rather than while input != &#39;exit&#39;...end loop.</li><li>I knew that I wanted to access several levels of information, scraping from various URLs, and being able to pass in different URL based on the user’s input (e.g. if user inputs for the Pulitzer Awards, the Scraper.scrape_award() method must return information based on the Pulitzer Awards URL. If user inputs for Man Booker Prize, the expected return should be from the Man Booker URL). I knew then that I needed to pass in the URL as an argument for the Scraper.scrape_award() method. Knowing this, I included a :url key into the top-level awards hash, whose value will be passed in to Scraper.scrape_award(). Then, the second-level books hash can scrape from and access from the passed in URL—the same concept applies as we scrape from a third-level URL for individual book information. I wasn’t sure if this was workable, as previous labs I worked on hasn’t used a multi-level, real-time updated website, and therefore had no need for this flow. But it was! This was the best revelation I learned while building this project, knowing that versatility can be built into code.</li><li>I couldn’t access HTML values for attributes which are not href. The rating values on the B&amp;N website was stored within the aria-label attribute, which does not return a value when I attempted to access it. I also couldn’t access the books listed under the <strong>Customers Who Bought This Item Also Bought </strong>section, which returns nothing as well. I’m still searching for answers.</li><li>Originally, upon scraping, I realised that I could access hash values and display them from the CLI class using Hash[:key], even without instantiating new objects and assigning them their arguments / attributes. This led to an oversight, where I published the working gem without practicing the Ruby object relationship methods, such as has-many. This was fixed by editing the awards, books, and book classes accordingly. Now we can access hash values, such as book.title and book.author using the attr_accessor.</li><li>At one point, as the terminal displayed a list of books, then went back to select another award, the list of books displayed was accumulated, resulting in 20–40–60… number of books. This was a disaster, and I had almost given up. However, it was soon realised that the bug was caused by CLI#make_book(award) method being called every time CLI#menu_award was called, and this adds a new array of books onto Books.all. #make_book(award)<em> </em>is needed to instantiate our Book object and to access various attributes of our Book, and we need that. To fix this, a method to clear the previous instantiated object was included before #make_book(award) is called, thus resetting the Books.all return value for each menu call.</li></ul><p>All in all, I wouldn’t have been able to overcome these challenges without talking through my code line by line, component by component, flow by flow, as suggested by Dakota.</p><p>By talking out my thought process based on this rough flow:</p><ul><li>What am I trying to do?</li><li>Is Ruby doing what I’m expecting her to do? (Yn)</li><li>If no, what’s happening instead, and why do we think it’s happening?</li><li>If it’s happening because of X—then, if we change Y, we expect Z to happen.</li><li>We test our hypothesis by changing Y, and we see if Z happens.</li><li>If Z happens, based on our understanding of X, we should know how to fix it and achieve what we were trying to do.</li><li>If Z doesn’t happen, don’t give up! Read up and look for help, and test different understandings to find the one that works with Ruby.</li></ul><p>This is a simple project, however, with several different components interacting with one another, it was soon quite easy to lose track of one of them (e.g. how best to access and display every single piece of information, at which stage have objects been instantiated and at which stage they have not been, etc.), and when I lost that one, I soon lost focus on the big picture and I had to start all over again. So here’s to remember to keep practicing, and to practice it <strong>right</strong>!</p><h3>5. Publishing</h3><p>Lastly, to publish a gem for the first time, I followed these simple steps:</p><ol><li>Edit the Gemspec file and update the Summary as well as Description specification. Make sure that all todo on the file has been rewritten to prevent any potential errors when publishing. Next, comment out the entire code block that says Prevent pushing this gem to RubyGems.org, otherwise we won’t be able to push our gem.</li><li>Change spec.bindir and spec.executables.</li><li>Add dependencies via spec.add_development_dependency and spec.add_dependency.</li><li>Update the version.rb file if necessary, following <a href="https://guides.rubygems.org/patterns/#semantic-versioning">semantic versioning</a> standards. There are many guides out there, including <a href="https://www.jvandemo.com/a-simple-guide-to-semantic-versioning/">this</a> and <a href="https://www.sitepoint.com/semantic-versioning-why-you-should-using/">this</a>.</li><li>Update the README.md file as well. This is to help users have an overview of the gem, as well as how to install and run the gem.</li><li>Make sure that your GitHub repo has all its files updated (latest commit and push).</li><li>Make sure that rake is installed—so we can run rake build followed by rake release, which will push our latest gem version onto <a href="http://rubygems.org/">RubyGems.org</a> for others to use! Alternatively, I also tried using gem build and gem push libri-0.x.x.gem to a similar effect. Another alternative is to install the gem-release gem, which provides several methods for helping with gem development that I will explore with further projects.</li></ol><p>Hope you enjoyed this post, and I hope that makes sense to you! Drop in any suggestions for the gem and I’ll work on it. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad1a936e3c95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Object Relationships in Ruby with Pokémons]]></title>
            <link>https://medium.com/@janicedarikho/learning-object-relationship-in-ruby-with-pok%C3%A9mons-c1f7e816fa8a?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1f7e816fa8a</guid>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[pokemon]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Sun, 03 Jun 2018 15:22:34 GMT</pubDate>
            <atom:updated>2018-06-04T14:36:08.230Z</atom:updated>
            <content:encoded><![CDATA[<p>After spending the better part of my Sunday trying to understand Object Relationship, and still not getting anywhere near a lightbulb moment (not even a dim one), I travelled across the Internet land for the very best explanation, searching far and wide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zxFg2OJcJRsBatiOVmL3fA.jpeg" /><figcaption><a href="http://knowyourmeme.com/memes/subcultures/pokemon">Pokémon</a> — 1st Gen Starters are vacationing in Alola</figcaption></figure><p>That’s when I stumbled upon this short post by <a href="https://medium.com/u/6d3b2b8bc83c">Han Lee</a>, where he described <a href="https://medium.com/@tpstar/object-relationships-in-ruby-explained-by-relationships-in-pokemons-8dd64c8af773">object relationship using Pokémon</a>. It was so good! But so short! 🤕</p><p>So I decided to take it further. In essence, object relationship is a concept used to illustrate how different instances of our classes can interact with one another, as with real-life situations. Our class instances can also be referred to as <strong>models</strong>. There are several basic ways in which models relate to one another—in this case, I’m going to practice the belongs to and the has many relationships.</p><p>In the world of Pokémons, you can have many Pokémons (e.g. Pikachu, Eevee, etc.). In a reciprocal manner, those Pokémons belong to you. And because you love Pokémons and you want to teach them more, each of your Pokémon also has many moves and those moves belong to each Pokémon with a specific type (e.g. electric, grass, etc.).</p><p>So let’s set up our three separate classes: Trainer, Pokemon, and Move.</p><p>As we commit to become the very best trainer, like no one ever was, Prof. Oak called us to his lab and asked for our trainer_name. At this point, we still have no Pokémons and our array starts empty. But no worries! We’ll earn our first starter Pokémon in no time!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8990969de6b931571ac08fbd09034391/href">https://medium.com/media/8990969de6b931571ac08fbd09034391/href</a></iframe><p>Alright. Now, let’s set up our Pokémons! Since our Pokémons belong to us, we are assigning attr_accessor :trainer at the beginning of the class. Next, our class Pokemon is responsible for recording all the Pokémons that we are going to encounter, and push them into our global variable @@pokedex. When we encounter a new Pokémon, we also need to record its pokemon_name and pokemon_type, among other things, but we’ll keep it to these two for simplicity! And because we’re still a Lv 1 trainer, most of our Pokémons have not been taught any special moves yet, and our instance variable pokemon_moves initiates to an empty array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e64ea07435fe3d1f96893aa33a04a8a/href">https://medium.com/media/7e64ea07435fe3d1f96893aa33a04a8a/href</a></iframe><p>We’re also going to create a Move class, not to complicate things, but because we promised to teach our best friends a few chops and kicks! Since we can only teach certain moves to Pokémons of a corresponding type, we also need to define pokemon_type when we’re creating a new instance variable move.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baf355d33ae56e9c309b84f71ed36dc6/href">https://medium.com/media/baf355d33ae56e9c309b84f71ed36dc6/href</a></iframe><p>Now, we’re done setting up! Let’s go back to our Trainer class. We’ve chosen Pikachu as our first starter, and we need a method within our class to add Pikachu onto our slots. Our #add_pokemon method will, <em>well</em>, add our Pokémon for us. And by assigning self to our pokemon.trainer, we automatically reciprocates the relationship between new Pokémon and ourselves, the trainer. Lastly, we can also check each Pokémon in our current slots using the #pokemon_slots method, which will also helpfully tell us our Pokémon’s type.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e23de103762c9b4ed3c3d5dc4655e4e3/href">https://medium.com/media/e23de103762c9b4ed3c3d5dc4655e4e3/href</a></iframe><p>So, let’s check on our code by calling on our methods!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9de8311d88213fbfc3cd78cd78a25e5a/href">https://medium.com/media/9de8311d88213fbfc3cd78cd78a25e5a/href</a></iframe><p>Now, next, after levelling up some, we want to teach our friends some <em>sick</em> moves. How do we do that? We already have our Move class, which we can use to call new moves anytime. What’s next? We probably need to define some methods in our Pokemon class so that we can assign a new move to a Pokémon. But our Pokémons can only learn moves that correspond to their types, so we need to code that conditional in as well. And finally, to look at all the moves each Pokémon knows, we use the known_moves method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5bace4778f93141c313b5e681c377617/href">https://medium.com/media/5bace4778f93141c313b5e681c377617/href</a></iframe><p>Let’s try calling our new methods!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c2de12b5ab8ae29f994e9df86466458/href">https://medium.com/media/6c2de12b5ab8ae29f994e9df86466458/href</a></iframe><p>All done! Here, we learn about how each class can use the informations in other classes to its advantage, especially with the help of attr_accessors. We also learned about how to access those information and represent them as strings or array, using Ruby’s built-in map method. We also used self whenever we want to use objects (data and behaviour) to describe something. We got to practice some conditionals along the way, too. So that’s it! Hope that was as much fun for you as it was for me!</p><p><em>All flub-ups and boo-boos, if there are any, are mine. Any questions, shoot a message anytime! I don’t bite. Follow me on Twitter at </em><a href="https://twitter.com/jouissances_"><em>@jouissances_</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1f7e816fa8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First Step]]></title>
            <link>https://medium.com/@janicedarikho/first-step-9937d04458db?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9937d04458db</guid>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[career-change]]></category>
            <category><![CDATA[full-stack]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Wed, 16 May 2018 12:02:41 GMT</pubDate>
            <atom:updated>2018-06-06T02:36:26.268Z</atom:updated>
            <content:encoded><![CDATA[<h4>This post marks my first step towards becoming a career Full Stack developer.</h4><p>I’m not, by any means, the first career changer who decided to pursue tech as a lifetime career. For me, that original career path is as a medical representative in Singapore, and eventually becoming a medical science liaison (MSL).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXixptvL4rzkx3EDuj38xw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/ieic5Tq8YMk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Chris Ried</a> on <a href="https://unsplash.com/search/photos/program?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I first dabbled in code when I was 16, designing custom HTML and CSS post templates for <a href="https://potterdirectory.tumblr.com/">online Harry Potter RPG forums</a>. I didn’t know it was called ‘code’ then, I just figured it made things look and work better. One thing led to another, and after my college graduation, I had plenty of free time while job-searching, and I clicked on an ad that led me to <a href="https://www.codecademy.com/catalog/subject/web-development">Codecademy</a>. I spent many hours learning the basics of Front End, and after a week, I decided to enrol in one of the Pro Intensive courses. As of now, they have 9 Intensive courses, from Build Websites from Scratch, Build Front-End Web Apps, Build Website UIs, Programming with Python, to Data Analysis. I completed the first three courses, but I still didn’t feel satisfied. I would browse through <a href="https://www.siteinspire.com/">SiteInspire</a> and I would get a headache while trying to apply my current skills to build those products. I couldn’t. I wanted to learn so much more. By now, 4 months have passed and I was just starting with my current job.</p><p>Prior to this job, I have never faced so many rejections in a day. Nevertheless, it taught me about perseverance and gradually, I learned a few things about the trade and how I can improve. I still learn to code after work hours, putting in hour after hour to this newfound hobby. I started asking my clients if they would like a freelance web development service, and several said yes! I’ve never been so excited — finally, I wasn’t offering a product that others made, I was offering <strong>my own product</strong>. Something that I can call my own and be proud of, something that potentially can help users and benefit the clients.</p><p>During these times, I sought out help like no other — I signed up for more courses, including design (and eventually, UI/UX Design), parsed through many arrays of resources (which I’ve collated <a href="https://airtable.com/shrJlUOffa9Q3dKrx]">here</a>) and determined which ones are worth the time and cost. I practiced a lot harder. I made <a href="https://www.codenewbie.org/podcast">CodeNewbie</a> and <a href="https://userdefenders.com/">User Defenders</a> part of my daily commute routine. I joined local coding Slack channels, attended free meetups, and approached potential mentors who I really admire and respect. I have never felt more exhausted, but at the same time, I have never felt so fulfilled, motivated, and thrilled about something. After mulling for a couple of weeks, it was <a href="https://twitter.com/saronyitbarek?lang=en">Saron</a>’s confidence, encouragement, and prowess that finally convinced me to join Flatiron School. And after completing the <a href="https://learn.co/tracks/bootcamp-prep">Bootcamp Prep,</a> I enrolled with a <a href="http://go.flatironschool.com/women-take-tech-lyft">Women Take Tech </a>scholarship (made possible by Flatiron and Lyft) under my belt.</p><p>There are many reasons why I believe that tech is a thriving industry and always will be. I’ll share a few here:</p><ol><li><strong>The possibility of creating and inventing any tech product is almost limitless.</strong><br>There isn’t an industry quite like this. The improvements in AI (think <a href="https://medium.com/@LanceUlanoff/did-google-duplex-just-pass-the-turing-test-ffcfe6868b02">Google Duplex</a>), science, and software languages in the past decade alone is enough proof that technology can be unstoppable. Furthermore, depending on the project scope, the cost of building a product can virtually be zero — except for time and effort.</li><li><strong>The intersection of many different disciplines with tech.</strong><br>The typical pillars of industrial sectors include STEM, arts, humanities, education, business, finance, and security. Tech is one sector which is able to connect multiple disciplines, allowing a diversity of resources to interact and create something unique. I’d like to think that <a href="https://www.wired.com/brandlab/2018/03/dxc-creating-tech-economy-future/">in the future</a>, these different areas would have integrated tech in their system so deep, that everything will become dependent on tech to operate efficiently, and thus increasing the demand for skilled engineers.</li><li><strong>The community is superb, supportive, and incredibly resourceful.</strong><br>There is something about the tech community that is truly encouraging. From open-source projects to a casual extended helping hand from a senior developer, there is no place where a newbie developer wouldn’t feel welcome. Some developers can be quite critical, yes, but there are so many others who are willing to help and guide a newbie along on the right path. There is no metropolitan city on Earth that doesn’t have a local coding community meetup, or an annual conference, or a coding bootcamp. Also, #MINSWAN.</li><li><strong>Coding allows for the expression of both an individual’s creative and logical processes.</strong><br>Firstly, this may not directly contribute to the progress of tech as a whole, and secondly, it is a lesser known concept about programming, which is substantiated <a href="https://www.infosun.fim.uni-passau.de/cl/publications/docs/SKA+14.pdf">here</a>. As a discipline, computer science and data theories may seem to have a tendency to focus more towards logical thinking; however, the fact that there are many ways to solve a problem proves that creativity is required in the field of programming. And at an individual’s level, this feature of coding can be very liberating, encouraging more and more learners to participate in the ecosystem.</li></ol><p>I have many other slew of reasons, but I’m sure that I might be preaching to the choir here. I’m also very opinionated about the importance of design in creating impactful products, which is why I’m also enrolled in a UX Design course. After my Flatiron graduation, I would like to find a Junior Developer position where I’m also allowed to be flexible and participate in the UX research team, or vice versa. I would like to find a job that provides me with a much better financial resource, future prospect, and autonomy when it comes to learning continuously. I would love to find a job that allows me the freedom to work remotely, preferably with a small, capable, and ambitious team.</p><p>In 5 years’ time, I hope to be able to also build a remote digital agency that focuses on creating impact for SMEs and non-profits.</p><p>There are many things I’m not confident about — such as the hiring climate in Singapore by the time I graduate, the discrepancy between the advertised salaries on bootcamps and the actual salaries which local companies are willing to offer. I would even be lying if I was to say that I’m perfectly confident that everything will go easy during this bootcamp, especially with the GMT +8 timezone and 3AM study groups.</p><p>But here’s to never giving up.</p><p><em>First published via </em><a href="http://learn.co/"><em>Learn.co</em></a><em>, at </em><a href="http://janicedarikho.com/"><em>janicedarikho.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9937d04458db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Expanse: An Ode for The Future]]></title>
            <link>https://medium.com/@janicedarikho/the-expanse-an-ode-for-the-future-13aa523bd761?source=rss-706a46ee0ea3------2</link>
            <guid isPermaLink="false">https://medium.com/p/13aa523bd761</guid>
            <category><![CDATA[books]]></category>
            <category><![CDATA[scifi]]></category>
            <category><![CDATA[science-fiction]]></category>
            <category><![CDATA[space]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <dc:creator><![CDATA[Janice Darikho]]></dc:creator>
            <pubDate>Sat, 12 May 2018 01:25:15 GMT</pubDate>
            <atom:updated>2018-05-16T11:58:54.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5862EOWgirtnBxxOqqQvrA.jpeg" /></figure><blockquote>A hundred and fifty years before, when the parochial disagreements between Earth and Mars had been on the verge of war, the Belt had been a far horizon of tremendous mineral wealth beyond viable economic reach, and the outer planets had been beyond even the most unrealistic corporate dream. Then Solomon Epstein had built his little modified fusion drive, popped it on the back of his three-man yacht, and turned it on. With a good scope, you could still see his ship going at a marginal percentage of the speed of light, heading out into the big empty. The best, longest funeral in the history of mankind. Fortunately, he’d left the plans on his home computer. The Epstein Drive hadn’t given humanity the stars, but it had delivered the planets.</blockquote><blockquote>— <strong>Leviathan Wakes</strong>, Book 1 of The Expanse Series</blockquote><p>I stumbled upon The Expanse from a podcast recommendation heard by a friend. We went on to watch it on Netflix, and fell in love with the stories. To me, politics stood out as the main theme. In a universe where the “enemies are often allies,” and where the protagonists had to choose which side(s) to fight for, the political theme of it all is hardly obscure. Set in the year 2350, three full centuries after today, governments are still shoving each other back and forth and showing off arms (the only difference being—the distance between them has now increased to planetary proportion). Essentially, the narrative is saying that, even with modified fusion drives, high-tech medical robots, lab-synthesised foods, and linguistic conflations, nothing fundamental to humanity will change.</p><p><strong>‘Survival of the fittest’ still holds. </strong>Belters, a majority of whom are oppressed blue-collar workers, had to laboriously slave in exchange for artificial gravity, filtered air and kibbles. The ones who could survive in space — which involves possessing a working knowledge of spaceship maintenance and engaging in acceleration burns higher than that of their asteroidal gravity—will live on. The Martians’ sole purpose of existing seems to be to live in fear and suspicion of a perpetually impending inter-planetary war. Earthers, well, we stay the same. Full of complacency, ready to show arms, eyes always on the bottom line. Always ready to cite good intentions while being absolutely blind to collateral damages (reference to Mao, a megalomaniacal conglomerate keen on alien experimentations).</p><p><strong>Imperialism and exploitation of the ‘others’ is the modus operandi. </strong>In this not-so-distant future, Earth’s resources has been drained dry, and Belters had to work and provide for the Earth—mostly in the form of ores and minerals, as the asteroids contain a wealth of those. In exchange, the Belters were given oxygen, water, and fake foods (mostly soy derivatives). Their altered physiology of having born in low-gravity entraps them onto the asteroids; they would not be able to go anywhere without physical therapy and a concoction of bone-density increasing pharmaceuticals (which they cannot afford).</p><p><strong>Technology went on to advance further than humanity did.</strong> This has spoiler alerts, so I’ll leave this just here for now. Hint: Has to do with military.</p><p>Secondary to the political diplomacy and deterrence (D&amp;D) back-and-forth, I was amazed by how realistic the setting seems. The best and brightest of Earth have colonised Mars for approximately three generations, and these Martians seem to have two sole purposes of existing—to make Mars self-sustaining and to prepare themselves against an impending war from Earth. And as if Mars itself wasn’t going to be viable enough, some Earth and Mars settlers travelled even further towards Jupiter and Saturn, towards the main asteroid Belt, where they had to teach asteroids how to spin and to create artificial gravity for the colonies to live. Of course, when readers looked into the <a href="https://www.youtube.com/watch?v=gU9dCWY7G2M">scientific concepts underneath this feat</a>, it doesn’t make much sense—but The Expanse still manages to touch on details that other sci-fi series completely ignores. Several examples include the physiological changes between generational Martians and Belters who grew up in low gravity, the pharmaceutical ‘juice’ needed to sustain lives when ships go on hard acceleration burns, the radio lag during inter-planetary communications, etc.</p><p>If all these fiction bear some truth in the future, we’ll perhaps be doomed, but when humanity unites itself eventually, there will be hope.</p><p>All in all, an awesome read. Check it out on Amazon <a href="https://www.amazon.com/gp/bookseries/B00K7B2CRQ">here</a>. (<strong>Book 8: Tiamat’s Wrath is available for pre-order</strong>! To be published in December 2018.) Meanwhile, check out the series on Netflix <a href="https://www.netflix.com/sg/title/80029822">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13aa523bd761" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>