<?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 Raphael Ugwu on Medium]]></title>
        <description><![CDATA[Stories by Raphael Ugwu on Medium]]></description>
        <link>https://medium.com/@ugwuraphael?source=rss-c089388e3c20------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*J3wBUz8409BS_uvmKlJUxQ.jpeg</url>
            <title>Stories by Raphael Ugwu on Medium</title>
            <link>https://medium.com/@ugwuraphael?source=rss-c089388e3c20------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:19:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ugwuraphael/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[Redefining monetary value post-2020  —  the best is yet to come.]]></title>
            <link>https://ugwuraphael.medium.com/redefining-monetary-value-post-2020-the-best-is-yet-to-come-1f35418dcf6d?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f35418dcf6d</guid>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[africa]]></category>
            <category><![CDATA[venture-capital]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[investing]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Mon, 12 Apr 2021 07:29:42 GMT</pubDate>
            <atom:updated>2021-04-12T07:40:44.353Z</atom:updated>
            <content:encoded><![CDATA[<h3>Redefining monetary value post-2020 — the best is yet to come.</h3><h3>Before the pandemic</h3><p>Pre 2020, I had a “normal” 9 to 5 and I knew where my money (which was mostly in Nigerian Naira at the time) went. Measuring the value of something was more straightforward as central banks used data on inflation and unemployment to adjust interest rates and keep fiat circulation to reliable levels.</p><p>The inflow of money into startups, stocks, real estate, bonds, and cryptocurrency could be justified as fiat regulation systems based on the laws of demand and supply were in place for countries mainly seen as financial powerhouses. Here are the interest rates and inflation data of some developed countries circa January 2020. (I had most of these figures memorized as I traded a lot of FX at the time):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C0rYEdhSNpNmgYCe4kbAVQ.png" /><figcaption>I had most of these figures memorized as I traded a lot of FX at the time :)</figcaption></figure><p>These figures remained well within these ranges until March 2020 when the pandemic forced a worldwide lockdown. Stocks dropped massively (I bought a few), commodities such as oil saw their value <a href="https://www.weforum.org/agenda/2020/04/oil-barrel-prices-economic-supply-demand-coronavirus-covid19-united-states/">drop to below $0 a barrel</a> (didn’t buy this one, was a bit scared) and the global halting of activities prompted central banks of various countries to inject fiat into their economies. A few regions that did this include:</p><p>Europe — <a href="https://www.voanews.com/europe/european-central-bank-says-covid-stimulus-policies-stay-place">put out a total of $2.2 trillion as of January 2021.</a></p><p>Australia — <a href="https://www.bloomberg.com/news/articles/2021-03-28/australia-pulls-job-stimulus-worth-5-of-gdp-in-test-for-economy">supported their economy with an estimated $68 billion so far.</a></p><p>United Kingdom — <a href="https://edition.cnn.com/2021/03/03/economy/budget-2021-uk-stimulus/index.html">paid out over $558 billion so far and still plans to do more.</a></p><p>New Zealand — <a href="https://theconversation.com/new-zealands-covid-19-stimulus-is-a-lost-opportunity-to-move-towards-a-low-emissions-economy-155838">executed a fiscal stimulus plan for NZ$ 50 billion.</a></p><p>Canada — <a href="https://www.aljazeera.com/economy/2021/2/26/canada-sticking-with-79b-stimulus-plan-despite-debt-concerns">has a stimulus plan worth about $79 billion.</a></p><p>United States — <a href="https://www.forbes.com/sites/forbes-personal-shopper/2021/04/05/best-shoes-for-spring/?sh=478456624738">has the biggest plan we’ve got so far, about $4 trillion.</a></p><p>Two things stood out which convinced me that fiat would be useless as a store of value with times to come. First, a lot of tech bros I know maxed out low-interest loans in Naira with a rate of 1 USD/350 NGN, converted their loans to USD, and traded the bull run of April — December. Most of these loans were paid off by converting dollar profits when 1 USD was 450 NGN. This “V8 double-exhaust” run of profit convinced me that anyone who was “hodling” paper money was taking two steps backward.</p><p><em>FYI: The initial terms of the loan never changed.</em></p><p>Secondly, all the fiat pumping done by different governments to revive economies was beginning to have ripple effects which showed that paper money can’t be used as a reliable measure or store of value today. Not only did the pandemic expose the flaws in existing financial models, but it also opened up new possibilities to how people would interpret money and value.</p><h3>New gatekeepers of value</h3><p>Crypto, <a href="https://en.wikipedia.org/wiki/Non-fungible_token#:~:text=A%20non%2Dfungible%20token%20(NFT,other%20types%20of%20digital%20files.">non-fungible tokens</a>, and stocks are seeing increased adoption as means of value. Recently, <a href="https://www.cnbc.com/2021/02/08/tesla-buys-1point5-billion-in-bitcoin.html">Tesla purchased a huge amount of Bitcoin</a> and plans to make the cryptocurrency a payment method for its vehicles. Personally, I’m a huge fan of the refund policy they came up with:</p><ul><li><em>Say when you bought your Tesla, you paid $50,000 in BTC and the value of Bitcoin has increased since then — you will be refunded $50,000 in fiat USD.</em></li><li><em>If you bought your Tesla for $60,000 in Bitcoin and the value of Bitcoin has decreased since then, you will be refunded in Bitcoin.</em></li></ul><p><strong>And Africa???</strong> While it may seem like we’re playing catchup over here, a few African startups — backed by the influx of VC capital to the continent ( <em>part of that $4T has to find its way here innit?</em>) — have broken the mold, redefining what money means for Africans.</p><ul><li><a href="https://flutterwave.com/ng/">Flutterwave</a>: “The plumbing by which the water flows” — Flutterwave’s innovation has been able to create value for a lot of businesses and customers across Africa. With virtual bank transfers, invoices, virtual account numbers, virtual cards, and multi-currency payment infrastructure — it’s safe to say they are at the forefront of redefining payment processes in Africa.</li><li><a href="https://rise.capital/">Rise</a>: Leading the way in easily accessible investment management and embraced by millennials and Gen Zs across Africa, Rise’s investment plans are carefully formulated to hedge against inflation and beat the overall market. With an astounding team of finance experts and money managers, what makes Rise even more interesting is that it was launched in February 2020 — just a month before the market “went to ****” due to the pandemic, yet still managed to deliver on its investment plans for users.</li><li><a href="https://www.piggyvest.com/">Piggyvest</a>: Financial prudence among millennials wasn’t cool until these folks came along. Every feature of their product from Safelock to the quarterly investment plans screams “VALUE” from a hundred yards out.</li></ul><p>Cryptocurrency has been heavily adopted as well, with huge indigenous players like <a href="https://www.quidax.com/">Quidax</a> — who made cryptocurrency available to end-users and changed the face of the game which made external players realize the potential in Africa.</p><p>There has also been increased adoption of gift cards, vouchers, and airtime as stores of value and remittance. I think using these items to pay for goods and services will be a rising trend with time. There are a few players with key infrastructure for this — leading the charge is <a href="https://www.reloadly.com/">Reloadly</a>, which provides API integration and direct access to over 800 telco operators globally <em>( more than 150 of these are in Africa currently ).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*XkPQLBCigszTCsEgo9rBaQ.jpeg" /><figcaption>And with options for multiple currency conversion too! 🥳🥳🔥</figcaption></figure><h3>The future 🚀🚀🚀</h3><p>It’s very exciting to see where all this is headed. Even with the unpredictable regulative practices being enacted by most central banks in Africa, the innovative army of entrepreneurs in Africa continues to march on. Ten years from now:</p><ul><li>Will my cousin who lives in Accra be able to purchase a Mandarin course and pay in Chinese Yuan airtime using Reloadly?</li><li>Will my other cousin, who works in Nigeria, be able to take as many rides as she can on a <a href="https://safeboda.com/ng/">Safeboda</a>, and have the costs be deducted from her investment with Rise?</li><li>Will my business partner be able to import 80 tons of wheat from North America using cryptocurrency as a form of payment with Quidax acting as an escrow?</li><li>Will my significant other be able to take a loan from Flutterwave based on their Piggyvest savings score?</li></ul><p>The possibilities are endless and while we may all desire peace and profit, we as an ecosystem need to collectively do the groundwork to ensure the best scenario is achieved. For only we can create the future we want and no other. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f35418dcf6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Single File Components in Vue: Build a Zip Code Finder App]]></title>
            <link>https://ugwuraphael.medium.com/demystifying-single-file-components-in-vue-build-a-zip-code-finder-app-2459995cb4dd?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/2459995cb4dd</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Thu, 20 Jun 2019 10:52:50 GMT</pubDate>
            <atom:updated>2019-06-20T10:52:50.825Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Building single page applications using plain JavaScript can be a bit daunting. Frameworks such as Angular, React and Vue.js were created to provide a better platform to build both mobile and web applications. Vue offers a lot of awesome features that make web development totally worth it. In this post, we are going to learn how to build a single page application ― in this case a Zip Code finder app, with Vue. In case you were wondering, this is what our app will look like when we are done:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTPax3cU8DKw&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTPax3cU8DKw&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb7401c716fe12e2f9619e3a005d923a/href">https://medium.com/media/cb7401c716fe12e2f9619e3a005d923a/href</a></iframe><h3>Creating our Vue Project</h3><p>There are a number of ways to use Vue in your project:</p><p>Global installation via NPM, mainly used when building large scale applications:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/16ab449197a9de92fe12ba3bef461c78.js">https://gist.github.com/fullstackmafia/16ab449197a9de92fe12ba3bef461c78.js</a>&quot;&gt;&lt;/script&gt;</p><p>CDN inclusion via a &lt;script&gt; tag, mainly used for building compact applications:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/6711f1d33cb37c7daa899fbc80f0f809.js">https://gist.github.com/fullstackmafia/6711f1d33cb37c7daa899fbc80f0f809.js</a>&quot;&gt;&lt;/script&gt;</p><p>Vue’s CLI, mainly used when building sizable single page applications:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/d16a24c727ce511113f713ab3e55c4b2.js">https://gist.github.com/fullstackmafia/d16a24c727ce511113f713ab3e55c4b2.js</a>&quot;&gt;&lt;/script&gt;</p><p>When initializing our project using Webpack, we will be asked some questions. Answer these questions using the answers shown in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vy6QcQAqCIAp6iKKLEoVww.png" /></figure><p>Although not recommended for users with no prior knowledge of Node.js, using Vue CLI comes with a lot of advantages, some of which are:</p><p>* You can build processes that allow you use cool features such as ES6 or SCSS.</p><p>* You can build and put together single file templates.</p><p>* Vue CLI allows lazy loading, asynchronous operations, server- side rendering and code splitting.</p><p>In this post, we will be using Vue CLI for our demo. When our project has been set up, it should have a directory structure similar to the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*aTFd4C1cFThohqbp-8F3qw.png" /></figure><p>After setting up the project with Vue CLI and running npm run dev in your terminal, the following welcome page should open automatically in your browser at localhost on port 8080:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c8SlUZ_pWohQfNsxYubMyQ.png" /></figure><h3>Setting up our Vue Component</h3><p>To implement a zip code tracking service in our project, we will use <a href="http://www.zippopotam.us/">Zippopotam</a>, a free API service with responses in JSON format and no need to sign up. To enable us build portable components, Vue allows us create single component files with a `.vue` file extension. This way we can have our HTML, CSS and JavaScript code in one single file. Let’s start by navigating to the `./src/components` folder and replacing the `Helloworld.vue` example with a new file called `zip.vue`. In `zip.vue` we’ll include our HTML template, our Vue logic and our SCSS styling. Let’s first include our template:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/cb516e0cd87b5f239b7e83536c29010d.js">https://gist.github.com/fullstackmafia/cb516e0cd87b5f239b7e83536c29010d.js</a>&quot;&gt;&lt;/script&gt;</p><p>In our template, we create a form and using the `@submit.prevent` event modifier, we control how our form should be submitted. `@submit.prevent` does an awesome job of replacing JavaScript’s `event.preventDefault()` when working with forms. Though JavaScript event handlers can be called inside Vue methods, event modifiers allow us focus on making our methods purely about logic rather than also dealing with events from the DOM.</p><p>An input field for entering zip codes is created. It interacts with our script logic by using Vue’s `v-model` directive. `v-model` creates two-way data binding between our DOM and our Vue logic and updates data based on user input events. Here our `v-model` directive is attached to the current property in our Vue logic’s `data()` function.</p><p>Handling errors on the part of the user is very important. In this case, we will use Vue’s `v-if` directive to conditionally render a message to the DOM should a user input an invalid zip code. If a user inputs an invalid zip code, the following message will be displayed on the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEbtI1VAqd7u6wIBOWgqNA.png" /></figure><p>Information retrieved by our API when a user inputs a valid zip code can be in different modes. For the sake of clarity, our preferred mode would be a list display comprising of the following values:</p><ul><li>City</li><li>State</li><li>State Abbreviation</li><li>Longitude</li><li>Latitude</li></ul><p>To render a list in our DOM, we make use of Vue’s `v-for` directive. `v-for` renders a list of items based on an array. Its usage requires a rare syntax in the form of item in collection, where collection is the source data array and item is a reference to the array element being iterated on.</p><p>Because our list output depends on temporary DOM state (zip code as an input value), we use Vue’s unique `:key` attribute to enable us track the identity of each node and reuse as well as reorder existing elements.</p><p>Having a good idea of how our template works, let’s proceed to append our `&lt;script&gt;` tag containing our Vue logic and our `&lt;style&gt;` tag containing our template’s styling:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/b0aab8da889609294d3f13e3d46905f2.js">https://gist.github.com/fullstackmafia/b0aab8da889609294d3f13e3d46905f2.js</a>&quot;&gt;&lt;/script&gt;</p><p>Single file components are always given a unique name when initializing their Vue instance. It is this name other components use to interact with them should the need arise. Here, our component is named `zip`. Our component is exported using the `export` statement which is used when creating JavaScript modules to export functions, objects, or primitive values from the module so they can be used by other programs with the `import` statement.</p><p>Our data function contains any data that we intend to bind to our DOM. It returns an object that contains properties that can be bound to the DOM and are also accessible to other functions in the Vue instance object via using the `this` keyword.</p><p>Vue lets us define methods that can be accessed by our DOM. Events can be bound to a function and handled by creating the function in the method’s object. Our `getLocation()` function handles our API request and response formats via the use of promises.</p><p>The `catch()` method is implemented to handle rejected cases which could probably occur as a result of the user inputting an invalid zip code.</p><p>Embedded in our `&lt;style&gt;` tag is our styling for our single file component. Please note that it’s important to add the `scoped` keyword to our `&lt;style&gt;` tag if we want the embedded style to be limited to just the component it is included in.</p><h3>Component Communication in Vue</h3><p>In Vue, a single file component can be required in another component simply by using the `import` statement to import that component wherever it is required. This is very handy when we are building ambitious applications that require a lot of features. These features can then be imported under one “mother” `App.vue` file by using the following syntax:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/c1881bfee9600f302f2de0b8777ce85d.js">https://gist.github.com/fullstackmafia/c1881bfee9600f302f2de0b8777ce85d.js</a>&quot;&gt;&lt;/script&gt;</p><p>In our `src` folder, let’s navigate to `App.vue` and import our `zip` component:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/ad0bfaa10f5ff0dde74bf76ad5f5f579.js">https://gist.github.com/fullstackmafia/ad0bfaa10f5ff0dde74bf76ad5f5f579.js</a>&quot;&gt;&lt;/script&gt;</p><p>Here `zip` acts as a child component to `app`. By importing `zip` and including it in the component’s object, we make `zip` reusable in our `app` component. To include any imported templates that might have come along in `zip`, we create a new template in `app` and in it, we insert the custom tag of `zip`:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/6319f335d3c64e6809407c7c543bf7c1.js">https://gist.github.com/fullstackmafia/6319f335d3c64e6809407c7c543bf7c1.js</a>&quot;&gt;&lt;/script&gt;</p><p>Now our app can be styled generally instead of using the `scope` keyword to limit individual styles as we did in `zip`:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/d89c27fe536f3b9534083fb754caa0c0.js">https://gist.github.com/fullstackmafia/d89c27fe536f3b9534083fb754caa0c0.js</a>&quot;&gt;&lt;/script&gt;</p><p>In our project, we may want to include certain libraries and plugins such as BootStrap, jQuery or Lodash. Vue makes it possible to work with third party libraries or plugins. To include a library via `&lt;link&gt;` or `&lt;script&gt;` tag, navigate to the `index.html` file in your project’s root folder and insert the link of the library you want to use in your project:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/2afb2dec3f5b8b07b9e04333d98751f6.js">https://gist.github.com/fullstackmafia/2afb2dec3f5b8b07b9e04333d98751f6.js</a>&quot;&gt;&lt;/script&gt;</p><p>Using third party plugins could be a bit tricky. In this project we will use `vue-resource`, a plugin that provides services for making HTTP requests. In our CLI, let’s navigate to our project folder’s directory and install `vue-resource`:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/b9db6f2080ef7ea857691c4abf561761.js">https://gist.github.com/fullstackmafia/b9db6f2080ef7ea857691c4abf561761.js</a>&quot;&gt;&lt;/script&gt;</p><p>We can confirm if `vue-resource` was successfully installed by opening the `package.json` file in our project folder and checking if `vue-resource` is included in the dependencies object:</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/4006c636ef5dd0e09c3acd7653835639.js">https://gist.github.com/fullstackmafia/4006c636ef5dd0e09c3acd7653835639.js</a>&quot;&gt;&lt;/script&gt;</p><p>To include `vue-resource` in our project, let’s navigate to the `main.js` file in our project folder. In `main.js`, we import every parent component as well as every installed library or plugin that is required by our application. Let’s proceed to import Vue which was installed earlier when we configured Vue’s CLI In our project. We will also be importing `vue-resource` and our parent component `App`:</p><p>(N.B: If you are having problems importing Vue into main.js, you can run npm install vue in your CLI to install Vue globally).</p><p>&lt;script src=”<a href="https://gist.github.com/fullstackmafia/27ad0babde3cf6efcfe875e168c591a9.js">https://gist.github.com/fullstackmafia/27ad0babde3cf6efcfe875e168c591a9.js</a>&quot;&gt;&lt;/script&gt;</p><p>A new Vue instance is created where our entry component has an `el` property which uses a query selector to attach our imported template and component to the DOM — which in this case is `index.html`.</p><h3>Conclusion</h3><p>Building applications in Vue using the approach of single file components is a concept which should be adapted for best practices. For building applications with a lot of components, it is recommended to use <a href="https://vuejs.org/v2/guide/routing.html">vue-router</a>. To get an awesome head start on Vue Router, check out this <a href="https://scotch.io/tutorials/getting-started-with-vue-router">post</a> by <a href="https://twitter.com/edzynda">Ed Zynda</a>. If you’d like to contribute to this project, feel free to check it out on <a href="https://github.com/fullstackmafia/vue.js-zip-finder">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2459995cb4dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everyday dot JS; Building a Scientific Calculator with Vanilla JS]]></title>
            <link>https://medium.com/techtrument/everyday-dot-js-building-a-scientific-calculator-with-vanilla-js-b1c351910528?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1c351910528</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Sat, 19 Aug 2017 10:45:22 GMT</pubDate>
            <atom:updated>2017-08-19T21:24:00.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwsXyrPPepbRJWvQkxfqqQ.jpeg" /><figcaption><a href="http://www.ifpa.org.tw/news_detail/77.htm?cfrom=1">http://www.ifpa.org.tw/news_detail/77.htm?cfrom=1</a></figcaption></figure><p>Calculate… it’s all we seem to do all the time. From planning budgets and getaways to what’s left in our 401k account, it all involves a bit of calculation. It’s no different for software developers too; we calculate when we build stuff. Right now that “stuff” we’re going to build step by step, and patch piece by piece, is a scientific calculator.</p><p>Now this won’t involve APIs which makes it very concise and easy (or kind of tricky) for us. Skills you’ll need are a good command of HTML, CSS and JavaScript. Use your imagination, we’re going to be doing a lot of DOM manipulation here as well. It’s fair to say we’ve gotten off to a good start. Let’s do this!</p><p><em>( If you’d rather just copy and paste code, then figure out how it works over a cup of coffee, there’s a back door with a flight of stairs that’ll take you </em><a href="https://codepen.io/fullstackmafia/pen/XaZBjB"><em>there</em></a><em> )</em></p><h3>Adding your buttons</h3><p>We’re going to begin with our HTML here, creating buttons that will define how we’ll use our calculator. Every scientific calculator has it’s functionality grouped into four types; basic functions ( +, -, *, / …..), trigger keys (backspace, clear and enter), number keys (0–9 basically) and advanced functions (ln, cos, log, rad, x^ …..). For easier manipulation when assigning functions in JavaScript and styling in CSS, we’ll give each button a class of button as well as a class from one of these four; basic-stuff , numbers , triggers and complex-stuff :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*IHVGRXk6c3T_fM_SPFEJag.png" /></figure><h3>Adding our Trigger functions</h3><p>In our next step, we’ll have to create our three most important buttons; CLEAR , ENTER and BACKSPACE . With one or two functions and some good old JavaScript methods, we’ll be done with this part in no time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*1pckGka7S_vajHh3bRf5Dw.png" /></figure><h3>Tackling syntax errors</h3><p>Our calculator should be able to log syntax errors when a wrong calculation, say 7-*8 is inputted. We’ll have to create a function for this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*t7-_qHJKq-jbNbruN8I-YA.png" /></figure><h3>Defining our button functions</h3><p>Here we’ll proceed to define each button’s function. This can easily be done via the <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math">JavaScript Math Object</a>. We’ll be covering a whole lot. To get you fired up, here’s some excerpts from the code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*weO0aEAJrNK67aXRmBF3Hg.png" /></figure><h3>Integrating our functions with our buttons</h3><p>The final piece of our puzzle? Giving our users something to click and seeing it actually works. Remember we gave every button a class of button earlier on? We’re about to put what we did to good use. We’ll create an array of every element with the class name button and loop through the array, calling each button and assigning it’s appropriate function. It’s some long code ( 10,000 lines yeah! :)) but as usual we’ll provide excerpts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*10rSJXxlHrJZrsYbDFqs7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*seJsIZDIPgK62MPDTwg4oQ.png" /></figure><h3>Conclusion</h3><p>We’ve crossed the finish line, notice I didn’t say anything about CSS? This is because unlike HTML and JavaScript, you’re allowed to do your own “thing” in CSS; or so it seems. People seem to think CSS is easy, I’m taking sides with <a href="https://medium.com/u/584caaf5bf10">Otis Wright</a> <a href="https://hackernoon.com/if-css-is-so-easy-why-does-everyone-suck-e4442cc9428a">here</a>.</p><p>You can review the calculator <a href="https://codepen.io/fullstackmafia/pen/XaZBjB">here</a>, if you wish. Cheers!</p><p><em>If you liked this, kindly give an ovation with the applause button, thanks in advance!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1c351910528" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrument/everyday-dot-js-building-a-scientific-calculator-with-vanilla-js-b1c351910528">Everyday dot JS; Building a Scientific Calculator with Vanilla JS</a> was originally published in <a href="https://medium.com/techtrument">Hackmamba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with LogRocket; Fixing productivity issues with your App.]]></title>
            <link>https://medium.com/techtrument/getting-started-with-logrocket-fixing-productivity-issues-with-your-app-349983ffd995?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/349983ffd995</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[logrocket]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Thu, 10 Aug 2017 16:12:59 GMT</pubDate>
            <atom:updated>2017-08-10T16:18:41.541Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N6R0a10NrJlr5adCqXZTtA.jpeg" /><figcaption><a href="http://vistanews.ru/uploads/posts/2016-01/1453267890_193564.jpg">http://vistanews.ru/uploads/posts/2016-01/1453267890_193564.jpg</a></figcaption></figure><p>For the thousandth time, you test! On Chrome, Firefox, Safari, Edge, Opera, Midori (wait, what the hell is that?) and Internet Explorer (even though we laughed at the memes, we’re all to scared to pull the plug and leave our dear IE out of the equation). For mobile and web; you’re leaving no stone unturned here. Your app is going to change the world! It’s going to change how humans control machines - or how machines control humans (there’s no limit to how crazy these ideas can get, believe me). You’ve got so much in store for this app that it’s all… just… so…..</p><p>Buddy, you better wake up from your reverie. Your app is going to have bugs! Sorry if I hurt your feelings, (part of me didn’t intend to really) but this isn’t High School Musical. We’re going to have issues here; issues with users who don’t even know their way around, server issues, even issues with the kind of folks who don’t have working Wi-Fi drivers on their device yet, download Xender and then give it a one star review. The bad news is, there will always be demons, the good news is we can keep real-time track of these demons, where they are coming from and how to send them back into the pit.</p><p><strong>Enter LogRocket! </strong>A pro JavaScript tool from the stables of <a href="https://medium.com/u/db592a2b460f">Matt Arbesfeld</a> and <a href="https://medium.com/u/761b6ecc0758">Ben Edelstein</a>, it was designed for the “once-in-a-while-I’m-confused” software developer (that’s you and I really). When your app goes gold, LogRocket records sessions of every action users carry out, captures logs and reproduces bugs. This in general helps fix issues faster. It’s high time you stopped guessing why bugs happen, come with me.</p><h3>Installing LogRocket</h3><p>First of all, we need to visit <a href="https://app.logrocket.com/">LogRocket</a> to obtain an app ID for all our interactions.</p><p>Then we install via npm by logging the following on our CLI:</p><p>npm i --save logrocket</p><p>In the opening lines of our code:</p><p>import LogRocket from &#39;logrocket&#39;;</p><p>LogRocket.init(&#39;app/id&#39;);</p><h3>Collecting feedback with LogRocket.</h3><p>The primary function of LogRocket is to collect user data in various ways, this helps you to debug issues quicker and understand how users behave. Other ways of accomplishing this include:</p><ol><li>Automatically capturing Redux actions, Redux state and console logs from your app.</li><li>Captures real live videos of users on your app, a feature made possible with the aid of <a href="https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver">MutationObserver API</a>. LogRocket lets you replay these videos so you can have a hands on approach to the problem as well as identify corresponding user behavior.</li><li>Handling network requests and responses. LogRocket does this by making use of the XmlHttpRequest and fetch APIs to get request and response data from your app, taking into account status codes, headers and bodies.</li><li>Capturing performance data. Although still in Alpha, your app’s Frames Per Second (FPS), bandwidth and memory usage are captured so as to assist you have a better understanding of a user’s general experience with your app.</li></ol><h3>Data Privacy with LogRocket</h3><p>With all this user data flying around, it’s only right to know about how discreet LogRocket is with handling data, right? Well LogRocket takes privacy serious enough to hide user data such as passwords, personal data and credit card data. Knowing there’s a line to cross when gathering enough information to help with debugging is key here. To implement this, LogRocket’s SDK was designed to allow developers make decisions on what kind of information to exclude from LogRocket reports (need I say that since privacy and security can never get old, constant updates are being made to LogRocket and features are added). The SDK accomplishes this by adding the class name _lr-hide to any DOM element you want to make private. This way any DOM element(s) that the private DOM element is a parent of won’t leave the parent browser. Form data and password fields are not excluded from this, _lr-hide can also be added to input and textarea DOM elements.</p><h3>Security with LogRocket</h3><p>As previously stated, the significance of security and handling user data cannot be stressed on enough. It’s important both users and engineers feel secure with any tools used to enhance an app. While bearing in mind that the most effective way to stay secure is to avoid unnecessary exposure of sensitive data in the first place, here are a couple of ways LogRocket keeps you covered:</p><ol><li>It blocks third party cookies; LogRocket does not create a unique profile to track users across domains that are not related to the user.</li><li>When using LogRocket with your app, you can block recording and collection of any Personally Identifiable Information (PII) inserted by keystroke in forms or defined by users. LogRocket does this through a series of mediums, some of which are:</li></ol><ul><li>An API developed by LogRocket to identify and block PII of any kind before it leaves the user’s browser. This tool also enables users to easily identify PII fields and thus maintain astronomical levels of data security.</li><li>Blocking client-side keystrokes; This occurs by default, inputs of passwords, credit cards and other sensitive fields are not captured by LogRocket.</li></ul><p>3. It complies with certain important rules and policies on security and PII regulation, a few of which are <a href="https://en.wikipedia.org/wiki/Health_Insurance_Portability_and_Accountability_Act">Health Insurance Portability and Accountability Act</a> (HIPAA), <a href="https://en.wikipedia.org/wiki/Payment_Card_Industry_Data_Security_Standard">Payment Card Industry Data Security Standard</a> (PCI DSS) and the <a href="https://en.wikipedia.org/wiki/Gramm%E2%80%93Leach%E2%80%93Bliley_Act">Gramm-Leach-Bliley Act</a> (GLBA) to ensure that it doesn’t receive any personal information from its users and that any data it processes remains anonymous.</p><h3>Performance with LogRocket</h3><p>Aha! The juicy part… With engineering and applications, performance is key. Having a bogged down app should be the last of your worries when using LogRocket. It improves and ensures that performance is at an optimum level by:</p><ul><li>Adding a small shim of negligible size (&lt; 8kb) to intercept browser APIs. For successful interception, the shim has to load before the page loads. The entire process adds a very negligible increase in page loading time.</li><li>Utilizing User Interface (UI) threads. Because the most limited resource in the browser is CPU utilization on the UI thread, LogRocket was built to perform all long-running tasks in a worker thread. This decreases workload on the main thread and ensures that the only work done on the main thread is sending data to the worker thread.</li><li>Limiting the bandwidth usage by browsers via the aid of a highly optimized binary compression format. This ensures that all compression and loading is done on a worker thread.</li></ul><p>There you have it! Monitoring deployed and in-production apps couldn’t be more seamless. I could go on and on but you’ve got to see things for yourself <a href="https://logrocket.com/">here</a>. I stumbled on LogRocket after having a torrid time tracking issues and what not, I can only wish I’d known earlier, lol :)... Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=349983ffd995" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrument/getting-started-with-logrocket-fixing-productivity-issues-with-your-app-349983ffd995">Getting started with LogRocket; Fixing productivity issues with your App.</a> was originally published in <a href="https://medium.com/techtrument">Hackmamba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a live stream gaming platform with JQuery and Twitch TV API]]></title>
            <link>https://medium.com/dailyjs/building-a-live-stream-gaming-platform-with-jquery-and-twitch-tv-api-91effd0c3fcc?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/91effd0c3fcc</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[twitch]]></category>
            <category><![CDATA[api-integration]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Tue, 01 Aug 2017 12:35:54 GMT</pubDate>
            <atom:updated>2017-08-01T12:35:54.263Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CM8XxPdWL_jM_NMz4O7gZg.jpeg" /><figcaption><a href="http://wallpapercave.com/gamer-wallpapers">http://wallpapercave.com/gamer-wallpapers</a> [Oops!]</figcaption></figure><p>Gaming… It’s a word that quite a number of us can connect to, from Nintendo’s <a href="https://en.wikipedia.org/wiki/Game_%26_Watch">Game &amp; Watch</a> of the early eighties to PlayStation 4 where we are now, we’ve been part of this ride and we’ve enjoyed every bit of it. Apart from being players, quite a number of us love to watch and for this reason, live streaming of video games; what began as a hobby for most, is now a global enterprise. Together we’ll walk through a step by step process of creating your very own live gaming platform.</p><h3>What we want. . .</h3><p>We’re going to make a list of what we expect of our platform. Whatever we build can’t be called a platform until:</p><ol><li>It is super light weight, response time must be as fast as possible.</li><li>It can show us who’s online and who’s not.</li><li>We can click on a profile’s username and watch what they’re streaming ( if they’re online) or check out their profile ( if they’re not ) without having to sign in while watching.</li><li>For profiles that are online, we can also see additional details and information about what they’re streaming.</li><li>We can see if an account has been closed or suspended.</li></ol><p>To bring our features to life, we’ll have to use a couple of things of which the most important ones are: creative thinking, JavaScript and an API (application programming interface) call. For our API, we shall employ the services of <a href="https://www.twitch.tv/">Twitch TV</a>. We’re using Twitch’s API because it’s got content that’s really robust and that’s what we need to make this happen. Now we have all the pieces, let’s put this jigsaw together.</p><p><em>P.S : If you’d rather view the app straight away then click </em><a href="https://codepen.io/fullstackmafia/pen/NgOZWN"><em>here</em></a></p><h3>Creating our landing page</h3><p>First of all, we need to build our landing page with good old HTML and CSS. This is the part where all the creativity you can muster is encouraged; fonts, color combinations, transitions… you name it. It all counts here…</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Faek5xjf5%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Faek5xjf5%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/c50d5d43b0e52afda41a6986bcef54c6/href">https://medium.com/media/c50d5d43b0e52afda41a6986bcef54c6/href</a></iframe><h3>Getting our API data</h3><p>To get data on every profile ( or streamer) on our platform, we’ll have to make a URL (uniform resource locator) request to Twitch. Doing this involves having a client ID which will be embedded in our request, the ID can be obtained by signing up with Twitch.</p><p>Now we’ve gotten the ID, we can proceed to create an array of our streamers and assign them to a variable for easier rendering whenever we need it, we’ll also assign our client identification to another variable for the same purpose of ease. Same applies to the two URLs which will be used to fetch data from Twitch’s API; one for fetching every user in the array and the other for fetching what they’re streaming, not to forget our function where all the action will be happening as well, once we’ve created the necessary variables, we can move forward:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2F58z0m7dn%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2F58z0m7dn%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/08c9824a29cdc1c7389ba5a986c1cc47/href">https://medium.com/media/08c9824a29cdc1c7389ba5a986c1cc47/href</a></iframe><h3>Adding our user data for all profiles</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*JH2jK8hocgSQ65yw4OreUw.png" /><figcaption>Fetched API data for all our users.</figcaption></figure><p>For every user in our array of streamers <em>(check second demo), </em>we’ll append the data retrieved from our API call to our HTML. We can accomplish this via DOM manipulation with the aid of in built jQuery methods:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fwcwhg8ys%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Fwcwhg8ys%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc71236e0955a7bef06bc921a5cae775/href">https://medium.com/media/cc71236e0955a7bef06bc921a5cae775/href</a></iframe><h3>Filtering out our online users.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*A96FLngN-eEtcBCu-JkCBw.png" /><figcaption>Sample data stream for an online user.</figcaption></figure><p>To get our online users as well as create links that enable us watch what they’re streaming and show additional information about what they’re streaming, we’ll have to add certain conditions to our if statement in <strong>Demo 1</strong>. After adding these conditions, we can now append the data for online users to our DOM:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Ft7yhdqgw%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Ft7yhdqgw%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/94a82b8a5cadb6f43e92c5dcd6651ad1/href">https://medium.com/media/94a82b8a5cadb6f43e92c5dcd6651ad1/href</a></iframe><h3>Filtering out our offline users</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*zmC9xD5UiOH3jqBvqP5fBA.png" /><figcaption>Sample data stream for an offline user.</figcaption></figure><p>Now we’ve gotten our online users, all we need do is add the final part of our if statement and in it encapsulate the behavior of an offline user. When this is done, we can now append our data to the DOM.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Farpsfdrt%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Farpsfdrt%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/d79553d75eb6580d73a12d92b839d259/href">https://medium.com/media/d79553d75eb6580d73a12d92b839d259/href</a></iframe><h3>Enhancing our data display</h3><p>So far we’ve been able to get the necessary data we need and also filter it into appropriate sections but something is still missing, we need to add a bit of ease to our display, this way we can further understand stuff more clearly. A good solution is to use a drop down menu for all sections: all , online and offline . This way, we can easily command whichever section we want to display. We shall make use of the slideToggle() method in JQuery to achieve this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fmcf7ycgL%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Fmcf7ycgL%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a609e5f151a0c6919c6b336fcdce23f/href">https://medium.com/media/6a609e5f151a0c6919c6b336fcdce23f/href</a></iframe><h3>All done!</h3><p>There, you have it… your very own live stream gaming platform! You can tweak the data to give you results you never thought possible. I decided to go with JQuery in this project because it’s lightweight and it achieves the same results with less lines of code (who wants a bug scare anyway)? Do you feel different? Hit me up with what you think, I’ll be waiting in the comments section below… Adios!</p><p><em>I write basic JavaScript articles most of which are aimed at giving rookies a helping hand in getting started. If you liked this article, kindly click on the green 💚 below to recommend this article so others can see it too. Thanks!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91effd0c3fcc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dailyjs/building-a-live-stream-gaming-platform-with-jquery-and-twitch-tv-api-91effd0c3fcc">Building a live stream gaming platform with JQuery and Twitch TV API</a> was originally published in <a href="https://medium.com/dailyjs">DailyJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Prettier: Writing clean concise code]]></title>
            <link>https://medium.com/dailyjs/getting-started-with-prettier-writing-clean-concise-code-6838e0912175?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/6838e0912175</guid>
            <category><![CDATA[text-editor]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Sun, 30 Jul 2017 20:19:34 GMT</pubDate>
            <atom:updated>2017-08-01T11:17:31.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*_RL6pj7t2ZOvFKaVIi_xhg.jpeg" /><figcaption><a href="https://www.flickr.com/photos/khiavdim/2942890819">https://www.flickr.com/photos/khiavdim/2942890819</a></figcaption></figure><p>Ever stared at your code and thought: <em>“Wow this is really messy”</em>, semicolons here, square and curly brackets there. Sometimes we painstakingly try to clean things up, but who wants to clean 300 lines of JavaScript <em>(more often than not, it probably wasn’t even created by you)</em>?</p><p>Enter <strong>Prettier: </strong>Prettier is simply a JavaScript formatter. Designed by <a href="https://twitter.com/jlongster">James Long</a>, it supports languages like JavaScript (ES8 included), TypeScript, JSX, Flow, JSON, GraphQL and even CSS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4877k4Hq9dPdtmvg9hnGFA.jpeg" /></figure><h3>“Why do I need Prettier?”</h3><p>It’s only human that most people don’t even know what they need. Asides the occasional debate over lunch about how many spaces you should leave before a semicolon, where and where not to indent, or if functions should follow up on the same line or not.</p><p>Some of the reasons you’ll be needing Prettier are:</p><ol><li><strong>Cleaning up an existing code base: </strong>So you get hired at Startup X, you get to meet the team, it’s all good until you’re given a backlog of work to take care of and you spend the first hour figuring what goes where <em>( crazy right)</em>.</li><li><strong>Taking care of newbies:</strong> Everyday a lot of people take that decision to learn how to code, they begin their journey on a decent project, write say 50 lines of code <em>(jumbled and all)</em> and then come across this amazing repo on GitHub with 6,789 stars. Curious, they decide to take a look and come across syntax that looks like a Lamborghini parked in the driveway. To many of these newcomers, it’s intimidating… <em>“Will I ever be like this?”</em> they ask. Buddy, Prettier can get you your own Lamborghini. 🏎</li><li><strong>Creating a recognized style guide: </strong>With all the debates over which style is the best, it’s only suitable we have something that sets a standard right? A standard we can all accept, something we can trust and most importantly, something to stop the debates; because they’re time wasting.</li><li><strong>Writing code: </strong>We want to stop spending half our time adding semicolons <em>(yeah Prettier does that)</em>, figuring out how many lines of space to leave and all that. We want to do what we signed up for in the first place, which is write code!</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4877k4Hq9dPdtmvg9hnGFA.jpeg" /></figure><h3>Getting started with Prettier</h3><p>To install Prettier, all we need to do is go to our command line interface (CLI) and say:</p><p>yarn global add prettier</p><p>For those of us who don’t know it yet, Yarn is a package or dependency manager for JavaScript. You can look it up <a href="https://yarnpkg.com/lang/en/">here</a>. After installation, we should see something similar to this on our CLI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*NZioS4am1tVOsFUpRy8SaQ.png" /><figcaption>This is from a PC using Linux Mint 18.1. Certain parameters may vary.</figcaption></figure><p>After installation, we can simply check for what version of Prettier we got by typing prettier -v on our CLI. At this time, the latest release is 1.5.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*5aNuTu1cj6vyCQsBecOGDw.png" /></figure><h3>Using Prettier on our files</h3><p>Let’s say we’ve got this really messed up file weather-app.js . It’s almost a basket case, no semicolons, poor indentation… you name it. We’re going to fix all of this with Prettier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*arkBbiLGo9wCojzc2GJMNg.png" /><figcaption>The first 30 lines of ‘weather-app.js’ (Its like they put me in a Siberian Prison!)</figcaption></figure><p>Let’s navigate to the project folder that contains weather-app.js:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*ZsTVTSg2d52HaAzdrdncIQ.png" /></figure><p>What we’ll do now is to give Prettier some parameters on how we want our code to be formatted, typing into our CLI :</p><p>prettier --single-quote --print -width=120 weather-app.js</p><p>We’ll get the supposed syntax, that’s what our code is meant to look like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*K5wCNp3r6qRTpYsOcj9Xaw.png" /></figure><p>Pretty shiny right? To implement it on our code, we’ll add the --write command to the parameters we previously gave Prettier.</p><p>The syntax will now be:</p><p>prettier --single-quote --print -width=120 --write weather-app.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*sv_GcBObT3XiAFJZXZJ-mQ.png" /></figure><p>And voila! 💫 Our messy code is formatted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*qmHqr2cSm9LiQDJN6P4HuQ.png" /></figure><p>But hey, we shouldn’t have to open our terminal and slam down snippets of commands each time we want to format our code, that would make Prettier more of an inconvenience than a tool. For this reason, we’re going to integrate Prettier with our editor; it’s going to run automatically on save, thus making it very seamless.</p><blockquote>What you’re about to see is an integration for Sublime Text, for instructions on how to integrate Prettier on other editors, go <a href="https://github.com/prettier/prettier#editor-integration">here</a>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4877k4Hq9dPdtmvg9hnGFA.jpeg" /></figure><h3>Integrating Prettier into your code editor</h3><p>One limitation of Prettier to keep in mind is that it doesn’t have a good way of running project level configurations… <em>yet</em>. With that said, let’s proceed to integrating Prettier into our code editor:</p><ol><li>On your code editor (Sublime Text), open Command Prompt ( ctrl+shift+p ). Navigate to <strong>Package Control: Install Package </strong>and then search for<strong> “JsPrettier”.</strong></li><li>Once the package is installed, open Command Prompt once more, navigate to <strong>“JsPrettier Settings - User”. </strong>This opens up your personal settings and you should see something like this:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*J2C5CA6D3oSM_zsVhoLxgg.png" /></figure><p>3. At the first value prettier_cli_path , we’ll specify where Prettier is. All we need to do is go to our CLI and input: which prettier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*j_VLLfqjLIpN54V9ljH05g.png" /></figure><p>..we’ll then copy the resulting path and attribute it to our value.</p><p>4. At node_path , we’ll do the same as in the previous step, only this time we’ll input: which node</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*1PbhS0H_FuZ9_l3k1AL0ig.png" /></figure><p>5. Change &quot;auto_format_on_save&quot; to true</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*WYZkSU3ejubIoAHqShRMVQ.png" /></figure><p>It’s okay to change any of the values in prettier_options according to your taste with the exception of the parser value. It is recommended that you use flow instead of babylon as you will benefit from type annotations if you use the former whereas the latter has some small inconsistencies.</p><p>To learn more about what options to choose, navigate to <strong>“JsPrettier Settings - Default”</strong> instead of <strong>“JsPrettier Settings - User”</strong>.</p><p>But what if someone wants to work on your already formatted project and the person doesn’t want to install Prettier. This sequence of commands relayed to our CLI will address the issue:</p><p>Navigate to the directory where the project folders are and type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*VCgw8XR1CAuPqrUl3xcr1Q.png" /></figure><p>This will format any files with .js extensions inside the js-files folder. To verify if the files were really formatted, we’ll have to tweak the command a little by removing the opening and closing backslashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*ShPm3nNLNab9ilpOiVTvGg.png" /></figure><p>Notice the grayed out list of files? That’s to indicate that they’ve been formatted. Any files that were not formatted would be white.</p><p>This sequence is really useful in the sense that it’s kind of an escape route for users that want to work with Prettier but don’t want to install it on their code editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrJKJqBsksWd-8uKM9OvgA.png" /></figure><p>So there you have it, clean code all the way! Like I earlier said, Prettier is a new tool developed by <a href="https://twitter.com/jlongster">James Lon</a>g. I came across it on <a href="https://github.com/prettier/prettier#editor-integration">Github</a> and fell in love with it, I just had to share.</p><p>If you have any opinions on it as well, I’d be delighted to hear them. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6838e0912175" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dailyjs/getting-started-with-prettier-writing-clean-concise-code-6838e0912175">Getting started with Prettier: Writing clean concise code</a> was originally published in <a href="https://medium.com/dailyjs">DailyJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making the most of your sphere with JavaScript: Building a mini encyclopedia with jQuery and API…]]></title>
            <link>https://medium.com/techtrument/making-the-most-of-your-sphere-with-javascript-building-a-mini-encyclopedia-with-jquery-and-api-bf8b17a1b1ed?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf8b17a1b1ed</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Sun, 09 Jul 2017 10:15:42 GMT</pubDate>
            <atom:updated>2017-07-09T10:15:42.508Z</atom:updated>
            <content:encoded><![CDATA[<h3>Making the most of your sphere with JavaScript: Building a mini encyclopedia with jQuery and API calls.</h3><p>Tech is aimed at solving problems… as well as taking existing solutions and perfecting them (or at least trying to perfect them, nothing’s perfect folks). It’s for this reason that we examine every niche of life with the objective of identifying a problem and solving it. It’s for this reason that today; we’re going to build a mini encyclopedia (Yeah a “mini” one, the main stuff bores people to death. We want information… <em>but not too much</em>).</p><p>So like it is with every “building”, let’s make a list of what we actually want from our encyclopedia:</p><ol><li>We want our encyclopedia to be a lightweight search engine, where virtually anything can be looked up and information pertaining to the related subject gotten in a matter of seconds.</li><li>We don’t want to be choked to death with information so whatever it is we’re looking up, we just want short summaries as descriptions and not fine print.</li><li>We may want to be educated but not have any particular stuff in mind. For this reason, we want a button that when clicked, takes us to something new. For every time it’s clicked, a random topic has to show up.</li><li>Interestingly, some of us want to be choked with information (yes I know, they exist). We want people like them to have access to this extra information. For this, we’re going to have external links for each of the ten entries that pop up as search results.</li></ol><p>Now we know what we want, let’s get to building!</p><h3>Creating a search bar</h3><p>For our search bar, we want something dynamic, something we can pour out our heart to and it gives us what we want. The following demo will show us how to create just that:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2F9nfj79vv%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2F9nfj79vv%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/86a547f3c87a9abbfc1d331b6636e203/href">https://medium.com/media/86a547f3c87a9abbfc1d331b6636e203/href</a></iframe><h3>Adding a URL that fetches random content.</h3><p>For our random content link, we’re going to make use of Wikipedia’s random URL . It’s a special feature that when enabled, gets random articles each time a request is made. To get this going:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2F03p6z0k7%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2F03p6z0k7%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/f11db15dea1de79163f5381082eb645f/href">https://medium.com/media/f11db15dea1de79163f5381082eb645f/href</a></iframe><h3>Getting our “data” and filtering out the “garbage”</h3><p>At this point it’s apparent our search engine has to return data. To accomplish this, we’ll have to use Wikipedia’s search API. To filter out stuff, we’ll have to add our own parameter to it’s URL to tell it how much to fetch and how much to leave out:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2F2svkk3rm%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2F2svkk3rm%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/72da64566120216b6ea74712b8332156/href">https://medium.com/media/72da64566120216b6ea74712b8332156/href</a></iframe><p>To get the full functionality, we’ll enclose myURL in a getJSON function:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fv37hcmg2%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Fv37hcmg2%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e81ddbef9e78904ec7073742378653c/href">https://medium.com/media/4e81ddbef9e78904ec7073742378653c/href</a></iframe><p>Now we may type all the functions we want and fetch all the data we want but if we don’t find a way to make it interact with our DOM, it’s just going to be another truckload of garbage. For this reason, we’re going to find a way to append that data to our DOM:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fnyn00u3v%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Fnyn00u3v%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/421373e0ab52d1a9d8a0a7abea8b0402/href">https://medium.com/media/421373e0ab52d1a9d8a0a7abea8b0402/href</a></iframe><p>Now that everything is complete, we can now…. OH MY DAYS!! We forgot to add all this juicy functionality to our search bar. Well at this stage you’ve got to admit that’s pretty easy, all we have to do is create one last function, assign it to a variable and embed in it all we’ve done so far:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Ftvs1f1kf%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Ftvs1f1kf%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/85160532758f78f4b0bfc4fb57d0fd10/href">https://medium.com/media/85160532758f78f4b0bfc4fb57d0fd10/href</a></iframe><p>And then solving the final piece of the puzzle with jQuery’s (you see why jQuery came first in the topic and not that API thingy?) submit() method:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fedx28o19%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Fedx28o19%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2cfd063f0cb80483d5b40baa1bf3b12/href">https://medium.com/media/b2cfd063f0cb80483d5b40baa1bf3b12/href</a></iframe><p>There! For your projects, articles, look up challenges, journals, whenever you’re bored in traffic, spelling bees… look no further, get this amazing encyclopedia only for $3.99! (God I’d make a perfect salesman). You could check out the full project on my <a href="https://codepen.io/fullstackmafia/pen/zwgPba">CodePen</a>, tweaking and maiming are sooo allowed. Cheers!</p><p><em>If you enjoyed this itsy-bitsy beginner article, be sure to hit that green</em> 💚 <em>below so others can see it too. Thanks!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf8b17a1b1ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techtrument/making-the-most-of-your-sphere-with-javascript-building-a-mini-encyclopedia-with-jquery-and-api-bf8b17a1b1ed">Making the most of your sphere with JavaScript: Building a mini encyclopedia with jQuery and API…</a> was originally published in <a href="https://medium.com/techtrument">Hackmamba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript properties and methods: String.prototype.includes()]]></title>
            <link>https://medium.com/dailyjs/javascript-properties-and-methods-string-prototype-includes-1e7a2298aca6?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e7a2298aca6</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Sat, 08 Jul 2017 07:38:31 GMT</pubDate>
            <atom:updated>2017-07-08T07:38:31.633Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*xlH2gQ4UzhhHQ6Pfba09PA.png" /><figcaption><a href="https://devdojo.com/course/javascript-basics/using-javascript">https://devdojo.com/course/javascript-basics/using-javascript</a></figcaption></figure><p>Trying to decide if a string may or may not be found within another string? The includes() method is perfect for this purpose, it checks for the presence of a string in another (longer) string, returning true if the string is found or false if otherwise.</p><p><strong>SYNTAX: </strong>str.includes(searchString[, position])</p><p><strong>PARAMETERS:</strong></p><p>searchString : The string we are searching for within the larger string.</p><p>position: The position at which we begin to search for searchString. This position’s default value is 0. This parameter is optional when implementing the method.</p><p>Case Sensitivity: The includes() method is case sensitive. An expression such as the one below will return false .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*IUKf6DF7X8ZKQkXE1TYSyw.png" /></figure><p>A more detailed explanation on how to use this method would be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*EC8ihz8MwJZBR7dHDsToSg.png" /></figure><p>In some cases, the include() method may not be available in all JavaScript implementations, do not fear! There is a quick workaround known as a polyfill (a browser fallback made in JavaScript that allows functionality you expect to work in modern browsers to work in older browsers):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*HuWE6uXW2Eiijhw5VKyFMw.png" /><figcaption>polyfill for includes() method</figcaption></figure><p><strong>Browser Compatibility: </strong>str.includes() is compatible with desktop browsers such as Chrome(41), Firefox(18–48), Edge, Opera and Safari. It is not compatible with Internet Explorer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e7a2298aca6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dailyjs/javascript-properties-and-methods-string-prototype-includes-1e7a2298aca6">Javascript properties and methods: String.prototype.includes()</a> was originally published in <a href="https://medium.com/dailyjs">DailyJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Geolocation based Weather App with Vanilla JS and DarkSky API]]></title>
            <link>https://medium.com/dailyjs/making-the-most-of-your-sphere-with-javascript-building-a-geolocation-based-weather-app-with-3df5ae1fcb27?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/3df5ae1fcb27</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Mon, 03 Jul 2017 10:23:25 GMT</pubDate>
            <atom:updated>2017-11-24T14:32:07.232Z</atom:updated>
            <content:encoded><![CDATA[<h4>Making the most of your sphere with JavaScript</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GsImz-edoeuqCMfKxDus0w.jpeg" /></figure><p>Summer’s here! 🌞 We all know how unpredictable the weather could be during this period, one moment it’s Helios flooding everywhere with his rays, the next it’s raining cats and dogs. In time like this (and other times too), you need to stay not just one, but ten steps ahead of nature. What’s going to keep you going? Not an umbrella, not sunscreen…..but….. <em>A WEATHER APP</em>!</p><p>Great news! I bring to you, “THE” weather app; created out of the desire to learn more, what started out as a side project is actually going to be your Superman this summer.</p><p>With plain JavaScript and an application programming interface (API) call (please use Google here 😉), we managed to make this possible. I say “we” because really, every developer has another developer leaning over their shoulder, seeing what they can’t see, and taking the keyboard for a second or two to create some magic. <em>(To </em><a href="https://twitter.com/codebeast"><em>Chris</em></a><em> and </em><a href="https://twitter.com/iChuloo"><em>William</em></a><em>, thanks a lot guys!)</em></p><p>Now lunch is over, let’s get to building this app…</p><p>We’ve built it already though, just sit back while we walk you through the entire maze. Grab your gear!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4877k4Hq9dPdtmvg9hnGFA.jpeg" /></figure><h3>Getting your current location</h3><p>First of all, we need to be able to get your current location, be it stationary or changing.</p><p>Fortunately, this can be achieved via the geolocation.getCurrentPosition() method which is a JavaScript inbuilt web API call that is used to get the current position of a device and representing that position in the form of latitude and longitude.</p><p>Implementing this method is quite easy, we simply use an <strong>IF/ELSE </strong>statement to get our current location:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2F16cc8hsw%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2F16cc8hsw%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc23b15e6bda98c9ed05ab0a8dacb31b/href">https://medium.com/media/cc23b15e6bda98c9ed05ab0a8dacb31b/href</a></iframe><h3><strong>Getting your current location’s weather data</strong></h3><p>Now that we know where you are, the next step is to find out what the weather’s like.</p><p>Lots of API providers were out there but we chose <a href="https://darksky.net/">DarkSky</a> to provide us with the data we need. To make an API call, we have to create a function showWeather which will contain our URL. Our URL will have to contain the variables lat and long (both obviously will be arguments in showWeather), these can be included with the aid of back-ticks (which are used to enclose template literals). To avoid problems created by Cross-Origin Resource Sharing (CORS), we shall specify that our request format be in JSONP , we shall also append a callback function displayWeather that can be used to access the data retrieved from the API call.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Ff29ohfz3%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Ff29ohfz3%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/30eeb67605440af2d04f9dd4ea98852b/href">https://medium.com/media/30eeb67605440af2d04f9dd4ea98852b/href</a></iframe><h3>Creating functions to modify the weather data</h3><p>More often than none, we’ll have to modify the data we retrieved from DarkSky. Certain values might be different from what we actually want (temperature might be in Fahrenheit instead of Celsius, humidity could be in decimals and so on). To do this,Math.round() is one of the methods we’ll use extensively in our conversions.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2F8amt9gh5%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2F8amt9gh5%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca2d780aae11bb8f51e48eb1e2c89a8c/href">https://medium.com/media/ca2d780aae11bb8f51e48eb1e2c89a8c/href</a></iframe><h3>Adding weather icons to our data</h3><p>Users want things easy. Asides seeing a summary about how it’s going to rain today, you want to also see dark clouds and thunderbolts as these are more likely to appeal to you than anything else.</p><p>To achieve this, we had to attach weather icons (skycons if you will) to our weather data:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fnsard14a%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2Fnsard14a%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f741a727a81f246536ca2062b5d57d3/href">https://medium.com/media/2f741a727a81f246536ca2062b5d57d3/href</a></iframe><h3>Displaying our weather data</h3><p>Now the grand finale, creating the interface for our app. Using HTML, CSS and JavaScript, this should be no trouble. We’ll be sure to finish just in time to catch the Yankees game!</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2FLts6kg71%2F&amp;src=https%3A%2F%2Fjsfiddle.net%2FLts6kg71%2Fembedded%2F&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/02e2013333b40bb0b58c49ab13d9ec86/href">https://medium.com/media/02e2013333b40bb0b58c49ab13d9ec86/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrJKJqBsksWd-8uKM9OvgA.png" /></figure><p>There! Wasn’t so hard was it? You’re officially good to go. To use an umbrella or not? To wear sunglasses or not? It’s all up to you now.</p><p>You can check out the app <a href="https://codepen.io/fullstackmafia/pen/XRLOGM">here</a> <em>(If you scrolled all the way down for this link, I know… I thought of you before writing this </em>🙂<em>)</em>. Feel free to play around and create your own mess, you might just invent something while you’re at it.</p><p><em>If you liked this, do click on that little 👏 below a few times. Thanks!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3df5ae1fcb27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dailyjs/making-the-most-of-your-sphere-with-javascript-building-a-geolocation-based-weather-app-with-3df5ae1fcb27">Building a Geolocation based Weather App with Vanilla JS and DarkSky API</a> was originally published in <a href="https://medium.com/dailyjs">DailyJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building A Movie Quote Randomizer with Vanilla JS and Mashape API]]></title>
            <link>https://medium.com/dailyjs/building-a-movie-quote-randomizer-with-vanilla-js-and-mashape-api-545256ad6306?source=rss-c089388e3c20------2</link>
            <guid isPermaLink="false">https://medium.com/p/545256ad6306</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Raphael Ugwu]]></dc:creator>
            <pubDate>Sun, 25 Jun 2017 17:22:26 GMT</pubDate>
            <atom:updated>2017-07-07T15:05:33.802Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRdeIHHH6J86civ7IAs8bQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4877k4Hq9dPdtmvg9hnGFA.jpeg" /></figure><p>Using application user interfaces (APIs) can be a bit tricky and confusing to beginner developers who are building an app for the first time. This tutorial aims at giving a brief and concise directive to building an app with plain JavaScript and jQuery while making API calls.</p><p>Before we begin, it’s important to highlight what we expect of our app. For a movie quote randomizer which can generate a random quote at will, expectations are as follows:</p><ol><li>A user can click on a button and generate a random quote with the quotes author from a famous movie.</li><li>A user can click on another button to tweet out the quote generated.</li><li>For every random quote that comes up, the background color of the paragraph shall also change (transitioning slowly) to a random color.</li></ol><h3>Getting the API</h3><p>The first step usually is to sign up with a reliable API service provider. In this case, we shall be relying on <a href="https://market.mashape.com/">Mashape</a> to help us with what we need, which is an API that when called, provides an object consisting of several arrays of movie quotes and their authors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HSZH-9d6NAYYWuT0pMe4CQ.png" /><figcaption>A Movie Quote Randomizer API on Mashape</figcaption></figure><h3>Making an AJAX Request</h3><p>Next, we shall use jQuery to make an AJAX request to Mashape. The good thing is that the Uniform Resource Locators (URL) to Mashape’s APIs are already Cross-Origin Resource Sharing (<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS">CORS</a>) enabled. This prevents issues of domain conflicts when making API calls.</p><p>Making the AJAX request is quite simple and straightforward:</p><pre>var loadquote = function() {<br>    $.ajax({<br>            type: &quot;GET&quot;,<br>            url: &quot;https://andruxnet-random-famous-  quotes.p.mashape.com/?cat=movies&amp;count=1&quot;,<br>            data: {},<br>            dataType: &#39;json&#39;,<br>            success: function(data) {<br>            $(&quot;#quote-text&quot;).html(&#39;&quot;&#39; + data.quote + &#39;&quot;&#39;);<br>            $(&quot;#quote-author&quot;).html(&#39;&amp;mdash;&#39; + &#39; &#39; + data.author);  <br>            },<br>            error: function(err) { alert(&quot;Internet Disconnected!&quot;); },<br>            beforeSend: function(xhr) {<br>                xhr.setRequestHeader(&quot;X-Mashape-Authorization&quot;, &quot;Bk47jF0aCnmshsTi1VQAyxueTH2ap1BJxjejsnw9wHKPr2OmG4&quot;);<br>            }<br>    });<br>};</pre><p>As you might have noticed, using jQuery, we assigned our HTML paragraphs; quote-text and quote-author to fetch raw data from the “quote” and “author” keys in our data object.</p><p>We also embedded the entire AJAX call in a function and assigned it to a variable loadquote for easier accessibility and manipulation. The setRequestHeader()method contains our Mashape Authorization as well as our key <em>(every user has a unique key)</em>.</p><h3>Creating the Random Background Color Property</h3><p>As we mentioned earlier, we want our background to change whenever a new quote comes up. One way to do this is by making use of the Math.floor() and Math.random() functions.</p><p>Creating a variable called “backgroundChange”, we then proceed to assign a function to it that tells our app what to do with the background color:</p><pre>var backgroundChange = function() {<br>    x = Math.floor(Math.random() * 256);<br>    y = Math.floor(Math.random() * 256);<br>    z = Math.floor(Math.random() * 256);<br>    backgroundRGB = &quot;rgb(&quot; + x + &quot;,&quot; + y + &quot;,&quot; + z + &quot;)&quot;;<br>    document.getElementById(&quot;quote-design&quot;).style.backgroundColor = backgroundRGB;<br>}</pre><h3>Creating the Transition Effect</h3><p>Creating the transition effect is pretty easy, all we have to do is create a variable and assign our function which gets the HTML element where we want the transition to be and styles it accordingly:</p><pre>var transition = function() {<br>    document.getElementById(&quot;quote-design&quot;).style.transition = &quot;all 2s&quot;;<br>}</pre><h3>Adding a button that tweets the quote</h3><p>For our “twitter-share” button, we create a button in our HTML page and then use jQuery to manipulate it.</p><p>The tweet button is powered by a Twitter <a href="https://dev.twitter.com/overview/api/tweets">API</a> that tweets quotes. For the button to function properly, it’s important that we embed our jQuery method in our AJAX request:</p><pre>var loadquote = function() {<br>    $.ajax({<br>            type: &quot;GET&quot;,<br>            url: &quot;https://andruxnet-random-famous-  quotes.p.mashape.com/?cat=movies&amp;count=1&quot;,<br>            data: {},<br>            dataType: &#39;json&#39;,<br>            success: function(data) {<br>            $(&quot;#quote-text&quot;).html(&#39;&quot;&#39; + data.quote + &#39;&quot;&#39;);</pre><pre>            $(&#39;#twitter-share-button&#39;).attr(&#39;href&#39;, &#39;https://twitter.com/intent/tweet?text=&#39; + &#39;&quot;&#39; + data.quote + &#39;&quot;&#39; + &#39; &#39; + &#39; &#39; + &#39; &#39; + &#39; \u2014&#39; + &#39; &#39; + data.author).attr(&#39;target&#39;, &#39;_blank&#39;); // embed the method HERE<br>            },</pre><pre>            error: function(err) { alert(&quot;Internet Disconnected!&quot;); },<br>            beforeSend: function(xhr) {<br>                xhr.setRequestHeader(&quot;X-Mashape-Authorization&quot;, &quot;Bk47jF0aCnmshsTi1VQAyxueTH2ap1BJxjejsnw9wHKPr2OmG4&quot;);<br>            }<br>    });<br>};</pre><h3>Adding a button that changes the quote as well as transitions the background color</h3><p>Now for the final part, creating the most important button in the app! Having gotten this far, this should be no trouble to us.</p><p>To create the button, we simply insert a button element in our HTML section. We have the option of using the addEventListener() method in JavaScript or using .on() method in jQuery. We’ll go with the latter as it brings a lot of consistency to our API and simplifies our code base:</p><pre>$(&quot;#change-quote&quot;).on(&quot;click&quot;, function() {<br>    loadquote();<br>    backgroundChange();<br>    transition();<br>})</pre><p>As seen above, we embedded our loadquote(), backgroundChangeand transition() functions in our change-quote jQuery function. Once the button is clicked, these three functions will take place simultaneously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrJKJqBsksWd-8uKM9OvgA.png" /></figure><p><strong>There! </strong>We have successfully built a Movie Quote Randomizer, with the help of APIs, a jQuery library and best practices — and we kept our code clean and concise. For further details about the app, you can check it out <a href="https://codepen.io/fullstackmafia/pen/MmJWeP">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WzRbNl2WZrklJDkAJ0hQiQ.png" /></figure><blockquote>If you liked this article, be sure to recommend it as that would mean a lot to me Thanks. <em>🙂</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=545256ad6306" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dailyjs/building-a-movie-quote-randomizer-with-vanilla-js-and-mashape-api-545256ad6306">Building A Movie Quote Randomizer with Vanilla JS and Mashape API</a> was originally published in <a href="https://medium.com/dailyjs">DailyJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>