<?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 Andrew Rivera on Medium]]></title>
        <description><![CDATA[Stories by Andrew Rivera on Medium]]></description>
        <link>https://medium.com/@drewisatlas?source=rss-b21c95dfdde0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZhaN4JOzRACT8Ks7VQv9aA.jpeg</url>
            <title>Stories by Andrew Rivera on Medium</title>
            <link>https://medium.com/@drewisatlas?source=rss-b21c95dfdde0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:43:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@drewisatlas/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[Implementing Stacks and Queues in Javascript]]></title>
            <link>https://medium.com/@drewisatlas/implementing-stacks-and-queues-in-javascript-b3714dee112f?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3714dee112f</guid>
            <category><![CDATA[stack]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[queue]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Mon, 01 Apr 2019 03:59:05 GMT</pubDate>
            <atom:updated>2019-04-01T03:59:05.924Z</atom:updated>
            <content:encoded><![CDATA[<p>What is the difference between a Stack and a Queue? As a student studying Javascript that can be a little tricky to answer. Unlike other programming languages, Javascript does not have an explicit data structure for either a stack or a queue. So for a lot of self-taught programmers and Bootcamp grads they may not know how to use these more advanced data structures let how to build and implement them. The alternative is that they have been using them all along and never realized it. Get ready for a crash course is Stacks and Queues!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FZoAa7lsmym6UE%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FZoAa7lsmym6UE&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FZoAa7lsmym6UE%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="202" frameborder="0" scrolling="no"><a href="https://medium.com/media/26b1a47b86d1d1ef24f6d9384309a8c3/href">https://medium.com/media/26b1a47b86d1d1ef24f6d9384309a8c3/href</a></iframe><h3>What is a Stack?</h3><p>A stack is a linear data structure with a “last in first out” principle. What does that mean? Imagine we have a list of information. When we add something to the list it gets added to the end. When we remove something from the list, we remove it from the end. It is like a stack of paper we add pieces of paper to the stack, and we remove pieces of paper for the top of the stack (We don’t pull from the bottom, or the middle). The important thing to remember is that the same end of the data structure is used to insert and delete data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F6FA7Kkd3uM76M%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fpaper-stack-sander-6FA7Kkd3uM76M&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F6FA7Kkd3uM76M%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/a772c6b362b12acdb4e9726b0c0919d6/href">https://medium.com/media/a772c6b362b12acdb4e9726b0c0919d6/href</a></iframe><p>Stacks are used in programming to manage function invocations, build undo and redo functions, build routing, as well as keep track of page history. In Javascript, we don&#39;t have a Stack data structure immediately available to us. But we can implement a Stack in a couple of different ways: with an array, or with a linked list.</p><h4>Array Implementation of a Stack</h4><p>A stack is a linear data structure, so we can Array to have the same functionality as a stack. An array is a data type in javascript that stores a list of information in linear order and lucky for us it has a number of built-in methods for manipulating the array. The two methods that we will need to mimic the functionality of a stack are .push() and .pop().</p><blockquote>The <strong>push()</strong> method adds one or more elements to the end of an array and returns the new length of the array.</blockquote><blockquote>The <strong>pop()</strong> method removes the <strong>last</strong> element from an array and returns that element. This method changes the length of the array.</blockquote><p>With an array, we simply add elements onto it with the push method. and remove elements with the pop method. That is the functionality of a Stack.</p><pre>const stack = []            // create a new array</pre><pre>stack.push(‘google’)        // push &#39;google&#39; onto the stack</pre><pre>stack.push(‘instagram’)     // push &#39;instagram&#39; onto the stack</pre><pre>stack.push(‘youtube’)       // push &#39;youtube&#39; onto the stack</pre><pre>stack = [‘google’, ‘instagram’, ‘youtube’] // current stack</pre><pre>stack.pop()                 // remove last element added to stack      </pre><pre>//stack = [‘google’, ‘instagram’] // current stack</pre><h4>Singly Linked List Implementation of a Stack</h4><p>Although using an Array is useful, Arrays have methods that we don&#39;t need, and the elements have indices which are also unnecessary for a stack. All of those features use additional memory. Let’s say we wanted to create our own stack class using a singly linked list. We could use javascript classes to build stacks, nodes, as well as the methods to add and remove elements (or nodes) to the stack.</p><pre>//creates a node class that will represent elements/nodes in the stack</pre><pre>class Node {<br>  constructor (value) {<br>    this.value = value;<br>    this.next = next;<br>  }<br>}</pre><pre>//creates a Stack class that will store elements/nodes</pre><pre>class Stack {<br>  constructor () {<br>    this.first = null;<br>    this.last = null;<br>    this.size = 0;<br>  }</pre><pre>//when we want to add a node to the stack we call the push method on the stack and pass the value as an argument</pre><pre>push (value) {<br>    let node = new Node(value);<br>    if (this.size === 0) {<br>      this.first = node;<br>      this.last = node;<br>    } else if (this.size &gt;= 1) {<br>      let currFirst = this.first;<br>      this.first = node;<br>      this.first.next = currFirst;<br>    }<br>    return this.size++;<br>  }</pre><pre>//when we want to remove the last node off the stack we call the pop method</pre><pre>pop () {<br>    if (this.size === 0) {<br>      return null;<br>    }<br>    let temp = this.first;<br>    if (this.size === 1) {<br>      this.last = null;<br>    }<br>    this.first = this.first.next;<br>    this.size --;<br>    return this.first;<br>  }<br>}</pre><p>Now we can create stacks, and add and remove elements from them in a more memory efficient data structure than an Array.</p><h3>What is a Queue?</h3><p>A Queue is a linear data structure with a “first in first out” principle. Sounds familiar right? It is similar to a stack but what is different is how information is removed. Imagine we have a list of information. When we add something to the list it gets added to the end, just Like with a stack. However, instead of removing information from the end we will remove it from the line. It is like standing in a line (or queue *hint hint* if you are British). People enter the line at the end of it. People leave a line when they reach the front.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o85xLtFJbXy8ei7n2%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o85xLtFJbXy8ei7n2%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F3o85xLtFJbXy8ei7n2%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="217" frameborder="0" scrolling="no"><a href="https://medium.com/media/7eedf10ed0a7471ea3b5780d6c650bbf/href">https://medium.com/media/7eedf10ed0a7471ea3b5780d6c650bbf/href</a></iframe><p>Queues are used in programming anytime you are waiting in what seems like a line including background tasks, uploading resources, printing, and task processing. Just like with a Stack, In Javascript, we don’t have a Queue data structure immediately available to us. But again we can implement a Queue with an array, or with a linked list.</p><h4>Array Implementation of a Queue</h4><p>A Queue is a linear data structure, so we can again use an Array. But there is something different about using an Array for a Queue as opposed to a Stack. We are going to be adding data to the end of the queue, however, when we remove data from the beginning of the queue requires reindexing. Remember that each element in an array has an index which allows us to access a specific element immediately. Unlike when we remove an element from the end of an array, removing an element from the front causes every other element in the array to update its index which can cause performance issues for large data sets.</p><p>The two methods that we will need to mimic the functionality of a Queue are .push() and .shift().</p><blockquote>The <strong><em>push()</em></strong> method adds one or more elements to the end of an array and returns the new length of the array.</blockquote><blockquote>The <strong>shift()</strong> method removes the <strong>first</strong> element from an array and returns that removed element. This method changes the length of the array.</blockquote><pre>Const queue = [];           // create a new array</pre><pre>queue.push (‘first”)        // add &#39;first&#39; to the queue</pre><pre>queue.push (“second”)       // add &#39;second&#39; to the queue</pre><pre>queue.push (“third”)        // add &#39;third&#39; to the queue</pre><pre>queue = [‘first’, ‘second’, ‘third’] // current queue</pre><pre>queue.shift()               // remove the first element of the queue</pre><pre>queue = [‘second’, ‘third’] // current queue</pre><h4>Singly Linked List Implementation of a Queue</h4><p>This implementation allows us to avoid reindexing, and the extra methods an Array has. Using a Singly Linked List for a Queue is going to nearly identical to the classes and methods we built except for the method that removes items from the queue. We will name the methods that add and remove elements/ nodes from our queue, enqueue (to add), and dequeue (to remove).</p><pre>//create a Node class that will represent elements/nodes in the Queue<br> class Node {<br>   constructor (value) {<br>     this.value = value;<br>     this.next = null;<br>   }<br> }</pre><pre>//creates a Queue class to store the elements/nodes of the Queue<br> class Queue {<br>   constructor () {<br>     this.first = null;<br>     this.last = null;<br>     this.size = 0;<br>   }<br>   //enqueues a node<br>   enqueue(val) {<br>     let node = new Node(val);<br>     if (this.size === 0) {<br>       this.first = node;<br>       this.last = node;<br>     } else {<br>       this.last.next = node;<br>       this.last = node;<br>     }<br>     return this.size++;<br>   }</pre><pre>  //dequeues a node <br>  dequeue () {<br>    if (!this.first) {<br>      return null;<br>    }<br>    let temp = this.first;<br>    if (this.first === this.last){<br>      this.last = null;<br>    }<br>    this.first = this.first.next;<br>    this.size--;<br>    return temp.value;<br>  }<br> }</pre><h3>Conclusion</h3><p>In conclusion, Stacks and Queues are actually quite similar and relatively easy to build and use in Javascript. Arrays can be used to mimic the functionality of both Stacks and Queues. However, if you are looking for a leaner more specific way to build Stacks and Queues you can implement them yourself using Javascript Class syntax in your code. The key thing to remember is that a Stack is Last In First Out (LIFO), and a Queue is First In First Out (FIFO).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3714dee112f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“How I Made a Turn Based Game in React” Part 2: Turn-Based Logic]]></title>
            <link>https://medium.com/@drewisatlas/how-i-made-a-turn-based-game-in-react-part-2-turn-based-logic-9ddd84af5f7?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ddd84af5f7</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Mon, 25 Mar 2019 01:37:29 GMT</pubDate>
            <atom:updated>2019-03-25T01:37:29.696Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog post is part 2 in a series of blog posts detailing the creation of a turn-based game of “tag” built with react.js. I recommend reading <a href="https://medium.com/@drewisatlas/how-i-made-a-turn-based-game-in-react-part-1-basic-movement-6d892cb93947">part 1</a> of this series of blogs before continuing. That being said… welcome back!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZdHjqSoYG0zITcEbW6HTg.png" /><figcaption>“Let’s Play Tag” A turn-based game built in react.js</figcaption></figure><h3>Brief Recap</h3><p>Where we last left off we built the game board, set up our game state to keep track of player locations on the board, and built the functions that would control player movement. As of right now, the human controlled player moves with the arrow key and our computer controlled players are moving randomly around the board. However, there are no turn-based mechanics in the game which was one of the deliverables we defined. So let’s build that next!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FAhvlW1HV6QMtKx2hLY%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fufc-sport-AhvlW1HV6QMtKx2hLY&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FAhvlW1HV6QMtKx2hLY%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb15e6e38afc2b39d87e664ff60bc48d/href">https://medium.com/media/bb15e6e38afc2b39d87e664ff60bc48d/href</a></iframe><h3>Whose Turn Is It?</h3><p>You might remember in the last blog where we used redux to update a player location on the board. In order to keep track of whose turn it is I again use redux to control the state of our game. Specifically, I wanted to keep track of whose turn it is, and how many moves remain in their turn.</p><pre>const initialState = {<br>  players: 4,<br>  it: 4, <br>  whoseTurn: 1,         // Whose turn it is<br>  moves: 3,             // How many moves remain in this turn<br>  gameOver: false,<br>}</pre><p>Because each player can only move three spaces during the turn we set up a reducer case that will decrease the current moves stored in the games state by one. For the purposes of this blog lets just focus on the ‘DECREASE_MOVES’ case.</p><pre>const gameReducer = (state = initialState, action) =&gt; {<br>  switch (action.type) {<br>    case &#39;NEXT_TURN&#39;:<br>      return {...state, whoseTurn: action.whoseTurn }<br>    case &#39;DECREASE_MOVES&#39;:<br>      return {...state, moves: state.moves - 1}   //decreases moves<br>    case &#39;RESET_MOVES&#39;:<br>      return {...state, moves: 3}<br>    case &#39;READY_PLAYER_ONE&#39;:<br>      return {...state, whoseTurn: 1}<br>    case &#39;TAG_PLAYER&#39;:<br>      return {...state, it: action.it}<br>    default :<br>    return state<br>  }<br>}</pre><p>In order to use this case, we need an action that will implement the case that decrements the moves currently in the store. This action will be called anytime a player moves.</p><pre>export function decreaseMoves (){<br>  return {<br>    type: &quot;DECREASE_MOVES&quot;<br>  }<br>}</pre><p>Only once a player has depleted the moves for their turn (bringing the turn counter to 0) will their turn end, and the next players turn will begin. The simplest way to do this check is to run a function after a player moves to see if “moves” is equal to zero. A turn sequence should now operate like so:</p><ol><li>A player selects a location to move to.</li></ol><p>2. Checks are run to make sure the location is valid (not occupied by a player or out of bounds of the game board).</p><p>3. If valid the player moves to that location.</p><p>4. The moves counter in the game state is decremented.</p><p>5. A check is run to see if any moves remain.</p><pre>checkMoves = () =&gt; {<br>    if (this.props.game.moves === 0) {<br>      console.log(&#39;this players turn is over&#39;);<br>      this.endPlayerTurn()<br>    } else {<br>      console.log(`${this.props.game.moves} remaining`)<br>    }<br>  }</pre><p>If moves remain, the player can move again. If no moves remain, then it is the next player&#39;s turn.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FX4S7WV6kV0BGM%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fcomedy-bang-fred-armisen-cbbtv-X4S7WV6kV0BGM&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FX4S7WV6kV0BGM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a3317f3d70a4220b528ec21999f9cb7/href">https://medium.com/media/3a3317f3d70a4220b528ec21999f9cb7/href</a></iframe><h3>Switching To The Next Player</h3><p>Before we can switch to the next player’s turn we need to do two things. We need to reset the move counter back up to three, and then update state to the next player number. We can do this by creating a function that will call two functions, a “resetMoves” reducer action and a “nextTurn” function.</p><pre>endPlayerTurn = () =&gt; {<br>    console.log(&quot; ending turn&quot;)<br>    this.props.resetMoves() // this is a reducer action <br>    this.nextTurn()<br>  }</pre><pre>nextTurn = () =&gt; {</pre><pre>let currentPlayer = this.getPlayerObject(this.props.game.whoseTurn)<br>    if (currentPlayer === this.props.players[this.props.players.length -1]) { <br>      let readyNextPlayer = this.props.players[0]<br>        return this.props.nextTurn(readyNextPlayer.id)<br>    } else {<br>      let playerIndex = this.props.players.findIndex( player =&gt; {<br>        return player === currentPlayer<br>      })<br>      let readyNextPlayer = this.props.players[playerIndex + 1]<br>      return this.props.nextTurn(readyNextPlayer.id)<br>    }<br>  }</pre><h4>Reset Moves</h4><p>Remember that reducer we looked at earlier? Did you notice the case for “RESET_MOVES”? We can use that case by making an action to reset the moves. When the game reducer runs this case we set the moves counter back to three.</p><pre>export function resetMoves (){<br>  return {<br>    type: &quot;RESET_MOVES&quot;<br>  }<br>}</pre><pre>// excerpt from the reducer //</pre><pre>case &#39;RESET_MOVES&#39;:<br>      return {...state, moves: 3}</pre><h4>Next Turn</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxT5LMTD1lvLeTDDH8c%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fseason-15-the-simpsons-15x11-xT5LMTD1lvLeTDDH8c&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxT5LMTD1lvLeTDDH8c%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="328" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1cd70b9c0c0b036a546605584dc8a22/href">https://medium.com/media/d1cd70b9c0c0b036a546605584dc8a22/href</a></iframe><p>The next turn function first has to check if the current player id is equal to the total player numbers. If this is the case, then the next player is going to be the first player. Otherwise, we simply increment the player id by one, to the next player id number. In order to update the state of the game to the new player, we then pass that player number as an argument to a reducer action called “nextTurn”. This will update “whoseTurn” in the game state.</p><pre>export function nextTurn(payload){<br>  return {<br>    type: &#39;NEXT_TURN&#39;,<br>    whoseTurn: payload,<br>  }<br>}</pre><pre>// excerpt from the reducer //</pre><pre>case &#39;NEXT_TURN&#39;:<br>      return {...state, whoseTurn: action.whoseTurn }</pre><h3>Conclusion</h3><p>At this point in the game’s development, we now have players that can move around the board in a turn-based sequence. In upcoming blogs, I plan to go over how I built AI for the computer players, the tagging mechanics for the game, and other aspects of this games development. If you want to know when those blogs are released please <strong>click the follow button up top.</strong></p><p>Check out this demo video of the game in its current state:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FeQWGUh98r28%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DeQWGUh98r28&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FeQWGUh98r28%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/95707d5f37ad55a9d0c98c117dde8913/href">https://medium.com/media/95707d5f37ad55a9d0c98c117dde8913/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ddd84af5f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Closure?]]></title>
            <link>https://medium.com/@drewisatlas/what-is-a-closure-46ce460e2b47?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/46ce460e2b47</guid>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[closures-functions]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 02:21:37 GMT</pubDate>
            <atom:updated>2019-03-18T02:21:37.045Z</atom:updated>
            <content:encoded><![CDATA[<h3>An interview Question</h3><p>“What is a Closure?” I was recently asked this in an interview. I knew the basic idea of what Closures are. They are a feature in Javascript that allows functions to remember the variables from when the function was called. A closure provides a snapshot of the scope chain from when the function is called. I explained these points to my interviewer. He nodded in agreement, and asked me a follow-up question, “Why are closures important?” I didn’t have an answer for that. I didn’t know at that moment, but I was going to find out (and share my findings with all of you!). Let’s get started!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FaMh59aKR8vjdC%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fseinfeld-preseason-aMh59aKR8vjdC&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FaMh59aKR8vjdC%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/b271eda4a789022be143d1b57457a75d/href">https://medium.com/media/b271eda4a789022be143d1b57457a75d/href</a></iframe><h3>A Refresher on Closures</h3><p>According to Mozilla’s Developer Network, a closure is defined as:</p><blockquote>The combination of a function and the lexical environment within which that function was declared.</blockquote><p>Let’s see if we can explain it easier terms to understand…</p><p>Try to think of functions as values, and these values have some attributes:</p><ul><li>The code in the body of the function.</li><li>The environment in which they were created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*vnqVGnV8HMzwWKfy9HarfA.png" /><figcaption>source: <a href="https://lostechies.com/">https://lostechies.com/</a></figcaption></figure><p>When a function is declared the function definition is being stored as well as all the variables, and other function values at the time of creation. A closure is essentially taking a snapshot of the environment(or scope) that exists at the creation of the function.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FdlMOpFMswphLy%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fbeautiful-open-cartoonishly-dlMOpFMswphLy&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FdlMOpFMswphLy%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fdf75f88f7d09c44646f3e3260799e9/href">https://medium.com/media/1fdf75f88f7d09c44646f3e3260799e9/href</a></iframe><p>Let’s look at a simple example, an excerpt of “Eloquent Javascript” by Marijn Haverbeke.</p><pre>function wrapValue(n) {       <br>  let local = n;<br>  return () =&gt; local;<br>}</pre><pre>let wrap1 = wrapValue(1); <br>let wrap2 = wrapValue(2);<br>console.log(wrap1());<br>// → 1<br>console.log(wrap2());<br>// → 2<br></pre><pre>Excerpt From: Marijn Haverbeke. “Eloquent JavaScript.” iBooks.</pre><ol><li>We <strong>define a function</strong> called wrapValue that takes an argument of n.</li><li>wrapValue encloses a local variable, that is equal to the argument passed in.</li><li>wrapValue <strong>returns a function</strong> that returns the local variable.</li></ol><p>. The inner function will have access to all of its outer scopes. Look at what happens when we call the functions and save them to variables. Every time the function is called, a new local variable is created. Each instance of the function has its own local variable from when it was created. We don’t have to worry about other function calls changing the local variable in the function.</p><h3>Why Are Closures Important</h3><p>So now that we have an understanding of what a closure is, let’s discuss why they are important and what we can do with them.</p><h4>Protecting Variables and Privacy</h4><p>When you enclose a variable inside of the outer function you protect it from being accessed and potentially rewritten by any other parts of your program with the exception of the inner functions, these functions are also known as privileged methods. Imagine if you had multiple functions that needed to access a counter. It would be dangerous to put the counter in the global scope of your program. but if we wrote our functions to include the counters in their closures we can prevent messing up our counters. Take a look at this example from the MDN web docs:</p><pre>const counter = (function() {<br>  let privateCounter = 0;<br>  function changeBy(val) {<br>    privateCounter += val;<br>  }<br>  return {<br>    increment: function() {<br>      changeBy(1);<br>    },<br>    decrement: function() {<br>      changeBy(-1);<br>    },<br>    value: function() {<br>      return privateCounter;<br>    }<br>  };<br>})();<br><br>console.log(counter.value()); // logs 0<br>counter.increment();<br>counter.increment();<br>console.log(counter.value()); // logs 2<br>counter.decrement();<br>console.log(counter.value()); // logs 1</pre><p>The methods inside the scope of the counter variable give us access to the counter, keeping it private from the global scope.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FleqmpruKOh3gY%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fthe-nanny-diaries-leqmpruKOh3gY&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FleqmpruKOh3gY%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="252" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5fa966eb9b7204d7ab7502a2d875200/href">https://medium.com/media/d5fa966eb9b7204d7ab7502a2d875200/href</a></iframe><h3>Conclusion</h3><p>In conclusion, we got to review what a closure is and how we can use it to keep variables protected and private from other functions. Learning is an ongoing affair for me, so if you know of some other common uses for closures please feel free to leave a comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46ce460e2b47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“How I Made a Turn Based Game in React” Part 1: Basic Movement]]></title>
            <link>https://medium.com/@drewisatlas/how-i-made-a-turn-based-game-in-react-part-1-basic-movement-6d892cb93947?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d892cb93947</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Tue, 05 Feb 2019 01:03:25 GMT</pubDate>
            <atom:updated>2019-02-05T01:03:25.248Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZdHjqSoYG0zITcEbW6HTg.png" /><figcaption>“Let’s Play Tag” A turn-based game built in react.js</figcaption></figure><p>It started simple enough, I had two and a half weeks to develop a final project for school. I knew what I wanted to build, I wanted to build a game. I just needed to come up with an idea to base it off of. I asked my friend Carly to give me some ideas and talking to her made me think of childhood, and that, in turn, made me think of one of my favorite games to play as a child, “Tag”. That would be my concept.</p><h3>Identifying Deliverables</h3><p>I now had my concept, I wanted to make a game of “Tag”. The Rules and gameplay would operate like so :</p><ul><li>There are 4 players at the start of the game. One human controlled player that moves around the board with arrow keys, and three computer-controlled players that would move based on functions in the program that would determine the most logical move to make.</li><li>Each player takes a turn moving around the board, moving three spaces per turn.</li><li>One player starts the game as “It”. If the “it” player ends their turn next to another player, that player then becomes it.</li><li>Each player starts with three lives, losing a life each time they are tagged. If they lose all of their lives they are removed from the board.</li><li>This seemed Like a good basic game, nothing too fancy but something I could build off of in the future and make even better.</li><li>The last player standing is the winner.</li></ul><h3>Step One: Building the Board</h3><p>The first thing I would need to do while building this game is the game board. I knew I wanted it to resemble a checkerboard and it would contain 4 players at the start of the game. I did this by building a board component with 8 columns containing 8 div elements.</p><pre>&lt;div className=&#39;column&#39; style={{gridArea:&#39;1/1/9/2&#39;}}&gt;<br>        &lt;div className=&#39;aDiv item&#39;&gt;&lt;/div&gt;<br>        &lt;div className=&#39;bDiv item&#39;&gt;&lt;/div&gt;<br>        &lt;div className=&#39;aDiv item&#39;&gt;&lt;/div&gt;<br>        &lt;div className=&#39;bDiv item&#39;&gt;&lt;/div&gt;<br>        &lt;div className=&#39;aDiv item&#39;&gt;&lt;/div&gt;<br>        &lt;div className=&#39;bDiv item&#39;&gt;&lt;/div&gt;<br>        &lt;div className=&#39;aDiv item&#39;&gt;&lt;/div&gt;<br>        &lt;div className=&#39;bDiv item&#39;&gt;&lt;/div&gt;<br>      &lt;/div&gt;</pre><p>I used CSS grid area to give each space a grid area, this would be crucial to my game’s mechanics. It would serve as a way to keep track of where players are and write functions that kept track of the movement of characters and tag locations on the board.</p><h3>Step Two: Managing the State of the Game</h3><p>In order to keep track of where players were located on the board, I would be using Redux to update a piece of each player’s state that stored the player’s location as a grid area when they moved on their turn.</p><pre>const initialState = [<br>    {id: 1, gridArea:&quot;4/5&quot;, lives: 3, type: &#39;user&#39;, sprite: sprite1, name: &#39;Andrew&#39;},<br>    {id: 2, gridArea:&quot;4/4&quot;, lives: 3, type: &#39;CPU&#39;, sprite: sprite2, name:&#39;Pete&#39;},<br>    {id: 3, gridArea:&quot;5/5&quot;, lives: 3, type: &#39;CPU&#39;, sprite: sprite3, name:&#39;Jeremy&#39;},<br>    {id: 4, gridArea:&quot;5/4&quot;, lives: 3, type: &#39;CPU&#39;, sprite: sprite4, name: &#39;Charlie&#39;},<br>  ]</pre><p>Please note that you don’t need to use redux to control the state of the player locations, but I chose to do so because it kept things organized and made the player state easy to access anywhere I needed to in the codebase.</p><h3>Step Three: Making Players Move</h3><p>Now that I had a board for my players to move around, and somewhere to store the player locations (state) it was time to add the players. I added two components to my game one for a “User-controlled player” and one for a “CPU controlled player”. The reason being that although the players would all have identical movement restrictions I wanted to make sure one component had movement functions designed to make decisions on behalf of the player (for the CPU players) and one that would take it’s movement commands from the keyboard for the user controlled player.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxT0CyEc4pmF2Eb3Asg%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fsupersimple-exercise-elephant-xT0CyEc4pmF2Eb3Asg&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxT0CyEc4pmF2Eb3Asg%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/675fc6b853731c4a29e4c03edf064b55/href">https://medium.com/media/675fc6b853731c4a29e4c03edf064b55/href</a></iframe><h4>The User Controlled Player</h4><p>For the user controlled player, I started by adding an event listener to the user Player Component after the component was mounted to the board. This would listen for keydown commands and call a function in the component that controlled the user’s Movement.</p><pre>componentDidMount () {<br>      window.addEventListener(&#39;keydown&#39;, this.userMovementLogic)<br>  }</pre><p>The “userMovementLogic” function would have to do a few things before it could update the player’s state to the new location.</p><p>First, it needs to access the player’s state to grab the current x and y coordinates of the player.</p><pre>let coordinates = this.props.player.gridArea.split(&#39;/&#39;)<br>    console.log(coordinates);<br>    let xCoord = parseInt(coordinates[1])<br>    let yCoord = parseInt(coordinates[0])</pre><p>Then based on the key that was pressed down it would change either the x or y coordinate.</p><pre>if (event.key === &quot;ArrowUp&quot;){<br>      yCoord -= 1<br>    } else if (event.key === &quot;ArrowDown&quot;){<br>      yCoord += 1<br>    } else if (event.key === &quot;ArrowLeft&quot;){<br>      xCoord -= 1<br>    } else if (event.key === &quot;ArrowRight&quot;){<br>      xCoord += 1<br>    }<br>newCoordinates = `${yCoord}/${xCoord}`</pre><p>With the newly updated coordinates, the function then checks to make sure that the new grid area is within the borders of the game board, and not a board space that is already occupied by another player. If this new location passes these checks then the player’s state is updated to the new location. If the new location didn&#39;t pass the check the player would not be able to move to that space.</p><pre>if ((yCoord &lt;= 8 &amp;&amp; yCoord &gt;= 1) &amp;&amp; (xCoord &gt;= 1 &amp;&amp; xCoord &lt;= 8) &amp;&amp; (this.checkPlayerCollision(newCoordinates))) {<br>   let updatedPlayer = {...this.props.player, gridArea: newCoordinates }<br>   this.updateAndDispatchPlayers(updatedPlayer)</pre><p>This is how I was able to control the user player’s movement, but note that turn logic, three spaces per turn movement restrictions, and tags have not incorporated into the code just yet.</p><h4>The CPU Controlled Player</h4><p>When first starting the creation of this game I knew that the biggest challenge of building this game would be writing the AI for the CPU controlled players. Going over the logic for just that alone is worthy of another blog post (coming soon). At this point, I had the user controlled player moving with the arrow keys, and now I wanted to get the CPU player moving in the most basic way possible, randomly.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o6Mb3vH0gqA8Nabte%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fseason-9-the-simpsons-9x6-3o6Mb3vH0gqA8Nabte&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o6Mb3vH0gqA8Nabte%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="331" frameborder="0" scrolling="no"><a href="https://medium.com/media/36991d3137ee3dd8ca7b2d281bc10fcc/href">https://medium.com/media/36991d3137ee3dd8ca7b2d281bc10fcc/href</a></iframe><p>To do this I would need to find a way to run a function that moves the computer players autonomously. So I set an interval to make the CPU players move after a specified period of time.</p><pre>componentDidMount () {<br>    this.movementInterval = setInterval(this.randomCpuMovement, 750)<br>  }</pre><p>The “randomCpuMovement” function would access the player’s state to get the current x and y coordinates of the player the same way it did for the User player but instead of using the arrow keys to determine the movement direction it would use Math.random().</p><pre>let randMoveDirection = Math.random();</pre><pre>if (randMoveDirection &lt;= 0.25) {<br>        yCoord -= 1<br>      } else if (randMoveDirection &gt; 0.25 &amp;&amp; randMoveDirection &lt;= 0.50){<br>        yCoord += 1<br>      } else if (randMoveDirection &gt; 0.50 &amp;&amp; randMoveDirection &lt;= 0.75){<br>        xCoord += 1<br>      } else if (randMoveDirection &gt; 0.75 &amp;&amp; randMoveDirection &lt;= 1.00){<br>        xCoord -= 1<br>      }</pre><p>Then the same checks would be run to make sure the player is within the bounds of the game board and not attempting to move to a spot where a player is already located. If the move is valid the state for that player is updated and the player moves to the new spot. Otherwise, the player would do nothing and wait for the interval to run that function but with a movement command that did pass the checks required to move to an empty space.</p><h3>Conclusion</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl3JDKYkWVEnxPYrrq%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fbuzzfeed-ladylike-builds-furniture-l3JDKYkWVEnxPYrrq&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl3JDKYkWVEnxPYrrq%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="240" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e285e996d226aa517c62f88e54158a2/href">https://medium.com/media/3e285e996d226aa517c62f88e54158a2/href</a></iframe><p>At this point in the game’s development, we now have a human controlled player that can move around the board based on arrow key input, and CPU controlled players that move around randomly on the board (not the smartest players but it’s progress). In upcoming blogs, I plan to go over how I implemented the turn-based mechanics of the game, built AI for the computer players, and other aspects of this games development. If you want to know when those blogs are released please <strong>click the follow button up top.</strong></p><p>Check out this demo video of the game in its current state:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FeQWGUh98r28%3Fstart%3D1%26feature%3Doembed%26start%3D1&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DeQWGUh98r28&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FeQWGUh98r28%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/07f0db746214909b9694a49974fa5a7f/href">https://medium.com/media/07f0db746214909b9694a49974fa5a7f/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d892cb93947" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Lifecycle Methods: What are they? When do we use them?]]></title>
            <link>https://medium.com/@drewisatlas/react-lifecycle-methods-what-are-they-when-do-we-use-them-edccb5ec860a?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/edccb5ec860a</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 20:31:24 GMT</pubDate>
            <atom:updated>2019-01-10T20:31:24.697Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the elements of React that left me both confused and intrigued me at the same time was React Lifecycle Methods. It was not anything I had encountered in my programming experience, a new concept that I could see the potential in becoming quite useful. But what did they do?</p><p>React Lifecycle methods allow us to specify what happens in your Document Object Model (DOM) at predetermined times of the Lifecycle. Remember that the main purpose of React is to modify the DOM (Document Object Model) to match what components you want to render onto the screen. React does this by adding, updating, and removing DOM nodes. Different lifecycle methods correspond with each of these three actions. So let’s start there!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSO--5BPT1K_YK6VqRy4vg.png" /><figcaption>source: <a href="http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/">http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/</a></figcaption></figure><h3>Mounting</h3><p>Mounting refers to adding nodes to the DOM. The lifecycle Methods that relate to mounting include <strong>constructor()</strong>,<strong> render()</strong>, and <strong>componentDidMount()</strong>.</p><h4>constructor() method</h4><p>The constructor method is called before any nodes are added to the DOM, in other words, it is called before mounting. Typically the most common use of the constructor method is for <strong>initializing local </strong><a href="https://thinkster.io/tutorials/understanding-react-state"><strong>state </strong></a>(setting up the state for the component).</p><h4>render() method</h4><p>The render method, old reliable, it is the only required method for a class component. This method does most of the work in React and its main job is to <strong>return the JSX of your component.</strong></p><h4>componentDidMount() method</h4><p>The componentDidMount method is called after the component has rendered (see above) for the first time. This method runs after the component output has been rendered onto the DOM. This method is commonly used to <strong>load data</strong>, and do anything that required the component to be there before we could interact with it.</p><p>But you might be thinking, why not load data with the constructor phase before the DOM renders? Long story short, you cannot set State on an unmounted component.</p><h3>Updating</h3><p>Updates occur when there is a state in props, and as a result, there are two life cycle methods that can be called when an update occurs. <strong>Render()</strong> and <strong>componentDidUpdate().</strong></p><h4>render() … again</h4><p>It’s important to realize that a component will often render differently based on the current state or props being provided to the render function. For this reason, if the state or props is changed the render method will be run again with the updated state and props.</p><h4>componentDidUpdate()</h4><p>Similar to componentDidMount() is called after the DOM’s initial render, componentDidUpdate() is called immediately after updating occurs. ComponentDidUpdate gives you access to your previous props, previous state and the value of a returned snapshot (this value is returned by a less common life cycle method called getSnapshotBeforeUpdate ). This method is used primarily when you want to do something relating to committed changes on the DOM from an update such as an <strong>autosave feature.</strong></p><h3>Unmounting</h3><p>There is one method that is called when a component is being removed from the DOM, <strong>componentWillUnmount().</strong></p><h4>componentWillUnmount()</h4><p>The componentWillUnmount method is invoked after a component is unmounted or destroyed. This is the <strong>cleanup </strong>method. It is typically used to remove any of the leftover things such as network requests, event listeners, elements that are no longer needed.</p><p>Long story short we can modify the DOM by adding, updating and removing DOM nodes with React. This happens in three phases Mounting the nodes, updating the nodes(if a change is made to the props or state of a component), and unmounting the nodes. React’s lifecycle methods that you can call during these phases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edccb5ec860a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginners Guide to VPN’s]]></title>
            <link>https://medium.com/@drewisatlas/a-beginners-guide-to-vpns-a9dbfe49e768?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9dbfe49e768</guid>
            <category><![CDATA[vpn]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Thu, 27 Dec 2018 00:37:34 GMT</pubDate>
            <atom:updated>2018-12-27T00:37:34.378Z</atom:updated>
            <content:encoded><![CDATA[<p>Whenever I find myself in a situation where there is free Wifi I never use it. Why? Because I have been warned by much more tech-savvy people than myself that these types of networks leave you vulnerable to malicious users that could gain access to your personal information (credit card numbers, SSN, login information, etc.) And they are right, how do I know that the WIFI at this particular coffee shop or airport has not been compromised? To take it a step further, when you use the internet how do you know that your Internet Service provider isn’t accessing your data in order to harvest information and profit from it? The real question then becomes, how can I safely protect information I send and receive while using the internet? After some quick googling, there was a term that kept popping up over and over again, “VPN” or “Virtual Private Network”. Before we get into what a VPN is and how it works let&#39;s take a step back and talk about Public and Private Networks.</p><h3>Public Network VS Private Network</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*wG7BYi4TlF6oE1o-0z8G_Q.jpeg" /><figcaption>Image Source <a href="https://buffered.com/faq/what-are-the-benefits-of-vpn/">https://buffered.com/faq/what-are-the-benefits-of-vpn/</a></figcaption></figure><p>A public network is a type of network where anyone can gain access and freely use it to connect to other networks or the internet. Think of this like the wifi you would use at Panera, an airport, anywhere that anyone can use the Internet. Public networks typically have little to no restrictions, thus there is a higher chance of security risks when accessing them. Since anyone can access a public network, malicious users may try to infiltrate the system of unsuspecting users that are also using the public network.</p><p>A private network is a network that has restrictions and access rules in order to allow access to certain individuals only. This type of network is configured so that devices outside the network cannot access it. Does your network at home require a password? Then it is considered a private network. Only users that have a username and password can access it.</p><p>There is no technical difference between private and public networks except for the security, addressing and authentication systems in place.</p><h3>What is a VPN?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*NYBPl7ei5TxMdyUH7yAZUg.png" /><figcaption>Image Source <a href="https://www.iplocation.net/vpn">https://www.iplocation.net/vpn</a></figcaption></figure><p>This brings us to VPN’s. A Virtual Private Network is a Private Network that is built to be used over a public infrastructure. VPN’s allow users to securely access a network from different locations from a public network, typically through the Internet. Accessing a network from an unsecured public network puts your data at risk. But a VPN allows you to securely access a private network and share data remotely through public networks. VPN’s do this by routing your data through an encrypted tunnel (this is called tunneling), while simultaneously masking your identity and location (you are using the VPN’s address.</p><p>VPN’s are utilized by many businesses because they allow employees to securely access data stored on a company’s network, but VPN’s are very popular with individual users as well. VPN’s are the best way to secure your personal data (and your employer&#39;s data), hide your IP address, and subvert “The Man” (government content filters). This is because VPN’s allow individuals to spoof their physical location. The user’s IP address is replaced by the VPN provider, allowing them to bypass content filters.</p><h3>What Makes A VPN Secure?</h3><p>A VPN is secure because of two things.</p><ol><li><strong>Dedicated Connections: </strong>a virtual path between two points for the user to send data through.</li><li><strong>Tunneling/Encryption Protocols: </strong>The encapsulation of Data that is being sent across a public network. Some common encryption protocols include:</li></ol><p><strong>IP Security (IPSec):</strong> Used to encrypt data packets. There are two modes, Transport mode which only encrypts the message within the packet, and Tunneling Mode which encrypts the entire Data Packet.</p><p><strong>Layer 2 Tunneling Protocol (L2TP) /IPsec:</strong> Generates the tunnel, while IPsec protocol handles the encryption, channel security, and data integrity checks to ensure all of the packets have arrived and the channel has not been compromised.</p><p><strong>Point-to-Point Tunneling Protocol (PPTP):</strong> Not the most secure method. This method only tunnels and encapsulates the data packet. A secondary protocol has to be used to handle the encryption.</p><p><strong>Secure Shell (SSH):</strong> Creates both the VPN tunnel and the encryption that protects it. The data itself isn’t encrypted but the channel it is moving through is.</p><p>With these two tools, the VPN can generate virtual p2p connections. Even if someone was able to access the transmitted data, the data would still be encrypted. Different VPN providers use different protocols to encrypt the data being sent through it.</p><h3>How can I access a VPN?</h3><p>Accessing a VPN is essentially a two-step process:</p><ol><li>Connect to the public internet through an Internet Service Provider.</li><li>Initiate a VPN connection using client-side software.</li></ol><p>The Software established a secure connection and grants the user access to the private network. There are a number of different VPN providers that are a quick google away. But if you would like to get your feet wet with a free VPN option two of the more popular options are listed below:</p><ul><li><a href="https://openvpn.net/">Business VPN For Secure Networking | OpenVPN</a></li><li><a href="https://www.vpn.net/">VPN.net - Hamachi by LogMeIn</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9dbfe49e768" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Music With Javascript]]></title>
            <link>https://medium.com/@drewisatlas/making-music-with-javascript-9e466b3b84d1?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e466b3b84d1</guid>
            <category><![CDATA[web-audio-api]]></category>
            <category><![CDATA[sound-design]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Thu, 13 Dec 2018 17:33:35 GMT</pubDate>
            <atom:updated>2018-12-13T17:33:35.691Z</atom:updated>
            <content:encoded><![CDATA[<p>As a musician that is currently learning how to code I wondered to myself how might a developer be able to make a music application? I am talking about an application that at the very least can allow me to make sound waves at specific frequencies, and If I can manipulate those sound waves that would be a huge plus. Luckily, after a quick google search, I stumbled upon “Web Audio API”.</p><h3>What is Web Audio API?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1X3ZczKngPsUR43AcC7PJA.png" /></figure><p>Web Audio API allows us to handle audio in web applications through “Audio Context”. An Audio Context is essentially an “Audio Routing Graph” that is built from audio modules linked together. In a music technology context, this would be called the “signal flow”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*aNgIXCPobuw72vaeRi3mtA.png" /><figcaption>Signal Flow for a simple Synthesizer</figcaption></figure><p>The Web Audio API provides the ability to build audio sources, choose audio sources, add effects to audio, create audio visualizations, apply spatial effects (such as panning) and much more. Web Audio API does this through “Audio Nodes”.</p><pre>const AudioContext = window.AudioContext || window.webkitAudioContext;<br>const audioCtx = new AudioContext();</pre><h3>Audio Nodes: What Do They Do?</h3><p>Everything.</p><p>Audio nodes are used for every aspect of the audio context. There are input nodes, which produce the sound source. There are modification nodes that provide the ability to modify a sound source, and output nodes, which allow you to save or hear those sounds.</p><h3>Input Nodes</h3><p>The input nodes break down into two options:</p><ul><li>Media Element / Audio Source Node</li><li>Oscillator Node</li></ul><p>The Media Element Node allows you to start with an audio file or video file, While an Oscillator Node allows you to create a sound from scratch. You can do this by assigning the oscillator a type such as a sine wave, square wave, sawtooth wave etc.</p><pre>let osc = audioCtx.createOscillator();<br>osc.type = &#39;sine&#39;;<br>osc.frequency.value = 880;</pre><h3>Modification Nodes</h3><p>Modification Nodes are added to the audio context in order to manipulate the input nodes. How might you manipulate an audio node? Some useful modification nodes include:</p><p><strong>GainNodes:</strong> this controls how much audio signal is coming through. If</p><p><strong>DynamicsCompressorNode: </strong>This attenuates a signal when it passes a certain threshold. This is a great tool for dealing with sounds that may be quite at some points and really loud at others.</p><p><strong>BiquadFilterNode: </strong>This node allows you to control the filtering (eq) effects of the sound source. This is essential for creating any type of complex sound from a simple waveform, or for removing unappealing frequencies from an audio file when it plays back.</p><p><strong>ConvolverNode: </strong>This node allows you to add real-time linear effects (reverb) to your audio source.</p><p><strong>DelayNode: </strong>This node allows you to add a dynamically adjustable variable delay to your audio signal.</p><h3>Output Nodes</h3><p>Audio Node objects can have inputs and/or outputs. Routing to an output occurs within the Audio Context which contains a single AudioDestination Node. However, you can arrange your chain of nodes to modify the Source.</p><pre>source.connect(context.destination);</pre><h3>Learn By Doing</h3><p>If you are interested in building apps with Web Audio API, below you will find a list of tutorials for a number of different application styles utilizing this tool.</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Advanced_techniques">Advanced techniques: Creating and sequencing audio</a></li><li><a href="http://marcgg.com/blog/2016/11/01/javascript-audio/">Generate Sounds Programmatically With Javascript</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e466b3b84d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problem Solving: A Strategic Approach]]></title>
            <link>https://medium.com/@drewisatlas/problem-solving-a-strategic-approach-acffe861f788?source=rss-b21c95dfdde0------2</link>
            <guid isPermaLink="false">https://medium.com/p/acffe861f788</guid>
            <category><![CDATA[problem-solving]]></category>
            <dc:creator><![CDATA[Andrew Rivera]]></dc:creator>
            <pubDate>Fri, 02 Nov 2018 13:35:17 GMT</pubDate>
            <atom:updated>2018-11-02T13:35:17.628Z</atom:updated>
            <content:encoded><![CDATA[<p>When it comes to solving problems, what is your approach? Do you have a plan? Do you think about the problem before jumping into solving it? The ability to solve one’s problems is not dictated by a persons intelligence. It is a skill, one that can be learned, and trained. More importantly, that it is a process. A process that anyone can follow and help you stack the odds in your favor when tackling the most difficult white boarding problems, coding problems, and even life problems.</p><h4>Start With a Plan</h4><blockquote>“By failing to prepare, you are preparing to fail.” <br>― <strong>Benjamin Franklin</strong></blockquote><p>Would you attempt to construct a building without a blue print? As humans living in a world that is more fast paced than ever it is really easy to look at a problem and think that the best course of action is to just jump in guns blazing and hoping for the best. Before trying to solve any problem try to formulate a plan or gather the necessary pieces of information to determine a plan.</p><p>Formulating a plan allows you to think about the problem. What is the final product you are trying to achieve? What necessary steps will you need to take to get there? Even if your plan is wrong, you will identify how different parts of your problem work together through trial and error. Additionally, planning forces you to break up the problem into smaller chunks or steps. the smaller those steps, the easier it will be to solve and have the added benefit of providing a feeling of accomplishment with the completion of each step.</p><h4>Start With What You Know</h4><blockquote>“I am the wisest man alive, for I know one thing, and that is that I know nothing.” <br>― <strong>Plato, </strong><a href="https://www.goodreads.com/work/quotes/1625515"><strong>The Republic</strong></a></blockquote><p>You now have a plan for how to tackle your problem. What now? Would you start working on a portion of the problem that you don’t know how to do? Of course not, start with the easiest, most familiar tasks. It helps you build momentum, instill trust in yourself with small victories and is much better than spending an hour on the most difficult part of the problem and driving yourself crazy in the process.</p><h4>Experiment Experiment Experiment</h4><blockquote>“Suspecting and knowing are not the same.” <br>― <strong>Rick Riordan, </strong><a href="https://www.goodreads.com/work/quotes/3346751"><strong>The Lightning Thief</strong></a></blockquote><p>It’s called computer science for a reason. Sometimes the best way to make progress is to try something and observe the results. This isn’t to be confused with relying on luck and randomly selected actions. There should still be a method to the madness, ideally following the plan that you set forth originally to solve your problem. Try to hypothesize what a certain piece of code will result in, and see if you get that result. Even if you don’t the result may provide another piece to the puzzle.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acffe861f788" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>