<?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 Michael Yuki Romero on Medium]]></title>
        <description><![CDATA[Stories by Michael Yuki Romero on Medium]]></description>
        <link>https://medium.com/@michaelyukiromero?source=rss-72fcca079883------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*p0G17y4YSIjJnybM</url>
            <title>Stories by Michael Yuki Romero on Medium</title>
            <link>https://medium.com/@michaelyukiromero?source=rss-72fcca079883------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:36:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michaelyukiromero/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[Gomu Gomu no Array.reduce()]]></title>
            <link>https://medium.com/@michaelyukiromero/gomu-gomu-no-array-reduce-ed54535f8ce3?source=rss-72fcca079883------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed54535f8ce3</guid>
            <category><![CDATA[one-piece]]></category>
            <category><![CDATA[iterators]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[reduce]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Michael Yuki Romero]]></dc:creator>
            <pubDate>Sun, 21 Jul 2019 05:50:47 GMT</pubDate>
            <atom:updated>2019-07-21T05:50:47.336Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using reduce in Javascript</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*O6Zed8qsNXdfLWuX.png" /><figcaption>Prepping our body to understand reduce()</figcaption></figure><p>Hey guys, it’s your boy Mike coming at you with a helpful iterator to use and understand on your JavaScript journey. Recently I stumbled upon a code challenge that wanted you to build <em>reduce()</em> from scratch — it was fairly simple, but then I came across a challenge that wanted me to return a new array with elements found in all of the inputs(<em>multidimensional array</em>) using reduce. Before this challenge, I only knew that reduce was able to sum up the total of numbers in an array and nothing else. I had no idea that it had any other functionality to it. Let’s go ahead and dive into it now…</p><h3>What is Reduce?</h3><blockquote>Reduce — a method that executes a <strong>reducer</strong> function (that you provide) on each element of the array, resulting in a single output value.<br><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce">MDN Documentation</a></blockquote><p>To dumb it down, reduce accepts a function and goes through every item inside the array and performs an action based on the function you provided and returns a single item.</p><p>The function we provide it with has 4 parameters — 2 of which are optional. An <strong>accumulator</strong><em>(the total)</em>, <strong>currentValue</strong><em>(current element)</em>, <strong>index</strong><em>(current element’s position in the array)</em>, <strong>array</strong><em>(the array reduce was called on)</em>.</p><p>Reducer not only accepts a function as an argument, but it has a 2nd optional argument called <strong>initialValue</strong>. By default if the <strong>initialValue</strong> was not provided, it is set to the first element of the array, otherwise it’s set to the value provided; this can be an object, array, string or number.</p><pre>const array = [1, 2, 3];<br>const initialValue = 10;</pre><pre>// WITHOUT AN INITIALVALUE<br>array.reduce( (accumulator, currentValue) =&gt; {<br>  return accumulator + currentValue;<br>});<br>// returns 6</pre><pre>// WITH AN INITIALVALUE SET TO 10<br>array.reduce( function(accumulator, currentValue) {<br>  return accumulator + currentValue;<br>}, initialValue);<br>// returns 16</pre><h3>Creating Reduce</h3><p>One of the best ways to understand iterators is by creating them ourselves. We already know how to use reduce, but to really understand what is happening behind the scenes — we’re going to recreate it.</p><pre>function reduce(array, callback, initialValue) {<br>  if ( Array.isArray(array) ) {<br>    let accumulator;<br>    <br>   if (initialValue === undefined) {<br>      accumulator = array[0];<br>      array = array.slice(1);<br>   } else {<br>      accumulator = initialValue;<br>   }</pre><pre>   array.forEach( ele =&gt; {<br>      accumulator = callback(accumulator, ele);<br>   })</pre><pre>   return accumulator;<br>  } else {<br>      return &quot;TypeError: First argument must be an array.&quot;<br>  }<br>}</pre><p>We know that reduce can only be used on a Array, so we check first whether it’s an array or not, if it ain’t we just throw an error. Next we want to check if an <strong>initialValue</strong> was provided, if it is then we set the <strong>accumulator</strong> to the <strong>initialValue</strong>, otherwise we set <strong>accumulator</strong> to the first element of the array and we begin our first iteration at index 1 instead of 0. Finally, we iterate through the array and execute the callback passing in the accumulator and current element.</p><h3>Testing Reduce</h3><p>If you still don’t really understand, try messing with the actual reduce iterator and produce errors.</p><h4>Calling reduce on other data types</h4><pre>let someObj = {a: 1, b: 2, c: 3};<br>let someNum = 4;<br>let someString = &quot;Hello&quot;;<br>let someArray = [1, 2, 3];</pre><pre>someObj.reduce( (acc, val) =&gt; acc + val)    // TypeError<br>someNum.reduce( (acc, val) =&gt; acc + val)    // TypeError<br>someString.reduce( (acc, val) =&gt; acc + val) // TypeError<br>someArray.reduce( (acc, val) =&gt; acc + val)  // 6</pre><h4>Passing only one argument</h4><pre>const arr = [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;a&#39;];</pre><pre>arr.reduce( acc =&gt; {<br>  return acc;<br>})<br>// returns &#39;a&#39;;</pre><pre>arr.reduce( acc =&gt; {<br>  return 1 + acc;<br>})<br>// returns &#39;1111a&#39;</pre><pre>arr.reduce( acc =&gt; {<br>  return acc;<br>}, [])<br>// returns []</pre><h3>Revisiting Our Previous Code challenge</h3><blockquote>return a new array with elements found in all of the inputs(<em>multidimensional array</em>) using reduce</blockquote><pre>const arr1 = [5, 10, 15, 20];<br>const arr2 = [15, 88, 1, 5, 7];<br>const arr3 = [1, 10, 15, 5, 20];<br>console.log(intersection([arr1, arr2, arr3])); // should log: [5, 15]</pre><h4>The Answer</h4><pre>function intersection(arr) {<br>  const common = [];</pre><pre>  const obj = arr.flat().reduce( (all, ele) =&gt; {<br>    ele in all ? all[ele]++ : all[ele] = 1;<br>    <br>    return all;<br>  }, {})<br>  <br>  <br>  for (let key in obj) {<br>    obj[key] === arr.length ? common.push(parseInt(key)) : null<br>  }<br>  <br>  return common;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*0JcOhajgjP4JP1kt.jpg" /><figcaption>Later Guys!</figcaption></figure><p>There you have it guys! Hope I made it easier for you to use reduce for more than just summing up numbers. You can flatten a multidimensional array, keep count of elements through an object, etc. And don’t forget to drop a clap!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed54535f8ce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a React app using GitHub (The Ninja Way)]]></title>
            <link>https://medium.com/@michaelyukiromero/deploy-a-react-app-using-github-the-ninja-way-11c94c047251?source=rss-72fcca079883------2</link>
            <guid isPermaLink="false">https://medium.com/p/11c94c047251</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[naruto]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Michael Yuki Romero]]></dc:creator>
            <pubDate>Wed, 10 Jul 2019 22:19:01 GMT</pubDate>
            <atom:updated>2019-07-10T22:19:01.833Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*VU7WysYGex_Bl8Fq.gif" /><figcaption>Engineer Secret Art: Deploying Jutsu!</figcaption></figure><p>If you’re familiar with or you’re a crazy fan of Naruto like yours truly, then at some point in your life you must’ve ran down the school halls or streets like a ninja with your arms wailing behind you; perhaps tried a couple hand signs or two in an attempt to summon the boss toad Gamabunta. Point is, I’m here to teach you the Engineer’s Secret Art: Deploying Jutsu (on GitHub)!</p><h3>BOAR HAND SIGN</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/0*OlJK7oBoxVLknfrv" /><figcaption>Step One</figcaption></figure><p>Make sure you are inside your React app directory (folder) and in your terminal run the command listed above.</p><pre>npm install gh-pages --save-dev</pre><h3>DOG HAND SIGN</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/0*1LXdsiNSER6mOe4u" /><figcaption>Step Two</figcaption></figure><p>If you haven’t already created a Repo for your project on GitHub, go ahead and create one. Then you’re gonna run the code below. Otherwise you can skip this step.</p><pre>git remote add origin &lt;Insert Repo Link&gt;<br>git push -u origin master</pre><h3>BIRD HAND SIGN</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/0*R79ckw1yZInzokm4" /><figcaption>Step Three</figcaption></figure><p>Inside your <strong><em>package.json</em></strong> file, you’re going to add a new key called homepage with its value being your github username &amp; repos name together.</p><pre>// package.json</pre><pre>{<br>  &quot;name&quot;: &quot;react-app-name&quot;,<br>  &quot;version&quot;: &quot;0.1.0&quot;,<br>  &quot;private&quot;: true,<br>  &quot;homepage&quot;: &quot;http://github_username.github.io/repo_name&quot;,<br>  &quot;dependencies&quot;: ...<br>}</pre><h3>MONKEY HAND SIGN</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/0*ux_TsBfmLgxYRu4Z" /><figcaption>Step Four</figcaption></figure><p>We will remain inside the <strong><em>package.json</em></strong> file one last time. This time, we’re going to add two new key and value pairs but inside the <strong><em>scripts</em></strong> key. Both &quot;predeploy&quot;: &quot;npm run build&quot; &amp; &quot;deploy&quot;: &quot;gh-pages -d build&quot;</p><pre>// package.json</pre><pre>{<br>  &quot;name&quot;: &quot;react-app-name&quot;,<br>  &quot;version&quot;: &quot;0.1.0&quot;,<br>  ...<br>  &quot;scripts&quot;: {<br>    ...<br>    &quot;predeploy&quot;: &quot;npm run build&quot;,<br>    &quot;deploy&quot;: &quot;gh-pages -d build&quot;<br>  }<br>  ...<br>}</pre><h3>RAM HAND SIGN</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/0*cviYc1e8Q0hcq5RI" /><figcaption>Step Five</figcaption></figure><p>Last and finally step, inside the terminal you can go ahead and type npm run deploy and just sit back and watch your summoned app come to life! If all went well, you should see a link inside your terminal; go ahead and copy and paste it to your browser and your site is live!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*MOtGIV6vR_NJesvT.gif" /><figcaption>Gamabunta the React App!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/0*yjWg9CmH6jEK--I8.gif" /><figcaption>Aww Shucks…</figcaption></figure><p>That’s all folks! Now go on out and use this newly founded jutsu! Dattebayo! Don’t forget to leave a clap…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11c94c047251" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Guide to Exporting Modules (node.js)]]></title>
            <link>https://medium.com/@michaelyukiromero/quick-guide-to-exporting-modules-node-js-1638d235ac16?source=rss-72fcca079883------2</link>
            <guid isPermaLink="false">https://medium.com/p/1638d235ac16</guid>
            <category><![CDATA[node-for-begginners]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[export]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Michael Yuki Romero]]></dc:creator>
            <pubDate>Sun, 07 Jul 2019 01:45:03 GMT</pubDate>
            <atom:updated>2019-07-07T01:47:40.659Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*xuRkW9ycTov0fSQ1.jpg" /></figure><p>Hello there readers, this is a quick (hopefully simple) guide to learning how to use <em>modules</em> on Node.js. Incase you don’t know or forgot what a module is, it is<strong><em> small pieces of reusable code</em></strong>. Here is a great quote to better understand: “<em>Good authors divide their books into chapters and sections; good programmers divide their programs into modules</em>”.</p><blockquote>Note: For this tutorial, I have created a directory with <strong>two files</strong>; one named <strong>app.js</strong> &amp; the other named <strong>modules.js</strong>. (You can name them whatever you please)</blockquote><pre>// module.js</pre><pre>const addTwo = (num) =&gt; {<br>  return num + 2;<br>}</pre><pre>module.exports = addTwo;</pre><p>Inside the <strong>module.js</strong> file, I created a simple function. Below it, I am exporting that function by using module.exports = addTwo . This will allow our function <em>addTwo</em> to be used in any other file we’d like. By default <em>module.exports</em><strong><em> </em></strong>returns an empty object if we just declare it and if we set it to any value, it would return that value.</p><pre>module.exports              // returns {}<br>module.exports = 2          // returns 2<br>module.exports = &quot;Hi there&quot; // returns &quot;Hi there&quot;<br>module.exports = addTwo     // returns addTwo definition<br>module.exports = 2 + 2      // returns 4</pre><p>Now inside our <strong>app.js</strong> we can import the function <em>addTwo </em>by using the <em>require() </em>keyword and storing it into a variable. We have to make sure to pass in the file path of where the function exists in. Assuming they live in the same directory, we pass in &quot;./module&quot; . We could also have written it like this &quot;./module.js&quot; , but by default, Javascript adds the file extension to the end of the path. Now if we print the variable where we stored our function in, we should see the functions definition. Since we know it’s a function, to use it, we must invoke it by adding the parenthesis next to it like this moduleFunctions(5) and pass in any number we’d like.</p><blockquote>Note: To run the file, you must have node.js installed (<a href="https://nodejs.org/en/">install here</a>). Open up the terminal/command line, and traverse inside the directory where the files live and run node app.js .</blockquote><pre>// app.js<br>const moduleFunctions = require(&quot;./module&quot;)</pre><pre>console.log(moduleFunctions)    // returns the function definition<br>console.log(moduleFunctions(5)) // returns 7</pre><h3>Multiple Exports</h3><pre>// module.js</pre><pre>const addTwo = (num) =&gt; {<br>  return num + 2;<br>}</pre><pre>const subtractTwo = (num) =&gt; {<br>  return num - 2;<br>}</pre><pre>const PI = 3.14;</pre><pre>// Shorthand way (object literal)<br>module.exports = {<br>  addTwo: addTwo,<br>  subtractTwo: subtractTwo,<br>  PI: PI<br>}</pre><pre>// Long way (using dot notation)<br>module.exports.addTwo = addTwo;<br>module.exports.subtractTwo = subtractTwo;<br>module.exports.PI = PI;</pre><pre>// Long way (using bracket notation)<br>module.exports[&quot;addTwo&quot;] = addTwo;<br>module.exports[&quot;subtractTwo&quot;] = subtractTwo;<br>module.exports[&quot;PI&quot;] = PI;</pre><p>Multiple exports sounds scary at first, but since we know that by default <em>module.exports</em> is an object; we can use bracket notation, dot notation or using an object literal. The short way as shown above is by using a object literal as opposed to using dot or brackets.</p><pre>// app.js<br>const moduleFunctions = require(&quot;./module&quot;)</pre><pre>console.log(moduleFunctions)  <br>// returns {addTwo: addTwo, subtractTwo: subtractTwo, PI: 3.14}</pre><pre>console.log(moduleFunctions.addTwo(5))      // returns 7<br>console.log(moduleFunctions.subtractTwo(5)) // returns 3<br>console.log(moduleFunctions.PI)             // returns 3.14<br>console.log(moduleFunctions.addTwo(module.Functions.PI)) <br>// returns 5.14</pre><p>Inside our <strong>app.js </strong>we just have to call on the function the same way we call values from objects using its key.</p><ul><li><a href="https://www.freecodecamp.org/news/javascript-modules-a-beginner-s-guide-783f7d7a5fcc/">JavaScript Modules: A Beginner&#39;s Guide</a></li><li><a href="https://stackoverflow.com/questions/46677752/the-difference-between-requirex-and-import-x/46677972">The difference between &quot;require(x)&quot; and import x</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/0*mst6GFAxzGTkIDQd.gif" /><figcaption>Leave that clap</figcaption></figure><blockquote>Anyways, thats it for the tutorial, hope you all learned a thing or two and don’t forget to leave a clap at the end of this.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1638d235ac16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming: Art Point of View]]></title>
            <link>https://medium.com/@michaelyukiromero/programming-art-point-of-view-7e3959bb1d52?source=rss-72fcca079883------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e3959bb1d52</guid>
            <category><![CDATA[expression]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[skills]]></category>
            <category><![CDATA[entertainment]]></category>
            <category><![CDATA[art]]></category>
            <dc:creator><![CDATA[Michael Yuki Romero]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 14:34:19 GMT</pubDate>
            <atom:updated>2019-04-15T14:34:19.500Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*_PyLW1YQOCVk7CWI.jpg" /></figure><p>Programming often times is seen more as a career; and while it truly is a career path, it is also a tool to express yourself. Thus asking the question, <em>can Programming be a form of Art</em>? <strong>Yes</strong> and here is why…</p><h3>💡Creativity</h3><p>Programming requires you to be creative. On personal projects, you have to think about the design of your site or app. From picking out a color theme, logos &amp; images that will make your site visually appealing to creating your storyboard as how you want the User to navigate within your site/app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jtTQ1WfatGnd9VQ2zgjQXw.png" /><figcaption><a href="http://www.rleonardi.com/interactive-resume/">http://www.rleonardi.com/interactive-resume/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PCq4dRhZmeVVqncgqEByiw.png" /><figcaption><a href="http://www.elsamuse.com/en/">http://www.elsamuse.com/en/</a></figcaption></figure><h3>🔧 SKILL</h3><p>Programming requires skills. This is obvious and a no brainer. It takes practice and practice to learn and understand concepts. Every new programming language or framework you learn is a newly acquired skill. Debugging and learning to read errors is a major skill in this field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*raWO3dhM4jMjf9VY-kZzNg.png" /></figure><h3>📺 ENGAGEMENT/ENTERTAINMENT</h3><p>Programming can be engaging and entertainment for the user and/or programmer. For me personally, building out a small feature and seeing it work is both engaging and entertaining for me. It provides amusement and enjoyment whenever I build something that works — or when my code breaks and I finally solve it. What you produce (site, app, games) can be entertainment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*v6B0sKV20LLMTvaT.jpg" /><figcaption><a href="http://www.cardhunter.com/">http://www.cardhunter.com/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*niXRYVERDAsPjNnK.jpg" /><figcaption><a href="https://www.runescape.com/splash">https://www.runescape.com/splash</a></figcaption></figure><h3>🖼️ MEANING</h3><p>Programming has meaning for both a user and the creator. From the creators side; what we choose to build potentially has meaning. What we feel at the moment or an experience we had can ultimately be reasons why we choose to create something. For a user, possibly ranting on Instagram or Facebook could prove to be an escape for them. It provides meaning in a sense that they can share experiences or stories they had with the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*crhuIHk0A62l7PSD.jpg" /><figcaption>www.facebook.com</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mUl4SUpdePgFwuHh.png" /><figcaption>www.Uber.com</figcaption></figure><h3>🗿CONCLUSION</h3><p>In my opinion, programming can be a form of art, depending on the programmer. Ultimately the meaning behind what you create will lead to your creativity; while the skills will bring the idea to life and then provide entertainment or engage users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e3959bb1d52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Start]]></title>
            <link>https://medium.com/@michaelyukiromero/game-start-14451732e005?source=rss-72fcca079883------2</link>
            <guid isPermaLink="false">https://medium.com/p/14451732e005</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[phaser-3]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Michael Yuki Romero]]></dc:creator>
            <pubDate>Fri, 22 Mar 2019 04:29:18 GMT</pubDate>
            <atom:updated>2019-03-24T00:08:41.698Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Beginner’s “Beginners Guide” to Phaser 3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*Qr9Vul-VS4cZIlpW.gif" /><figcaption>Developers, developers, developers, developers…</figcaption></figure><p>I’m sure most of us (developers) have thought about creating a game for the first time at some point in our lives. Well <em>woopty — doo</em>! I’ve been messing and dissecting around with <a href="https://phaser.io/download"><strong>Phaser 3</strong></a><strong> </strong>for the past couple of days. And by the way, Phaser 3 is a framework used to build HTML5 games if you were wondering. Any who, let’s begin…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SXioioQ7s3E5Tg6G" /></figure><h3>INSTALLING</h3><p>!!!→<a href="http://phaser.io/tutorials/getting-started-phaser3/part2"><strong>Click here</strong></a>←!!! for Phaser’s guide on installation. Make sure to follow steps 2 to 5.<br><em>NOTE: make sure you have the latest cdn script added to your HTML file unless you’re doing npm install.</em></p><pre>&lt;script src=&quot;//cdn.jsdelivr.net/npm/phaser@3.16.2/dist/phaser.min.js&quot;&gt;&lt;/script&gt;</pre><h3>INITIALIZING NEW GAME</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*ZQ_mXEn-j8Wv5Le42LFTag.png" /><figcaption>New Game</figcaption></figure><p>So <strong>Phaser.Game()</strong> is the main controller. This is where you define your game settings. It is responsible for parsing your configurations (<em>config), </em>creating the renderer, processing the Scene Manager and begin the game. <br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.Game.html#toc1__anchor">#Phaser.Game-Documentation</a></p><p>Your <strong>config</strong> object, is basically the settings or foundation on which you build your game upon. There are many properties (<em>type, width, height, etc.</em>) you can pass in depending on what and how you want your game to look and feel.</p><p>→ <strong>type: </strong>is the renderer you wanna use; such as — CANVAS | WEBGL | AUTO . Its usually best to keep it at AUTO so it can choose the renderer for you.</p><p>→ <strong>width/height: </strong>is the width/height of the game in pixels</p><p>→ <strong>physics: </strong>is an object that accepts about 1 to 4 properties. The first being <strong><em>default </em></strong>which states what physics engine you wanna use upon load. The next 3 are <strong><em>arcade, impact </em></strong>&amp;<strong><em> matter</em></strong><em> </em>which are all just engines that phaser runs on. <a href="http://www.html5gamedevs.com/topic/37762-physics-arcade-vs-impact-vs-matter/">#arcade-vs-impact-vs-matter</a><br><a href="https://photonstorm.github.io/phaser3-docs/global.html#PhysicsConfig">#physics-config-Documentation</a></p><p>→ <strong>scene: </strong>is an object that just registers the scenes of your game through properties and its values (functions). By default you are provided with <strong><em>preload, create,</em> </strong>&amp;<strong> <em>update</em></strong>. Which the first two are essential and the first scene will always run first.</p><p>→ <strong>transparent: </strong>makes your default background transparent instead of black when set to true.</p><p>There are many more properties you can pass in, but these are some of the most common ones. Check below for the documentation:<br><a href="https://photonstorm.github.io/phaser3-docs/global.html#GameConfig">#GameConfig-Documentation</a></p><h3>PRELOAD</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*SuiNNLyVDg8aTornWj8Y-A.png" /><figcaption>Preloading…</figcaption></figure><p>The <strong>preload() </strong>method is basically where you wanna load up your sprites, sprite sheets, atlas, tiles, sound, data files, etc. This does not display them, this only sets them up to be displayed later. There are 3 ways of which I know clearly on how to load a sprite.<br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html#toc0__anchor">#preload()-documentation</a></p><ol><li><strong>SINGLE SPRITE</strong> → this.load.image(&#39;sky&#39;, &#39;assets/skies/space3.png&#39;) <strong><em>this</em></strong> refers to the initialize object. the snippet above accepts 2 arguments. The <strong><em>key</em></strong> of which you can call the image by, and the <strong><em>filePath</em></strong> as to where the image is located as either a string or array.<br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html#image__anchor">#load.image()-documentation</a></li><li><strong>SPRITE SHEET </strong>→ this.load.spritesheet(&#39;bot&#39;, &#39;assets/robot.png&#39;, {frameWidth: 85, frameHeight: 130}) the spritesheet() accepts the same two arguments ; a <strong><em>key</em></strong> &amp; <strong><em>filePath</em></strong> along with a <strong><em>frameConfig</em></strong>. The frameConfig is an object that specifies a frame width &amp; height of each sprite inside the sheet. It is kind of like cropping the sprites to create separate images. If you specify the wrong dimensions or your sprites are not aligned correctly, then the sprites upon animation will not display properly. <br>TIP → → (<em>You can try to use a website like </em><a href="http://www.spritecow.com/"><em>SPRITECOW</em></a><em> to find the dimensions or do it yourself by checking the full width &amp; height of the sheet and divide it by the amount of single sprites.)<br></em><a href="https://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html#spritesheet__anchor"><em>#load.spritesheet()-documentation</em></a></li><li><strong>ATLAS </strong>→ this.load.atlas(&#39;mainmenu&#39;, &#39;assets/mainmenu.png&#39;, &#39;assets/mainmenu.json&#39;) the atlas() also accepts a <strong><em>key</em></strong> &amp; <strong><em>filePath</em></strong>, plus a <strong><em>jsonFile</em></strong>. The jsonFile is where the data of each individual sprite is located such as: the filename, the size, the frame location in x &amp; y coordinates, etc. An atlas is helpful when you have different sized sprites and also uses less memory when loading a game.<br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html#atlas__anchor">#load.atlas()-documentation</a><br>TIP → → (<em>You can </em><a href="https://ezgif.com/sprite-cutter"><em>convert</em></a><em> your sprite sheets or gifs into single files and use a program like </em><a href="https://www.codeandweb.com/texturepacker"><em>TexturePacker</em></a><em> or </em><a href="http://renderhjs.net/shoebox/"><em>Shoebox</em></a><em> to create an atlas JSON file.</em>)</li></ol><h3>CREATE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*APlal-pWBnaixlP7-pBoqQ.png" /><figcaption>creating your game</figcaption></figure><p>The <strong><em>create()</em></strong> is where we want to initialize our game objects, characters, player(s), platforms, background image/parallax, set up colliders, gravity, animations, etc.</p><p>Order in which you define your sprites/tiles matter! If you define your characters or platforms first and then your background, then your background image will be overlapping everything else. So remember to load your backgrounds first before anything unless you do this via CSS.</p><h4>Creating Images/Sprites</h4><p>this.add.image(400, 300, &#39;sky&#39;); → this is just creating a basic image, usually for static backgrounds, logos or scenery. The first two parameters are the <strong><em>x &amp; y coordinates</em></strong> of where you want the image to be. For the x-coordinate, it starts at 0; but the more you increase the number, the more to the right it goes. Y-coordinate begins from the top of the screen at 0, so the more you increase the number, the lower you position the image. The last parameter is the <strong><em>key</em></strong> of the item we defined back in our preload().<br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Image.html">#add.image()-documentation</a></p><p>this.physics.add.sprite(100, 350, &#39;bot&#39;, 0) → creates a sprite with <strong><em>x &amp; y coordinates</em></strong>, a <strong><em>key</em></strong> previously defined at preload() and the <strong><em>frame</em></strong> as either a string of the sprite image file you wanna use or as an integer if using a sprite sheet. Sprite objects can be used as either static or dynamic (animations). The <strong><em>physics</em></strong> property just enables the sprite to fall, otherwise it just stays in the air. When you add physics to an object, you get extra functions you can call like <em>collider()</em>, <em>setBounce()</em>, etc.<br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Sprite.html">#add.sprite()-documentation</a></p><h4>Groups (physics enabled &amp; regular)</h4><p>this.add.group() is used when you wanna “group” up objects that you’re gonna reuse. <br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Group.html">#add.group()-documentation</a></p><p>this.physics.add.group() pretty much makes any objects you pass in have a physics body to it.<br><a href="https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Group.html">#physics.add.group()-documentation</a></p><h3>RESOURCES</h3><ul><li><a href="https://medium.com/@jerra.haynes/a-real-persons-guide-to-phaser-3-or-how-i-learned-to-stop-worrying-and-love-the-gun-part-1-9cc6361f377c">A REAL PERSON’S GUIDE TO PHASER 3: OR, HOW I LEARNED TO STOP WORRYING AND LOVE THE GUN, PART 1</a></li><li><a href="http://labs.phaser.io/index.html?dir=&amp;q=">Phaser 3 Examples</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F88DS3Z8nOdY%3Fstart%3D2%26feature%3Doembed%26start%3D2&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D88DS3Z8nOdY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F88DS3Z8nOdY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8f25e3dd00b444c484c45d4571d40d6/href">https://medium.com/media/d8f25e3dd00b444c484c45d4571d40d6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14451732e005" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SMS on Rails (Easy Tutorial)]]></title>
            <link>https://medium.com/@michaelyukiromero/sms-on-rails-easy-tutorial-e5a017df6066?source=rss-72fcca079883------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5a017df6066</guid>
            <category><![CDATA[my-hero-academia]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[sms]]></category>
            <category><![CDATA[twilio]]></category>
            <dc:creator><![CDATA[Michael Yuki Romero]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 00:43:34 GMT</pubDate>
            <atom:updated>2019-03-16T05:09:48.913Z</atom:updated>
            <content:encoded><![CDATA[<h4>Rails &amp; Twilio</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/0*9LelkOFyApJ54P7_.png" /><figcaption>MOM! Look what I built! &gt;.&lt;</figcaption></figure><p>Today I’m going to show you a quick and easy Tutorial on <strong>sending a Text Message from your website to your phone</strong> (<em>You proud of me yet dad!?</em>). All you are going to really need is <strong>Rails</strong> framework &amp; <strong>Twilio</strong>.</p><h3><strong>STEP 1:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q3vOkCNZOotDkSq28lHwhA.png" /><figcaption><strong>STEP 1: Sign up @</strong><a href="https://www.twilio.com/"><strong>https://www.twilio.com/</strong></a></figcaption></figure><p>Start by <strong>signing up</strong> for Twilio — a cloud communications platform that allows to send &amp; receive text messages, phone calls, etc. When signing up, Twilio will ask you to <strong>verify your phone number</strong>. If you don’t, you can’t use Twilio then. Don’t worry, you get a <strong>FREE TRAIL with $15</strong> to use as you’d like, so your wallet won’t get hurt by any of this.</p><h3>STEP 2:</h3><p><strong><em>2.a</em></strong>) Open up your terminal and <strong>create a new Rails project</strong> in any directory (folder) you want:</p><pre>$ rails new SMSonRails</pre><p><strong><em>2.b</em></strong>) Next go inside your newly created project and <strong>add the Twilio gem into your Gemfile</strong>:</p><pre>gem &#39;twilio-ruby&#39;</pre><p><strong><em>2.c</em></strong>) Back to your terminal, let’s <strong>bundle install</strong> the project so we can start building upon it:</p><pre>$ bundle install</pre><p><em>If by any chance you get a </em><em>#&lt;LoadError: Error loading the &#39;sqlite3&#39; Active Record adapter. Just go inside your Gemfile &amp; locate sqlite3 &amp; add </em><em>&#39;~&gt; 1.3.6&#39; next to it.</em></p><h3>STEP 3:</h3><p><strong><em>3.a</em></strong>) Begin by <strong>building out your routes</strong> inside <em>config/routes.rb</em>. Both <strong>:index</strong> &amp; <strong>:create</strong> is a must! <em>(NOTE: I used no models, only a controller &amp; its view)</em></p><pre>resources :texts, only: [:index, :create]</pre><p><strong><em>3.b</em></strong>)<strong> Add a controller</strong> into <em>app/controllers/texts_controller.rb </em>with both index &amp; create methods:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*CxModKcU77flbnwP-Hj_qw.png" /><figcaption><em>We’re going to send a text from our create method</em></figcaption></figure><p><strong><em>3.c</em></strong>) Inside your views folder, create a new folder called “texts” and <strong>create a file called index.html.erb</strong>. This is the view the user will see. Lets <strong>add a form_tag</strong> along with a simple <strong>text_field_tag</strong> and <strong>submit_tag</strong>:</p><pre>&lt;%= form_tag texts_path do %&gt;<br>  &lt;%= text_field_tag &quot;input&quot; %&gt;<br>  &lt;%= submit_tag &quot;Send&quot; %&gt;<br>&lt;% end %&gt;</pre><p><strong><em>3.d</em></strong>)<strong> Run the rails server</strong> in your terminal and inside your browser type in <a href="http://localhost:3000/"><strong><em>http://localhost:3000/</em></strong></a><em> </em>and lets see our basic page:</p><pre>$ rails s</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFBw44R1ktrPJA3E7KsPzg.png" /><figcaption>localhost:3000</figcaption></figure><h3>STEP 4:</h3><p><strong>4.a</strong>) Now we can start <strong>implementing Twilio into our website</strong>. Go back to the Twilio page (assuming you’re still signed in) &amp; go to the <strong>Console Dashboard</strong>. We need to purchase a <strong>programmable phone number</strong> with the <strong>free $15</strong> they gave us. That’ll allow us to send messages to our phone:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*tkjaGeFmWU3xGFBM.png" /><figcaption><strong>Using our Free money to buy a Programmable phone number</strong></figcaption></figure><p><strong>4.b</strong>) Let’s go ahead and <strong>add the Twilio Rest Client</strong> inside our <strong>TextsController’s #create</strong> method:</p><pre>def create<br>  account_sid = &#39;ACXXXXXXXXXXXXXXXXXXXXXXXX&#39;<br>  auth_token = &#39;yyyyyyyyyyyyyyyyyyyyyyyyy&#39;<br>  @client = Twilio::REST::Client.new(account_sid, auth_token)<br><br>  from = &#39;+15551234567&#39; # Your Twilio number<br>  to = &#39;+15555555555&#39; # Your mobile phone number<br><br>  @client.messages.create(<br>  from: from,<br>  to: to,<br>  body: &quot;Hey friend!&quot; # The message you send<br>  )<br>end</pre><p><strong>4.c</strong>) Go back to your Twilio account and <strong>copy your ACCOUNT SID</strong>&amp; <strong>AUTH TOKEN</strong> they have provided and paste them over the two variables values we created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/0*6Zxba0DQgTVAqZyA.png" /></figure><p><strong>4.d</strong>) Finally you can test it out by going to your page and clicking on the send button and receive a “Hey friend!” text on your phone in a few seconds. But remember we want to try and send anything we type on the field tag. So inside the #create method go ahead and change the value of body to params[:input].</p><h3>END RESULT:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5q4uaXTCYP9ugozJopLJPA.png" /><figcaption>With some added styling</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U8f2WJJe52yJZDflU9Q5nA.jpeg" /><figcaption>Text received!</figcaption></figure><blockquote><strong><em>PS: There is a better &amp; optimal way of doing this with a few changes, check out below Resources “Twilio Rails blog” .</em></strong></blockquote><h3><strong>RESOURCES:</strong></h3><ul><li><a href="https://www.twilio.com/docs/sms/quickstart/ruby">Twilio Ruby Quickstart Guide</a></li><li><a href="https://www.twilio.com/blog/2017/12/send-sms-ruby-rails-5-coffee.html">Twilio Rails blog</a></li><li><a href="https://www.twilio.com/blog/send-an-sms-react-twilio">Twilio React blog</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5a017df6066" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to API RESTful-ly]]></title>
            <link>https://medium.com/@michaelyukiromero/how-to-api-restful-ly-bbeb862fb5a6?source=rss-72fcca079883------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbeb862fb5a6</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <dc:creator><![CDATA[Michael Yuki Romero]]></dc:creator>
            <pubDate>Tue, 26 Feb 2019 03:39:13 GMT</pubDate>
            <atom:updated>2019-02-26T14:33:44.307Z</atom:updated>
            <content:encoded><![CDATA[<h4>REST Version</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/0*hyyx1oUIDag5Too5.png" /><figcaption>Red requesting Pokemon via an API</figcaption></figure><p>Welcome to the world of Progra’mons. Where people fight over which language is better (<em>*cough*</em> Javascript <em>*cough*</em>), while others just create in peace. Anyways before we get off topic, like Pokemon game versions, there are multiple versions of APIs: <strong>SOAP</strong> &amp; <strong>REST</strong> version. Today we’ll be focusing strictly on REST(REpresentational State Transfer), but before we jump into using RESTful APIs; here is a quick summary of what an API is:</p><ul><li>API = “Application Programming Interface”</li><li>APIs are like User Interfaces (hence the “I” in API) for machines; machines access information via an API as you would through your smartphone</li><li>API is a contract between an Application (<strong>consumer</strong>) &amp; Service (<strong>provider</strong>); determines a set of standards on how to exchange information and/or functionality</li></ul><h3>REST-in-Peace</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*GA758fjtDaHzt5FL.gif" /><figcaption>Snorlax used rest…</figcaption></figure><p>REST APIs usually work like a website. They make a call to the server using HTTP verbs such as <strong>GET, POST, PUT </strong>and <strong>DELETE, </strong>and receive data back. The data they receive is in JSON format; which stands for Javascript Object Notation. Usually because it looks like a Javascript object. <strong><em>(See Below)</em></strong></p><pre><strong>{<br> </strong>”base_experience”: <strong>62</strong>,<br> ”forms”: <strong>[<br>    {</strong>“name”: “charmander”,<br>     ”url”: “<a href="https://pokeapi.co/api/v2/pokemon-form/4/">https://pokeapi.co/api/v2/pokemon-form/4/</a>&quot;<br>    <strong>}<br> ],<br> </strong>&quot;height&quot;: <strong>6</strong>,<br> &quot;id&quot;: <strong>4</strong>,<br> &quot;is_default&quot;: <strong>true<br>}</strong></pre><p>Using the example above, JSON is compiled of <strong>key/value</strong> pairs ranging from nested strings, booleans, integers, arrays and objects (or hashes for you Ruby fans). Then we can utilize this information and possibly store into our database, create objects, and/or display onto our applications/sites.</p><p>All this is possible because of the standards that REST APIs follow. One of them being that through a <strong>request </strong>(url), the API should respond (<strong>response</strong>) with a piece of information (<strong>resource</strong>).</p><h3><strong>MAKING A REQUEST</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*gnRr6pRpG3ugySLu.gif" /><figcaption>Requesting my Lv.78 Shiny Sceptile holding his MegaStone</figcaption></figure><p>Let’s try this analogy assuming you played Pokemon before whether you like it or not. You the trainer (<strong>client</strong>) walks in to the Pokemon Center and straight to the PC. You’re presented with the following options: <em>Bill’s PC</em> &amp; <em>Red’s PC</em>. You click on Bill’s PC and click on the option <em>Withdraw </em>and you’re presented with a box filled of Pokemon. You choose your HM helper Rattata and bam, he’s in your party of 6.</p><p>The PC represents the API, because no matter what Pokemon Center you visit, the way you request and interact with it never changes.</p><p>The <strong>request</strong> here was: https://bills-PC.com/Box-1/?Withdraw=Rattata <br>The <strong>response</strong> was adding Rattata which is the <strong>resource</strong> on to your team.</p><p>Let’s go ahead and dissect the request. The request is made up of a <strong>root-endpoint</strong>, <strong>path</strong> &amp; <strong>query parameters</strong>. The root-endpoint is the base URL from the API you are requesting from. In this case, <a href="https://bills-pc.com/">https://bills-PC.com</a> is the root-endpoint. The path is the direction of the resource, again using the previous example /Box-1 . If we had just stopped there, then the response would be all the Pokemon inside Box-1. This is where query parameters come in handy: /?Withdraw=Rattata . Query params are attached to the end of a url to help define specific content or actions. Some APIs require you to sign up and/or purchase an API key, or require no key at all to add as a parameter.</p><h3>RESOURCES:</h3><ul><li><a href="https://www.youtube.com/watch?v=cpRcK4GS068&amp;list=PLcgRuP1JhcBP8Kh0MC53GH_pxqfOhTVLa&amp;index=1">APIs 101</a></li><li><a href="https://www.youtube.com/watch?v=Q-BpqyOT3a8">RESTful API</a></li><li><a href="https://www.youtube.com/watch?v=7YcW25PHnAA">REST API concepts &amp; Examples</a></li><li><a href="https://pokeapi.co/">Poke’ API</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbeb862fb5a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>